Author: manolo
Date: 2011-02-05 05:54:56 -0800 (Sat, 05 Feb 2011)
New Revision: 8374
Log:
Removed global variables fl_font_ and fl_size_ that are now distinct for each 
graphics device.

Modified:
   branches/branch-1.3/FL/Fl_Device.H
   branches/branch-1.3/FL/Fl_PostScript.H
   branches/branch-1.3/FL/fl_draw.H
   branches/branch-1.3/src/Fl_Device.cxx
   branches/branch-1.3/src/Fl_PostScript.cxx
   branches/branch-1.3/src/fl_font_mac.cxx
   branches/branch-1.3/src/fl_font_win32.cxx
   branches/branch-1.3/src/fl_font_x.cxx
   branches/branch-1.3/src/fl_font_xft.cxx
   branches/branch-1.3/src/gl_draw.cxx

Modified: branches/branch-1.3/FL/Fl_Device.H
===================================================================
--- branches/branch-1.3/FL/Fl_Device.H  2011-02-05 09:46:31 UTC (rev 8373)
+++ branches/branch-1.3/FL/Fl_Device.H  2011-02-05 13:54:56 UTC (rev 8374)
@@ -59,6 +59,8 @@
 
 #define MATRIX_STACK_SIZE 32
 #define MATRIX_STACK_MAX (MATRIX_STACK_SIZE - 1)
+/** A 2D coordinate transformation matrix
+ */
 struct matrix {double a, b, c, d, x, y;};
 
 // typedef what the x,y fields in a point are:
@@ -110,6 +112,8 @@
  in the \ref fl_drawings and \ref fl_attributes modules. 
   */
 class FL_EXPORT Fl_Graphics_Driver : public Fl_Device {
+  Fl_Font font_; // current font
+  Fl_Fontsize size_; // current font size
   enum {LINE, LOOP, POLYGON, POINT_};
   int sptr;
   matrix stack[MATRIX_STACK_SIZE];
@@ -199,7 +203,7 @@
   friend FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, 
int X,int Y,int W,int H, int D);
   friend void gl_start();
 
-  matrix *fl_matrix;
+  matrix *fl_matrix; /**< Points to the current coordinate transformation 
matrix */
 
   /** \brief The constructor. */
   Fl_Graphics_Driver();
@@ -345,7 +349,11 @@
 public:
   static const char *class_id;
   /** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */
-  virtual void font(Fl_Font face, Fl_Fontsize size) = 0;
+  virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ = 
size;}
+  /** \brief see fl_font(). */
+  Fl_Font font() {return font_; }
+  /** \brief see fl_size(). */
+  Fl_Fontsize size() {return size_; }
   /** \brief The destructor */
   virtual ~Fl_Graphics_Driver() {};
 };

Modified: branches/branch-1.3/FL/Fl_PostScript.H
===================================================================
--- branches/branch-1.3/FL/Fl_PostScript.H      2011-02-05 09:46:31 UTC (rev 
8373)
+++ branches/branch-1.3/FL/Fl_PostScript.H      2011-02-05 13:54:56 UTC (rev 
8374)
@@ -76,8 +76,6 @@
   Clip * clip_;
   
   int lang_level_;
-  int font_;
-  int size_;
   int gap_;
   int pages_;
   
@@ -182,8 +180,6 @@
   void transformed_vertex(double x, double y);
   
   void font(int face, int size);
-  int font(){return font_;};
-  int size(){return size_;};
   
   void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int 
ldelta=0){draw_scaled_image(d,x,y,w,h,w,h,delta,ldelta);};
   void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, 
int ld=0){draw_scaled_image_mono(d,x,y,w,h,w,h,delta,ld);};

Modified: branches/branch-1.3/FL/fl_draw.H
===================================================================
--- branches/branch-1.3/FL/fl_draw.H    2011-02-05 09:46:31 UTC (rev 8373)
+++ branches/branch-1.3/FL/fl_draw.H    2011-02-05 13:54:56 UTC (rev 8374)
@@ -480,20 +480,17 @@
   Lines should be spaced \p size pixels apart or more.
 */
 inline void fl_font(Fl_Font face, Fl_Fontsize size) { 
fl_graphics_driver->font(face,size); }
-extern FL_EXPORT Fl_Font fl_font_; ///< current font index
 
 /**
   Returns the \p face set by the most recent call to fl_font().
   This can be used to save/restore the font.
 */
