1 | // |
---|
2 | // "$Id$" |
---|
3 | // |
---|
4 | // Symbol test program for the Fast Light Tool Kit (FLTK). |
---|
5 | // |
---|
6 | // Copyright 1998-2005 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 | |
---|
28 | #include <stdio.h> |
---|
29 | #include <stdlib.h> |
---|
30 | #include <string.h> |
---|
31 | #include <ctype.h> |
---|
32 | #include <FL/Fl.H> |
---|
33 | #include <FL/Fl_Single_Window.H> |
---|
34 | #include <FL/Fl_Box.H> |
---|
35 | #include <FL/Fl_Value_Slider.H> |
---|
36 | #include <FL/fl_draw.H> |
---|
37 | |
---|
38 | int N = 0; |
---|
39 | #define W 70 |
---|
40 | #define H 70 |
---|
41 | #define ROWS 6 |
---|
42 | #define COLS 6 |
---|
43 | |
---|
44 | Fl_Window *window; |
---|
45 | Fl_Value_Slider *orientation; |
---|
46 | Fl_Value_Slider *size; |
---|
47 | |
---|
48 | void slider_cb(Fl_Widget *, void *) { |
---|
49 | static char buf[80]; |
---|
50 | int val = (int)orientation->value(); |
---|
51 | int sze = (int)size->value(); |
---|
52 | for (int i = window->children(); i--; ) { // all window children |
---|
53 | Fl_Widget *wc = window->child(i); |
---|
54 | const char *l = (const char *)(wc->user_data()); |
---|
55 | if ( l && *l == '@' ) { // all children with '@' |
---|
56 | l ++; |
---|
57 | if ( wc->box() == FL_NO_BOX ) { // ascii legend? |
---|
58 | if (val&&sze) sprintf(buf, "@@%+d%d%s", sze, val, l); |
---|
59 | else if (val) sprintf(buf, "@@%d%s", val, l); |
---|
60 | else if (sze) sprintf(buf, "@@%+d%s", sze, l); |
---|
61 | else sprintf(buf, "@@%s", l); |
---|
62 | } else { // box with symbol |
---|
63 | if (val&&sze) sprintf(buf, "@%+d%d%s", sze, val, l); |
---|
64 | else if (val) sprintf(buf, "@%d%s", val, l); |
---|
65 | else if (sze) sprintf(buf, "@%+d%s", sze, l); |
---|
66 | else sprintf(buf, "@%s", l); |
---|
67 | } |
---|
68 | wc->copy_label(buf); |
---|
69 | } |
---|
70 | } |
---|
71 | window->redraw(); |
---|
72 | } |
---|
73 | |
---|
74 | void bt(const char *name) { |
---|
75 | int x = N%COLS; |
---|
76 | int y = N/COLS; |
---|
77 | char buf[255]; |
---|
78 | N++; |
---|
79 | x = x*W+10; |
---|
80 | y = y*H+10; |
---|
81 | sprintf(buf, "@%s", name); |
---|
82 | Fl_Box *a = new Fl_Box(x,y,W-20,H-20); |
---|
83 | a->box(FL_NO_BOX); |
---|
84 | a->copy_label(buf); |
---|
85 | a->align(FL_ALIGN_BOTTOM); |
---|
86 | a->labelsize(11); |
---|
87 | a->user_data((void *)name); |
---|
88 | Fl_Box *b = new Fl_Box(x,y,W-20,H-20); |
---|
89 | b->box(FL_UP_BOX); |
---|
90 | b->copy_label(name); |
---|
91 | b->labelcolor(FL_DARK3); |
---|
92 | b->user_data((void *)name); |
---|
93 | } |
---|
94 | |
---|
95 | int main(int argc, char ** argv) { |
---|
96 | window = new Fl_Single_Window(COLS*W,ROWS*H+60); |
---|
97 | bt("@->"); |
---|
98 | bt("@>"); |
---|
99 | bt("@>>"); |
---|
100 | bt("@>|"); |
---|
101 | bt("@>[]"); |
---|
102 | bt("@|>"); |
---|
103 | bt("@<-"); |
---|
104 | bt("@<"); |
---|
105 | bt("@<<"); |
---|
106 | bt("@|<"); |
---|
107 | bt("@[]<"); |
---|
108 | bt("@<|"); |
---|
109 | bt("@<->"); |
---|
110 | bt("@-->"); |
---|
111 | bt("@+"); |
---|
112 | bt("@->|"); |
---|
113 | bt("@||"); |
---|
114 | bt("@arrow"); |
---|
115 | bt("@returnarrow"); |
---|
116 | bt("@square"); |
---|
117 | bt("@circle"); |
---|
118 | bt("@line"); |
---|
119 | bt("@menu"); |
---|
120 | bt("@UpArrow"); |
---|
121 | bt("@DnArrow"); |
---|
122 | bt("@search"); |
---|
123 | bt("@FLTK"); |
---|
124 | bt("@filenew"); |
---|
125 | bt("@fileopen"); |
---|
126 | bt("@filesave"); |
---|
127 | bt("@filesaveas"); |
---|
128 | bt("@fileprint"); |
---|
129 | bt("@refresh"); |
---|
130 | bt("@reload"); |
---|
131 | bt("@undo"); |
---|
132 | bt("@redo"); |
---|
133 | |
---|
134 | orientation = new Fl_Value_Slider( |
---|
135 | (int)(window->w()*.05+.5), window->h()-40, |
---|
136 | (int)(window->w()*.42+.5), 16, "Orientation"); |
---|
137 | orientation->type(FL_HORIZONTAL); |
---|
138 | orientation->range(0.0, 9.0); |
---|
139 | orientation->value(0.0); |
---|
140 | orientation->step(1); |
---|
141 | orientation->callback(slider_cb, 0); |
---|
142 | |
---|
143 | size = new Fl_Value_Slider( |
---|
144 | (int)(window->w()*.53+.5), window->h()-40, |
---|
145 | (int)(window->w()*.42+.5), 16, "Size"); |
---|
146 | size->type(FL_HORIZONTAL); |
---|
147 | size->range(-3.0, 9.0); |
---|
148 | size->value(0.0); |
---|
149 | size->step(1); |
---|
150 | size->callback(slider_cb, 0); |
---|
151 | |
---|
152 | window->resizable(window); |
---|
153 | window->show(argc,argv); |
---|
154 | return Fl::run(); |
---|
155 | } |
---|
156 | |
---|
157 | // |
---|
158 | // End of "$Id$". |
---|
159 | // |
---|