Author: manolo
Date: 2012-03-18 11:48:29 -0700 (Sun, 18 Mar 2012)
New Revision: 9293
Log:
Fix STR#2810: removed all uses of function Fl_Device::class_name().

Modified:
   branches/branch-1.3/FL/Fl_Device.H
   branches/branch-1.3/FL/Fl_Pixmap.H
   branches/branch-1.3/FL/x.H
   branches/branch-1.3/src/Fl_Bitmap.cxx
   branches/branch-1.3/src/Fl_Device.cxx
   branches/branch-1.3/src/Fl_Double_Window.cxx
   branches/branch-1.3/src/Fl_GDI_Printer.cxx
   branches/branch-1.3/src/Fl_Image.cxx
   branches/branch-1.3/src/Fl_Pixmap.cxx
   branches/branch-1.3/src/Fl_Text_Display.cxx
   branches/branch-1.3/src/Fl_cocoa.mm
   branches/branch-1.3/src/Fl_win32.cxx
   branches/branch-1.3/src/Fl_x.cxx
   branches/branch-1.3/src/fl_draw_image_mac.cxx
   branches/branch-1.3/src/fl_draw_image_win32.cxx
   branches/branch-1.3/src/fl_draw_pixmap.cxx
   branches/branch-1.3/src/fl_font_win32.cxx
   branches/branch-1.3/src/fl_line_style.cxx
   branches/branch-1.3/src/fl_rect.cxx

Modified: branches/branch-1.3/FL/Fl_Device.H
===================================================================
--- branches/branch-1.3/FL/Fl_Device.H  2012-03-18 16:02:40 UTC (rev 9292)
+++ branches/branch-1.3/FL/Fl_Device.H  2012-03-18 18:48:29 UTC (rev 9293)
@@ -73,6 +73,8 @@
   static const char *class_id;
   /** 
    Returns the name of the class of this object. 
+   Use of the class_name() function is discouraged because it will be removed 
from future FLTK versions.
+   
    The class of an instance of an Fl_Device subclass can be checked with code 
such as:
    \code
    if ( instance->class_name() == Fl_Printer::class_id ) { ... }
@@ -206,7 +208,7 @@
   friend void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int 
W,int H, int D);
   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 FL_EXPORT void gl_start();
-
+  friend void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen 
pixmap, int srcx, int srcy);
   matrix *fl_matrix; /**< Points to the current coordinate transformation 
matrix */
 
   /** \brief The constructor. */
@@ -360,7 +362,11 @@
    the image offset by the cx and cy arguments.
    */
   virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int 
cy) {}
-    
+#if FLTK_ABI_VERSION >= 10302
+  virtual
+#endif
+  void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int 
srcx, int srcy);
+  
 public:
   static const char *class_id;
   virtual const char *class_name() {return class_id;};
@@ -424,6 +430,7 @@
 #if ! defined(FL_DOXYGEN)
   static Fl_Offscreen create_offscreen_with_alpha(int w, int h);
 #endif
+  void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int 
srcx, int srcy);
 };
 #endif
 #if defined(WIN32) || defined(FL_DOXYGEN)
@@ -457,7 +464,20 @@
 #if ! defined(FL_DOXYGEN)
   void copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int 
srcx,int srcy);
 #endif
+  void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int 
srcx, int srcy);
 };
