diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-12-16 21:59:39 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-12-16 21:59:43 +0100 |
| commit | 469d3ef3d5e9bc27eb5cd0ef6532f89568604572 (patch) | |
| tree | 3a76a496fc53c2d50ab21f1d961b75a54fa1f7c6 /src | |
| parent | 638e762d3ebdb0b2e736e1deecaa7d86529fc1e5 (diff) | |
#842: Enables command line color arguments on macOS
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Screen_Driver.H | 2 | ||||
| -rw-r--r-- | src/Fl_Screen_Driver.cxx | 30 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx | 2 |
3 files changed, 33 insertions, 1 deletions
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 <FL/Fl_Image.H> #include <FL/Fl.H> +#include <FL/platform.H> #include <FL/Fl_Group.H> #include <FL/Fl_Window.H> #include <FL/Fl_Input.H> @@ -32,6 +33,12 @@ #include <FL/Fl_Tooltip.H> #include <string.h> // 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); |
