diff options
Diffstat (limited to 'src/fl_color.cxx')
| -rw-r--r-- | src/fl_color.cxx | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/src/fl_color.cxx b/src/fl_color.cxx index 33f92478d..735757427 100644 --- a/src/fl_color.cxx +++ b/src/fl_color.cxx @@ -124,6 +124,26 @@ Fl_XColor fl_xmap[1][256]; # define fl_overlay 0 # endif +/** Current color for drawing operations */ +Fl_Color fl_color_; + +void Fl_Device::color(Fl_Color i) { + if (i & 0xffffff00) { + unsigned rgb = (unsigned)i; + fl_color((uchar)(rgb >> 24), (uchar)(rgb >> 16), (uchar)(rgb >> 8)); + } else { + fl_color_ = i; + if(!fl_gc) return; // don't get a default gc if current window is not yet created/valid + XSetForeground(fl_display, fl_gc, fl_xpixel(i)); + } +} + +void Fl_Device::color(uchar r,uchar g,uchar b) { + fl_color_ = fl_rgb_color(r, g, b); + if(!fl_gc) return; // don't get a default gc if current window is not yet created/valid + XSetForeground(fl_display, fl_gc, fl_xpixel(r,g,b)); +} + /** \addtogroup fl_attributes @{ */ //////////////////////////////////////////////////////////////// @@ -161,22 +181,6 @@ ulong fl_xpixel(uchar r,uchar g,uchar b) { ) >> fl_extrashift; } -/** - Set the color for all subsequent drawing operations. - The closest possible match to the RGB color is used. - The RGB color is used directly on TrueColor displays. - For colormap visuals the nearest index in the gray - ramp or color cube is used. - If no valid graphical context (fl_gc) is available, - the foreground is not set for the current window. - \param[in] r,g,b color components -*/ -void Fl_Device::color(uchar r,uchar g,uchar b) { - fl_color_ = fl_rgb_color(r, g, b); - if(!fl_gc) return; // don't get a default gc if current window is not yet created/valid - XSetForeground(fl_display, fl_gc, fl_xpixel(r,g,b)); -} - //////////////////////////////////////////////////////////////// // Get a color out of the fltk colormap. Again for truecolor // visuals this is easy. For colormap this actually tries to allocate @@ -316,29 +320,6 @@ ulong fl_xpixel(Fl_Color i) { # endif } -/** Current color for drawing operations */ -Fl_Color fl_color_; - -/** - Sets the color for all subsequent drawing operations. - For colormapped displays, a color cell will be allocated out of - \p fl_colormap the first time you use a color. If the colormap fills up - then a least-squares algorithm is used to find the closest color. - If no valid graphical context (fl_gc) is available, - the foreground is not set for the current window. - \param[in] i color -*/ -void Fl_Device::color(Fl_Color i) { - if (i & 0xffffff00) { - unsigned rgb = (unsigned)i; - fl_color((uchar)(rgb >> 24), (uchar)(rgb >> 16), (uchar)(rgb >> 8)); - } else { - fl_color_ = i; - if(!fl_gc) return; // don't get a default gc if current window is not yet created/valid - XSetForeground(fl_display, fl_gc, fl_xpixel(i)); - } -} - /** Free color \p i if used, and clear mapping table entry. \param[in] i color index |
