diff --git a/FL/Fl_Abstract_Printer.H b/FL/Fl_Abstract_Printer.H
index 97f4092dc66f4e5ac4c6b6f3a2bf918b04a4a1ba..919126fac1fdd8aa25037db6c05e3a6674f3a862 100644
--- a/FL/Fl_Abstract_Printer.H
+++ b/FL/Fl_Abstract_Printer.H
@@ -39,7 +39,10 @@
  *
  This class has no public constructor: don't instantiate it; use Fl_Printer or Fl_PSfile_Device instead.
  */
-class Fl_Abstract_Printer {
+class Fl_Abstract_Printer : public Fl_Device {
+  friend class Fl_Pixmap;
+  friend class Fl_RGB_Image;
+  friend class Fl_Bitmap;
 private:
 #ifdef __APPLE__
   struct chain_elt {
@@ -59,11 +62,14 @@ protected:
   struct chain_elt *image_list_; 
   /** \brief the printer's graphics context, if there's one, NULL otherwise */
   void *gc; 
+  /** \brief the constructor */
+  Fl_Abstract_Printer(void) { gc = NULL; bg_r_ = bg_g_ = bg_b_ = 0; };
 #ifdef __APPLE__
   /** \brief deletes the page image list */
   void delete_image_list(); 
 #endif
 public:
+  Fl_Device *set_current(void);
   virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
   virtual int start_page(void);
   virtual int printable_rect(int *w, int *h);
@@ -85,4 +91,3 @@ public:
 //
 // End of "$Id$"
 //
-
diff --git a/FL/Fl_Bitmap.H b/FL/Fl_Bitmap.H
index 92fe91eee26f16c063e0781f4bdf1709d1c1df22..d47a82acf865e056231f9defd2fa0b243783ab85 100644
--- a/FL/Fl_Bitmap.H
+++ b/FL/Fl_Bitmap.H
@@ -40,8 +40,8 @@ struct Fl_Menu_Item;
   (bitmap) images. Images are drawn using the current color.
 */
 class FL_EXPORT Fl_Bitmap : public Fl_Image {
-  friend class Fl_Graphics_Device;
-public:
+  friend class Fl_Device;
+  public:
 
   /** pointer to raw bitmap data */
   const uchar *array;
@@ -58,6 +58,7 @@ public:
   unsigned id_;
 #endif // __APPLE__ || WIN32
 
+  void generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy);
   public:
 
   /** The constructors create a new bitmap from the specified bitmap data */
diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H
index ad8506f1e8f0f319d1dc54b46243e28d9d51eb1a..8eaaa0c8752c80b322b86d89da7d7203d604ac37 100644
--- a/FL/Fl_Device.H
+++ b/FL/Fl_Device.H
@@ -1,8 +1,8 @@
 //
 // "$Id$"
 //
-// Definition of classes Fl_Device, Fl_Display_Device, Fl_Graphics_Device
-// for the Fast Light Tool Kit (FLTK).
+// Definition of classes Fl_Device, Fl_Display, Fl_Quartz_Display, Fl_GDI_Display,
+// and Fl_Xlib_Display for the Fast Light Tool Kit (FLTK).
 //
 // Copyright 2010 by Bill Spitzak and others.
 //
@@ -26,7 +26,7 @@
 //     http://www.fltk.org/str.php
 //
 /** \file Fl_Device.H 
- \brief declaration of classes Fl_Device, Fl_Display_Device.
+ \brief declaration of classes Fl_Device, Fl_Display.
 */
 
 #ifndef Fl_Device_H
@@ -45,12 +45,14 @@
 #include <stdio.h>
 #endif
 
+class Fl_Widget;
 class Fl_Device;
-class Fl_Display_Device;
+class Fl_Display;
+class Fl_Abstract_Printer;
 /** \brief Points to the device that currently receives all graphics requests */
-extern Fl_Device *fl_device;
+FL_EXPORT extern Fl_Device *fl_device;
 /** \brief Points to the platform's display device */
-extern Fl_Display_Device *fl_display_device;
+FL_EXPORT extern Fl_Display *fl_display_device;
 
 /**
  signature of image generation callback function.
@@ -69,18 +71,18 @@ typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf);
  support all of FLTK drawing functions.
  <br> The preferred FLTK API for drawing operations is the function collection of the 
  \ref fl_drawings and \ref fl_attributes modules. 
- <br> Alternatively, methods of the Fl_Device class can be called
+ <br> Alternatively, member functions of the Fl_Device class can be called
  using the global variable Fl_Device * \ref fl_device that points at all time to the single device 
  (an instance of an Fl_Device subclass) that's currently receiving graphics requests:
  \code fl_device->rect(x, y, w, h); \endcode
- <br>Each protected method of the Fl_Device class has the same effect as the
+ <br>Each member function of the Fl_Device class has the same effect and parameter list as the
  function of the \ref fl_drawings and \ref fl_attributes modules which bears the same name
- prefixed with fl_ and has the same parameter list.
+ prefixed with fl_ .
   */
 class Fl_Device {
 protected:
   /** \brief The device type */
-  const char *type_; 
+  int type_; 
   /** \brief red color for background and/or mixing if device does not support masking or alpha */
   uchar bg_r_; 
   /** \brief green color for background and/or mixing if device does not support masking or alpha */
@@ -90,7 +92,6 @@ protected:
   friend class Fl_Pixmap;
   friend class Fl_Bitmap;
   friend class Fl_RGB_Image;
-  friend class Fl_PS_Device;
   friend void fl_rect(int x, int y, int w, int h);
   friend void fl_rectf(int x, int y, int w, int h);
   friend void fl_line_style(int style, int width, char* dashes);
@@ -238,103 +239,73 @@ protected:
   /** \brief see fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D). */
   virtual   void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
   // Image classes
-  /** \brief Draws an Fl_RGB_Image object to the device. 
-   *
-   Specifies a bounding box for the image, with the origin (upper left-hand corner) of 
-   the image offset by the cx and cy arguments.
-   */
-  virtual   void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) {};
-  /** \brief Draws an Fl_Pixmap object to the device. 
-   *
-   Specifies a bounding box for the image, with the origin (upper left-hand corner) of 
-   the image offset by the cx and cy arguments.
-   */
-  virtual   void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy) {};
-  /** \brief Draws an Fl_Bitmap object to the device. 
-   *
-   Specifies a bounding box for the image, with the origin (upper left-hand corner) of 
-   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) {};
-    
+  virtual   void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
+  virtual   void draw(Fl_Bitmap * bmp,int XP, int YP, int WP, int HP, int cx, int cy);  
+  virtual   void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
+  
 public:
-  /** A name that identifies each subclass of Fl_Device */
-  static const char *device_type;
   /** 
-   @brief An RTTI emulation of device classes. 
-   *
-   The type of an instance of an Fl_Device subclass can be checked with code such as:
-   \code
-   if ( fl_device->type() == Fl_Printer::device_type ) { ... }
-   \endcode
+   @brief All implemented graphics output devices.
    */
-  inline const char *type() {return type_;};
+  enum device_types { 
+    xlib_display = 0, /**< The X11 display. */
+    quartz_display,  /**< The Mac OS X display. */
+    gdi_display,  /**< The MSWindows display. */
+    gdi_printer = 256,  /**< The MSWindows printer. */
+    quartz_printer,  /**< The Mac OS X printer. */
+    postscript_device  /**< The PostScript device. */
+  };
+  /** 
+   @brief An RTTI emulation of device classes. It returns values < 256 if it is a display device 
+   */
+  inline int type() {return type_;};
   virtual Fl_Device *set_current(void);
-
+  
   virtual ~Fl_Device() {};
   static Fl_Device *current();
   
   /**
    @brief    Returns the platform's display device.
    */
-  static Fl_Display_Device *display_device() { return fl_display_device; };
+  static Fl_Display *display_device() { return fl_display_device; };
   
 };
+extern FL_EXPORT Fl_Device *fl_device;
 
-#if defined(__APPLE__) 
-// The Mac OS X-specific graphics class.
-class Fl_Graphics_Device : public Fl_Device {
-protected:
-  Fl_Graphics_Device() { type_ = device_type; };
-public:
-  static const char *device_type;
-  void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
-  void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
-  void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
+/**
+ @brief A virtual class subclassed for OS-specific display graphics.
+ */
+class Fl_Display : public Fl_Device {
+  friend class Fl_PSfile_Device;
 };
-typedef Fl_Graphics_Device Fl_Quartz_Device;
 
-#elif defined(WIN32) 
-// The MSWindows-specific graphics class.
-class Fl_Graphics_Device : public Fl_Device {
-protected:
-  Fl_Graphics_Device() { type_ = device_type; };
+#if defined(__APPLE__) || defined(FL_DOXYGEN)
+/**
+ @brief The Mac OS X-specific display graphics class.
+ */
+class Fl_Quartz_Display : public Fl_Display {
 public:
-  static const char *device_type;
-  void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
-  void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
-  void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
+  Fl_Quartz_Display() { type_ = quartz_display; };
 };
-typedef  Fl_Graphics_Device Fl_GDI_Device;
-
-#else
+#endif
+#if defined(WIN32) || defined(FL_DOXYGEN)
 /**
- @brief A class representing OS-specific graphics system.
- *
- This class is also named Fl_Quartz_Device on Mac OS X, Fl_GDI_Device on MS-Win, Fl_Xlib_Device on X11.
- A graphics system can be shared by various devices (e.g., display, printer, clipboard).
+ @brief The MSWindows-specific display graphics class.
  */
-class Fl_Graphics_Device : public Fl_Device {
-protected:
-  Fl_Graphics_Device() { type_ = device_type; };
+class Fl_GDI_Display : public Fl_Display {
 public:
-  static const char *device_type;
-  void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
-  void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
-  void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
+  Fl_GDI_Display() { type_ = gdi_display; };
 };
-typedef  Fl_Graphics_Device Fl_Xlib_Device;
 #endif
-
+#if !( defined(__APPLE__) || defined(WIN32)) || defined(FL_DOXYGEN)
 /**
- @brief The platform's display.
-*/
-class Fl_Display_Device : public Fl_Graphics_Device {
+ @brief The X11-specific display graphics class.
+ */
+class Fl_Xlib_Display : public Fl_Display {
 public:
-  static const char *device_type;
-  Fl_Display_Device() { type_ = device_type; };
+  Fl_Xlib_Display() { type_ = xlib_display; };
 };
-
+#endif
 
 #endif // Fl_Device_H
 
diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H
index 2cb77978cd53a2a67b2bece3324e9192f6661aa7..ff10b1ef6d3141a96870ecb868bca2622e19d81f 100644
--- a/FL/Fl_Image.H
+++ b/FL/Fl_Image.H
@@ -188,7 +188,8 @@ class FL_EXPORT Fl_Image {
   &lt;FL/Fl_RGB_Image.H&gt; should be included.
 */
 class FL_EXPORT Fl_RGB_Image : public Fl_Image {
-  friend class Fl_Graphics_Device;
+  friend class Fl_Device;
+  void generic_device_draw(int X, int Y, int W, int H, int cx=0, int cy=0);
   public:
 
   const uchar *array;
diff --git a/FL/Fl_PSfile_Device.H b/FL/Fl_PSfile_Device.H
index d829e0789b85258563dd3b17093d4bacb1ec9b97..a0fdba70d732b031bbdad0749dce79f952579a14 100644
--- a/FL/Fl_PSfile_Device.H
+++ b/FL/Fl_PSfile_Device.H
@@ -33,238 +33,229 @@
 #define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */
 
 /**
- \brief Sends all graphics to PostScript.
+ \brief Sends all graphics to a local PostScript file; same API as Fl_Printer class.
  *
- PostScript text output is presently implemented only for the latin character set.
+ This class has the same API as class Fl_Printer except for start_job() member function.
+ <p>PostScript text output is presently implemented only for the latin character set.
  FLTK's standard fonts are output using PostScript's standard fonts: Helvetica, Courier, 
  Times (and their bold, oblique, italic variants), Symbol, ZapfDingbats.
  */
-FL_EXPORT class Fl_PS_Device : public  Fl_Device {
-public: 
-  static const char *device_type;
-  /**
-   \brief Possible page formats.
-   */
-  enum Page_Format {
-    A0 = 0,
-    A1,
-    A2,
-    A3,
-    A4,
-    A5,
-    A6,
-    A7,
-    A8,
-    A9,
-    B0,
-    B1,
-    B2,
-    B3,
-    B4,
-    B5,
-    B6,
-    B7,
-    B8,
-    B9,
-    B10,
-    C5E,
-    DLE,
-    EXECUTIVE,
-    FOLIO,
-    LEDGER,
-    LEGAL,
-    LETTER,
-    TABLOID,
-    ENVELOPE,
-    MEDIA = 0x1000
-  };
-  
-  /**
-   \brief Possible page layouts.
-   */
-  enum Page_Layout {PORTRAIT = 0, LANDSCAPE = 0x100, REVERSED = 0x200, ORIENTATION = 0x300};
+FL_EXPORT class Fl_PSfile_Device : public  Fl_Abstract_Printer {
+  public: 
+    /**
+     \brief Possible page formats.
+     */
+    enum Page_Format {
+      A0 = 0,
+      A1,
+      A2,
+      A3,
+      A4,
+      A5,
+      A6,
+      A7,
+      A8,
+      A9,
+      B0,
+      B1,
+      B2,
+      B3,
+      B4,
+      B5,
+      B6,
+      B7,
+      B8,
+      B9,
+      B10,
+      C5E,
+      DLE,
+      EXECUTIVE,
+      FOLIO,
+      LEDGER,
+      LEGAL,
+      LETTER,
+      TABLOID,
+      ENVELOPE,
+      MEDIA = 0x1000
+    };
+    
+    /**
+     \brief Possible page layouts.
+     */
+    enum Page_Layout {PORTRAIT = 0, LANDSCAPE = 0x100, REVERSED = 0x200, ORIENTATION = 0x300};
     
 #ifndef FL_DOXYGEN
-protected:
-  enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
-  
-typedef struct page_format {
-  int width;
-  int height;
-  const char *name;
-} page_format;
-  
-class Clip {
+  private:
+    enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
+    
+    class Clip{
+    public:
+      int x, y, w, h;
+      Clip *prev;
+    };
+    Clip * clip_;
+    
+    int lang_level_;
+    int font_;
+    int size_;
+    Fl_Color color_;
+    int gap_;
+    int pages_;
+    
+    double width_;
+    double height_;
+    
+    int shape_;
+    int linewidth_;// need for clipping, lang level 1-2
+    int linestyle_;//
+    int interpolate_; //interpolation of images
+    unsigned char cr_,cg_,cb_;
+    char  linedash_[256];//should be enought
+    void concat();  // transform ror scalable dradings...
+    void reconcat(); //invert
+    void recover(); //recovers the state afrer grestore (such as line styles...)
+    void reset();
+    
+    uchar * mask;
+    int mx; // width of mask;
+    int my; // mask lines
+    //Fl_Color bg_;
+    int (*close_cmd_)(FILE *);
+    int page_policy_;
+    int nPages;
+    int orientation_;
+    
+    float scale_x;
+    float scale_y;
+    float angle;
+    int left_margin;
+    int top_margin;
+  protected:
+    typedef struct page_format {
+      int width;
+      int height;
+      const char *name;
+    } page_format;
+   
+    FILE *output;
+    double pw_, ph_;
+    static const page_format page_formats[NO_PAGE_FORMATS];
+    
+    uchar bg_r, bg_g, bg_b;
+    int start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout);
+    /*  int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
+     */
+    void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };
+    void draw(int angle, const char *str, int n, int x, int y);
+    void transformed_draw(const char* s, int n, double x, double y); //precise text placing
+    void transformed_draw(const char* s, double x, double y);
+    int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
+    void draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
+    void draw_scaled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
+    void draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D);
+    void draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D);
+    
+    enum Page_Format page_format_;
+    char *ps_filename_;
+    // implementation of drawing methods
+    void color(Fl_Color c);
+    //void bg_color(Fl_Color bg);
+    void color(uchar r, uchar g, uchar b);
+    Fl_Color color(){return color_;};
+    
+    void push_clip(int x, int y, int w, int h);
+    int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
+    int not_clipped(int x, int y, int w, int h);
+    void push_no_clip();
+    void pop_clip();
+    
+    void line_style(int style, int width=0, char* dashes=0);
+    
+    void rect(int x, int y, int w, int h);
+    void rectf(int x, int y, int w, int h);
+    
+    void xyline(int x, int y, int x1);
+    void xyline(int x, int y, int x1, int y2);
+    void xyline(int x, int y, int x1, int y2, int x3);
+    
+    void yxline(int x, int y, int y1);
+    void yxline(int x, int y, int y1, int x2);
+    void yxline(int x, int y, int y1, int x2, int y3);
+    
+    void line(int x1, int y1, int x2, int y2);
+    void line(int x1, int y1, int x2, int y2, int x3, int y3);  
+    
+    void loop(int x0, int y0, int x1, int y1, int x2, int y2);
+    void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
+    void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
+    void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
+    void point(int x, int y);
+    
+    void begin_points();
+    void begin_line();
+    void begin_loop();
+    void begin_polygon();
+    void vertex(double x, double y);
+    void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3);
+    void circle(double x, double y, double r);
+    void arc(double x, double y, double r, double start, double a);
+    void arc(int x, int y, int w, int h, double a1, double a2);
+    void pie(int x, int y, int w, int h, double a1, double a2);
+    void end_points();
+    void end_line();
+    void end_loop();
+    void end_polygon();
+    void begin_complex_polygon(){begin_polygon();};
+    void gap(){gap_=1;};
+    void end_complex_polygon(){end_polygon();};
+    void transformed_vertex(double x, double y);
+    
+    void font(int face, int size);
+    int font(){return font_;};
+    int size(){return size_;};
+    double width(unsigned c);
+    double width(const char* s, int n);
+    int descent();
+    int height();
+    
+    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);};
+    void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3){draw_scaled_image(call,data, x, y, w, h, w, h, delta);};
+    void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1){draw_scaled_image_mono(call, data, x, y, w, h, w, h, delta);};
+    
+    void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
+    void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
+    void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
+    
   public:
-    int x, y, w, h;
-    Clip *prev;
-  };
-  Clip * clip_;
-  
-  int lang_level_;
-  int font_;
-  int size_;
-  Fl_Color color_;
-  int gap_;
-  int pages_;
-  
-  double width_;
-  double height_;
-  
-  int shape_;
-  int linewidth_;// need for clipping, lang level 1-2
-  int linestyle_;//
-  int interpolate_; //interpolation of images
-  unsigned char cr_,cg_,cb_;
-  char  linedash_[256];//should be enough
-  void concat();  // transform ror scalable dradings...
-  void reconcat(); //invert
-  void recover(); //recovers the state after grestore (such as line styles...)
-  void reset();
-  
-  uchar * mask;
-  int mx; // width of mask;
-  int my; // mask lines
-  //Fl_Color bg_;
-  int (*close_cmd_)(FILE *);
-  int page_policy_;
-  int nPages;
-  int orientation_;
-  
-  float scale_x;
-  float scale_y;
-  float angle;
-  int left_margin;
-  int top_margin;
- 
-  FILE *output;
-  double pw_, ph_;
-  static const page_format page_formats[NO_PAGE_FORMATS];
-  
-  uchar bg_r, bg_g, bg_b;
-  Fl_PS_Device(void);
-  int start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout);
-  /*  int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
-   */
-  void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };
-  void draw(int angle, const char *str, int n, int x, int y);
-  void transformed_draw(const char* s, int n, double x, double y); //precise text placing
-  void transformed_draw(const char* s, double x, double y);
-  int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
-  void draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
-  void draw_scaled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
-  void draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D);
-  void draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D);
-  
-  enum Page_Format page_format_;
-  char *ps_filename_;
-  // implementation of drawing methods
-  void color(Fl_Color c);
-  //void bg_color(Fl_Color bg);
-  void color(uchar r, uchar g, uchar b);
-  Fl_Color color(){return color_;};
-  
-  void push_clip(int x, int y, int w, int h);
-  int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
-  int not_clipped(int x, int y, int w, int h);
-  void push_no_clip();
-  void pop_clip();
-  
-  void line_style(int style, int width=0, char* dashes=0);
-  
-  void rect(int x, int y, int w, int h);
-  void rectf(int x, int y, int w, int h);
-  
-  void xyline(int x, int y, int x1);
-  void xyline(int x, int y, int x1, int y2);
-  void xyline(int x, int y, int x1, int y2, int x3);
-  
-  void yxline(int x, int y, int y1);
-  void yxline(int x, int y, int y1, int x2);
-  void yxline(int x, int y, int y1, int x2, int y3);
-  
-  void line(int x1, int y1, int x2, int y2);
-  void line(int x1, int y1, int x2, int y2, int x3, int y3);  
-  
-  void loop(int x0, int y0, int x1, int y1, int x2, int y2);
-  void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
-  void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
-  void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
-  void point(int x, int y);
-  
-  void begin_points();
-  void begin_line();
-  void begin_loop();
-  void begin_polygon();
-  void vertex(double x, double y);
-  void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3);
-  void circle(double x, double y, double r);
-  void arc(double x, double y, double r, double start, double a);
-  void arc(int x, int y, int w, int h, double a1, double a2);
-  void pie(int x, int y, int w, int h, double a1, double a2);
-  void end_points();
-  void end_line();
-  void end_loop();
-  void end_polygon();
-  void begin_complex_polygon(){begin_polygon();};
-  void gap(){gap_=1;};
-  void end_complex_polygon(){end_polygon();};
-  void transformed_vertex(double x, double y);
-  
-  void font(int face, int size);
-  int font(){return font_;};
-  int size(){return size_;};
-  double width(unsigned c);
-  double width(const char* s, int n);
-  int descent();
-  int height();
-  
-  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);};
-  void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3){draw_scaled_image(call,data, x, y, w, h, w, h, delta);};
-  void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1){draw_scaled_image_mono(call, data, x, y, w, h, w, h, delta);};
-  
-  void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
-  void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
-  void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
+    void page_policy(int p);
+    int page_policy(){return page_policy_;};
+    void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;};
+    FILE * file() {return output;};
+    //void orientation (int o);
+    //Fl_PSfile_Device(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
+    //Fl_PSfile_Device(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor
+    void interpolate(int i){interpolate_=i;};
+    int interpolate(){return interpolate_;}
     
