You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.0KB

  1. //
  2. // "$Id: symbols.cxx 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Symbol test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <ctype.h>
  31. #include <FL/Fl.H>
  32. #include <FL/Fl_Double_Window.H>
  33. #include <FL/Fl_Box.H>
  34. #include <FL/Fl_Value_Slider.H>
  35. #include <FL/fl_draw.H>
  36. int N = 0;
  37. #define W 70
  38. #define H 70
  39. #define ROWS 6
  40. #define COLS 6
  41. Fl_Double_Window *window;
  42. Fl_Value_Slider *orientation;
  43. Fl_Value_Slider *size;
  44. void slider_cb(Fl_Widget *, void *) {
  45. static char buf[80];
  46. int val = (int)orientation->value();
  47. int sze = (int)size->value();
  48. for (int i = window->children(); i--; ) { // all window children
  49. Fl_Widget *wc = window->child(i);
  50. const char *l = (const char *)(wc->user_data());
  51. if ( l && *l == '@' ) { // all children with '@'
  52. l ++;
  53. if ( wc->box() == FL_NO_BOX ) { // ascii legend?
  54. if (val&&sze) sprintf(buf, "@@%+d%d%s", sze, val, l);
  55. else if (val) sprintf(buf, "@@%d%s", val, l);
  56. else if (sze) sprintf(buf, "@@%+d%s", sze, l);
  57. else sprintf(buf, "@@%s", l);
  58. } else { // box with symbol
  59. if (val&&sze) sprintf(buf, "@%+d%d%s", sze, val, l);
  60. else if (val) sprintf(buf, "@%d%s", val, l);
  61. else if (sze) sprintf(buf, "@%+d%s", sze, l);
  62. else sprintf(buf, "@%s", l);
  63. }
  64. wc->copy_label(buf);
  65. }
  66. }
  67. window->redraw();
  68. }
  69. void bt(const char *name) {
  70. int x = N%COLS;
  71. int y = N/COLS;
  72. char buf[255];
  73. N++;
  74. x = x*W+10;
  75. y = y*H+10;
  76. sprintf(buf, "@%s", name);
  77. Fl_Box *a = new Fl_Box(x,y,W-20,H-20);
  78. a->box(FL_NO_BOX);
  79. a->copy_label(buf);
  80. a->align(FL_ALIGN_BOTTOM);
  81. a->labelsize(11);
  82. a->user_data((void *)name);
  83. Fl_Box *b = new Fl_Box(x,y,W-20,H-20);
  84. b->box(FL_UP_BOX);
  85. b->copy_label(name);
  86. b->labelcolor(FL_DARK3);
  87. b->user_data((void *)name);
  88. }
  89. int main(int argc, char ** argv) {
  90. window = new Fl_Double_Window(COLS*W,ROWS*H+60);
  91. bt("@->");
  92. bt("@>");
  93. bt("@>>");
  94. bt("@>|");
  95. bt("@>[]");
  96. bt("@|>");
  97. bt("@<-");
  98. bt("@<");
  99. bt("@<<");
  100. bt("@|<");
  101. bt("@[]<");
  102. bt("@<|");
  103. bt("@<->");
  104. bt("@-->");
  105. bt("@+");
  106. bt("@->|");
  107. bt("@||");
  108. bt("@arrow");
  109. bt("@returnarrow");
  110. bt("@square");
  111. bt("@circle");
  112. bt("@line");
  113. bt("@menu");
  114. bt("@UpArrow");
  115. bt("@DnArrow");
  116. bt("@search");
  117. bt("@FLTK");
  118. bt("@filenew");
  119. bt("@fileopen");
  120. bt("@filesave");
  121. bt("@filesaveas");
  122. bt("@fileprint");
  123. bt("@refresh");
  124. bt("@reload");
  125. bt("@undo");
  126. bt("@redo");
  127. orientation = new Fl_Value_Slider(
  128. (int)(window->w()*.05+.5), window->h()-40,
  129. (int)(window->w()*.42+.5), 16, "Orientation");
  130. orientation->type(FL_HORIZONTAL);
  131. orientation->range(0.0, 9.0);
  132. orientation->value(0.0);
  133. orientation->step(1);
  134. orientation->callback(slider_cb, 0);
  135. size = new Fl_Value_Slider(
  136. (int)(window->w()*.53+.5), window->h()-40,
  137. (int)(window->w()*.42+.5), 16, "Size");
  138. size->type(FL_HORIZONTAL);
  139. size->range(-3.0, 9.0);
  140. size->value(0.0);
  141. size->step(1);
  142. size->callback(slider_cb, 0);
  143. window->resizable(window);
  144. window->show(argc,argv);
  145. return Fl::run();
  146. }
  147. //
  148. // End of "$Id: symbols.cxx 7903 2010-11-28 21:06:39Z matt $".
  149. //