+
+/**
+ The graphics driver used when printing on MSWindows.
+ *
+ This class is implemented only on the MSWindows platform. It 's extremely 
similar to Fl_GDI_Graphics_Driver.
+ */
+class FL_EXPORT Fl_GDI_Printer_Graphics_Driver : public Fl_GDI_Graphics_Driver 
{
+public:
+  static const char *class_id;
+  const char *class_name() {return class_id;};
+  void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
+};
 #endif
 #if !(defined(__APPLE__) || defined(WIN32))
 /**
@@ -487,6 +507,7 @@
   void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
   int height();
   int descent();
+  void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int 
srcx, int srcy);
 };
 #endif
 

Modified: branches/branch-1.3/FL/Fl_Pixmap.H
===================================================================
--- branches/branch-1.3/FL/Fl_Pixmap.H  2012-03-18 16:02:40 UTC (rev 9292)
+++ branches/branch-1.3/FL/Fl_Pixmap.H  2012-03-18 18:48:29 UTC (rev 9293)
@@ -3,7 +3,7 @@
 //
 // Pixmap header file for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -38,10 +38,13 @@
 class FL_EXPORT Fl_Pixmap : public Fl_Image {
   friend class Fl_Quartz_Graphics_Driver;
   friend class Fl_GDI_Graphics_Driver;
+  friend class Fl_GDI_Printer_Graphics_Driver;
   friend class Fl_Xlib_Graphics_Driver;
   void copy_data();
   void delete_data();
   void set_data(const char * const *p);
+  int prepare(int XP, int YP, int WP, int HP, int cx, int cy,
+                        int &X, int &Y, int &W, int &H);
 
   protected:
 

Modified: branches/branch-1.3/FL/x.H
===================================================================
--- branches/branch-1.3/FL/x.H  2012-03-18 16:02:40 UTC (rev 9292)
+++ branches/branch-1.3/FL/x.H  2012-03-18 18:48:29 UTC (rev 9293)
@@ -3,7 +3,7 @@
 //
 // X11 header file for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2011 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -86,7 +86,7 @@
 typedef ulong Fl_Offscreen;
 #   define fl_create_offscreen(w,h) \
   XCreatePixmap(fl_display, \
-             (Fl_Surface_Device::surface()->class_name() == 
Fl_Display_Device::class_id ? \
+             (Fl_Surface_Device::surface() == 
Fl_Display_Device::display_device() ? \
              fl_window : fl_xid(Fl::first_window()) ) , \
              w, h, fl_visual->depth)
 // begin/end are macros that save the old state in local variables:

Modified: branches/branch-1.3/src/Fl_Bitmap.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Bitmap.cxx       2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/Fl_Bitmap.cxx       2012-03-18 18:48:29 UTC (rev 
9293)
@@ -295,7 +295,7 @@
   HDC tempdc;
   int save;
   BOOL use_print_algo = false;
-  if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) {
+  if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) {
     static HMODULE hMod = NULL;
     if (!hMod) {
       hMod = LoadLibrary("MSIMG32.DLL");

Modified: branches/branch-1.3/src/Fl_Device.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Device.cxx       2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/Fl_Device.cxx       2012-03-18 18:48:29 UTC (rev 
9293)
@@ -3,7 +3,7 @@
 //
 // implementation of Fl_Device class for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 2010-2011 by Bill Spitzak and others.
+// Copyright 2010-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -29,6 +29,7 @@
 #endif
 #if defined(WIN32) || defined(FL_DOXYGEN)
 const char *Fl_GDI_Graphics_Driver::class_id = "Fl_GDI_Graphics_Driver";
+const char *Fl_GDI_Printer_Graphics_Driver::class_id = 
"Fl_GDI_Printer_Graphics_Driver";
 #endif
 #if !(defined(__APPLE__) || defined(WIN32))
 const char *Fl_Xlib_Graphics_Driver::class_id = "Fl_Xlib_Graphics_Driver";
@@ -42,6 +43,9 @@
   _surface = this;
 }
 
+FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver; // the current target device 
of graphics operations
+Fl_Surface_Device* Fl_Surface_Device::_surface; // the current target surface 
of graphics operations
+
 const Fl_Graphics_Driver::matrix Fl_Graphics_Driver::m0 = {1, 0, 0, 1, 0, 0};
 
 Fl_Graphics_Driver::Fl_Graphics_Driver() {
@@ -88,6 +92,7 @@
 #endif
   fl_mac_os_version = versionMajor * 10000 + versionMinor * 100 + 
versionBugFix;
 #endif
+this->set_current();
 };
 
 

Modified: branches/branch-1.3/src/Fl_Double_Window.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Double_Window.cxx        2012-03-18 16:02:40 UTC 
(rev 9292)
+++ branches/branch-1.3/src/Fl_Double_Window.cxx        2012-03-18 18:48:29 UTC 
(rev 9293)
@@ -59,7 +59,6 @@
   Fl_Window::show();
 }
 
-static void fl_copy_offscreen_to_display(int x, int y, int w, int h, 
Fl_Offscreen pixmap, int srcx, int srcy);
 
 /** \addtogroup fl_drawings
  @{
@@ -70,23 +69,46 @@
  \param pixmap  offscreen buffer containing the rectangle to copy
  \param srcx,srcy origin in offscreen buffer of rectangle to copy
  */