-inline Fl_Font fl_font() {return fl_font_;}
-/** \brief current font size */
-extern FL_EXPORT Fl_Fontsize fl_size_;
+inline Fl_Font fl_font() {return fl_graphics_driver->font();}
 /**
   Returns the \p size set by the most recent call to fl_font().
   This can be used to save/restore the font.
 */
-inline Fl_Fontsize fl_size() {return fl_size_;}
+inline Fl_Fontsize fl_size() {return fl_graphics_driver->size();}
 
 // information you can get about the current font:
 /**

Modified: branches/branch-1.3/src/Fl_Device.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Device.cxx       2011-02-05 09:46:31 UTC (rev 
8373)
+++ branches/branch-1.3/src/Fl_Device.cxx       2011-02-05 13:54:56 UTC (rev 
8374)
@@ -54,11 +54,13 @@
 static matrix m0 = {1, 0, 0, 1, 0, 0};
 
 Fl_Graphics_Driver::Fl_Graphics_Driver() {
-       sptr=0; rstackptr=0; 
-       fl_clip_state_number=0;
-       m = m0; 
-       fl_matrix = &m; 
-       p = (XPOINT *)0;
+  font_ = 0;
+  size_ = 0;
+  sptr=0; rstackptr=0; 
+  fl_clip_state_number=0;
+  m = m0; 
+  fl_matrix = &m; 
+  p = (XPOINT *)0;
 };
 
 //

Modified: branches/branch-1.3/src/Fl_PostScript.cxx
===================================================================
--- branches/branch-1.3/src/Fl_PostScript.cxx   2011-02-05 09:46:31 UTC (rev 
8373)
+++ branches/branch-1.3/src/Fl_PostScript.cxx   2011-02-05 13:54:56 UTC (rev 
8374)
@@ -589,15 +589,14 @@
 void Fl_PostScript_Graphics_Driver::recover(){
   color(cr_,cg_,cb_);
   line_style(linestyle_,linewidth_,linedash_);
-  font(font_,size_);
+  font(Fl_Graphics_Driver::font(), Fl_Graphics_Driver::size());
 }
 
 void Fl_PostScript_Graphics_Driver::reset(){
   gap_=1;
   clip_=0;
   cr_=cg_=cb_=0;
-  font_=FL_HELVETICA;
-  size_=12;
+  Fl_Graphics_Driver::font(FL_HELVETICA, 12);
   linewidth_=0;
   linestyle_=FL_SOLID;
   strcpy(linedash_,"");
@@ -932,7 +931,7 @@
   fprintf(output, "/%s SF\n" , _fontNames[f]);
   fprintf(output,"%i FS\n", s);
   Fl_Display_Device::display_device()->driver()->font(f,s); // Use display 
fonts for font measurement
-  font_ = f; size_ = s;
+  Fl_Graphics_Driver::font(f, s);
 }
 
 void Fl_PostScript_Graphics_Driver::color(Fl_Color c) {

Modified: branches/branch-1.3/src/fl_font_mac.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_mac.cxx     2011-02-05 09:46:31 UTC (rev 
8373)
+++ branches/branch-1.3/src/fl_font_mac.cxx     2011-02-05 13:54:56 UTC (rev 
8374)
@@ -250,18 +250,12 @@
 ////////////////////////////////////////////////////////////////
 // Public interface:
 
-Fl_Font fl_font_ = 0;
-Fl_Fontsize fl_size_ = 0;
-
-
 void Fl_Quartz_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
   if (fnum==-1) {
-    fl_font_ = 0; 
-    fl_size_ = 0;
+    Fl_Graphics_Driver::font(0, 0);
     return;
   }
-  fl_font_ = fnum;
-  fl_size_ = size;
+  Fl_Graphics_Driver::font(fnum, size);
   fl_font(find(fnum, size));
 }
 

Modified: branches/branch-1.3/src/fl_font_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_win32.cxx   2011-02-05 09:46:31 UTC (rev 
8373)
+++ branches/branch-1.3/src/fl_font_win32.cxx   2011-02-05 13:54:56 UTC (rev 
8374)
@@ -132,11 +132,11 @@
 ////////////////////////////////////////////////////////////////
 // Public interface:
 
-Fl_Font fl_font_ = 0;
-Fl_Fontsize fl_size_ = 0;
+static Fl_Font fl_font_ = 0;
+static Fl_Fontsize fl_size_ = 0;
 //static HDC font_gc;
 
-void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) {
+static void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) {
   if (fnum==-1) { // just make sure that we will load a new font next time
     fl_font_ = 0; fl_size_ = 0; fl_angle_ = 0;
     return;
@@ -148,6 +148,7 @@
 
 void Fl_GDI_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
   fl_font(fnum, size, 0);
+  Fl_Graphics_Driver::font(fl_font_, fl_size_);
 }
 
 int fl_height() {

Modified: branches/branch-1.3/src/fl_font_x.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_x.cxx       2011-02-05 09:46:31 UTC (rev 
8373)
+++ branches/branch-1.3/src/fl_font_x.cxx       2011-02-05 13:54:56 UTC (rev 
8374)
@@ -260,8 +260,6 @@
 ////////////////////////////////////////////////////////////////
 // Public interface:
 
-Fl_Font fl_font_ = 0;
-Fl_Fontsize fl_size_ = 0;
 void *fl_xftfont = 0;
 static GC font_gc;
 
@@ -271,11 +269,11 @@
 
 void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
   if (fnum==-1) {
-    fl_font_ = 0; fl_size_ = 0;
+    Fl_Graphics_Driver::font(0, 0);
     return;
   }
-  if (fnum == fl_font_ && size == fl_size_) return;
-  fl_font_ = fnum; fl_size_ = size;
+  if (fnum == Fl_Graphics_Driver::font() && size == 
Fl_Graphics_Driver::size()) return;
+  Fl_Graphics_Driver::font(fnum, size);
   Fl_Font_Descriptor* f = find(fnum, size);
   if (f != fl_fontsize) {
     fl_fontsize = f;

Modified: branches/branch-1.3/src/fl_font_xft.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_xft.cxx     2011-02-05 09:46:31 UTC (rev 
8373)
+++ branches/branch-1.3/src/fl_font_xft.cxx     2011-02-05 13:54:56 UTC (rev 
8374)
@@ -110,8 +110,8 @@
 
 #define current_font (fl_fontsize->font)
 
-Fl_Font fl_font_ = 0;
-Fl_Fontsize fl_size_ = 0;
+static Fl_Font fl_font_ = 0;
+static Fl_Fontsize fl_size_ = 0;
 int fl_angle_ = 0; // internal for rotating text support
 Fl_XFont_On_Demand fl_xfont;
 void *fl_xftfont = 0;
@@ -154,6 +154,7 @@
 
 void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
   fl_font(fnum,size,0);
+  Fl_Graphics_Driver::font(fl_font_, fl_size_);
 }
 
 static XftFont* fontopen(const char* name, bool core, int angle) {

Modified: branches/branch-1.3/src/gl_draw.cxx
===================================================================
--- branches/branch-1.3/src/gl_draw.cxx 2011-02-05 09:46:31 UTC (rev 8373)
+++ branches/branch-1.3/src/gl_draw.cxx 2011-02-05 13:54:56 UTC (rev 8374)
@@ -35,6 +35,7 @@
 #include <FL/gl.h>
 #include <FL/x.H>
 #include <FL/fl_draw.H>
+#include <FL/Fl_Device.H>
 #include "Fl_Gl_Choice.H"
 #include "Fl_Font.H"
 #include <FL/fl_utf8.h>
@@ -161,8 +162,7 @@
 # if HAVE_GL
 
   // clear variables used mostly in fl_font
-  fl_font_ = 0;
-  fl_size_ = 0;
+  fl_graphics_driver->font(0, 0);
 
   for (int j = 0 ; j < FL_FREE_FONT ; ++j)
   {

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

Reply via email to