43
Fl_Value_Slider *orientation;
44
Fl_Value_Slider *size;
44
46
void slider_cb(Fl_Widget *w, void *) {
45
47
static char buf[80];
46
int val = (int)(((Fl_Value_Slider*)w)->value());
47
Fl_Window *win = (Fl_Window*)w->parent(); // get parent window
48
for (int i = win->children(); i--; ) { // all window children
49
Fl_Widget *wc = win->child(i);
48
int val = (int)orientation->value();
49
int sze = (int)size->value();
50
for (int i = window->children(); i--; ) { // all window children
51
Fl_Widget *wc = window->child(i);
50
52
const char *l = wc->label();
51
53
if ( *l == '@' ) { // all children with '@'
52
54
if ( *(++l) == '@' ) { // ascii legend?
54
while (isdigit(*l)) { l++; }
55
if (val == 0) { sprintf(buf, "@@%s", l); }
56
else { sprintf(buf, "@@%d%s", val, l); }
56
while (isdigit(*l)||(*l=='+'&&l[1])||*l=='-') { l++; }
57
if (val&&sze) sprintf(buf, "@@%+d%d%s", sze, val, l);
58
else if (val) sprintf(buf, "@@%d%s", val, l);
59
else if (sze) sprintf(buf, "@@%+d%s", sze, l);
60
else sprintf(buf, "@@%s", l);
57
61
} else { // box with symbol
58
while (isdigit(*l)) { l++; }
59
if (val == 0) { sprintf(buf, "@%s", l); }
60
else { sprintf(buf, "@%d%s", val, l); }
62
while (isdigit(*l)||(*l=='+'&&l[1])||*l=='-') { l++; }
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);
62
68
free((void*)(wc->label()));
63
69
wc->label(strdup(buf));
69
75
void bt(const char *name) {
112
Fl_Value_Slider slider((int)(window->w()*.10+.5),
114
(int)(window->w()*.80+.5),
117
slider.type(FL_HORIZONTAL);
118
slider.range(0.0, 9.0);
121
slider.callback(slider_cb, &slider);
120
orientation = new Fl_Value_Slider(
121
(int)(window->w()*.05+.5), window->h()-40,
122
(int)(window->w()*.42+.5), 16, "Orientation");
123
orientation->type(FL_HORIZONTAL);
124
orientation->range(0.0, 9.0);
125
orientation->value(0.0);
126
orientation->step(1);
127
orientation->callback(slider_cb, 0);
129
size = new Fl_Value_Slider(
130
(int)(window->w()*.53+.5), window->h()-40,
131
(int)(window->w()*.42+.5), 16, "Size");
132
size->type(FL_HORIZONTAL);
133
size->range(-3.0, 9.0);
136
size->callback(slider_cb, 0);
123
138
window->resizable(window);
124
139
window->show(argc,argv);