+#if FLTK_ABI_VERSION >= 10302
+inline void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, 
int srcx, int srcy) {
+  fl_graphics_driver->copy_offscreen(x, y, w, h, pixmap, srcx, srcy);
+}
+#else
 void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int 
srcx, int srcy) {
+#ifdef WIN32
+  if (fl_graphics_driver->class_name() == Fl_GDI_Graphics_Driver::class_id ||
+      fl_graphics_driver->class_name() == 
Fl_GDI_Printer_Graphics_Driver::class_id) {
+#else
   if (fl_graphics_driver->class_name() == 
Fl_Display_Device::display_device()->driver()->class_name()) {
-    fl_copy_offscreen_to_display(x, y, w, h, pixmap, srcx, srcy);
+#endif
+#ifdef USE_X11
+    ((Fl_Xlib_Graphics_Driver*)fl_graphics_driver)->copy_offscreen(x, y, w, h, 
pixmap, srcx, srcy);
+#elif defined(WIN32)
+    ((Fl_GDI_Graphics_Driver*)fl_graphics_driver)->copy_offscreen(x, y, w, h, 
pixmap, srcx, srcy);
+#elif defined(__APPLE__)
+    ((Fl_Quartz_Graphics_Driver*)fl_graphics_driver)->copy_offscreen(x, y, w, 
h, pixmap, srcx, srcy);
+#endif
   }
   else { // when copy is not to the display
-    fl_begin_offscreen(pixmap);
-    uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0);
-    fl_end_offscreen();
-    fl_draw_image(img, x, y, w, h, 3, 0);
-    delete[] img;
+    fl_graphics_driver->copy_offscreen(x, y, w, h, pixmap, srcx, srcy);
   }
 }
+#endif // FLTK_ABI_VERSION
 /** @} */
 
+/** see fl_copy_offscreen() */
+void Fl_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, 
Fl_Offscreen pixmap, int srcx, int srcy)
+{
+  fl_begin_offscreen(pixmap);
+  uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0);
+  fl_end_offscreen();
+  fl_draw_image(img, x, y, w, h, 3, 0);
+  delete[] img;
+}
+
 #if defined(USE_X11)
 
-static void fl_copy_offscreen_to_display(int x, int y, int w, int h, 
Fl_Offscreen pixmap, int srcx, int srcy) {
+void Fl_Xlib_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, 
Fl_Offscreen pixmap, int srcx, int srcy) {
   XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y);
 }
 
@@ -158,7 +180,7 @@
   return new_gc;
 }
 
-static void fl_copy_offscreen_to_display(int x,int y,int w,int h,HBITMAP 
bitmap,int srcx,int srcy) {
+void Fl_GDI_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,HBITMAP 
bitmap,int srcx,int srcy) {
   HDC new_gc = CreateCompatibleDC(fl_gc);
   int save = SaveDC(new_gc);
   SelectObject(new_gc, bitmap);
@@ -171,11 +193,11 @@
   HDC new_gc = CreateCompatibleDC(fl_gc);
   int save = SaveDC(new_gc);
   SelectObject(new_gc, bitmap);
+  fl_can_do_alpha_blending(); // make sure this is called
   BOOL alpha_ok = 0;
   // first try to alpha blend
   // if to printer, always try alpha_blend
-  int to_display = Fl_Surface_Device::surface()->class_name() == 
Fl_Display_Device::class_id; // true iff display output
-  if ( (to_display && fl_can_do_alpha_blending()) || 
Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) {
+  if ( Fl_Surface_Device::surface() != Fl_Display_Device::display_device() || 
fl_can_do_alpha_blending() ) {
     if (fl_alpha_blend) alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc, 
srcx, srcy, w, h, blendfunc);
   }
   // if that failed (it shouldn't), still copy the bitmap over, but now alpha 
is 1
@@ -194,6 +216,7 @@
   return 1;
 }
 
+#if ! defined(FL_DOXYGEN)
 Fl_Offscreen Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(int w, int 
h) {
   void *data = calloc(w*h,4);
   CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
@@ -202,6 +225,7 @@
   CGColorSpaceRelease(lut);
   return (Fl_Offscreen)ctx;
 }
