Author: manolo
Date: 2011-02-06 04:32:23 -0800 (Sun, 06 Feb 2011)
New Revision: 8384
Log:
Replaced global variable fl_color_ by a private member of the 
Fl_Graphics_Driver class,
and a public getter to it: Fl_Graphics_Driver::color().

Modified:
   branches/branch-1.3/FL/Fl_Device.H
   branches/branch-1.3/FL/fl_draw.H
   branches/branch-1.3/src/Fl_PostScript.cxx
   branches/branch-1.3/src/Fl_cocoa.mm
   branches/branch-1.3/src/fl_color.cxx
   branches/branch-1.3/src/fl_color_mac.cxx
   branches/branch-1.3/src/fl_color_win32.cxx
   branches/branch-1.3/src/fl_font_xft.cxx

Modified: branches/branch-1.3/FL/Fl_Device.H
===================================================================
--- branches/branch-1.3/FL/Fl_Device.H  2011-02-06 12:20:16 UTC (rev 8383)
+++ branches/branch-1.3/FL/Fl_Device.H  2011-02-06 12:32:23 UTC (rev 8384)
@@ -114,6 +114,7 @@
 class FL_EXPORT Fl_Graphics_Driver : public Fl_Device {
   Fl_Font font_; // current font
   Fl_Fontsize size_; // current font size
+  Fl_Color color_; // current color
   enum {LINE, LOOP, POLYGON, POINT_};
   int sptr;
   matrix stack[MATRIX_STACK_SIZE];
@@ -236,7 +237,7 @@
   /** \brief see fl_rtl_draw(const char *str, int n, int x, int y). */
   virtual void rtl_draw(const char *str, int n, int x, int y) = 0;
   /** \brief see fl_color(Fl_Color c). */
-  virtual void color(Fl_Color c) = 0;
+  virtual void color(Fl_Color c) {color_ = c;}
   /** \brief see fl_color(uchar r, uchar g, uchar b). */
   virtual void color(uchar r, uchar g, uchar b) = 0;
   /** \brief see fl_point(int x, int y). */
@@ -350,10 +351,12 @@
   static const char *class_id;
   /** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */
   virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ = 
size;}
-  /** \brief see fl_font(). */
+  /** \brief see fl_font(void). */
   Fl_Font font() {return font_; }
   /** \brief see fl_size(). */
   Fl_Fontsize size() {return size_; }
+  /** \brief see fl_color(void). */
+  Fl_Color color() {return color_;}
   /** \brief The destructor */
   virtual ~Fl_Graphics_Driver() {};
 };

Modified: branches/branch-1.3/FL/fl_draw.H
===================================================================
--- branches/branch-1.3/FL/fl_draw.H    2011-02-06 12:20:16 UTC (rev 8383)
+++ branches/branch-1.3/FL/fl_draw.H    2011-02-06 12:32:23 UTC (rev 8384)
@@ -72,13 +72,11 @@
  \param[in] r,g,b color components
  */
 inline void    fl_color(uchar r, uchar g, uchar b) 
{fl_graphics_driver->color(r,g,b); } // select actual color
-/** \brief The current color */
-extern FL_EXPORT Fl_Color fl_color_;
 /**
   Returns the last fl_color() that was set.
   This can be used for state save/restore.
 */
-inline Fl_Color fl_color() {return fl_color_;}
+inline Fl_Color fl_color() {return fl_graphics_driver->color();}
 /** @} */
 
 /** \addtogroup fl_drawings

Modified: branches/branch-1.3/src/Fl_PostScript.cxx
===================================================================
--- branches/branch-1.3/src/Fl_PostScript.cxx   2011-02-06 12:20:16 UTC (rev 
8383)
+++ branches/branch-1.3/src/Fl_PostScript.cxx   2011-02-06 12:32:23 UTC (rev 
8384)
@@ -940,7 +940,7 @@
 }
 
 void Fl_PostScript_Graphics_Driver::color(unsigned char r, unsigned char g, 
unsigned char b) {
-  fl_color_ = fl_rgb_color(r, g, b);
+  Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
   cr_ = r; cg_ = g; cb_ = b;
   if (r == g && g == b) {
     double gray = r/255.0;

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2011-02-06 12:20:16 UTC (rev 8383)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2011-02-06 12:32:23 UTC (rev 8384)
@@ -2238,7 +2238,6 @@
 }
 
 // helper function to manage the current CGContext fl_gc
-extern Fl_Color fl_color_;
 extern class Fl_Font_Descriptor *fl_fontsize;
 extern void fl_font(class Fl_Font_Descriptor*);
 extern void fl_quartz_restore_line_style_();
@@ -2253,7 +2252,7 @@
     CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the 
context
     }
   fl_font(fl_fontsize);
-  fl_color(fl_color_);
+  fl_color(fl_graphics_driver->color());
   fl_quartz_restore_line_style_();
 }
 

Modified: branches/branch-1.3/src/fl_color.cxx
===================================================================
--- branches/branch-1.3/src/fl_color.cxx        2011-02-06 12:20:16 UTC (rev 
8383)
+++ branches/branch-1.3/src/fl_color.cxx        2011-02-06 12:32:23 UTC (rev 
8384)
@@ -124,22 +124,19 @@
 #    define fl_overlay 0
 #  endif
 
-/** Current color for drawing operations */
-Fl_Color fl_color_;
-
 void Fl_Xlib_Graphics_Driver::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;
