diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-04-10 21:53:03 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-04-10 21:53:03 +0000 |
| commit | 5b20fbdce435bf8a367c06400d0119810ad71d20 (patch) | |
| tree | bc58937538320e77bef9e53f982eaa77da361fdc /test | |
| parent | ba3bde19c53daa277f566cb7d5114b374605bcb2 (diff) | |
Fixed symbol demo label bug (STR #777)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4260 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
| -rw-r--r-- | test/symbols.cxx | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/test/symbols.cxx b/test/symbols.cxx index 3d43ea4f9..08d21dc59 100644 --- a/test/symbols.cxx +++ b/test/symbols.cxx @@ -49,24 +49,21 @@ void slider_cb(Fl_Widget *w, void *) { int sze = (int)size->value(); for (int i = window->children(); i--; ) { // all window children Fl_Widget *wc = window->child(i); - const char *l = wc->label(); - if ( *l == '@' ) { // all children with '@' - if ( *(++l) == '@' ) { // ascii legend? - l++; - while (isdigit(*l)||(*l=='+'&&l[1])||*l=='-') { l++; } + const char *l = (const char *)(wc->user_data()); + if ( l && *l == '@' ) { // all children with '@' + l ++; + if ( wc->box() == FL_NO_BOX ) { // ascii legend? if (val&&sze) sprintf(buf, "@@%+d%d%s", sze, val, l); else if (val) sprintf(buf, "@@%d%s", val, l); else if (sze) sprintf(buf, "@@%+d%s", sze, l); else sprintf(buf, "@@%s", l); } else { // box with symbol - while (isdigit(*l)||(*l=='+'&&l[1])||*l=='-') { l++; } if (val&&sze) sprintf(buf, "@%+d%d%s", sze, val, l); else if (val) sprintf(buf, "@%d%s", val, l); else if (sze) sprintf(buf, "@%+d%s", sze, l); else sprintf(buf, "@%s", l); } - free((void*)(wc->label())); - wc->label(strdup(buf)); + wc->copy_label(buf); } } window->redraw(); @@ -80,11 +77,17 @@ void bt(const char *name) { x = x*W+10; y = y*H+10; sprintf(buf, "@%s", name); - Fl_Box *a = new Fl_Box(FL_NO_BOX,x,y,W-20,H-20,strdup(buf)); + Fl_Box *a = new Fl_Box(x,y,W-20,H-20); + a->box(FL_NO_BOX); + a->copy_label(buf); a->align(FL_ALIGN_BOTTOM); a->labelsize(11); - Fl_Box *b = new Fl_Box(FL_UP_BOX,x,y,W-20,H-20,strdup(name)); + a->user_data((void *)name); + Fl_Box *b = new Fl_Box(x,y,W-20,H-20); + b->box(FL_UP_BOX); + b->copy_label(name); b->labelcolor(FL_DARK3); + b->user_data((void *)name); } int main(int argc, char ** argv) { |