-public:
-  void page_policy(int p);
-  int page_policy(){return page_policy_;};
-  void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;};
-  FILE * file() {return output;};
-  //void orientation (int o);
-  //Fl_PSfile_Device(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
-  //Fl_PSfile_Device(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor
-  void interpolate(int i){interpolate_=i;};
-  int interpolate(){return interpolate_;}
-  
-  void page(double pw, double ph, int media = 0);
-  void page(int format);
-  
-  void place(double x, double y, double tx, double ty, double scale = 1);
+    void page(double pw, double ph, int media = 0);
+    void page(int format);
+    
+    void place(double x, double y, double tx, double ty, double scale = 1);
+    int start_page (void);
+    int printable_rect(int *w, int *h);
+    void margins(int *left, int *top, int *right, int *bottom);
+    void origin(int x, int y);
+    void scale (float scale_x, float scale_y);
+    void rotate(float angle);
+    void translate(int x, int y);
+    void untranslate(void);
+    int end_page (void);    
+    void end_job(void);
 #endif // FL_DOXYGEN
-};
-
-/**
- \brief Sends graphics output to a local PostScript file.
- */
-class Fl_PSfile_Device : public Fl_PS_Device , public Fl_Abstract_Printer {
-public:
-  static const char *device_type;
   Fl_PSfile_Device(void);
   int start_job(int pagecount, enum Page_Format format = A4, enum Page_Layout layout = PORTRAIT);
   int start_job(FILE *ps_output, int pagecount, enum Page_Format format = A4, enum Page_Layout layout = PORTRAIT);
-  int start_page (void);
-  int printable_rect(int *w, int *h);
-  void margins(int *left, int *top, int *right, int *bottom);
-  void origin(int x, int y);
-  void scale (float scale_x, float scale_y);
-  void rotate(float angle);
-  void translate(int x, int y);
-  void untranslate(void);
-  int end_page (void);    
-  void end_job(void);
   virtual ~Fl_PSfile_Device();
   
   /** [this text may be customized at run-time] */
diff --git a/FL/Fl_Pixmap.H b/FL/Fl_Pixmap.H
index 446af15f6d08e8235d0a3a1e02635b0a60c71445..8cab445a5eb452f98e0dd4baa54b3182f1bfb675 100644
--- a/FL/Fl_Pixmap.H
+++ b/FL/Fl_Pixmap.H
@@ -45,7 +45,7 @@ struct Fl_Menu_Item;
   (pixmap) images, including transparency.
 */
 class FL_EXPORT Fl_Pixmap : public Fl_Image {
-  friend class Fl_Graphics_Device;
+  friend class Fl_Device;
   void copy_data();
   void delete_data();
   void set_data(const char * const *p);
@@ -67,6 +67,7 @@ class FL_EXPORT Fl_Pixmap : public Fl_Image {
   unsigned id_; // for internal use
   unsigned mask_; // for internal use (mask bitmap)
 #endif // __APPLE__ || WIN32
+  void generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy);
   
   public:
 
diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H
index 409385dfb08f405634d3c2dd01f4b9368d7b2722..8aba8dc811fc61a65d3120e60495cc7f87c7edf1 100644
--- a/FL/Fl_Printer.H
+++ b/FL/Fl_Printer.H
@@ -72,7 +72,7 @@
  <li>Mac OS X platform: all graphics requests print as on display.
  </ul>
  */
-class Fl_Printer : public Fl_Graphics_Device , public Fl_Abstract_Printer {
+class Fl_Printer : public Fl_Abstract_Printer {
 private:
 #ifdef __APPLE__
   float scale_x;
@@ -126,15 +126,14 @@ public:
 class Fl_Printer : public Fl_PSfile_Device {
 
 public:
-  Fl_Printer(void) { gc = NULL; bg_r_ = bg_g_ = bg_b_ = 0; };
+
+  Fl_Printer(void) {};
   ~Fl_Printer(void) {};
   int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
 
 #endif	// Fl_Printer (platform-dependent)
 
   // Fl_Printer:: common for all platforms
-  Fl_Device *set_current(void);
-  static const char *device_type;
 
 public:	// just to be sure ...
 
diff --git a/src/Fl_Abstract_Printer.cxx b/src/Fl_Abstract_Printer.cxx
index 4560ad7df8680dc618df24f092ec7b82ca85b75f..0490dcc68294106ceb37d4ac34cbe92c7b328ee0 100644
--- a/src/Fl_Abstract_Printer.cxx
+++ b/src/Fl_Abstract_Printer.cxx
@@ -70,7 +70,7 @@ void Fl_Abstract_Printer::print_widget(Fl_Widget* widget, int delta_x, int delta
       int width, height;
       this->printable_rect(&width, &height);
       drawn_by_plugin = pi->print(widget, 0, 0, height);
-      }
+    }
   }
   if (!drawn_by_plugin) {
     widget->draw();
@@ -126,7 +126,7 @@ void Fl_Abstract_Printer::origin(int *x, int *y)
 void Fl_Abstract_Printer::print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y)
 {
   int slice, width, offset, count = 0;
-  Fl_Device *current = Fl_Device::display_device()->set_current();
+  Fl_Device::display_device()->set_current();
   Fl_Window *save_front = Fl::first_window();
   win->show();
   fl_gc = NULL;
@@ -144,7 +144,7 @@ void Fl_Abstract_Printer::print_window_part(Fl_Window *win, int x, int y, int w,
     image_data[count++] = fl_read_image(NULL, x + offset, y, width, h);
   }  
   save_front->show();
-  current->set_current();
+  this->set_current();
   for ( int i = 0, offset = 0; i < count; i++, offset += slice) {
     width = slice; 
     if (offset + width > w) width = w - offset;
@@ -179,6 +179,18 @@ void Fl_Abstract_Printer::delete_image_list()
 }
 #endif
 
+Fl_Device *Fl_Abstract_Printer::set_current(void)
+{
+#ifdef __APPLE__
+  fl_gc = (CGContextRef)gc;
+#elif defined(WIN32)
+  fl_gc = (HDC)gc;
+#else
+  fl_gc = (_XGC*)gc;
+#endif
+  return this->Fl_Device::set_current();
+}
+
 
 /**
  @brief Starts a print job.
diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx
index 18d26cc6aa8c5c5057e238b995adfdefe49d8bf8..13d5bcaee35162df137071427dfe9a3745507507 100644
--- a/src/Fl_Bitmap.cxx
+++ b/src/Fl_Bitmap.cxx
@@ -37,7 +37,6 @@
 #include <FL/Fl_Widget.H>
 #include <FL/Fl_Menu_Item.H>
 #include <FL/Fl_Bitmap.H>
-#include <FL/Fl_Printer.H>
 #include "flstring.h"
 
 #if defined(__APPLE_QUARTZ__)
@@ -252,66 +251,49 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
   fl_device->draw(this, XP, YP, WP, HP, cx, cy);
 }
 
-static int start(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int w, int h, int cx, int cy, 
-		 int &X, int &Y, int &W, int &H)
-{
+void Fl_Bitmap::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy) {
+  if (!array) {
+    draw_empty(XP, YP);
+    return;
+  }
+
   // account for current clip region (faster on Irix):
-  fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
+  int X,Y,W,H; fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
   cx += X-XP; cy += Y-YP;
   // clip the box down to the size of image, quit if empty:
   if (cx < 0) {W += cx; X -= cx; cx = 0;}
-  if (cx+W > w) W = w-cx;
-  if (W <= 0) return 1;
+  if ((cx+W) > w()) W = w()-cx;
+  if (W <= 0) return;
   if (cy < 0) {H += cy; Y -= cy; cy = 0;}
-  if (cy+H > h) H = h-cy;
-  if (H <= 0) return 1;
-  return 0;
-}
+  if ((cy+H) > h()) H = h()-cy;
+  if (H <= 0) return;
 
-#ifdef __APPLE__
-void Fl_Quartz_Device::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
-  int X, Y, W, H;
-  if (!bm->array) {
-    bm->draw_empty(XP, YP);
-    return;
-  }
-  if (start(bm, XP, YP, WP, HP, bm->w(), bm->h(), cx, cy, X, Y, W, H)) {
-    return;
-  }
-  if (!bm->id_) bm->id_ = fl_create_bitmask(bm->w(), bm->h(), bm->array);
-  if (bm->id_ && fl_gc) {
-    CGRect rect = { { X, Y }, { W, H } };
-    Fl_X::q_begin_image(rect, cx, cy, bm->w(), bm->h());
-    CGContextDrawImage(fl_gc, rect, (CGImageRef)bm->id_);
-    Fl_X::q_end_image();
-  }
-}
+#if defined(USE_X11)
+  if (!id_) id_ = fl_create_bitmask(w(), h(), array);
 
+  XSetStipple(fl_display, fl_gc, id_);
+  int ox = X-cx; if (ox < 0) ox += w();
+  int oy = Y-cy; if (oy < 0) oy += h();
+  XSetTSOrigin(fl_display, fl_gc, ox, oy);
+  XSetFillStyle(fl_display, fl_gc, FillStippled);
+  XFillRectangle(fl_display, fl_window, fl_gc, X, Y, W, H);
+  XSetFillStyle(fl_display, fl_gc, FillSolid);
 #elif defined(WIN32)
-void Fl_GDI_Device::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
-  int X, Y, W, H;
-  if (!bm->array) {
-    bm->draw_empty(XP, YP);
-    return;
-  }
-  if (start(bm, XP, YP, WP, HP, bm->w(), bm->h(), cx, cy, X, Y, W, H)) {
-    return;
-  }
-  if (!bm->id_) bm->id_ = fl_create_bitmap(bm->w(), bm->h(), bm->array);
-  
+  if (!id_) id_ = fl_create_bitmap(w(), h(), array);
+
   typedef BOOL (WINAPI* fl_transp_func)  (HDC,int,int,int,int,HDC,int,int,int,int,UINT);
   static fl_transp_func fl_TransparentBlt;
   HDC tempdc;
   int save;
   BOOL use_print_algo = false;
-  if (fl_device->type() == Fl_Printer::device_type) {
+  if (fl_device->type() == Fl_Device::gdi_printer) {
     static HMODULE hMod = NULL;
     if (!hMod) {
       hMod = LoadLibrary("MSIMG32.DLL");
       if (hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, "TransparentBlt");
-    }
+      }
     if (hMod) use_print_algo = true;
-  }
+    }
   if (use_print_algo) { // algorithm for bitmap output to Fl_GDI_Printer
     Fl_Offscreen tmp_id = fl_create_offscreen(W, H);
     fl_begin_offscreen(tmp_id);
@@ -327,48 +309,37 @@ void Fl_GDI_Device::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx,
     fl_color(save_c); // back to bitmap's color
     tempdc = CreateCompatibleDC(fl_gc);
     save = SaveDC(tempdc);
-    SelectObject(tempdc, (HGDIOBJ)bm->id_);
+    SelectObject(tempdc, (HGDIOBJ)id_);
     SelectObject(fl_gc, fl_brush()); // use bitmap's desired color
     BitBlt(fl_gc, 0, 0, W, H, tempdc, 0, 0, 0xE20746L); // draw bitmap to offscreen
     fl_end_offscreen(); // offscreen data is in tmp_id
     SelectObject(tempdc, (HGDIOBJ)tmp_id); // use offscreen data
     // draw it to printer context with background color as transparent
-    fl_TransparentBlt(fl_gc, X,Y,W,H, tempdc, cx, cy, bm->w(), bm->h(), RGB(r, g, b) ); 
+    fl_TransparentBlt(fl_gc, X,Y,W,H, tempdc, cx, cy, w(), h(), RGB(r, g, b) ); 
     fl_delete_offscreen(tmp_id);
-  }
+    }
   else { // algorithm for bitmap output to display
     tempdc = CreateCompatibleDC(fl_gc);
     save = SaveDC(tempdc);
-    SelectObject(tempdc, (HGDIOBJ)bm->id_);
+    SelectObject(tempdc, (HGDIOBJ)id_);
     SelectObject(fl_gc, fl_brush());
     // secret bitblt code found in old MSWindows reference manual:
     BitBlt(fl_gc, X, Y, W, H, tempdc, cx, cy, 0xE20746L);
-  }
+    }
   RestoreDC(tempdc, save);
   DeleteDC(tempdc);
-}  
-
-#else // Xlib
-void Fl_Xlib_Device::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
-  int X, Y, W, H;
-  if (!bm->array) {
-    bm->draw_empty(XP, YP);
-    return;
-  }
-  if (start(bm, XP, YP, WP, HP, bm->w(), bm->h(), cx, cy, X, Y, W, H)) {
-    return;
+#elif defined(__APPLE_QUARTZ__)
+  if (!id_) id_ = fl_create_bitmask(w(), h(), array);
+  if (id_ && fl_gc) {
+    CGRect rect = { { X, Y }, { W, H } };
+    Fl_X::q_begin_image(rect, cx, cy, w(), h());
+    CGContextDrawImage(fl_gc, rect, (CGImageRef)id_);
+    Fl_X::q_end_image();
   }
-  if (!bm->id_) bm->id_ = fl_create_bitmask(bm->w(), bm->h(), bm->array);
-  
-  XSetStipple(fl_display, fl_gc, bm->id_);
-  int ox = X-cx; if (ox < 0) ox += bm->w();
-  int oy = Y-cy; if (oy < 0) oy += bm->h();
-  XSetTSOrigin(fl_display, fl_gc, ox, oy);
-  XSetFillStyle(fl_display, fl_gc, FillStippled);
-  XFillRectangle(fl_display, fl_window, fl_gc, X, Y, W, H);
-  XSetFillStyle(fl_display, fl_gc, FillSolid);
-}
+#else
+# error unsupported platform
 #endif
+}
 
 /**
   The destructor free all memory and server resources that are used by
diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx
index ceead089f5342925f4edb027447d79aa4a49c23c..9c76d3f6f20efcdb60b9ababa77a3c89a5fa0916 100644
--- a/src/Fl_Device.cxx
+++ b/src/Fl_Device.cxx
@@ -29,10 +29,32 @@
 #include <FL/Fl_Device.H>
 #include <FL/Fl_Image.H>
 
-const char *Fl_Device::device_type = "Fl_Device";
-const char *Fl_Display_Device::device_type = "Fl_Display_Device";
-const char *Fl_Graphics_Device::device_type = "Fl_Graphics_Device";
+/** \brief Draws an Fl_Pixmap object to the device. 
+ *
+ Specifies a bounding box for the image, with the origin (upper left-hand corner) of 
+ the image offset by the cx and cy arguments.
+ */
+void Fl_Device::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) {
+  pxm->generic_device_draw(XP, YP, WP, HP, cx, cy);
+}
+
+/** \brief Draws an Fl_Bitmap object to the device. 
+ *
+ Specifies a bounding box for the image, with the origin (upper left-hand corner) of 
+ the image offset by the cx and cy arguments.
+ */
+void Fl_Device::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
+  bm->generic_device_draw(XP, YP, WP, HP, cx, cy);
+}
 
+/** \brief Draws an Fl_RGB_Image object to the device. 
+ *
+ Specifies a bounding box for the image, with the origin (upper left-hand corner) of 
+ the image offset by the cx and cy arguments.
+ */
+void Fl_Device::draw(Fl_RGB_Image *rgb, int XP, int YP, int WP, int HP, int cx, int cy) {
+  rgb->generic_device_draw(XP, YP, WP, HP, cx, cy);
+}
 
 /**
  @brief Sets this device (display, printer, local file) as the target of future graphics calls.
diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx
index 70462a2ab2fa243bc15f76a12ed4cac779463599..89f8388441e314fd27d0829fd28a301dee14fd17 100644
--- a/src/Fl_Double_Window.cxx
+++ b/src/Fl_Double_Window.cxx
@@ -28,7 +28,6 @@
 #include <config.h>
 #include <FL/Fl.H>
 #include <FL/Fl_Double_Window.H>
-#include <FL/Fl_Printer.H>
 #include <FL/x.H>
 #include <FL/fl_draw.H>
 
@@ -149,9 +148,8 @@ void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int src
   SelectObject(new_gc, bitmap);
   BOOL alpha_ok = 0;
   // first try to alpha blend
-  // if to printer, always try alpha_blend
-  int to_display = Fl_Device::current()->type() == Fl_Display_Device::device_type; // true iff display output
-  if ( (to_display && fl_can_do_alpha_blending()) || Fl_Device::current()->type() == Fl_Printer::device_type) 
+  int to_display = Fl_Device::current()->type() < 256; // true iff display output
+  if ( (!to_display) || fl_can_do_alpha_blending()) // if not on display, always try 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
   if (!alpha_ok)
diff --git a/src/Fl_GDI_Printer.cxx b/src/Fl_GDI_Printer.cxx
index 8a464888178e7d2cd47e24e2b722c850c85172d7..f89374095c158e485b4f5d4f09866487d1623d3e 100644
--- a/src/Fl_GDI_Printer.cxx
+++ b/src/Fl_GDI_Printer.cxx
@@ -36,7 +36,7 @@ extern HWND fl_window;
 
 Fl_Printer::Fl_Printer(void) : Fl_Abstract_Printer() {
   hPr = NULL;
-  type_ = device_type;
+  type_ = gdi_printer;
 }
 
 Fl_Printer::~Fl_Printer(void) {
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index 36078952398e477a5fd3f53dfbca501a087622d0..bf39f6b09e2c4ab15e51a9e5a1b074d3178df11d 100644
--- a/src/Fl_Image.cxx
+++ b/src/Fl_Image.cxx
@@ -437,7 +437,7 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
   fl_device->draw(this, XP, YP, WP, HP, cx, cy);
 }
 
-/*void Fl_RGB_Image::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy) {
+void Fl_RGB_Image::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy) {
   // Don't draw an empty image...
   if (!d() || !array) {
     draw_empty(XP, YP);
@@ -542,146 +542,8 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
 #else
 # error unsupported platform
 #endif
-}*/
-
-static int start(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int w, int h, int cx, int cy, 
-		 int &X, int &Y, int &W, int &H)
-{
-  // account for current clip region (faster on Irix):
-  fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
-  cx += X-XP; cy += Y-YP;
-  // clip the box down to the size of image, quit if empty:
-  if (cx < 0) {W += cx; X -= cx; cx = 0;}
-  if (cx+W > w) W = w-cx;
-  if (W <= 0) return 1;
-  if (cy < 0) {H += cy; Y -= cy; cy = 0;}
-  if (cy+H > h) H = h-cy;
-  if (H <= 0) return 1;
-  return 0;
 }
 
-#ifdef __APPLE__
-void Fl_Quartz_Device::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
-  int X, Y, W, H;
-  // Don't draw an empty image...
-  if (!img->d() || !img->array) {
-    img->draw_empty(XP, YP);
-    return;
-  }
-  if (start(img, XP, YP, WP, HP, img->w(), img->h(), cx, cy, X, Y, W, H)) {
-    return;
-  }
-  if (!img->id_) {
-    CGColorSpaceRef lut = 0;
-    if (img->d()<=2)
-      lut = CGColorSpaceCreateDeviceGray();
-    else
-      lut = CGColorSpaceCreateDeviceRGB();
-    CGDataProviderRef src = CGDataProviderCreateWithData( 0L, img->array, img->w()*img->h()*img->d(), 0L);
-    img->id_ = CGImageCreate( img->w(), img->h(), 8, img->d()*8, img->ld()?img->ld():img->w()*img->d(),
-			lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
-			src, 0L, false, kCGRenderingIntentDefault);
-    CGColorSpaceRelease(lut);
-    CGDataProviderRelease(src);
-  }
-  if (img->id_ && fl_gc) {
-    CGRect rect = { { X, Y }, { W, H } };
-    Fl_X::q_begin_image(rect, cx, cy, img->w(), img->h());
-    CGContextDrawImage(fl_gc, rect, (CGImageRef)img->id_);
-    Fl_X::q_end_image();
-  }
-}
-
-#elif defined(WIN32)
-void Fl_GDI_Device::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
-  int X, Y, W, H;
-  // Don't draw an empty image...
-  if (!img->d() || !img->array) {
-    img->draw_empty(XP, YP);
-    return;
-  }
-  if (start(img, XP, YP, WP, HP, img->w(), img->h(), cx, cy, X, Y, W, H)) {
-    return;
-  }
-  if (!img->id_) {
-    img->id_ = fl_create_offscreen(img->w(), img->h());
-    if ((img->d() == 2 || img->d() == 4) && fl_can_do_alpha_blending()) {
-      fl_begin_offscreen((Fl_Offscreen)img->id_);
-      fl_draw_image(img->array, 0, 0, img->w(), img->h(), img->d()|FL_IMAGE_WITH_ALPHA, img->ld());
-      fl_end_offscreen();
-    } else {
-      fl_begin_offscreen((Fl_Offscreen)img->id_);
-      fl_draw_image(img->array, 0, 0, img->w(), img->h(), img->d(), img->ld());
-      fl_end_offscreen();
-      if (img->d() == 2 || img->d() == 4) {
-        img->mask_ = fl_create_alphamask(img->w(), img->h(), img->d(), img->ld(), img->array);
-      }
-    }
-  }
-  if (img->mask_) {
-    HDC new_gc = CreateCompatibleDC(fl_gc);
-    int save = SaveDC(new_gc);
-    SelectObject(new_gc, (void*)img->mask_);
-    BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND);
-    SelectObject(new_gc, (void*)img->id_);
-    BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT);
-    RestoreDC(new_gc,save);
-    DeleteDC(new_gc);
-  } else if (img->d()==2 || img->d()==4) {
-    fl_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);
-  }
-}
-
-#else
-void Fl_Xlib_Device::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
-  int X, Y, W, H;
-  // Don't draw an empty image...
-  if (!img->d() || !img->array) {
-    img->draw_empty(XP, YP);
-    return;
-  }
-  if (start(img, XP, YP, WP, HP, img->w(), img->h(), cx, cy, X, Y, W, H)) {
-    return;
-  }
-  if (!img->id_) {
-    if (img->d() == 1 || img->d() == 3) {
-      img->id_ = fl_create_offscreen(img->w(), img->h());
-      fl_begin_offscreen((Fl_Offscreen)img->id_);
-      fl_draw_image(img->array, 0, 0, img->w(), img->h(), img->d(), img->ld());
-      fl_end_offscreen();
-    }
-  }
-  if (img->id_) {
-    if (img->mask_) {
-      // I can't figure out how to combine a mask with existing region,
-      // so cut the image down to a clipped rectangle:
-      int nx, ny; fl_clip_box(X,Y,W,H,nx,ny,W,H);
-      cx += nx-X; X = nx;
-      cy += ny-Y; Y = ny;
-      // make X use the bitmap as a mask:
-      XSetClipMask(fl_display, fl_gc, img->mask_);
-      int ox = X-cx; if (ox < 0) ox += img->w();
-      int oy = Y-cy; if (oy < 0) oy += img->h();
-      XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy);
-    }
-    
-    fl_copy_offscreen(X, Y, W, H, img->id_, cx, cy);
-    
-    if (img->mask_) {
-      // put the old clip region back
-      XSetClipOrigin(fl_display, fl_gc, 0, 0);
-      fl_restore_clip();
-    }
-  } else {
-    // Composite image with alpha manually each time...
-    alpha_blend(img, X, Y, W, H, cx, cy);
-  }
-}
-
-#endif
-
 void Fl_RGB_Image::label(Fl_Widget* widget) {
   widget->image(this);
 }
