From 80465e4bfff4fd298fa6fb40ccb624d4abd57709 Mon Sep 17 00:00:00 2001 From: Bill Spitzak Date: Mon, 13 May 2002 05:05:11 +0000 Subject: Backported the fltk2.0 tooltips. This may be somewhat binary incompatable as Fl_Widget::tooltip(x) is no longer an inline (though the previous version will work if there is at least one call to the new one). It may be better to just enable tooltips all the time. Also Fl_Tooltip::enable() is changed, but few programs call that. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2210 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- test/input.cxx | 17 +++++++++++++++-- test/symbols.cxx | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/input.cxx b/test/input.cxx index 1b18ce145..4892c4d92 100644 --- a/test/input.cxx +++ b/test/input.cxx @@ -1,5 +1,5 @@ // -// "$Id: input.cxx,v 1.5.2.4.2.2 2002/01/01 15:11:33 easysw Exp $" +// "$Id: input.cxx,v 1.5.2.4.2.3 2002/05/13 05:05:11 spitzak Exp $" // // Input field test program for the Fast Light Tool Kit (FLTK). // @@ -77,13 +77,18 @@ int main(int argc, char **argv) { int y = 10; input[0] = new Fl_Input(70,y,300,30,"Normal:"); y += 35; + input[0]->tooltip("Normal input field"); // input[0]->cursor_color(FL_SELECTION_COLOR); // input[0]->maximum_size(20); // input[0]->static_value("this is a testgarbage"); input[1] = new Fl_Float_Input(70,y,300,30,"Float:"); y += 35; + input[1]->tooltip("Input field for floating-point number"); input[2] = new Fl_Int_Input(70,y,300,30,"Int:"); y += 35; + input[2]->tooltip("Input field for integer number"); input[3] = new Fl_Secret_Input(70,y,300,30,"Secret:"); y += 35; + input[3]->tooltip("Input field for password"); input[4] = new Fl_Multiline_Input(70,y,300,100,"Multiline:"); y += 105; + input[4]->tooltip("Input field for short text with newlines"); for (int i = 0; i < 4; i++) { input[i]->when(0); input[i]->callback(cb); @@ -93,24 +98,32 @@ int main(int argc, char **argv) { Fl_Button *b; b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_&CHANGED"); b->callback(toggle_cb, FL_WHEN_CHANGED); y += 25; + b->tooltip("Do callback each time the text changes"); b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_&RELEASE"); b->callback(toggle_cb, FL_WHEN_RELEASE); y += 25; + b->tooltip("Do callback when widget loses focus"); b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_&ENTER_KEY"); b->callback(toggle_cb, FL_WHEN_ENTER_KEY); y += 25; + b->tooltip("Do callback when user hits Enter key"); b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_&NOT_CHANGED"); b->callback(toggle_cb, FL_WHEN_NOT_CHANGED); y += 25; + b->tooltip("Do callback even if the text is not changed"); y += 5; b = new Fl_Button(10,y,200,25,"&print changed()"); b->callback(button_cb); + b->tooltip("Print widgets that have changed() flag set"); b = new Fl_Button(220,y1,100,25,"color"); y1 += 25; b->color(input[0]->color()); b->callback(color_cb, (void*)0); + b->tooltip("Color behind the text"); b = new Fl_Button(220,y1,100,25,"selection_color"); y1 += 25; b->color(input[0]->selection_color()); b->callback(color_cb, (void*)1); b->labelcolor(fl_contrast(FL_BLACK,b->color())); + b->tooltip("Color behind selected text"); b = new Fl_Button(220,y1,100,25,"textcolor"); y1 += 25; b->color(input[0]->textcolor()); b->callback(color_cb, (void*)2); b->labelcolor(fl_contrast(FL_BLACK,b->color())); + b->tooltip("Color of the text"); window->end(); window->show(argc,argv); @@ -118,5 +131,5 @@ int main(int argc, char **argv) { } // -// End of "$Id: input.cxx,v 1.5.2.4.2.2 2002/01/01 15:11:33 easysw Exp $". +// End of "$Id: input.cxx,v 1.5.2.4.2.3 2002/05/13 05:05:11 spitzak Exp $". // diff --git a/test/symbols.cxx b/test/symbols.cxx index 45958d990..8b93256fb 100644 --- a/test/symbols.cxx +++ b/test/symbols.cxx @@ -1,5 +1,5 @@ // -// "$Id: symbols.cxx,v 1.4.2.3.2.2 2002/01/01 15:11:33 easysw Exp $" +// "$Id: symbols.cxx,v 1.4.2.3.2.3 2002/05/13 05:05:11 spitzak Exp $" // // Symbol test program for the Fast Light Tool Kit (FLTK). // @@ -26,19 +26,46 @@ #include #include #include +#include #include #include #include +#include #include int N = 0; -#define W 60 -#define H 60 +#define W 70 +#define H 70 #define ROWS 5 #define COLS 5 Fl_Window *window; +void slider_cb(Fl_Widget *w, void *data) { + static char buf[80]; + int val = (int)(((Fl_Value_Slider*)w)->value()); + Fl_Window *win = (Fl_Window*)w->parent(); // get parent window + for (int i = win->children(); i--; ) { // all window children + Fl_Widget *wc = win->child(i); + const char *l = wc->label(); + if ( *l == '@' ) { // all children with '@' + if ( *(++l) == '@' ) { // ascii legend? + l++; + while (isdigit(*l)) { l++; } + if (val == 0) { sprintf(buf, "@@%s", l); } + else { sprintf(buf, "@@%d%s", val, l); } + } else { // box with symbol + while (isdigit(*l)) { l++; } + if (val == 0) { sprintf(buf, "@%s", l); } + else { sprintf(buf, "@%d%s", val, l); } + } + free((void*)(wc->label())); + wc->label(strdup(buf)); + } + } + win->redraw(); +} + void bt(const char *name) { int x = N%COLS; int y = N/COLS; @@ -50,12 +77,12 @@ void bt(const char *name) { Fl_Box *a = new Fl_Box(FL_NO_BOX,x,y,W-20,H-20,strdup(buf)); a->align(FL_ALIGN_BOTTOM); a->labelsize(11); - Fl_Box *b = new Fl_Box(FL_UP_BOX,x,y,W-20,H-20,name); + Fl_Box *b = new Fl_Box(FL_UP_BOX,x,y,W-20,H-20,strdup(name)); b->labelcolor(FL_DARK3); } int main(int argc, char ** argv) { - window = new Fl_Single_Window(COLS*W,ROWS*H+20); + window = new Fl_Single_Window(COLS*W,ROWS*H+60); bt("@->"); bt("@>"); bt("@>>"); @@ -81,11 +108,23 @@ bt("@line"); bt("@menu"); bt("@UpArrow"); bt("@DnArrow"); + + Fl_Value_Slider slider((int)(window->w()*.10+.5), + window->h()-40, + (int)(window->w()*.80+.5), + 16, + "Orientation"); + slider.type(FL_HORIZONTAL); + slider.range(0.0, 9.0); + slider.value(0.0); + slider.step(1); + slider.callback(slider_cb, &slider); + window->resizable(window); window->show(argc,argv); return Fl::run(); } // -// End of "$Id: symbols.cxx,v 1.4.2.3.2.2 2002/01/01 15:11:33 easysw Exp $". +// End of "$Id: symbols.cxx,v 1.4.2.3.2.3 2002/05/13 05:05:11 spitzak Exp $". // -- cgit v1.2.3