1 // 2 // "$Id$" 3 // 4 // Unit tests for the Fast Light Tool Kit (FLTK). 5 // 6 // Copyright 1998-2010 by Bill Spitzak and others. 7 // 8 // Nods to Edmanuel Torres for the widget layout (STR#2672) 9 // 10 // This library is free software. Distribution and use rights are outlined in 11 // the file "COPYING" which should have been included with this file. If this 12 // file is missing or damaged, see the license at: 13 // 14 // http://www.fltk.org/COPYING.php 15 // 16 // Please report all bugs and problems on the following page: 17 // 18 // http://www.fltk.org/str.php 19 // 20 21 #include <FL/Fl_Choice.H> 22 23 // needed by Edmanuel's test layout 24 #include <FL/Fl_Button.H> 25 #include <FL/Fl_Tabs.H> 26 #include <FL/Fl_Group.H> 27 #include <FL/Fl_Clock.H> 28 #include <FL/Fl_Progress.H> 29 #include <FL/Fl_Slider.H> 30 #include <FL/Fl_Scrollbar.H> 31 #include <FL/Fl_Value_Slider.H> 32 #include <FL/Fl_Value_Output.H> 33 #include <FL/Fl_Adjuster.H> 34 #include <FL/Fl_Counter.H> 35 #include <FL/Fl_Roller.H> 36 #include <FL/Fl_Value_Input.H> 37 #include <FL/Fl_Input.H> 38 #include <FL/Fl_Output.H> 39 #include <FL/Fl_Text_Editor.H> 40 #include <FL/Fl_Text_Display.H> 41 #include <FL/Fl_File_Input.H> 42 #include <FL/Fl_Box.H> 43 #include <FL/Fl_Light_Button.H> 44 #include <FL/Fl_Check_Button.H> 45 46 class SchemesTest : public Fl_Group { 47 Fl_Choice *schemechoice; SchemeChoice_CB(Fl_Widget *,void * data)48 static void SchemeChoice_CB(Fl_Widget*,void *data) { 49 SchemesTest *st = (SchemesTest*)data; 50 const char *name = st->schemechoice->text(); 51 if ( name ) { 52 Fl::scheme(name); // change scheme 53 st->window()->redraw(); // redraw window 54 } 55 } 56 public: create()57 static Fl_Widget *create() { 58 return new SchemesTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); 59 } SchemesTest(int X,int Y,int W,int H)60 SchemesTest(int X,int Y,int W,int H) : Fl_Group(X,Y,W,H) { 61 schemechoice = new Fl_Choice(X+125,Y,140,25,"FLTK Scheme"); 62 schemechoice->add("none"); 63 schemechoice->add("plastic"); 64 schemechoice->add("gtk+"); 65 schemechoice->add("gleam"); 66 schemechoice->value(0); 67 schemechoice->labelfont(FL_HELVETICA_BOLD); 68 const char *name = Fl::scheme(); 69 if ( name ) { 70 if ( strcmp(name, "plastic") == 0) { schemechoice->value(1); } 71 else if ( strcmp(name, "gtk+") == 0) { schemechoice->value(2); } 72 else if ( strcmp(name, "gleam") == 0) { schemechoice->value(3); } 73 } 74 schemechoice->callback(SchemeChoice_CB, (void*)this); 75 76 Fl_Window *subwin = new Fl_Window(X,Y+30,W,H-30); 77 subwin->begin(); 78 { 79 // Pasted from Edmanuel's gleam test app 80 { Fl_Button* o = new Fl_Button(10, 9, 90, 25, "button"); 81 o->box(FL_UP_BOX); 82 o->color((Fl_Color)101); 83 o->tooltip("selection_color() = default"); 84 o->labelfont(5); 85 } // Fl_Button* o 86 { Fl_Button* o = new Fl_Button(10, 36, 90, 25, "button"); 87 o->box(FL_UP_BOX); 88 o->color((Fl_Color)179); 89 o->selection_color(o->color()); 90 o->tooltip("selection_color() = color()"); 91 o->labelfont(4); 92 o->labelcolor(FL_BACKGROUND2_COLOR); 93 } // Fl_Button* o 94 { Fl_Button* o = new Fl_Button(10, 63, 90, 25, "button"); 95 o->box(FL_UP_BOX); 96 o->color((Fl_Color)91); 97 o->selection_color(fl_lighter(o->color())); 98 o->tooltip("selection_color() = fl_lighter(color())"); 99 } // Fl_Button* o 100 { Fl_Button* o = new Fl_Button(10, 90, 90, 25, "button"); 101 o->box(FL_UP_BOX); 102 o->color(FL_INACTIVE_COLOR); 103 o->selection_color(fl_darker(o->color())); 104 o->tooltip("selection_color() = fl_darker(color())"); 105 o->labelcolor(FL_BACKGROUND2_COLOR); 106 } // Fl_Button* o 107 { Fl_Tabs* o = new Fl_Tabs(10, 120, 320, 215); 108 o->color(FL_DARK1); 109 o->selection_color(FL_DARK1); 110 { Fl_Group* o = new Fl_Group(14, 141, 310, 190, "tab1"); 111 //o->box(FL_THIN_UP_BOX); 112 o->color(FL_DARK1); 113 o->selection_color((Fl_Color)23); 114 o->hide(); 115 { Fl_Clock* o = new Fl_Clock(24, 166, 130, 130); 116 o->box(FL_THIN_UP_BOX); 117 o->color((Fl_Color)12); 118 o->selection_color(FL_BACKGROUND2_COLOR); 119 o->labelcolor(FL_BACKGROUND2_COLOR); 120 o->tooltip("Fl_Clock with thin up box"); 121 } // Fl_Clock* o 122 { new Fl_Progress(22, 306, 290, 20); 123 } // Fl_Progress* o 124 { Fl_Clock* o = new Fl_Clock(179, 166, 130, 130); 125 o->box(FL_THIN_DOWN_BOX); 126 o->color((Fl_Color)26); 127 o->tooltip("Fl_Clock with thin down box"); 128 } // Fl_Clock* o 129 o->end(); 130 } // Fl_Group* o 131 { Fl_Group* o = new Fl_Group(15, 140, 310, 190, "tab2"); 132 //o->box(FL_THIN_UP_BOX); 133 o->color(FL_DARK1); 134 { Fl_Slider* o = new Fl_Slider(20, 161, 25, 155); 135 o->box(FL_DOWN_BOX); 136 o->tooltip("Fl_Slider with down box"); 137 } // Fl_Slider* o 138 { Fl_Scrollbar* o = new Fl_Scrollbar(50, 161, 25, 155); 139 o->value(0, 50, 1, 100); 140 o->box(FL_DOWN_BOX); 141 o->tooltip("Fl_Scrollbar with down box"); 142 } // Fl_Scrollbar* o 143 { Fl_Value_Slider* o = new Fl_Value_Slider(115, 161, 25, 155); 144 o->box(FL_DOWN_BOX); 145 } // Fl_Value_Slider* o 146 { Fl_Value_Output* o = new Fl_Value_Output(240, 265, 75, 25); 147 o->box(FL_DOWN_BOX); 148 o->tooltip("Fl_Value_Output with down box"); 149 } // Fl_Value_Output* o 150 { Fl_Adjuster* o = new Fl_Adjuster(185, 210, 100, 25); 151 o->tooltip("Fl_Adjuster"); 152 } // Fl_Adjuster* o 153 { Fl_Counter* o = new Fl_Counter(185, 180, 100, 25); 154 o->box(FL_DOWN_BOX); 155 o->tooltip("Fl_Counter with down box"); 156 } // Fl_Counter* o 157 { Fl_Roller* o = new Fl_Roller(85, 161, 25, 155); 158 o->box(FL_UP_BOX); 159 o->tooltip("Fl_Roller with up box"); 160 } // Fl_Roller* o 161 { Fl_Value_Input* o = new Fl_Value_Input(155, 265, 75, 25); 162 o->box(FL_DOWN_BOX); 163 o->tooltip("Fl_Value_Input with down box"); 164 } // Fl_Value_Input* o 165 o->end(); 166 } // Fl_Group* o 167 { Fl_Group* o = new Fl_Group(15, 140, 310, 190, "tab3"); 168 //o->box(FL_THIN_UP_BOX); 169 o->color(FL_DARK1); 170 o->hide(); 171 { Fl_Input* o = new Fl_Input(40, 230, 120, 25); 172 o->box(FL_DOWN_BOX); 173 o->tooltip("Fl_Input with down box"); 174 } // Fl_Input* o 175 { Fl_Output* o = new Fl_Output(40, 260, 120, 25); 176 o->box(FL_DOWN_BOX); 177 o->tooltip("Fl_Output with down box"); 178 } // Fl_Output* o 179 { Fl_Text_Editor* o = new Fl_Text_Editor(180, 160, 125, 55); 180 o->box(FL_DOWN_FRAME); 181 o->color((Fl_Color)80); 182 o->tooltip("Fl_Text_Editor with down frame"); 183 o->textsize(8); 184 o->buffer(new Fl_Text_Buffer()); 185 o->buffer()->text("Text editor"); 186 } // Fl_Text_Editor* o 187 { Fl_Text_Display* o = new Fl_Text_Display(180, 230, 125, 55); 188 o->box(FL_DOWN_FRAME); 189 o->color((Fl_Color)12); 190 o->tooltip("Fl_Text_Display with down frame"); 191 o->textsize(8); 192 o->buffer(new Fl_Text_Buffer()); 193 o->buffer()->text("Text display"); 194 } // Fl_Text_Display* o 195 { Fl_File_Input* o = new Fl_File_Input(40, 290, 265, 30); 196 o->box(FL_DOWN_BOX); 197 o->tooltip("Fl_File_Input with down box"); 198 } // Fl_File_Input* o 199 o->end(); 200 } // Fl_Group* o 201 o->end(); 202 } // Fl_Tabs* o 203 { Fl_Box* o = new Fl_Box(341, 10, 80, 50, "thin box\ndown1"); 204 o->box(FL_THIN_DOWN_BOX); 205 o->color((Fl_Color)20); 206 o->labelsize(10); 207 } // Fl_Box* o 208 { Fl_Box* o = new Fl_Box(430, 10, 80, 50, "thin box\nup1"); 209 o->box(FL_THIN_UP_BOX); 210 o->color(FL_SELECTION_COLOR); 211 o->labelcolor((Fl_Color)6); 212 o->labelsize(10); 213 } // Fl_Box* o 214 { Fl_Box* o = new Fl_Box(341, 71, 80, 44, "thin box\ndown2"); 215 o->box(FL_THIN_DOWN_BOX); 216 o->color((Fl_Color)190); 217 o->labelsize(10); 218 } // Fl_Box* o 219 { Fl_Box* o = new Fl_Box(430, 71, 80, 44, "thin box\nup2"); 220 o->box(FL_THIN_UP_BOX); 221 o->color((Fl_Color)96); 222 o->labelcolor(FL_BACKGROUND2_COLOR); 223 o->labelsize(10); 224 } // Fl_Box* o 225 { Fl_Box* o = new Fl_Box(341, 127, 80, 50, "box down3"); 226 o->box(FL_DOWN_BOX); 227 o->color((Fl_Color)3); 228 o->labelsize(10); 229 } // Fl_Box* o 230 { Fl_Box* o = new Fl_Box(430, 127, 80, 50, "box up3"); 231 o->box(FL_UP_BOX); 232 o->color((Fl_Color)104); 233 o->labelcolor((Fl_Color)3); 234 o->labelsize(10); 235 } // Fl_Box* o 236 { Fl_Box* o = new Fl_Box(341, 189, 80, 50, "box down4"); 237 o->box(FL_DOWN_BOX); 238 o->color((Fl_Color)42); 239 o->labelcolor(FL_DARK_RED); 240 o->labelsize(10); 241 } // Fl_Box* o 242 { Fl_Box* o = new Fl_Box(430, 189, 80, 50, "box up4"); 243 o->box(FL_UP_BOX); 244 o->color((Fl_Color)30); 245 o->labelcolor((Fl_Color)26); 246 o->labelsize(10); 247 } // Fl_Box* o 248 { Fl_Box* o = new Fl_Box(341, 251, 80, 82, "box down5"); 249 o->box(FL_DOWN_BOX); 250 o->color((Fl_Color)19); 251 o->labelcolor((Fl_Color)4); 252 o->labelsize(10); 253 } // Fl_Box* o 254 { Fl_Box* o = new Fl_Box(430, 251, 80, 82, "box up5"); 255 o->box(FL_UP_BOX); 256 o->color(FL_FOREGROUND_COLOR); 257 o->labelcolor(FL_BACKGROUND2_COLOR); 258 o->labelsize(10); 259 } // Fl_Box* o 260 { Fl_Light_Button* o = new Fl_Light_Button(110, 10, 105, 25, "Light"); 261 o->box(FL_DOWN_BOX); 262 o->color(FL_BACKGROUND2_COLOR); 263 o->selection_color((Fl_Color)30); 264 o->tooltip("Fl_Light_Button with down box"); 265 } // Fl_Light_Button* o 266 { Fl_Check_Button* o = new Fl_Check_Button(110, 37, 105, 25, "Check"); 267 o->box(FL_DOWN_FRAME); 268 o->down_box(FL_DOWN_BOX); 269 o->color(FL_DARK1); 270 o->tooltip("Fl_Check_Button with down frame"); 271 } // Fl_Check_Button* o 272 { Fl_Input* o = new Fl_Input(220, 10, 100, 25); 273 o->box(FL_DOWN_BOX); 274 o->color((Fl_Color)23); 275 o->tooltip("Fl_Input with down box"); 276 } // Fl_Input* o 277 { Fl_Adjuster* o = new Fl_Adjuster(110, 65, 80, 43); 278 o->box(FL_UP_BOX); 279 o->color(FL_INACTIVE_COLOR); 280 o->selection_color(FL_BACKGROUND2_COLOR); 281 o->labelcolor((Fl_Color)55); 282 o->tooltip("Fl_Adjuster with up box"); 283 } // Fl_Adjuster* o 284 { Fl_Text_Editor* o = new Fl_Text_Editor(220, 53, 100, 29, "down frame"); 285 o->box(FL_DOWN_FRAME); 286 o->color((Fl_Color)19); 287 o->selection_color(FL_DARK1); 288 o->tooltip("Fl_Adjuster with down frame"); 289 } // Fl_Text_Editor* o 290 { Fl_Text_Editor* o = new Fl_Text_Editor(220, 99, 100, 38, "up frame"); 291 o->box(FL_UP_FRAME); 292 o->color((Fl_Color)19); 293 o->selection_color(FL_DARK1); 294 o->tooltip("Fl_Text_Editor with up frame"); 295 } // Fl_Text_Editor* o 296 } 297 subwin->end(); 298 subwin->resizable(subwin); 299 subwin->show(); 300 } 301 }; 302 303 UnitTest schemestest("schemes test", SchemesTest::create); 304 305 // 306 // End of "$Id$ 307 // 308