diff --git a/src/Fl_PS_Printer.cxx b/src/Fl_PS_Printer.cxx
index e79ff8a3bc80303396776bbc9f1c1d2d0bcd9d9a..347c4064412755815ec6654d4492478fad218271 100644
--- a/src/Fl_PS_Printer.cxx
+++ b/src/Fl_PS_Printer.cxx
@@ -32,34 +32,25 @@
 #include <FL/Fl_PSfile_Device.H>
 #include <FL/Fl_Native_File_Chooser.H>
 
-const char *Fl_PS_Device::device_type = "Fl_PS_Device";
-const char *Fl_PSfile_Device::device_type = "Fl_PSfile_Device";
 const char *Fl_PSfile_Device::file_chooser_title = "Select a .ps file";
 
 /**
  @brief The constructor.
  */
-Fl_PS_Device::Fl_PS_Device(void)
+Fl_PSfile_Device::Fl_PSfile_Device(void)
 {
   close_cmd_ = 0;
   //lang_level_ = 3;
   lang_level_ = 2;
   mask = 0;
   ps_filename_ = NULL;
-  type_ = device_type;
+  type_ = postscript_device;
   scale_x = scale_y = 1.;
-}
-
-/**
- @brief The constructor.
- */
-Fl_PSfile_Device::Fl_PSfile_Device(void)
-{
-  type_ = device_type;
 #ifdef __APPLE__
   gc = fl_gc; // the display context is used by fl_text_extents()
 #endif
 }
