summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx38
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h1
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx34
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h1
-rw-r--r--src/drivers/X11/Fl_X11_Screen_Driver.cxx44
-rw-r--r--src/drivers/X11/Fl_X11_Screen_Driver.h1
6 files changed, 118 insertions, 1 deletions
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
index 9c6ff5dfa..e34f8b998 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
+++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
@@ -19,6 +19,7 @@
#include "../../config_lib.h"
#include "Fl_Cocoa_Screen_Driver.h"
+#include <FL/Fl.H>
#include <FL/fl_ask.h>
#include <stdio.h>
@@ -145,6 +146,43 @@ int Fl_Cocoa_Screen_Driver::parse_color(const char* p, uchar& r, uchar& g, uchar
}
+static void set_selection_color(uchar r, uchar g, uchar b)
+{
+ Fl::set_color(FL_SELECTION_COLOR,r,g,b);
+}
+
+
+// MacOS X currently supports two color schemes - Blue and Graphite.
+// Since we aren't emulating the Aqua interface (even if Apple would
+// let us), we use some defaults that are similar to both. The
+// Fl::scheme("plastic") color/box scheme provides a usable Aqua-like
+// look-n-feel...
+void Fl_Cocoa_Screen_Driver::get_system_colors()
+{
+ fl_open_display();
+
+ if (!bg2_set) Fl::background2(0xff, 0xff, 0xff);
+ if (!fg_set) Fl::foreground(0, 0, 0);
+ if (!bg_set) Fl::background(0xd8, 0xd8, 0xd8);
+
+#if 0
+ // this would be the correct code, but it does not run on all versions
+ // of OS X. Also, setting a bright selection color would require
+ // some updates in Fl_Adjuster and Fl_Help_Browser
+ OSStatus err;
+ RGBColor c;
+ err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor, 24, true, &c);
+ if (err)
+ set_selection_color(0x00, 0x00, 0x80);
+ else
+ set_selection_color(c.red, c.green, c.blue);
+#else
+ set_selection_color(0x00, 0x00, 0x80);
+#endif
+}
+
+
+
//
// End of "$Id$".
//
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h
index 02852c514..b06192205 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h
+++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h
@@ -61,6 +61,7 @@ public:
virtual void flush();
// --- global colors
virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b);
+ virtual void get_system_colors();
};
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
index f30bee01c..9c3b450cd 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
@@ -241,7 +241,7 @@ void Fl_WinAPI_Screen_Driver::flush()
// simulation of XParseColor:
-int Fl_WinAPI_Screen_Driverparse_color(const char* p, uchar& r, uchar& g, uchar& b)
+int Fl_WinAPI_Screen_Driver::parse_color(const char* p, uchar& r, uchar& g, uchar& b)
{
if (*p == '#') p++;
size_t n = strlen(p);
@@ -265,6 +265,38 @@ int Fl_WinAPI_Screen_Driverparse_color(const char* p, uchar& r, uchar& g, uchar&
}
+static void set_selection_color(uchar r, uchar g, uchar b)
+{
+ Fl::set_color(FL_SELECTION_COLOR,r,g,b);
+}
+
+
+static void getsyscolor(int what, const char* arg, void (*func)(uchar,uchar,uchar))
+{
+ if (arg) {
+ uchar r,g,b;
+ if (!fl_parse_color(arg, r,g,b))
+ Fl::error("Unknown color: %s", arg);
+ else
+ func(r,g,b);
+ } else {
+ DWORD x = GetSysColor(what);
+ func(uchar(x&255), uchar(x>>8), uchar(x>>16));
+ }
+}
+
+
+void Fl_WinAPI_Screen_Driver::get_system_colors()
+{
+ if (!bg2_set) getsyscolor(COLOR_WINDOW, fl_bg2,Fl::background2);
+ if (!fg_set) getsyscolor(COLOR_WINDOWTEXT, fl_fg, Fl::foreground);
+ if (!bg_set) getsyscolor(COLOR_BTNFACE, fl_bg, Fl::background);
+ getsyscolor(COLOR_HIGHLIGHT, 0, set_selection_color);
+}
+
+
+
+
//
// End of "$Id$".
// \ No newline at end of file
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h
index ac9849246..b44b70ebb 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h
@@ -55,6 +55,7 @@ public:
virtual void flush();
// --- global colors
virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b);
+ virtual void get_system_colors();
};
diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx
index 49fa840f5..7991e94f8 100644
--- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx
@@ -246,6 +246,50 @@ int Fl_X11_Screen_Driver::parse_color(const char* p, uchar& r, uchar& g, uchar&
}
+// Read colors that KDE writes to the xrdb database.
+
+// XGetDefault does not do the expected thing: it does not like
+// periods in either word. Therefore it cannot match class.Text.background.
+// However *.Text.background is matched by pretending the program is "Text".
+// But this will also match *.background if there is no *.Text.background
+// entry, requiring users to put in both (unless they want the text fields
+// the same color as the windows).
+
+static void set_selection_color(uchar r, uchar g, uchar b)
+{
+ Fl::set_color(FL_SELECTION_COLOR,r,g,b);
+}
+
+static void getsyscolor(const char *key1, const char* key2, const char *arg, const char *defarg, void (*func)(uchar,uchar,uchar))
+{
+ if (!arg) {
+ arg = XGetDefault(fl_display, key1, key2);
+ if (!arg) arg = defarg;
+ }
+ XColor x;
+ if (!XParseColor(fl_display, fl_colormap, arg, &x))
+ Fl::error("Unknown color: %s", arg);
+ else
+ func(x.red>>8, x.green>>8, x.blue>>8);
+}
+
+
+void Fl_X11_Screen_Driver::get_system_colors()
+{
+ fl_open_display();
+ const char* key1 = 0;
+ if (Fl::first_window()) key1 = Fl::first_window()->xclass();
+ if (!key1) key1 = "fltk";
+ if (!bg2_set)
+ getsyscolor("Text","background", fl_bg2, "#ffffff", Fl::background2);
+ if (!fg_set)
+ getsyscolor(key1, "foreground", fl_fg, "#000000", Fl::foreground);
+ if (!bg_set)
+ getsyscolor(key1, "background", fl_bg, "#c0c0c0", Fl::background);
+ getsyscolor("Text", "selectBackground", 0, "#000080", set_selection_color);
+}
+
+
//
// End of "$Id$".
//
diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.h b/src/drivers/X11/Fl_X11_Screen_Driver.h
index 27ced8822..f93e6e2d0 100644
--- a/src/drivers/X11/Fl_X11_Screen_Driver.h
+++ b/src/drivers/X11/Fl_X11_Screen_Driver.h
@@ -59,6 +59,7 @@ public:
virtual void flush();
// --- global colors
virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b);
+ virtual void get_system_colors();
};