+#endif
 
 /** \addtogroup fl_drawings
  @{
@@ -227,7 +251,7 @@
   if(count == 1) free((void*)data);
 }
 
-static void fl_copy_offscreen_to_display(int x,int y,int w,int h,Fl_Offscreen 
osrc,int srcx,int srcy) {
+void Fl_Quartz_Graphics_Driver::copy_offscreen(int x,int y,int w,int 
h,Fl_Offscreen osrc,int srcx,int srcy) {
   CGContextRef src = (CGContextRef)osrc;
   void *data = CGBitmapContextGetData(src);
   int sw = CGBitmapContextGetWidth(src);

Modified: branches/branch-1.3/src/Fl_GDI_Printer.cxx
===================================================================
--- branches/branch-1.3/src/Fl_GDI_Printer.cxx  2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/Fl_GDI_Printer.cxx  2012-03-18 18:48:29 UTC (rev 
9293)
@@ -27,7 +27,7 @@
 
 Fl_System_Printer::Fl_System_Printer(void) : Fl_Paged_Device() {
   hPr = NULL;
-  driver(new Fl_GDI_Graphics_Driver);
+  driver(new Fl_GDI_Printer_Graphics_Driver);
 }
 
 Fl_System_Printer::~Fl_System_Printer(void) {

Modified: branches/branch-1.3/src/Fl_Image.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Image.cxx        2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/Fl_Image.cxx        2012-03-18 18:48:29 UTC (rev 
9293)
@@ -532,7 +532,7 @@
   } else if (img->d()==2 || img->d()==4) {
     copy_offscreen_with_alpha(X, Y, W, H, (Fl_Offscreen)img->id_, cx, cy);
   } else {
-    fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)img->id_, cx, cy);
+    copy_offscreen(X, Y, W, H, (Fl_Offscreen)img->id_, cx, cy);
   }
 }
 
@@ -569,7 +569,7 @@
       XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy);
     }
     
-    fl_copy_offscreen(X, Y, W, H, img->id_, cx, cy);
+    copy_offscreen(X, Y, W, H, img->id_, cx, cy);
     
     if (img->mask_) {
       // put the old clip region back

Modified: branches/branch-1.3/src/Fl_Pixmap.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Pixmap.cxx       2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/Fl_Pixmap.cxx       2012-03-18 18:48:29 UTC (rev 
9293)
@@ -92,69 +92,50 @@
   return 0;
 }
 
-#ifdef __APPLE__
-void Fl_Quartz_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, 
int HP, int cx, int cy) {
-  int X, Y, W, H;
-  if (pxm->w() < 0) pxm->measure();
-  int code = start(pxm, XP, YP, WP, HP, pxm->w(), pxm->h(), cx, cy, X, Y, W, 
H);
+int Fl_Pixmap::prepare(int XP, int YP, int WP, int HP, int cx, int cy,
+                          int &X, int &Y, int &W, int &H) {
+  if (w() < 0) measure();
+  int code = start(this, XP, YP, WP, HP, w(), h(), cx, cy, X, Y, W, H);
   if (code) {
-    if (code == 2) pxm->draw_empty(XP, YP);
-    return;
-    }
-  if (!pxm->id_) {
-    pxm->id_ = create_offscreen_with_alpha(pxm->w(), pxm->h());
-    fl_begin_offscreen((Fl_Offscreen)pxm->id_);
-    fl_draw_pixmap(pxm->data(), 0, 0, FL_GREEN);
-    fl_end_offscreen();
-    }
-  fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
-}
-
-#elif defined(WIN32)
-void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int 
HP, int cx, int cy) {
-  int X, Y, W, H;
-  if (pxm->w() < 0) pxm->measure();
-  int code = start(pxm, XP, YP, WP, HP, pxm->w(), pxm->h(), cx, cy, X, Y, W, 
H);
-  if (code) {
-    if (code == 2) pxm->draw_empty(XP, YP);
-    return;
+    if (code == 2) draw_empty(XP, YP);
+    return 1;
   }
-  if (!pxm->id_) {
-    pxm->id_ = fl_create_offscreen(pxm->w(), pxm->h());
-    fl_begin_offscreen((Fl_Offscreen)pxm->id_);
+  if (!id_) {
+#ifdef __APPLE__
+    id_ = Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(w(), h());
+#else
+    id_ = fl_create_offscreen(w(), h());
+#endif
+    fl_begin_offscreen((Fl_Offscreen)id_);
+#ifndef __APPLE__
     uchar *bitmap = 0;
     fl_mask_bitmap = &bitmap;
-    fl_draw_pixmap(pxm->data(), 0, 0, FL_BLACK);
+#endif
+    fl_draw_pixmap(data(), 0, 0, FL_BLACK);
+#ifndef __APPLE__
     fl_mask_bitmap = 0;
     if (bitmap) {
-      pxm->mask_ = fl_create_bitmask(pxm->w(), pxm->h(), bitmap);
+      mask_ = fl_create_bitmask(w(), h(), bitmap);
       delete[] bitmap;
     }
+#endif
     fl_end_offscreen();
   }
-  if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) {
-    typedef BOOL (WINAPI* fl_transp_func)  
(HDC,int,int,int,int,HDC,int,int,int,int,UINT);
-    static HMODULE hMod = NULL;
-    static fl_transp_func fl_TransparentBlt = NULL;
-    if (!hMod) {
-      hMod = LoadLibrary("MSIMG32.DLL");
-      if(hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, 
"TransparentBlt");
-    }
-    if (fl_TransparentBlt) {
-      HDC new_gc = CreateCompatibleDC(fl_gc);
-      int save = SaveDC(new_gc);
-      SelectObject(new_gc, (void*)pxm->id_);
-      // print all of offscreen but its parts in background color
-      extern UINT win_pixmap_bg_color; // computed by fl_draw_pixmap()
-      fl_TransparentBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, pxm->w(), pxm->h(), 
win_pixmap_bg_color );
-      RestoreDC(new_gc,save);
-      DeleteDC(new_gc);
-    }
-    else {
-      fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
-    }
-  }
-  else if (pxm->mask_) {
+  return 0;
+}  
+
+#ifdef __APPLE__
+void Fl_Quartz_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, 
int HP, int cx, int cy) {
+  int X, Y, W, H;
+  if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;
+  copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
+}
+
+#elif defined(WIN32)
+void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int 
HP, int cx, int cy) {
+  int X, Y, W, H;
+  if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;
+  if (pxm->mask_) {
     HDC new_gc = CreateCompatibleDC(fl_gc);
     int save = SaveDC(new_gc);
     SelectObject(new_gc, (void*)pxm->mask_);
@@ -164,32 +145,39 @@
     RestoreDC(new_gc,save);
     DeleteDC(new_gc);
   } else {
-    fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
+    copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
   }
 }
 
-#else // Xlib
-void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int 
HP, int cx, int cy) {
+void Fl_GDI_Printer_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int 
WP, int HP, int cx, int cy) {
   int X, Y, W, H;
-  if (pxm->w() < 0) pxm->measure();
-  int code = start(pxm, XP, YP, WP, HP, pxm->w(), pxm->h(), cx, cy, X, Y, W, 
H);
-  if (code) {
-    if (code == 2) pxm->draw_empty(XP, YP);
-    return;
+  if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;
+  typedef BOOL (WINAPI* fl_transp_func)  
(HDC,int,int,int,int,HDC,int,int,int,int,UINT);
+  static HMODULE hMod = NULL;
+  static fl_transp_func fl_TransparentBlt = NULL;
+  if (!hMod) {
+    hMod = LoadLibrary("MSIMG32.DLL");
+    if(hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, 
"TransparentBlt");
   }
-  if (!pxm->id_) {
-    pxm->id_ = fl_create_offscreen(pxm->w(), pxm->h());
-    fl_begin_offscreen((Fl_Offscreen)pxm->id_);
-    uchar *bitmap = 0;
-    fl_mask_bitmap = &bitmap;
-    fl_draw_pixmap(pxm->data(), 0, 0, FL_BLACK);
-    fl_mask_bitmap = 0;
-    if (bitmap) {
-      pxm->mask_ = fl_create_bitmask(pxm->w(), pxm->h(), bitmap);
-      delete[] bitmap;
-    }
-    fl_end_offscreen();
+  if (fl_TransparentBlt) {
+    HDC new_gc = CreateCompatibleDC(fl_gc);
+    int save = SaveDC(new_gc);
+    SelectObject(new_gc, (void*)pxm->id_);
+    // print all of offscreen but its parts in background color
+    extern UINT win_pixmap_bg_color; // computed by fl_draw_pixmap()
+    fl_TransparentBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, pxm->w(), pxm->h(), 
win_pixmap_bg_color );
+    RestoreDC(new_gc,save);
+    DeleteDC(new_gc);
   }
+  else {
+    copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
+  }
+}
+
+#else // Xlib
+void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int 
HP, int cx, int cy) {
+  int X, Y, W, H;
+  if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;
   if (pxm->mask_) {
     // I can't figure out how to combine a mask with existing region,
     // so cut the image down to a clipped rectangle:
@@ -202,7 +190,7 @@
     int oy = Y-cy; if (oy < 0) oy += pxm->h();
     XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy);
   }
-  fl_copy_offscreen(X, Y, W, H, pxm->id_, cx, cy);
+  copy_offscreen(X, Y, W, H, pxm->id_, cx, cy);
   if (pxm->mask_) {
     // put the old clip region back
     XSetClipOrigin(fl_display, fl_gc, 0, 0);

Modified: branches/branch-1.3/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Display.cxx 2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/Fl_Text_Display.cxx 2012-03-18 18:48:29 UTC (rev 
9293)
@@ -3369,7 +3369,7 @@
   // draw the non-text, non-scrollbar areas.
   if (damage() & FL_DAMAGE_ALL) {
     //    printf("drawing all (box = %d)\n", box());
-    if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) {
+    if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) {
       // if to printer, draw the background
       fl_rectf(text_area.x, text_area.y, text_area.w, text_area.h, color() );
     }

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2012-03-18 16:02:40 UTC (rev 9292)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2012-03-18 18:48:29 UTC (rev 9293)
@@ -89,8 +89,6 @@
 
 static Fl_Quartz_Graphics_Driver fl_quartz_driver;
 static Fl_Display_Device fl_quartz_display(&fl_quartz_driver);
-FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver = 
(Fl_Graphics_Driver*)&fl_quartz_driver; // the current target device of 
graphics operations
-Fl_Surface_Device* Fl_Surface_Device::_surface = 
(Fl_Surface_Device*)&fl_quartz_display; // the current target surface of 
graphics operations
 Fl_Display_Device *Fl_Display_Device::_display = &fl_quartz_display; // the 
platform display
 
 // public variables

Modified: branches/branch-1.3/src/Fl_win32.cxx
===================================================================
--- branches/branch-1.3/src/Fl_win32.cxx        2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/Fl_win32.cxx        2012-03-18 18:48:29 UTC (rev 
9293)
@@ -3,7 +3,7 @@
 //
 // WIN32-specific code for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -85,8 +85,6 @@
 
 static Fl_GDI_Graphics_Driver fl_gdi_driver;
 static Fl_Display_Device fl_gdi_display(&fl_gdi_driver);
-FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver = 
(Fl_Graphics_Driver*)&fl_gdi_driver; // the current target driver of graphics 
operations
-Fl_Surface_Device* Fl_Surface_Device::_surface = 
(Fl_Surface_Device*)&fl_gdi_display; // the current target surface of graphics 
operations
 Fl_Display_Device *Fl_Display_Device::_display = &fl_gdi_display; // the 
platform display
 
 // dynamic wsock dll handling api:
@@ -1949,7 +1947,7 @@
 }
 
 Fl_Region XRectangleRegion(int x, int y, int w, int h) {
-  if (Fl_Surface_Device::surface()->class_name() == 
Fl_Display_Device::class_id) return CreateRectRgn(x,y,x+w,y+h);
+  if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) 
return CreateRectRgn(x,y,x+w,y+h);
   // because rotation may apply, the rectangle becomes a polygon in device 
coords
   POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} };
   LPtoDP(fl_gc, pt, 4);

Modified: branches/branch-1.3/src/Fl_x.cxx
===================================================================
--- branches/branch-1.3/src/Fl_x.cxx    2012-03-18 16:02:40 UTC (rev 9292)
+++ branches/branch-1.3/src/Fl_x.cxx    2012-03-18 18:48:29 UTC (rev 9293)
@@ -3,7 +3,7 @@
 //
 // X specific code for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2011 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -54,8 +54,6 @@
 
 static Fl_Xlib_Graphics_Driver fl_xlib_driver;
 static Fl_Display_Device fl_xlib_display(&fl_xlib_driver);
-FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver = 
(Fl_Graphics_Driver*)&fl_xlib_driver; // the current target device of graphics 
operations
-Fl_Surface_Device* Fl_Surface_Device::_surface = 
(Fl_Surface_Device*)&fl_xlib_display; // the current target surface of graphics 
operations
 Fl_Display_Device *Fl_Display_Device::_display = &fl_xlib_display;// the 
platform display
 
 ////////////////////////////////////////////////////////////////

Modified: branches/branch-1.3/src/fl_draw_image_mac.cxx
===================================================================
--- branches/branch-1.3/src/fl_draw_image_mac.cxx       2012-03-18 16:02:40 UTC 
(rev 9292)
+++ branches/branch-1.3/src/fl_draw_image_mac.cxx       2012-03-18 18:48:29 UTC 
(rev 9293)
@@ -3,7 +3,7 @@
 //
 // MacOS image drawing code for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -55,7 +55,7 @@
 
   const void *array = buf;
   uchar *tmpBuf = 0;
-  if (cb || Fl_Surface_Device::surface()->class_name() == 
Fl_Printer::class_id) {
+  if (cb || Fl_Surface_Device::surface() != 
Fl_Display_Device::display_device()) {
     tmpBuf = new uchar[ H*W*delta ];
     if (cb) {
       for (int i=0; i<H; i++) {

Modified: branches/branch-1.3/src/fl_draw_image_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_draw_image_win32.cxx     2012-03-18 16:02:40 UTC 
(rev 9292)
+++ branches/branch-1.3/src/fl_draw_image_win32.cxx     2012-03-18 18:48:29 UTC 
(rev 9293)
@@ -3,7 +3,7 @@
 //
 // WIN32 image drawing code for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -169,7 +169,7 @@
   int blocking = h;
   {int size = linesize*h;
   // when printing, don't limit buffer size not to get a crash in StretchDIBits
-  if (size > MAXBUFFER && Fl_Surface_Device::surface()->class_name() != 
Fl_Printer::class_id) {
+  if (size > MAXBUFFER && Fl_Surface_Device::surface() == 
Fl_Display_Device::display_device()) {
     size = MAXBUFFER;
     blocking = MAXBUFFER/linesize;
   }
@@ -247,7 +247,7 @@
         }            
       }
     }
-    if(Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) {
+    if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) {
       // if print context, device and logical units are not equal, so 
SetDIBitsToDevice
       // does not do the expected job, whereas StretchDIBits does it.
       StretchDIBits(fl_gc, x, y+j-k, w, k, 0, 0, w, k,

Modified: branches/branch-1.3/src/fl_draw_pixmap.cxx
===================================================================
--- branches/branch-1.3/src/fl_draw_pixmap.cxx  2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/fl_draw_pixmap.cxx  2012-03-18 18:48:29 UTC (rev 
9293)
@@ -3,7 +3,7 @@
 //
 // Pixmap drawing code for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -332,9 +332,7 @@
 #endif
   
 #ifdef  __APPLE_QUARTZ__
-  if (fl_graphics_driver->class_name() == Fl_Quartz_Graphics_Driver::class_id 
) {
-    bool transparent = (transparent_index>=0);
-    transparent = true;
+  if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) {
     U32 *array = new U32[d.w * d.h], *q = array;
     for (int Y = 0; Y < d.h; Y++) {
       const uchar* p = data[Y];
@@ -349,18 +347,9 @@
        }
       }
     }
-    CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
-    CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, d.w * d.h 
* 4, 0L);
-    CGImageRef img = CGImageCreate(d.w, d.h, 8, 4*8, 4*d.w,
-                                  lut, 
transparent?kCGImageAlphaLast:kCGImageAlphaNoneSkipLast,
-                                  src, 0L, false, kCGRenderingIntentDefault);
-    CGColorSpaceRelease(lut);
-    CGDataProviderRelease(src);
-    CGRect rect = { { x, y} , { d.w, d.h } };
-    Fl_X::q_begin_image(rect, 0, 0, d.w, d.h);
-    CGContextDrawImage(fl_gc, rect, img);
-    Fl_X::q_end_image();
-    CGImageRelease(img);
+    Fl_RGB_Image* rgb = new Fl_RGB_Image((uchar*)array, d.w, d.h, 4);
+    rgb->draw(x, y);
+    delete rgb;
     delete[] array;
     }
   else {

Modified: branches/branch-1.3/src/fl_font_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_win32.cxx   2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/fl_font_win32.cxx   2012-03-18 18:48:29 UTC (rev 
9293)
@@ -3,7 +3,7 @@
 //
 // WIN32 font selection routines for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2011 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -263,7 +263,7 @@
 
 // if printer context, extents shd be converted to logical coords
 #define EXTENTS_UPDATE(x,y,w,h) \
-  if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { 
on_printer_extents_update(x,y,w,h); }
+  if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { 
on_printer_extents_update(x,y,w,h); }
 
 // Function to determine the extent of the "inked" area of the glyphs in a 
string
 void Fl_GDI_Graphics_Driver::text_extents(const char *c, int n, int &dx, int 
&dy, int &w, int &h) {

Modified: branches/branch-1.3/src/fl_line_style.cxx
===================================================================
--- branches/branch-1.3/src/fl_line_style.cxx   2012-03-18 16:02:40 UTC (rev 
9292)
+++ branches/branch-1.3/src/fl_line_style.cxx   2012-03-18 18:48:29 UTC (rev 
9293)
@@ -3,7 +3,7 @@
 //
 // Line style code for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -118,7 +118,7 @@
   fl_quartz_line_width_ = (float)width; 
   fl_quartz_line_cap_ = Cap[(style>>8)&3];
   // when printing kCGLineCapSquare seems better for solid lines
-  if ( Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id && 
style == FL_SOLID && dashes == NULL ) {
+  if ( Fl_Surface_Device::surface() != Fl_Display_Device::display_device() && 
style == FL_SOLID && dashes == NULL ) {
     fl_quartz_line_cap_ = kCGLineCapSquare;
     }
   fl_quartz_line_join_ = Join[(style>>12)&3];

Modified: branches/branch-1.3/src/fl_rect.cxx
===================================================================
--- branches/branch-1.3/src/fl_rect.cxx 2012-03-18 16:02:40 UTC (rev 9292)
+++ branches/branch-1.3/src/fl_rect.cxx 2012-03-18 18:48:29 UTC (rev 9293)
@@ -3,7 +3,7 @@
 //
 // Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
 //
 // This library is free software. Distribution and use rights are outlined in
 // the file "COPYING" which should have been included with this file.  If this
@@ -40,7 +40,7 @@
 
 #ifdef __APPLE_QUARTZ__
 extern float fl_quartz_line_width_;
-#define USINGQUARTZPRINTER  (Fl_Surface_Device::surface()->class_name() == 
Fl_Printer::class_id)
+#define USINGQUARTZPRINTER  (Fl_Surface_Device::surface() != 
Fl_Display_Device::display_device())
 #endif
 
 #ifdef USE_X11
@@ -612,7 +612,7 @@
   return XRectInRegion(r, x, y, w, h);
 #elif defined(WIN32)
   RECT rect;
-  if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { // 
in case of print context, convert coords from logical to device
+  if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { 
// in case of print context, convert coords from logical to device
     POINT pt[2] = { {x, y}, {x + w, y + h} };
     LPtoDP(fl_gc, pt, 2);
     rect.left = pt[0].x; rect.top = pt[0].y; rect.right = pt[1].x; rect.bottom 
= pt[1].y;
@@ -672,7 +672,7 @@
   } else {     // partial intersection
     RECT rect;
     GetRgnBox(temp, &rect);
-    if(Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { 
// if print context, convert coords from device to logical
+    if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { 
// if print context, convert coords from device to logical
       POINT pt[2] = { {rect.left, rect.top}, {rect.right, rect.bottom} };
       DPtoLP(fl_gc, pt, 2);
       X = pt[0].x; Y = pt[0].y; W = pt[1].x - X; H = pt[1].y - Y;

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

Reply via email to