+    Fl_Graphics_Driver::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_Xlib_Graphics_Driver::color(uchar r,uchar g,uchar b) {
-  fl_color_ = fl_rgb_color(r, g, b);
+  Fl_Graphics_Driver::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));
 }

Modified: branches/branch-1.3/src/fl_color_mac.cxx
===================================================================
--- branches/branch-1.3/src/fl_color_mac.cxx    2011-02-06 12:20:16 UTC (rev 
8383)
+++ branches/branch-1.3/src/fl_color_mac.cxx    2011-02-06 12:32:23 UTC (rev 
8384)
@@ -47,10 +47,8 @@
 
 Fl_XMap* fl_current_xmap;
 
-Fl_Color fl_color_;
-
 void Fl_Quartz_Graphics_Driver::color(Fl_Color i) {
-  fl_color_ = i;
+  Fl_Graphics_Driver::color(i);
   int index;
   uchar r, g, b;
   if (i & 0xFFFFFF00) {
@@ -75,7 +73,7 @@
 }
 
 void Fl_Quartz_Graphics_Driver::color(uchar r, uchar g, uchar b) {
-  fl_color_ = fl_rgb_color(r, g, b);
+  Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
   float fr = r/255.0f;
   float fg = g/255.0f;
   float fb = b/255.0f;

Modified: branches/branch-1.3/src/fl_color_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_color_win32.cxx  2011-02-06 12:20:16 UTC (rev 
8383)
+++ branches/branch-1.3/src/fl_color_win32.cxx  2011-02-06 12:32:23 UTC (rev 
8384)
@@ -92,14 +92,12 @@
   xmap.brush = -1;
 }
 
-Fl_Color fl_color_;
-
 void Fl_GDI_Graphics_Driver::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;
+    Fl_Graphics_Driver::color(i);
     Fl_XMap &xmap = fl_xmap[i];
     if (!xmap.pen) {
 #if USE_COLORMAP
@@ -121,7 +119,7 @@
 void Fl_GDI_Graphics_Driver::color(uchar r, uchar g, uchar b) {
   static Fl_XMap xmap;
   COLORREF c = RGB(r,g,b);
-  fl_color_ = fl_rgb_color(r, g, b);
+  Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
   if (!xmap.pen || c != xmap.rgb) {
     clear_xmap(xmap);
     set_xmap(xmap, c);

Modified: branches/branch-1.3/src/fl_font_xft.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_xft.cxx     2011-02-06 12:20:16 UTC (rev 
8383)
+++ branches/branch-1.3/src/fl_font_xft.cxx     2011-02-06 12:32:23 UTC (rev 
8384)
@@ -614,8 +614,8 @@
   // Use fltk's color allocator, copy the results to match what
   // XftCollorAllocValue returns:
   XftColor color;
-  color.pixel = fl_xpixel(fl_color_);
-  uchar r,g,b; Fl::get_color(fl_color_, r,g,b);
+  color.pixel = fl_xpixel(fl_graphics_driver->color());
+  uchar r,g,b; Fl::get_color(fl_graphics_driver->color(), r,g,b);
   color.color.red   = ((int)r)*0x101;
   color.color.green = ((int)g)*0x101;
   color.color.blue  = ((int)b)*0x101;
@@ -659,8 +659,8 @@
   // Use fltk's color allocator, copy the results to match what
   // XftCollorAllocValue returns:
   XftColor color;
-  color.pixel = fl_xpixel(fl_color_);
-  uchar r,g,b; Fl::get_color(fl_color_, r,g,b);
+  color.pixel = fl_xpixel(fl_graphics_driver->color());
+  uchar r,g,b; Fl::get_color(fl_graphics_driver->color(), r,g,b);
   color.color.red   = ((int)r)*0x101;
   color.color.green = ((int)g)*0x101;
   color.color.blue  = ((int)b)*0x101;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to