+
 /**
  @brief Begins the session where all graphics requests will go to a local PostScript file.
  *
@@ -116,7 +107,7 @@ Fl_PSfile_Device::~Fl_PSfile_Device() {
   #include "print_panel.cxx"
 #endif
 
-const Fl_PS_Device::page_format Fl_PS_Device::page_formats[NO_PAGE_FORMATS] = { // order of enum Page_Format
+const Fl_PSfile_Device::page_format Fl_PSfile_Device::page_formats[NO_PAGE_FORMATS] = { // order of enum Page_Format
 // comes from appendix B of 5003.PPD_Spec_v4.3.pdf
 
   // A* // index(Ai) = i
@@ -468,7 +459,7 @@ static const char * prolog_3 = // prolog relevant only if lang_level >2
 
 // end prolog 
 
-int Fl_PS_Device::start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout)
+int Fl_PSfile_Device::start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout)
 //returns 0 iff OK
 {
   int w, h, x;
@@ -526,13 +517,13 @@ int Fl_PS_Device::start_postscript (int pagecount, enum Page_Format format, enum
   return 0;
 }
 
-void Fl_PS_Device::recover(){
+void Fl_PSfile_Device::recover(){
   color(cr_,cg_,cb_);
   line_style(linestyle_,linewidth_,linedash_);
   font(font_,size_);
 }
 
-void Fl_PS_Device::reset(){
+void Fl_PSfile_Device::reset(){
   gap_=1;
   clip_=0;
   cr_=cg_=cb_=0;
@@ -551,7 +542,7 @@ void Fl_PS_Device::reset(){
   
 }
 
-void Fl_PS_Device::page_policy(int p){
+void Fl_PSfile_Device::page_policy(int p){
   page_policy_ = p;
   if(lang_level_>=2)
     fprintf(output,"<< /Policies << /Pagesize %i >> >> setpagedevice\n", p);
@@ -561,7 +552,7 @@ void Fl_PS_Device::page_policy(int p){
 
 
 
-void Fl_PS_Device::page(double pw, double ph, int media) {
+void Fl_PSfile_Device::page(double pw, double ph, int media) {
   
   if (nPages){
     fprintf(output, "CR\nGR\nGR\nGR\nSP\nrestore\n");
@@ -610,20 +601,20 @@ void Fl_PS_Device::page(double pw, double ph, int media) {
   fprintf(output, "GS\nCS\n");
 };
 
-void Fl_PS_Device::page(int format){
+void Fl_PSfile_Device::page(int format){
   
   
   if(format &  LANDSCAPE){
-    ph_=Fl_PS_Device::page_formats[format & 0xFF].width;
-    pw_=Fl_PS_Device::page_formats[format & 0xFF].height;
+    ph_=Fl_PSfile_Device::page_formats[format & 0xFF].width;
+    pw_=Fl_PSfile_Device::page_formats[format & 0xFF].height;
   }else{
-    pw_=Fl_PS_Device::page_formats[format & 0xFF].width;
-    ph_=Fl_PS_Device::page_formats[format & 0xFF].height;
+    pw_=Fl_PSfile_Device::page_formats[format & 0xFF].width;
+    ph_=Fl_PSfile_Device::page_formats[format & 0xFF].height;
   }
   page(pw_,ph_,format & 0xFF00);//,orientation only;
 };
 
-void Fl_PS_Device::rect(int x, int y, int w, int h) {
+void Fl_PSfile_Device::rect(int x, int y, int w, int h) {
   // Commented code does not work, i can't find the bug ;-(
   // fprintf(output, "GS\n");
   //  fprintf(output, "%i, %i, %i, %i R\n", x , y , w, h);
@@ -638,17 +629,17 @@ void Fl_PS_Device::rect(int x, int y, int w, int h) {
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::rectf(int x, int y, int w, int h) {
+void Fl_PSfile_Device::rectf(int x, int y, int w, int h) {
   fprintf(output, "%g %g %i %i FR\n", x-0.5, y-0.5, w, h);
 }
 
-void Fl_PS_Device::line(int x1, int y1, int x2, int y2) {
+void Fl_PSfile_Device::line(int x1, int y1, int x2, int y2) {
   fprintf(output, "GS\n");
   fprintf(output, "%i %i %i %i L\n", x1 , y1, x2 ,y2);
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::line(int x0, int y0, int x1, int y1, int x2, int y2) {
+void Fl_PSfile_Device::line(int x0, int y0, int x1, int y1, int x2, int y2) {
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x0 , y0);
@@ -658,7 +649,7 @@ void Fl_PS_Device::line(int x0, int y0, int x1, int y1, int x2, int y2) {
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::xyline(int x, int y, int x1, int y2, int x3){
+void Fl_PSfile_Device::xyline(int x, int y, int x1, int y2, int x3){
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x , y );
@@ -670,7 +661,7 @@ void Fl_PS_Device::xyline(int x, int y, int x1, int y2, int x3){
 };
 
 
-void Fl_PS_Device::xyline(int x, int y, int x1, int y2){
+void Fl_PSfile_Device::xyline(int x, int y, int x1, int y2){
   
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
@@ -681,7 +672,7 @@ void Fl_PS_Device::xyline(int x, int y, int x1, int y2){
   fprintf(output, "GR\n");
 };
 
-void Fl_PS_Device::xyline(int x, int y, int x1){
+void Fl_PSfile_Device::xyline(int x, int y, int x1){
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x , y);
@@ -691,7 +682,7 @@ void Fl_PS_Device::xyline(int x, int y, int x1){
   fprintf(output, "GR\n");
 };
 
-void Fl_PS_Device::yxline(int x, int y, int y1, int x2, int y3){
+void Fl_PSfile_Device::yxline(int x, int y, int y1, int x2, int y3){
   fprintf(output, "GS\n");
   
   fprintf(output,"BP\n");
@@ -703,7 +694,7 @@ void Fl_PS_Device::yxline(int x, int y, int y1, int x2, int y3){
   fprintf(output, "GR\n");
 };
 
-void Fl_PS_Device::yxline(int x, int y, int y1, int x2){
+void Fl_PSfile_Device::yxline(int x, int y, int y1, int x2){
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x , y);
@@ -713,7 +704,7 @@ void Fl_PS_Device::yxline(int x, int y, int y1, int x2){
   fprintf(output, "GR\n");
 };
 
-void Fl_PS_Device::yxline(int x, int y, int y1){
+void Fl_PSfile_Device::yxline(int x, int y, int y1){
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x , y);
@@ -722,7 +713,7 @@ void Fl_PS_Device::yxline(int x, int y, int y1){
   fprintf(output, "GR\n");
 };
 
-void Fl_PS_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
+void Fl_PSfile_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x0 , y0);
@@ -732,7 +723,7 @@ void Fl_PS_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
+void Fl_PSfile_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x0 , y0);
@@ -743,7 +734,7 @@ void Fl_PS_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3,
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
+void Fl_PSfile_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x0 , y0);
@@ -753,7 +744,7 @@ void Fl_PS_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
+void Fl_PSfile_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
   fprintf(output, "GS\n");
   fprintf(output,"BP\n");
   fprintf(output, "%i %i MT\n", x0 , y0 );
@@ -765,7 +756,7 @@ void Fl_PS_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::point(int x, int y){
+void Fl_PSfile_Device::point(int x, int y){
   rectf(x,y,1,1);
 }
 
@@ -788,7 +779,7 @@ static double dashes_cap[5][7]={
 };
 
 
-void Fl_PS_Device::line_style(int style, int width, char* dashes){
+void Fl_PSfile_Device::line_style(int style, int width, char* dashes){
   //line_styled_=1;
   
   linewidth_=width;
@@ -866,16 +857,16 @@ static const char *_fontNames[] = {
 "ZapfDingbats"
 };
 
-void Fl_PS_Device::font(int f, int s) {
+void Fl_PSfile_Device::font(int f, int s) {
   if (f >= FL_FREE_FONT)
     f = FL_COURIER;
   fprintf(output, "/%s SF\n" , _fontNames[f]);
   fprintf(output,"%i FS\n", s);
-  display_device()->font(f,s); // Use display fonts for font measurement
+  Fl_Device::display_device()->font(f,s); // Use display fonts for font measurement
   font_ = f; size_ = s;
 };
 
-void Fl_PS_Device::color(Fl_Color c) {
+void Fl_PSfile_Device::color(Fl_Color c) {
   //colored_=1;
   color_=c;
   Fl::get_color(c, cr_, cg_, cb_);
@@ -892,7 +883,7 @@ void Fl_PS_Device::color(Fl_Color c) {
   }
 }
 
-void Fl_PS_Device::color(unsigned char r, unsigned char g, unsigned char b) {
+void Fl_PSfile_Device::color(unsigned char r, unsigned char g, unsigned char b) {
   //colored_=1;
   cr_=r;cg_=g;cb_=b;
   if (r==g && g==b) {
@@ -907,14 +898,14 @@ void Fl_PS_Device::color(unsigned char r, unsigned char g, unsigned char b) {
   }
 }
 
-void Fl_PS_Device::draw(int angle, const char *str, int n, int x, int y)
+void Fl_PSfile_Device::draw(int angle, const char *str, int n, int x, int y)
 {
   fprintf(output, "GS %d %d translate %d rotate\n", x, y, - angle);
   this->transformed_draw(str, n, 0, 0);
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::transformed_draw(const char* str, int n, double x, double y){
+void Fl_PSfile_Device::transformed_draw(const char* str, int n, double x, double y){
   if (!n || !str || !*str)return;
   fprintf(output,"%g (", fl_width(str, n));
   int i=1;
@@ -939,18 +930,18 @@ void Fl_PS_Device::transformed_draw(const char* str, int n, double x, double y){
 struct matrix {double a, b, c, d, x, y;};
 extern matrix * fl_matrix;
 
-void Fl_PS_Device::concat(){
+void Fl_PSfile_Device::concat(){
   fprintf(output,"[%g %g %g %g %g %g] CT\n", fl_matrix->a , fl_matrix->b , fl_matrix->c , fl_matrix->d , fl_matrix->x , fl_matrix->y);
 }
 
-void Fl_PS_Device::reconcat(){
+void Fl_PSfile_Device::reconcat(){
   fprintf(output, "[%g %g %g %g %g %g] RCT\n" , fl_matrix->a , fl_matrix->b , fl_matrix->c , fl_matrix->d , fl_matrix->x , fl_matrix->y);
 }
 
 /////////////////  transformed (double) drawings ////////////////////////////////
 
 
-void Fl_PS_Device::begin_points(){
+void Fl_PSfile_Device::begin_points(){
   fprintf(output, "GS\n");
   concat();
   
@@ -959,7 +950,7 @@ void Fl_PS_Device::begin_points(){
   shape_=POINTS;
 };
 
-void Fl_PS_Device::begin_line(){
+void Fl_PSfile_Device::begin_line(){
   fprintf(output, "GS\n");
   concat();
   fprintf(output, "BP\n");
@@ -967,7 +958,7 @@ void Fl_PS_Device::begin_line(){
   shape_=LINE;
 };
 
-void Fl_PS_Device::begin_loop(){
+void Fl_PSfile_Device::begin_loop(){
   fprintf(output, "GS\n");
   concat();
   fprintf(output, "BP\n");
@@ -975,7 +966,7 @@ void Fl_PS_Device::begin_loop(){
   shape_=LOOP;
 };
 
-void Fl_PS_Device::begin_polygon(){
+void Fl_PSfile_Device::begin_polygon(){
   fprintf(output, "GS\n");
   concat();
   fprintf(output, "BP\n");
@@ -983,7 +974,7 @@ void Fl_PS_Device::begin_polygon(){
   shape_=POLYGON;
 };
 
-void Fl_PS_Device::vertex(double x, double y){
+void Fl_PSfile_Device::vertex(double x, double y){
   if(shape_==POINTS){
     fprintf(output,"%g %g MT\n", x , y);
     gap_=1;
@@ -996,7 +987,7 @@ void Fl_PS_Device::vertex(double x, double y){
     fprintf(output, "%g %g LT\n", x , y);
 };
 
-void Fl_PS_Device::curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3){
+void Fl_PSfile_Device::curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3){
   if(shape_==NONE) return;
   if(gap_)
     fprintf(output,"%g %g MT\n", x , y);
@@ -1008,7 +999,7 @@ void Fl_PS_Device::curve(double x, double y, double x1, double y1, double x2, do
 };
 
 
-void Fl_PS_Device::circle(double x, double y, double r){
+void Fl_PSfile_Device::circle(double x, double y, double r){
   if(shape_==NONE){
     fprintf(output, "GS\n");
     concat();
@@ -1023,7 +1014,7 @@ void Fl_PS_Device::circle(double x, double y, double r){
   
 };
 
-void Fl_PS_Device::arc(double x, double y, double r, double start, double a){
+void Fl_PSfile_Device::arc(double x, double y, double r, double start, double a){
   if(shape_==NONE) return;
   gap_=0;
   if(start>a)
@@ -1033,7 +1024,7 @@ void Fl_PS_Device::arc(double x, double y, double r, double start, double a){
   
 };
 
-void Fl_PS_Device::arc(int x, int y, int w, int h, double a1, double a2) {
+void Fl_PSfile_Device::arc(int x, int y, int w, int h, double a1, double a2) {
   fprintf(output, "GS\n");
   //fprintf(output, "BP\n");
   begin_line();
@@ -1052,7 +1043,7 @@ void Fl_PS_Device::arc(int x, int y, int w, int h, double a1, double a2) {
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::pie(int x, int y, int w, int h, double a1, double a2) {
+void Fl_PSfile_Device::pie(int x, int y, int w, int h, double a1, double a2) {
   
   fprintf(output, "GS\n");
   fprintf(output, "%g %g TR\n", x + w/2.0 -0.5 , y + h/2.0 - 0.5);
@@ -1064,7 +1055,7 @@ void Fl_PS_Device::pie(int x, int y, int w, int h, double a1, double a2) {
   fprintf(output, "GR\n");
 }
 
-void Fl_PS_Device::end_points(){
+void Fl_PSfile_Device::end_points(){
   gap_=1;
   reconcat();
   fprintf(output, "ELP\n"); //??
@@ -1072,14 +1063,14 @@ void Fl_PS_Device::end_points(){
   shape_=NONE;
 }
 
-void Fl_PS_Device::end_line(){
+void Fl_PSfile_Device::end_line(){
   gap_=1;
   reconcat();
   fprintf(output, "ELP\n");
   fprintf(output, "GR\n");
   shape_=NONE;
 }
-void Fl_PS_Device::end_loop(){
+void Fl_PSfile_Device::end_loop(){
   gap_=1;
   reconcat();
   fprintf(output, "ECP\n");
@@ -1087,7 +1078,7 @@ void Fl_PS_Device::end_loop(){
   shape_=NONE;
 }
 
-void Fl_PS_Device::end_polygon(){
+void Fl_PSfile_Device::end_polygon(){
   
   gap_=1;
   reconcat();
@@ -1096,7 +1087,7 @@ void Fl_PS_Device::end_polygon(){
   shape_=NONE;
 }
 
-void Fl_PS_Device::transformed_vertex(double x, double y){
+void Fl_PSfile_Device::transformed_vertex(double x, double y){
   reconcat();
   if(gap_){
     fprintf(output, "%g %g MT\n", x , y);
@@ -1108,7 +1099,7 @@ void Fl_PS_Device::transformed_vertex(double x, double y){
 
 /////////////////////////////   Clipping /////////////////////////////////////////////
 
-void Fl_PS_Device::push_clip(int x, int y, int w, int h) {
+void Fl_PSfile_Device::push_clip(int x, int y, int w, int h) {
   Clip * c=new Clip();
   clip_box(x,y,w,h,c->x,c->y,c->w,c->h);
   c->prev=clip_;
@@ -1120,7 +1111,7 @@ void Fl_PS_Device::push_clip(int x, int y, int w, int h) {
   
 }
 
-void Fl_PS_Device::push_no_clip() {
+void Fl_PSfile_Device::push_no_clip() {
   Clip * c = new Clip();
   c->prev=clip_;
   clip_=c;
@@ -1130,7 +1121,7 @@ void Fl_PS_Device::push_no_clip() {
     recover();
 }
 
-void Fl_PS_Device::pop_clip() {
+void Fl_PSfile_Device::pop_clip() {
   if(!clip_)return;
   Clip * c=clip_;
   clip_=clip_->prev;
@@ -1143,7 +1134,7 @@ void Fl_PS_Device::pop_clip() {
     recover();
 }
 
-int Fl_PS_Device::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H){
+int Fl_PSfile_Device::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H){
   if(!clip_){
     X=x;Y=y;W=w;H=h;
     return 1;
@@ -1179,7 +1170,7 @@ int Fl_PS_Device::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, i
   return ret;
 };
 
-int Fl_PS_Device::not_clipped(int x, int y, int w, int h){
+int Fl_PSfile_Device::not_clipped(int x, int y, int w, int h){
   if(!clip_) return 1;
   if(clip_->w < 0) return 1;
   int X, Y, W, H;
@@ -1351,7 +1342,7 @@ int Fl_Printer::start_job(int pages, int *firstpage, int *lastpage) {
     return 1;
   }
 
-  return Fl_PS_Device::start_postscript(pages, format, layout); // start printing
+  return Fl_PSfile_Device::start_postscript(pages, format, layout); // start printing
 }
 
 #endif // ! (defined(__APPLE__) || defined(WIN32) )
diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx
index a75b25a752c89241a6673e225c9e8d3c0c0b809f..d20132a3526ad44cb2c4b80b94a1808859e6d15e 100644
--- a/src/Fl_Pixmap.cxx
+++ b/src/Fl_Pixmap.cxx
@@ -47,7 +47,6 @@
 #include <FL/Fl_Widget.H>
 #include <FL/Fl_Menu_Item.H>
 #include <FL/Fl_Pixmap.H>
-#include <FL/Fl_Printer.H>
 
 #include <stdio.h>
 #include "flstring.h"
@@ -78,160 +77,120 @@ void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
   fl_device->draw(this, XP, YP, WP, HP, cx, cy);
 }
 
-static int start(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int w, int h, int cx, int cy, 
-		 int &X, int &Y, int &W, int &H)
-{
+void Fl_Pixmap::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy) {
   // ignore empty or bad pixmap data:
-  if (!pxm->data()) {
-    return 2;
+  if (!data()) {
+    draw_empty(XP, YP);
+    return;
   }
-  if (WP == -1) {
-    WP = w;
-    HP = h;
+  if (w()<0) measure();
+  if (WP==-1) {
+    WP = w();
+    HP = h();
   }
-  if (!w) {
-    return 2;
+  if (!w()) {
+    draw_empty(XP, YP);
+    return;
   }
   // account for current clip region (faster on Irix):
-  fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
+  int X,Y,W,H; fl_clip_box(XP,YP,WP,HP,X,Y,W,H);
   cx += X-XP; cy += Y-YP;
   // clip the box down to the size of image, quit if empty:
   if (cx < 0) {W += cx; X -= cx; cx = 0;}
-  if (cx+W > w) W = w-cx;
-  if (W <= 0) return 1;
+  if (cx+W > w()) W = w()-cx;
+  if (W <= 0) return;
   if (cy < 0) {H += cy; Y -= cy; cy = 0;}
-  if (cy+H > h) H = h-cy;
-  if (H <= 0) return 1;
-  return 0;
-}
-
-#ifdef __APPLE__
-void Fl_Quartz_Device::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->id_) {
-    pxm->id_ = fl_create_offscreen_with_alpha(pxm->w(), pxm->h());
-    fl_begin_offscreen((Fl_Offscreen)pxm->id_);
-    fl_draw_pixmap(pxm->data(), 0, 0, FL_GREEN);
+  if (cy+H > h()) H = h()-cy;
+  if (H <= 0) return;
+  if (!id_) {
+#ifdef __APPLE_QUARTZ__
+    id_ = fl_create_offscreen_with_alpha(w(), h());
+    fl_begin_offscreen((Fl_Offscreen)id_);
+    fl_draw_pixmap(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_Device::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->id_) {
-    pxm->id_ = fl_create_offscreen(pxm->w(), pxm->h());
-    fl_begin_offscreen((Fl_Offscreen)pxm->id_);
+#else
+    id_ = fl_create_offscreen(w(), h());
+    fl_begin_offscreen((Fl_Offscreen)id_);
     uchar *bitmap = 0;
     fl_mask_bitmap = &bitmap;
-    fl_draw_pixmap(pxm->data(), 0, 0, FL_BLACK);
+    fl_draw_pixmap(data(), 0, 0, FL_BLACK);
     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;
     }
     fl_end_offscreen();
+#endif
+  }
+
+#if defined(USE_X11)
+  if (mask_) {
+    // I can't figure out how to combine a mask with existing region,
+    // so cut the image down to a clipped rectangle:
+    int nx, ny; fl_clip_box(X,Y,W,H,nx,ny,W,H);
+    cx += nx-X; X = nx;
+    cy += ny-Y; Y = ny;
+    // make X use the bitmap as a mask:
+    XSetClipMask(fl_display, fl_gc, mask_);
+    int ox = X-cx; if (ox < 0) ox += w();
+    int oy = Y-cy; if (oy < 0) oy += h();
+    XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy);
   }
-  if (fl_device->type() == Fl_Printer::device_type) {
+  fl_copy_offscreen(X, Y, W, H, id_, cx, cy);
+  if (mask_) {
+    // put the old clip region back
+    XSetClipOrigin(fl_display, fl_gc, 0, 0);
+    fl_restore_clip();
+  }
+#elif defined(WIN32)
+  if (fl_device->type() == Fl_Device::gdi_printer) {
     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 (hMod) {
-      Fl_Offscreen tmp_id = fl_create_offscreen(pxm->w(), pxm->h());
+      Fl_Offscreen tmp_id = fl_create_offscreen(w(), h());
       fl_begin_offscreen(tmp_id);
       uchar *bitmap = 0;
       fl_mask_bitmap = &bitmap;
       // draw pixmap to offscreen
-      fl_draw_pixmap(pxm->data(), 0, 0); 
+      fl_draw_pixmap(data(), 0, 0); 
       fl_end_offscreen();
       HDC new_gc = CreateCompatibleDC(fl_gc);
       int save = SaveDC(new_gc);
       SelectObject(new_gc, (void*)tmp_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 );
+      fl_TransparentBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, w(), h(), win_pixmap_bg_color );
       RestoreDC(new_gc,save);
       DeleteDC(new_gc);
       fl_delete_offscreen(tmp_id);
     }
     else {
-      fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
+      fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id_, cx, cy);
     }
   }
-  else if (pxm->mask_) {
+  else if (mask_) {
     HDC new_gc = CreateCompatibleDC(fl_gc);
     int save = SaveDC(new_gc);
-    SelectObject(new_gc, (void*)pxm->mask_);
+    SelectObject(new_gc, (void*)mask_);
     BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND);
-    SelectObject(new_gc, (void*)pxm->id_);
+    SelectObject(new_gc, (void*)id_);
     BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT);
     RestoreDC(new_gc,save);
     DeleteDC(new_gc);
   } else {
-    fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
-  }
-}
-
-#else // Xlib
-void Fl_Xlib_Device::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;
+    fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id_, cx, cy);
   }
-  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 (pxm->mask_) {
-    // I can't figure out how to combine a mask with existing region,
-    // so cut the image down to a clipped rectangle:
-    int nx, ny; fl_clip_box(X,Y,W,H,nx,ny,W,H);
-    cx += nx-X; X = nx;
-    cy += ny-Y; Y = ny;
-    // make X use the bitmap as a mask:
-    XSetClipMask(fl_display, fl_gc, pxm->mask_);
-    int ox = X-cx; if (ox < 0) ox += pxm->w();
-    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);
-  if (pxm->mask_) {
-    // put the old clip region back
-    XSetClipOrigin(fl_display, fl_gc, 0, 0);
-    fl_restore_clip();
-  }
-}
-
+#elif defined(__APPLE_QUARTZ__)
+  fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id_, cx, cy);
+#else
+# error unsupported platform
 #endif
+}
 
 /**
   The destructor free all memory and server resources that are used by
diff --git a/src/Fl_Printer.cxx b/src/Fl_Printer.cxx
index 6072c8515208965811b19d55c50b6258ee4047ea..d6e8425b32076c1739db8d5ae5f5df8a45f464e6 100644
--- a/src/Fl_Printer.cxx
+++ b/src/Fl_Printer.cxx
@@ -58,20 +58,6 @@ const char *Fl_Printer::property_use = "Use";
 const char *Fl_Printer::property_save = "Save";
 const char *Fl_Printer::property_cancel = "Cancel";
 
-const char *Fl_Printer::device_type = "Fl_Printer";
-
-Fl_Device *Fl_Printer::set_current(void)
-{
-#ifdef __APPLE__
-  fl_gc = (CGContextRef)gc;
-#elif defined(WIN32)
-  fl_gc = (HDC)gc;
-#else
-  fl_gc = (_XGC*)gc;
-#endif
-  return this->Fl_Device::set_current();
-}
-
 //
 // End of "$Id$".
 //
diff --git a/src/Fl_Quartz_Printer.mm b/src/Fl_Quartz_Printer.mm
index 3d1fc48773f225138b204d2ad67d6cbedb2ba99b..874686d3a97eaf34ef872bf0efabc387c06a70af 100644
--- a/src/Fl_Quartz_Printer.mm
+++ b/src/Fl_Quartz_Printer.mm
@@ -40,7 +40,7 @@ Fl_Printer::Fl_Printer(void)
   x_offset = 0;
   y_offset = 0;
   scale_x = scale_y = 1.;
-  type_ = device_type;
+  type_ = quartz_printer;
 }
 
 Fl_Printer::~Fl_Printer(void) {}
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 2efbe55cca8cdd56286db379cae4ae57fe130490..6a9654f7508af8263acc67188544abac9b18f91d 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -131,9 +131,9 @@ static void createAppleMenu(void);
 static Fl_Region MacRegionMinusRect(Fl_Region r, int x,int y,int w,int h);
 static void cocoaMouseHandler(NSEvent *theEvent);
 
-static Fl_Display_Device fl_quartz_display;
-FL_EXPORT Fl_Display_Device *fl_display_device = (Fl_Display_Device*)&fl_quartz_display; // does not change
-FL_EXPORT Fl_Device *fl_device = (Fl_Device*)&fl_quartz_display; // the current target device of graphics operations
+static Fl_Quartz_Display fl_quartz_device;
+FL_EXPORT Fl_Display *fl_display_device = (Fl_Display*)&fl_quartz_device; // does not change
+FL_EXPORT Fl_Device *fl_device = (Fl_Device*)&fl_quartz_device; // the current target device of graphics operations
 
 // public variables
 int fl_screen;
@@ -2100,7 +2100,7 @@ void Fl_X::make(Fl_Window* w)
         winstyle |= NSResizableWindowMask;
       }
     } else {
-			if (w->resizable()) {
+      if (w->resizable()) {
         Fl_Widget *o = w->resizable();
         int minw = o->w(); if (minw > 100) minw = 100;
         int minh = o->h(); if (minh > 100) minh = 100;
@@ -2121,7 +2121,8 @@ void Fl_X::make(Fl_Window* w)
         winstyle = NSBorderlessWindowMask;
       }
     } else if (w->modal()) {
-      winstyle &= ~(NSResizableWindowMask | NSMiniaturizableWindowMask);
+      winstyle &= ~NSMiniaturizableWindowMask;
+      // winstyle &= ~(NSResizableWindowMask | NSMiniaturizableWindowMask);
       // winlevel = NSModalPanelWindowLevel;
     }
     else if (w->non_modal()) {
@@ -2998,7 +2999,6 @@ int MACscreen_init(XRectangle screens[])
   printer.end_page();
   printer.end_job();
 }
-
 @end
 
 static NSMenu *appleMenu;
@@ -3028,7 +3028,7 @@ static void createAppleMenu(void)
   [appleMenu setAutoenablesItems:NO];
   [menuItem setEnabled:YES];
   [appleMenu addItem:[NSMenuItem separatorItem]];
-  // end of temporary for testing Fl_Printer  
+// end of temporary for testing Fl_Printer  
   // Services Menu
   services = [[NSMenu alloc] init];
   [appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
@@ -3475,7 +3475,7 @@ WindowRef MACwindowRef(Fl_Window *w)
 
 // so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes
 CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h) {
-  if ( Fl_Device::current()->type() == Fl_Printer::device_type ) return CGRectMake(x, y, w-1.5 , h-1.5 ); 
+  if (Fl_Device::current()->type() == Fl_Device::quartz_printer) return CGRectMake(x, y, w-1.5 , h-1.5 ); 
   return CGRectMake(x, y, w > 0 ? w - 0.9 : 0, h > 0 ? h - 0.9 : 0);
 }
 
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index bcc07715c62c76305a512788c61602e72e278517..f26d639db62fbb53c9c9f45cf09ee07d91612e71 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -95,9 +95,9 @@
   for async mode proper operation, not mentioning the side effects...
 */
 
