STR #1052: updated color handling in test programs. If you are planning on creating labels based on foreground or background color, you should load the colors *before* creating the user interface. This is done by calling:

Fl::args(arc, argv);
Fl::set_system_colors();

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4626 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2005-11-02 13:57:56 +00:00
parent cddb39a066
commit 8979617990
6 changed files with 78 additions and 40 deletions

View File

@ -50,10 +50,19 @@ void bt(const char *name, Fl_Boxtype type, int square=0) {
}
int main(int argc, char ** argv) {
Fl::get_system_colors();
window = new Fl_Single_Window(4*W,ROWS*H);
window->box(FL_FLAT_BOX);
#if 0 // this code uses the command line arguments to set arbitrary color schemes
Fl::args(argc, argv);
Fl::get_system_colors();
#elif 0 // this code uses a single color to define a scheme
Fl::args(argc, argv);
Fl::get_system_colors();
Fl::background(113,113,198);
#else // this code uses the nice bright blue background to show box vs. frame types
Fl::get_system_colors();
window->color(12);// light blue
#endif
bt("FL_NO_BOX",FL_NO_BOX);
bt("FL_FLAT_BOX",FL_FLAT_BOX);
N += 2; // go to start of next row to line up boxes & frames
@ -93,7 +102,6 @@ int main(int argc, char ** argv) {
bt("FL_PLASTIC_THIN_DOWN_BOX",FL_PLASTIC_THIN_DOWN_BOX);
window->resizable(window);
window->end();
//window->show(argc,argv); // commented out, so we won't load any schemes
window->show();
return Fl::run();
}

View File

@ -46,7 +46,8 @@ int main(int argc, char ** argv) {
new Fl_Round_Button(150,50,160,30,"Fl_Round_Button");
new Fl_Check_Button(150,90,160,30,"Fl_Check_Button");
window->end();
window->show(argc,argv);
//window->show(argc,argv);
window->show();
return Fl::run();
}

View File

@ -138,6 +138,7 @@ void create_the_forms() {
int main(int argc, char **argv) {
Fl::scheme(NULL);
Fl::args(argc, argv);
Fl::get_system_colors();
create_the_forms();
#ifdef __APPLE__

View File

@ -1,45 +1,56 @@
# data file for the Fltk User Interface Designer (fluid)
version 0.99
gridx 5
gridy 5
snap 3
version 1.0107
header_name {.h}
code_name {.cxx}
Function {} {open
} {
Fl_Window {} {open
xywh {470 454 420 295} visible
xywh {379 190 420 369} type Double resizable visible
} {
Fl_Group the_group {
label {activate()/deactivate() called on this Fl_Group} open
xywh {25 25 375 235} box ENGRAVED_FRAME align 17
xywh {25 25 375 295} box ENGRAVED_FRAME align 17 resizable
} {
Fl_Button {} {
label button
xywh {50 50 105 25}
}
Fl_Light_Button {} {
label {light button}
xywh {50 80 105 25} value 1 align 16
}
Fl_Group {} {
label {Child group} open
xywh {50 100 105 85} box DOWN_FRAME
xywh {50 130 105 125} box DOWN_FRAME
} {
Fl_Check_Button {} {
label red
xywh {50 100 105 25} type Radio down_box DIAMOND_DOWN_BOX labelcolor 1
xywh {50 170 105 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 1 labelcolor 1
}
Fl_Check_Button {} {
label green
xywh {50 120 105 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 2 labelcolor 2
xywh {50 190 105 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 2 labelcolor 2
}
Fl_Check_Button {} {
label blue
xywh {50 140 105 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 4 labelcolor 4
xywh {50 210 105 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 4 labelcolor 4
}
Fl_Check_Button {} {
label white
xywh {50 160 105 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 7 labelcolor 7
xywh {50 230 105 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 55 labelcolor 55
}
Fl_Check_Button {} {
label check
xywh {50 130 105 25} down_box DOWN_BOX
}
Fl_Round_Button {} {
label round
xywh {50 150 105 25} down_box ROUND_DOWN_BOX
}
}
Fl_Slider {} {
label Fl_Slider
xywh {165 50 24 150} value 0.5
label Fl_Slider selected
xywh {165 50 24 205} value 0.5
}
Fl_Input {} {
xywh {195 50 195 30}
@ -47,51 +58,63 @@ Function {} {open
}
Fl_Menu_Button {} {
label menu open
xywh {235 105 110 30}
xywh {245 90 130 30}
} {
menuitem {} {
MenuItem {} {
label item
xywh {0 0 100 20}
xywh {0 0 100 20} labelsize 14
}
menuitem {} {
MenuItem {} {
label item
xywh {10 10 100 20}
xywh {10 10 100 20} labelsize 14
}
menuitem {} {
MenuItem {} {
label item
xywh {20 20 100 20}
xywh {20 20 100 20} labelsize 14
}
menuitem {} {
MenuItem {} {
label item
xywh {30 30 100 20}
xywh {30 30 100 20} labelsize 14
}
menuitem {} {
MenuItem {} {
label item
xywh {40 40 100 20}
xywh {40 40 100 20} labelsize 14
}
}
Fl_Box {} {
label Fl_Box
xywh {240 205 145 50} box EMBOSSED_FRAME labeltype SHADOW_LABEL labelfont 3 labelsize 38
}
Fl_Value_Output {} {
label {value:}
xywh {255 165 130 30} maximum 10000 step 1 textfont 5 textsize 24 textcolor 4
xywh {245 130 130 30} maximum 10000 step 1 textfont 5 textsize 24 textcolor 4
}
Fl_Box {} {
label Fl_Box
xywh {245 170 140 50} box EMBOSSED_FRAME labeltype SHADOW_LABEL labelfont 3 labelsize 38
}
Fl_Scrollbar {} {
label scrollbar selected
xywh {40 220 180 20} type Horizontal maximum 100
label scrollbar
xywh {40 274 180 20} type Horizontal
}
Fl_Roller {} {
label roller
xywh {235 230 25 65}
}
Fl_Dial {} {
label dial
xywh {275 235 50 50}
}
Fl_Clock {} {
label clock
xywh {335 235 50 50}
}
}
Fl_Button {} {
label active
callback {the_group->activate();}
xywh {25 265 185 25} type Radio value 1
xywh {25 330 185 25} type Radio value 1
}
Fl_Button {} {
label inactive
callback {the_group->deactivate();}
xywh {220 265 180 25} type Radio
xywh {220 330 180 25} type Radio
}
}
}

View File

@ -62,9 +62,9 @@ void button_cb(Fl_Widget *,void *) {
void color_cb(Fl_Widget* button, void* v) {
Fl_Color c;
switch ((int)v) {
case 0: c = FL_WHITE; break;
case 0: c = FL_BACKGROUND2_COLOR; break;
case 1: c = FL_SELECTION_COLOR; break;
default: c = FL_BLACK; break;
default: c = FL_FOREGROUND_COLOR; break;
}
uchar r,g,b; Fl::get_color(c, r,g,b);
if (fl_color_chooser(0,r,g,b)) {
@ -75,13 +75,17 @@ void color_cb(Fl_Widget* button, void* v) {
}
int main(int argc, char **argv) {
// the following two lines set the correct color scheme, so that
// calling fl_contrast below will return good results
Fl::args(argc, argv);
Fl::get_system_colors();
Fl_Window *window = new Fl_Window(400,400);
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]->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");

View File

@ -30,8 +30,9 @@
#include <FL/fl_ask.H>
#include <stdio.h>
int main(int, char **) {
int main(int argc, char **argv) {
Fl::scheme(NULL);
Fl::args(argc, argv);
Fl::get_system_colors();
fl_message("Spelling check sucessful, %d errors found with %g%% confidence",