summaryrefslogtreecommitdiff
path: root/src/drivers/WinAPI
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2016-02-13 12:57:00 +0000
committerMatthias Melcher <fltk@matthiasm.com>2016-02-13 12:57:00 +0000
commit5d1df0e789c794b8040c5db0d84b03ae2b42fd8d (patch)
tree4e99ebb978d30bf6c7138181489dd37ce435c310 /src/drivers/WinAPI
parent8deac1e6baf7a016aabd3b6cb5ccffd7f09263cd (diff)
Details on PORTME items. Move fl_parse_color() to screen drivers.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11163 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/WinAPI')
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx33
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h3
2 files changed, 32 insertions, 4 deletions
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
index 0569caca2..f30bee01c 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
@@ -20,11 +20,12 @@
#include "../../config_lib.h"
#include "Fl_WinAPI_Screen_Driver.h"
#include <FL/fl_ask.h>
+#include <stdio.h>
-# if !defined(HMONITOR_DECLARED) && (_WIN32_WINNT < 0x0500)
-# define COMPILE_MULTIMON_STUBS
-# include <multimon.h>
-# endif // !HMONITOR_DECLARED && _WIN32_WINNT < 0x0500
+#if !defined(HMONITOR_DECLARED) && (_WIN32_WINNT < 0x0500)
+# define COMPILE_MULTIMON_STUBS
+# include <multimon.h>
+#endif // !HMONITOR_DECLARED && _WIN32_WINNT < 0x0500
/**
@@ -239,6 +240,30 @@ void Fl_WinAPI_Screen_Driver::flush()
}
+// simulation of XParseColor:
+int Fl_WinAPI_Screen_Driverparse_color(const char* p, uchar& r, uchar& g, uchar& b)
+{
+ if (*p == '#') p++;
+ size_t n = strlen(p);
+ size_t m = n/3;
+ const char *pattern = 0;
+ switch(m) {
+ case 1: pattern = "%1x%1x%1x"; break;
+ case 2: pattern = "%2x%2x%2x"; break;
+ case 3: pattern = "%3x%3x%3x"; break;
+ case 4: pattern = "%4x%4x%4x"; break;
+ default: return 0;
+ }
+ int R,G,B; if (sscanf(p,pattern,&R,&G,&B) != 3) return 0;
+ switch(m) {
+ case 1: R *= 0x11; G *= 0x11; B *= 0x11; break;
+ case 3: R >>= 4; G >>= 4; B >>= 4; break;
+ case 4: R >>= 8; G >>= 8; B >>= 8; break;
+ }
+ r = (uchar)R; g = (uchar)G; b = (uchar)B;
+ return 1;
+}
+
//
// End of "$Id$".
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h
index 14bd1ff2d..ac9849246 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h
@@ -40,6 +40,7 @@ protected:
BOOL screen_cb(HMONITOR mon, HDC, LPRECT r);
public:
+ // --- screen configuration
virtual void init();
virtual int x();
virtual int y();
@@ -52,6 +53,8 @@ public:
virtual void beep(int type);
// --- global events
virtual void flush();
+ // --- global colors
+ virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b);
};