-static Fl_Display_Device fl_gdi_display;
-FL_EXPORT Fl_Display_Device *fl_display_device = (Fl_Display_Device*)&fl_gdi_display; // does not change
-FL_EXPORT Fl_Device *fl_device = (Fl_Device*)&fl_gdi_display; // the current target device of graphics operations
+static Fl_GDI_Display fl_gdi_device;
+FL_EXPORT Fl_Display *fl_display_device = (Fl_Display*)&fl_gdi_device; // does not change
+FL_EXPORT Fl_Device *fl_device = (Fl_Device*)&fl_gdi_device; // the current target device of graphics operations
 
 // dynamic wsock dll handling api:
 #if defined(__CYGWIN__) && !defined(SOCKET)
@@ -1925,7 +1925,7 @@ void fl_cleanup_dc_list(void) {          // clean up the list
 }
 
 Fl_Region XRectangleRegion(int x, int y, int w, int h) {
-  if (Fl_Device::current()->type() == Fl_Display_Device::device_type) return CreateRectRgn(x,y,x+w,y+h);
+  if (Fl_Device::current()->type() < 256) 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);
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index f80c110966fa73c087550820c31aace4e91647b2..1c81503f819cc097199aad7570476ac8134d4ad2 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -51,9 +51,9 @@
 #  include <X11/Xlocale.h>
 #  include <X11/Xlib.h>
 
