diff --git a/src/Fl_Screen_Driver.H b/src/Fl_Screen_Driver.H index 0772281a6..bfff5b03d 100644 --- a/src/Fl_Screen_Driver.H +++ b/src/Fl_Screen_Driver.H @@ -142,7 +142,7 @@ public: // --- global colors /* the default implementation of parse_color() may be enough */ virtual int parse_color(const char *p, uchar &r, uchar &g, uchar &b); - virtual void get_system_colors() {} + virtual void get_system_colors(); /* the default implementation of get_system_scheme() may be enough */ virtual const char *get_system_scheme(); diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx index 877576fdf..af6b3a3c3 100644 --- a/src/Fl_Screen_Driver.cxx +++ b/src/Fl_Screen_Driver.cxx @@ -23,6 +23,7 @@ #include "Fl_Screen_Driver.H" #include #include +#include #include #include #include @@ -32,6 +33,12 @@ #include #include // for memchr +// these are set by Fl::args() and override any system colors: from Fl_get_system_colors.cxx +extern const char *fl_fg; +extern const char *fl_bg; +extern const char *fl_bg2; +// end of extern additions workaround + char Fl_Screen_Driver::bg_set = 0; char Fl_Screen_Driver::bg2_set = 0; char Fl_Screen_Driver::fg_set = 0; @@ -181,6 +188,29 @@ int Fl_Screen_Driver::screen_num(int x, int y, int w, int h) return best_screen; } +static void getsyscolor(const char* arg, void (*func)(uchar,uchar,uchar)) +{ + if (arg && *arg) { + uchar r,g,b; + if (!fl_parse_color(arg, r,g,b)) + Fl::error("Unknown color: %s", arg); + else + func(r,g,b); + } +} + +static void set_selection_color(uchar r, uchar g, uchar b) +{ + Fl::set_color(FL_SELECTION_COLOR,r,g,b); +} + +void Fl_Screen_Driver::get_system_colors() +{ + if (!bg2_set) getsyscolor(fl_bg2, Fl::background2); + if (!fg_set) getsyscolor(fl_fg, Fl::foreground); + if (!bg_set) getsyscolor(fl_bg, Fl::background); + getsyscolor(0, set_selection_color); +} const char *Fl_Screen_Driver::get_system_scheme() { diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx index 012261b2c..7eb98b291 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx @@ -210,6 +210,8 @@ void Fl_Cocoa_Screen_Driver::get_system_colors() { open_display(); + Fl_Screen_Driver::get_system_colors(); + if (!bg2_set) Fl::background2(0xff, 0xff, 0xff); if (!fg_set) Fl::foreground(0, 0, 0); if (!bg_set) Fl::background(0xd8, 0xd8, 0xd8); diff --git a/test/hello.cxx b/test/hello.cxx index 299d58098..d7308cd78 100644 --- a/test/hello.cxx +++ b/test/hello.cxx @@ -26,6 +26,6 @@ int main(int argc, char **argv) { box->labelsize(36); box->labeltype(FL_SHADOW_LABEL); window->end(); - window->show();//argc, argv); + window->show(argc, argv); return Fl::run(); }