summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-01-09 07:26:49 +0000
committerManolo Gouy <Manolo>2018-01-09 07:26:49 +0000
commit3b437dae8ce735cded87e93021cb2026cc63cb30 (patch)
tree874a5c2e44dd202e26d980a804dabf7d6114454b
parent9f0e9ff8138fcd1ee817fe144282513283b0e331 (diff)
Put a default implementation of parse_color() in Fl_Screen_Driver and only Fl_X11_Screen_Driver reimplements it.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12628 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Screen_Driver.H3
-rw-r--r--src/Fl_Screen_Driver.cxx25
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H1
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx25
-rw-r--r--src/drivers/Pico/Fl_Pico_Screen_Driver.H1
-rw-r--r--src/drivers/Pico/Fl_Pico_Screen_Driver.cxx8
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H1
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx25
8 files changed, 28 insertions, 61 deletions
diff --git a/FL/Fl_Screen_Driver.H b/FL/Fl_Screen_Driver.H
index c3b36779b..df917a066 100644
--- a/FL/Fl_Screen_Driver.H
+++ b/FL/Fl_Screen_Driver.H
@@ -92,7 +92,8 @@ public:
virtual int ready() = 0;
virtual void grab(Fl_Window* win) = 0;
// --- global colors
- virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b) = 0;
+ /* 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() = 0;
virtual const char *get_system_scheme();
// --- global timers
diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx
index 822500a42..5c537ef14 100644
--- a/src/Fl_Screen_Driver.cxx
+++ b/src/Fl_Screen_Driver.cxx
@@ -495,6 +495,31 @@ void Fl_Screen_Driver::open_display()
}
}
+
+// simulation of XParseColor:
+int Fl_Screen_Driver::parse_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/Cocoa/Fl_Cocoa_Screen_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
index 5e318a2e3..3fe29700c 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
@@ -74,7 +74,6 @@ public:
virtual int ready();
virtual void grab(Fl_Window* win);
// --- global colors
- virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b);
virtual void get_system_colors();
virtual const char *get_system_scheme();
// --- global timers
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
index 1d0ae53d8..c009af328 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
+++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
@@ -167,31 +167,6 @@ void Fl_Cocoa_Screen_Driver::grab(Fl_Window* win)
}
-// simulation of XParseColor:
-int Fl_Cocoa_Screen_Driver::parse_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;
-}
-
-
static void set_selection_color(uchar r, uchar g, uchar b)
{
Fl::set_color(FL_SELECTION_COLOR,r,g,b);
diff --git a/src/drivers/Pico/Fl_Pico_Screen_Driver.H b/src/drivers/Pico/Fl_Pico_Screen_Driver.H
index 184fd9241..4d092f6dc 100644
--- a/src/drivers/Pico/Fl_Pico_Screen_Driver.H
+++ b/src/drivers/Pico/Fl_Pico_Screen_Driver.H
@@ -48,7 +48,6 @@ public:
virtual int ready();
virtual void grab(Fl_Window* win);
// --- global colors
- virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b);
virtual void get_system_colors();
// --- global timers
virtual void add_timeout(double time, Fl_Timeout_Handler cb, void *argp);
diff --git a/src/drivers/Pico/Fl_Pico_Screen_Driver.cxx b/src/drivers/Pico/Fl_Pico_Screen_Driver.cxx
index b165989bb..912e92144 100644
--- a/src/drivers/Pico/Fl_Pico_Screen_Driver.cxx
+++ b/src/drivers/Pico/Fl_Pico_Screen_Driver.cxx
@@ -108,12 +108,6 @@ void Fl_Pico_Screen_Driver::grab(Fl_Window* win)
}
-int Fl_Pico_Screen_Driver::parse_color(const char* p, uchar& r, uchar& g, uchar& b)
-{
- return 0;
-}
-
-
void Fl_Pico_Screen_Driver::get_system_colors()
{
}
@@ -142,4 +136,4 @@ void Fl_Pico_Screen_Driver::remove_timeout(Fl_Timeout_Handler cb, void *argp)
//
// 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 628fc9511..e28fb791a 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H
@@ -70,7 +70,6 @@ public:
virtual int ready();
virtual void grab(Fl_Window* win);
// --- global colors
- virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b);
virtual void get_system_colors();
virtual const char *get_system_scheme();
// --- global timers
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
index d4fed5922..03aa93ecf 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
@@ -299,31 +299,6 @@ void Fl_WinAPI_Screen_Driver::grab(Fl_Window* win)
}
-// simulation of XParseColor:
-int Fl_WinAPI_Screen_Driver::parse_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;
-}
-
-
static void set_selection_color(uchar r, uchar g, uchar b)
{
Fl::set_color(FL_SELECTION_COLOR,r,g,b);