-static Fl_Display_Device fl_xlib_display;
-FL_EXPORT Fl_Display_Device *fl_display_device = (Fl_Display_Device*)&fl_xlib_display; // does not change
-FL_EXPORT Fl_Device *fl_device = (Fl_Device*)&fl_xlib_display; // the current target device of graphics operations
+static Fl_Xlib_Display fl_xlib_device;
+FL_EXPORT Fl_Display *fl_display_device = (Fl_Display*)&fl_xlib_device; // does not change
+FL_EXPORT Fl_Device *fl_device = (Fl_Device*)&fl_xlib_device; // the current target device of graphics operations
 
 ////////////////////////////////////////////////////////////////
 // interface to poll/select call:
@@ -136,7 +136,9 @@ void Fl::add_fd(int n, void (*cb)(int, void*), void* v) {
 
 void Fl::remove_fd(int n, int events) {
   int i,j;
+# if !USE_POLL
   maxfd = -1; // recalculate maxfd on the fly
+# endif
   for (i=j=0; i<nfds; i++) {
 #  if USE_POLL
     if (pollfds[i].fd == n) {
@@ -150,8 +152,8 @@ void Fl::remove_fd(int n, int events) {
       if (!e) continue; // if no events left, delete this fd
       fd[i].events = e;
     }
-#  endif
     if (fd[i].fd > maxfd) maxfd = fd[i].fd;
+#  endif
     // move it down in the array if necessary:
     if (j<i) {
       fd[j] = fd[i];
@@ -1586,6 +1588,13 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
     XFree(hints);
   }
 
+  // set the window type for menu and tooltip windows to avoid animations (compiz)
+  if (win->menu_window() || win->tooltip_window()) {
+    Atom net_wm_type = XInternAtom(fl_display, "_NET_WM_WINDOW_TYPE", False);
+    Atom net_wm_type_kind = XInternAtom(fl_display, "_NET_WM_WINDOW_TYPE_MENU", False);
+    int ret = XChangeProperty(fl_display, xp->xid, net_wm_type, XA_ATOM, 32, PropModeReplace, (unsigned char*)&net_wm_type_kind, 1);
+  }
+
   XMapWindow(fl_display, xp->xid);
   if (showit) {
     win->set_visible();
diff --git a/src/fl_draw_image_win32.cxx b/src/fl_draw_image_win32.cxx
index fd7ee64eab88ad84bc617c074c7167e09a07e9f3..403dfd9feab2c73f5b9f587872cbcd9218a30a16 100644
--- a/src/fl_draw_image_win32.cxx
+++ b/src/fl_draw_image_win32.cxx
@@ -46,7 +46,6 @@
 
 #include <config.h>
 #include <FL/Fl.H>
-#include <FL/Fl_Printer.H>
 #include <FL/fl_draw.H>
 #include <FL/x.H>
 
@@ -255,7 +254,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
         }            
       }
     }
-    if(Fl_Device::current()->type() == Fl_Printer::device_type) {
+    if(Fl_Device::current()->type() == Fl_Device::gdi_printer) {
       // 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,
diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx
index 23521a678d6d06ec401e4575091890f9dd894bd4..fd0e3fdbfa0f4618e6b270b04d58283652196c71 100644
--- a/src/fl_font_win32.cxx
+++ b/src/fl_font_win32.cxx
@@ -24,9 +24,6 @@
 //
 //     http://www.fltk.org/str.php
 //
-
-#include <FL/Fl_Printer.H>
-
 static int fl_angle_ = 0;
 
 #ifndef FL_DOXYGEN
@@ -250,7 +247,7 @@ static void on_printer_extents_update(int &dx, int &dy, int &w, int &h)
 
 // if printer context, extents shd be converted to logical coords
 #define EXTENTS_UPDATE(x,y,w,h) \
-  if (Fl_Device::current()->type() == Fl_Printer::device_type) { on_printer_extents_update(x,y,w,h); }
+  if (Fl_Device::current()->type() == Fl_Device::gdi_printer) { on_printer_extents_update(x,y,w,h); }
 
 static unsigned short *ext_buff = NULL; // UTF-16 converted version of input UTF-8 string
 static unsigned wc_len = 0; // current string buffer dimension
diff --git a/src/fl_line_style.cxx b/src/fl_line_style.cxx
index 1dbea0a9126c269822fbfe3d04cfd3f80c91b28a..e93f159ec06239f42eb62a7fb01c553dac5f1488 100644
--- a/src/fl_line_style.cxx
+++ b/src/fl_line_style.cxx
@@ -33,10 +33,8 @@
 #include <FL/Fl.H>
 #include <FL/fl_draw.H>
 #include <FL/x.H>
-#include <FL/Fl_Printer.H>
 #include "flstring.h"
 #include <stdio.h>
-#include <FL/fl_ask.H>//TMP
 
 #ifdef __APPLE_QUARTZ__
 float fl_quartz_line_width_ = 1.0f;
@@ -119,9 +117,7 @@ void Fl_Device::line_style(int style, int width, char* dashes) {
   fl_quartz_line_width_ = (float)width; 
   fl_quartz_line_cap_ = Cap[(style>>8)&3];
   // when printing kCGLineCapSquare seems better for solid lines
-  if ( Fl_Device::current()->type() == Fl_Printer::device_type && style == FL_SOLID && dashes == NULL ) {
-    fl_quartz_line_cap_ = kCGLineCapSquare;
-    }
+  if (Fl_Device::current()->type() == quartz_printer && style == FL_SOLID) fl_quartz_line_cap_ = kCGLineCapSquare;
   fl_quartz_line_join_ = Join[(style>>12)&3];
   char *d = dashes; 
   static CGFloat pattern[16];
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index c9bdf6c472bc1169627811e72f98654e0450995b..df8cbef9a68be88951a1570b193501271947a450 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -38,13 +38,12 @@
 #include <config.h>
 #include <FL/Fl.H>
 #include <FL/Fl_Widget.H>
-#include <FL/Fl_Printer.H>
 #include <FL/fl_draw.H>
 #include <FL/x.H>
 
 #ifdef __APPLE_QUARTZ__
 extern float fl_quartz_line_width_;
-#define USINGQUARTZPRINTER  (Fl_Device::current()->type() == Fl_Printer::device_type)
+#define USINGQUARTZPRINTER  (Fl_Device::current()->type() == quartz_printer)
 #endif
 
 void Fl_Device::rect(int x, int y, int w, int h) {
@@ -511,7 +510,7 @@ int Fl_Device::not_clipped(int x, int y, int w, int h) {
 #elif defined(WIN32)
   if (!r) return 1;
   RECT rect;
-  if (Fl_Device::current()->type() == Fl_Printer::device_type) { // in case of print context, convert coords from logical to device
+  if (Fl_Device::current()->type() == Fl_Device::gdi_printer) { // 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;
@@ -573,7 +572,7 @@ int Fl_Device::clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int&
   } else {	// partial intersection
     RECT rect;
     GetRgnBox(temp, &rect);
-    if(Fl_Device::current()->type() == Fl_Printer::device_type) { // if print context, convert coords from device to logical
+    if(Fl_Device::current()->type() == Fl_Device::gdi_printer) { // 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;
diff --git a/src/ps_image.cxx b/src/ps_image.cxx
index 65e967755f9e5c871629afd7a811d97f002d690e..61534238c29f276db6e70ee3cc7ff05b1a28f7f7 100644
--- a/src/ps_image.cxx
+++ b/src/ps_image.cxx
@@ -34,7 +34,7 @@
 #include <FL/Fl_Pixmap.H>
 #include <FL/Fl_Bitmap.H>
  
-int Fl_PS_Device::alpha_mask(const uchar * data, int w, int h, int D, int LD){
+int Fl_PSfile_Device::alpha_mask(const uchar * data, int w, int h, int D, int LD){
 
   mask = 0;
   if((D/2)*2 != D){ //no mask info
@@ -182,27 +182,18 @@ int Fl_PS_Device::alpha_mask(const uchar * data, int w, int h, int D, int LD){
   return 0;
 }
 
+// bitwise inversion of all 4-bit quantities
+static const unsigned char swapped[16] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
 
-
-// TODO: anybody has more efficient algoritm?
-static inline uchar swap_byte(const uchar i){
-  uchar b =0;
-  if(i & 1) b |= 128;
-  if(i & 2) b |= 64;
-  if(i & 4) b |= 32;
-  if(i & 8) b |= 16;
-  if(i & 16) b |= 8;
-  if(i & 32) b |= 4;
-  if(i & 64) b |= 2;
-  if(i & 128) b |= 1;
-  return b;
-}
-
+// bitwise inversion of a byte
+static inline uchar swap_byte(const uchar b){
+ return (swapped[b & 0xF] << 4) | swapped[b >> 4];
+ }
 
 extern uchar **fl_mask_bitmap;
 
 
-void Fl_PS_Device::draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) {
+void Fl_PSfile_Device::draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) {
 
 
   if(D<3){ //mono
@@ -269,7 +260,7 @@ void Fl_PS_Device::draw_scaled_image(const uchar *data, double x, double y, doub
 
 };
 
-void Fl_PS_Device::draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D) {
+void Fl_PSfile_Device::draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D) {
 
   int level2_mask = 0;
   fprintf(output,"save\n");
@@ -357,7 +348,7 @@ void Fl_PS_Device::draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x
   delete[] rgbdata;
 }
 
-void Fl_PS_Device::draw_scaled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) {
+void Fl_PSfile_Device::draw_scaled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) {
 
   fprintf(output,"save\n");
 
@@ -418,7 +409,7 @@ void Fl_PS_Device::draw_scaled_image_mono(const uchar *data, double x, double y,
 
 
 
-void Fl_PS_Device::draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D) {
+void Fl_PSfile_Device::draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D) {
 
   fprintf(output,"save\n");
   int i,j,k;
@@ -467,7 +458,7 @@ void Fl_PS_Device::draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, dou
 ////////////////////////////// Image classes //////////////////////
 
 
-void Fl_PS_Device::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy){
+void Fl_PSfile_Device::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy){
   const char * const * di =pxm->data();
   int w,h;
   if (!fl_measure_pixmap(di, w, h)) return;
@@ -483,7 +474,7 @@ void Fl_PS_Device::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx,
   fl_mask_bitmap=0;
 };
 
-void Fl_PS_Device::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy){
+void Fl_PSfile_Device::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy){
   const uchar  * di = rgb->array;
   int w = rgb->w();
   int h = rgb->h();
@@ -497,7 +488,7 @@ void Fl_PS_Device::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int c
   mask=0;
 };
 
-void Fl_PS_Device::draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy){
+void Fl_PSfile_Device::draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy){
   const uchar  * di = bitmap->array;
   int w,h;
   int LD=(bitmap->w()+7)/8;