summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Abstract_Printer.H9
-rw-r--r--FL/Fl_Bitmap.H5
-rw-r--r--FL/Fl_Device.H137
-rw-r--r--FL/Fl_Image.H3
-rw-r--r--FL/Fl_PSfile_Device.H431
-rw-r--r--FL/Fl_Pixmap.H3
-rw-r--r--FL/Fl_Printer.H7
-rw-r--r--src/Fl_Abstract_Printer.cxx18
-rw-r--r--src/Fl_Bitmap.cxx109
-rw-r--r--src/Fl_Device.cxx28
-rw-r--r--src/Fl_Double_Window.cxx6
-rw-r--r--src/Fl_GDI_Printer.cxx2
-rw-r--r--src/Fl_Image.cxx140
-rw-r--r--src/Fl_PS_Printer.cxx127
-rw-r--r--src/Fl_Pixmap.cxx167
-rw-r--r--src/Fl_Printer.cxx14
-rw-r--r--src/Fl_Quartz_Printer.mm2
-rw-r--r--src/Fl_cocoa.mm16
-rw-r--r--src/Fl_win32.cxx8
-rw-r--r--src/Fl_x.cxx17
-rw-r--r--src/fl_draw_image_win32.cxx3
-rw-r--r--src/fl_font_win32.cxx5
-rw-r--r--src/fl_line_style.cxx6
-rw-r--r--src/fl_rect.cxx7
-rw-r--r--src/ps_image.cxx37
25 files changed, 773 insertions, 534 deletions
diff --git a/FL/Fl_Abstract_Printer.H b/FL/Fl_Abstract_Printer.H
index 919126fac..97f4092dc 100644
--- a/FL/Fl_Abstract_Printer.H
+++ b/FL/Fl_Abstract_Printer.H
@@ -39,10 +39,7 @@
*
This class has no public constructor: don't instantiate it; use Fl_Printer or Fl_PSfile_Device instead.
*/
-class Fl_Abstract_Printer : public Fl_Device {
- friend class Fl_Pixmap;
- friend class Fl_RGB_Image;
- friend class Fl_Bitmap;
+class Fl_Abstract_Printer {
private:
#ifdef __APPLE__
struct chain_elt {
@@ -62,14 +59,11 @@ 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);
@@ -91,3 +85,4 @@ public:
//
// End of "$Id$"
//
+
diff --git a/FL/Fl_Bitmap.H b/FL/Fl_Bitmap.H
index d47a82acf..92fe91eee 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_Device;
- public:
+ friend class Fl_Graphics_Device;
+public:
/** pointer to raw bitmap data */
const uchar *array;
@@ -58,7 +58,6 @@ class FL_EXPORT Fl_Bitmap : public Fl_Image {
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 8eaaa0c87..ad8506f1e 100644
--- a/FL/Fl_Device.H
+++ b/FL/Fl_Device.H
@@ -1,8 +1,8 @@
//
// "$Id$"
//
-// Definition of classes Fl_Device, Fl_Display, Fl_Quartz_Display, Fl_GDI_Display,
-// and Fl_Xlib_Display for the Fast Light Tool Kit (FLTK).
+// Definition of classes Fl_Device, Fl_Display_Device, Fl_Graphics_Device
+// 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.
+ \brief declaration of classes Fl_Device, Fl_Display_Device.
*/
#ifndef Fl_Device_H
@@ -45,14 +45,12 @@
#include <stdio.h>
#endif
-class Fl_Widget;
class Fl_Device;
-class Fl_Display;
-class Fl_Abstract_Printer;
+class Fl_Display_Device;
/** \brief Points to the device that currently receives all graphics requests */
-FL_EXPORT extern Fl_Device *fl_device;
+extern Fl_Device *fl_device;
/** \brief Points to the platform's display device */
-FL_EXPORT extern Fl_Display *fl_display_device;
+extern Fl_Display_Device *fl_display_device;
/**
signature of image generation callback function.
@@ -71,18 +69,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, member functions of the Fl_Device class can be called
+ <br> Alternatively, methods 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 member function of the Fl_Device class has the same effect and parameter list as the
+ <br>Each protected method of the Fl_Device class has the same effect as the
function of the \ref fl_drawings and \ref fl_attributes modules which bears the same name
- prefixed with fl_ .
+ prefixed with fl_ and has the same parameter list.
*/
class Fl_Device {
protected:
/** \brief The device type */
- int type_;
+ const char *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 */
@@ -92,6 +90,7 @@ 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);
@@ -239,73 +238,103 @@ 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
- 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:
- /**
- @brief All implemented graphics output devices.
+ /** \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.
*/
- 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. */
- };
+ 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) {};
+
+public:
+ /** A name that identifies each subclass of Fl_Device */
+ static const char *device_type;
/**
- @brief An RTTI emulation of device classes. It returns values < 256 if it is a display device
+ @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
*/
- inline int type() {return type_;};
+ inline const char *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 *display_device() { return fl_display_device; };
+ static Fl_Display_Device *display_device() { return fl_display_device; };
};
-extern FL_EXPORT Fl_Device *fl_device;
-/**
- @brief A virtual class subclassed for OS-specific display graphics.
- */
-class Fl_Display : public Fl_Device {
- friend class Fl_PSfile_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);
};
+typedef Fl_Graphics_Device Fl_Quartz_Device;
-#if defined(__APPLE__) || defined(FL_DOXYGEN)
-/**
- @brief The Mac OS X-specific display graphics class.
- */
-class Fl_Quartz_Display : public Fl_Display {
+#elif defined(WIN32)
+// The MSWindows-specific graphics class.
+class Fl_Graphics_Device : public Fl_Device {
+protected:
+ Fl_Graphics_Device() { type_ = device_type; };
public:
- Fl_Quartz_Display() { type_ = quartz_display; };
+ 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);
};
-#endif
-#if defined(WIN32) || defined(FL_DOXYGEN)
+typedef Fl_Graphics_Device Fl_GDI_Device;
+
+#else
/**
- @brief The MSWindows-specific display graphics class.
+ @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).
*/
-class Fl_GDI_Display : public Fl_Display {
+class Fl_Graphics_Device : public Fl_Device {
+protected:
+ Fl_Graphics_Device() { type_ = device_type; };
public:
- Fl_GDI_Display() { type_ = gdi_display; };
+ 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);
};
+typedef Fl_Graphics_Device Fl_Xlib_Device;
#endif
-#if !( defined(__APPLE__) || defined(WIN32)) || defined(FL_DOXYGEN)
+
/**
- @brief The X11-specific display graphics class.
- */
-class Fl_Xlib_Display : public Fl_Display {
+ @brief The platform's display.
+*/
+class Fl_Display_Device : public Fl_Graphics_Device {
public:
- Fl_Xlib_Display() { type_ = xlib_display; };
+ static const char *device_type;
+ Fl_Display_Device() { type_ = device_type; };
};
-#endif
+
#endif // Fl_Device_H
diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H
index ff10b1ef6..2cb77978c 100644
--- a/FL/Fl_Image.H
+++ b/FL/Fl_Image.H
@@ -188,8 +188,7 @@ 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_Device;
- void generic_device_draw(int X, int Y, int W, int H, int cx=0, int cy=0);
+ friend class Fl_Graphics_Device;
public:
const uchar *array;
diff --git a/FL/Fl_PSfile_Device.H b/FL/Fl_PSfile_Device.H
index a0fdba70d..3e1b1598e 100644
--- a/FL/Fl_PSfile_Device.H
+++ b/FL/Fl_PSfile_Device.H
@@ -33,229 +33,238 @@
#define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */
/**
- \brief Sends all graphics to a local PostScript file; same API as Fl_Printer class.
+ \brief Sends all graphics to PostScript.
*
- 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.
+ 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_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};
+FL_EXPORT class Fl_PS_Device : public Fl_Device {
+public:
+ static const char *Fl_PS_Device::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};
#ifndef FL_DOXYGEN
- 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);
-
+protected:
+ enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
+
+typedef struct page_format {
+ int width;
+ int height;
+ const char *name;
+} page_format;
+
+class Clip {
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);
+ 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 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);
+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);
#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 8cab445a5..446af15f6 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_Device;
+ friend class Fl_Graphics_Device;
void copy_data();
void delete_data();
void set_data(const char * const *p);
@@ -67,7 +67,6 @@ 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 8aba8dc81..409385dfb 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_Abstract_Printer {
+class Fl_Printer : public Fl_Graphics_Device , public Fl_Abstract_Printer {
private:
#ifdef __APPLE__
float scale_x;
@@ -126,14 +126,15 @@ public:
class Fl_Printer : public Fl_PSfile_Device {
public:
-
- Fl_Printer(void) {};
+ Fl_Printer(void) { gc = NULL; bg_r_ = bg_g_ = bg_b_ = 0; };
~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 0490dcc68..4560ad7df 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::display_device()->set_current();
+ Fl_Device *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();
- this->set_current();
+ current->set_current();
for ( int i = 0, offset = 0; i < count; i++, offset += slice) {
width = slice;
if (offset + width > w) width = w - offset;
@@ -179,18 +179,6 @@ 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 13d5bcaee..18d26cc6a 100644
--- a/src/Fl_Bitmap.cxx
+++ b/src/Fl_Bitmap.cxx
@@ -37,6 +37,7 @@
#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__)
@@ -251,49 +252,66 @@ 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);
}
-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;
- }
-
+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)
+{
// account for current clip region (faster on Irix):
- int X,Y,W,H; fl_clip_box(XP,YP,WP,HP,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;
+ 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;
+ if (cy+H > h) H = h-cy;
+ if (H <= 0) return 1;
+ return 0;
+}
-#if defined(USE_X11)
- if (!id_) id_ = fl_create_bitmask(w(), h(), array);
+#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();
+ }
+}
- 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)
- if (!id_) id_ = fl_create_bitmap(w(), h(), array);
-
+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);
+
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_Device::gdi_printer) {
+ if (fl_device->type() == Fl_Printer::device_type) {
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 (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);
@@ -309,37 +327,48 @@ void Fl_Bitmap::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int
fl_color(save_c); // back to bitmap's color
tempdc = CreateCompatibleDC(fl_gc);
save = SaveDC(tempdc);
- SelectObject(tempdc, (HGDIOBJ)id_);
+ SelectObject(tempdc, (HGDIOBJ)bm->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, w(), h(), RGB(r, g, b) );
+ fl_TransparentBlt(fl_gc, X,Y,W,H, tempdc, cx, cy, bm->w(), bm->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)id_);
+ SelectObject(tempdc, (HGDIOBJ)bm->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);
-#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();
+}
+
+#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;
}
-#else
-# error unsupported platform
-#endif
+ 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);
+
+ 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);
}
+#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 9c76d3f6f..ceead089f 100644
--- a/src/Fl_Device.cxx
+++ b/src/Fl_Device.cxx
@@ -29,32 +29,10 @@
#include <FL/Fl_Device.H>
#include <FL/Fl_Image.H>
-/** \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);
-}
+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_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 89f838844..70462a2ab 100644
--- a/src/Fl_Double_Window.cxx
+++ b/src/Fl_Double_Window.cxx
@@ -28,6 +28,7 @@
#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>
@@ -148,8 +149,9 @@ 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
- 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
+ // 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)
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 f89374095..8a4648881 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_ = gdi_printer;
+ type_ = device_type;
}
Fl_Printer::~Fl_Printer(void) {
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index bf39f6b09..360789523 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,8 +542,146 @@ void Fl_RGB_Image::generic_device_draw(int XP, int YP, int WP, int HP, int cx, i
#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 347c40644..e79ff8a3b 100644
--- a/src/Fl_PS_Printer.cxx
+++ b/src/Fl_PS_Printer.cxx
@@ -32,25 +32,34 @@
#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_PSfile_Device::Fl_PSfile_Device(void)
+Fl_PS_Device::Fl_PS_Device(void)
{
close_cmd_ = 0;
//lang_level_ = 3;
lang_level_ = 2;
mask = 0;
ps_filename_ = NULL;
- type_ = postscript_device;
+ type_ = device_type;
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.
*
@@ -107,7 +116,7 @@ Fl_PSfile_Device::~Fl_PSfile_Device() {
#include "print_panel.cxx"
#endif
-const Fl_PSfile_Device::page_format Fl_PSfile_Device::page_formats[NO_PAGE_FORMATS] = { // order of enum Page_Format
+const Fl_PS_Device::page_format Fl_PS_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
@@ -459,7 +468,7 @@ static const char * prolog_3 = // prolog relevant only if lang_level >2
// end prolog
-int Fl_PSfile_Device::start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout)
+int Fl_PS_Device::start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout)
//returns 0 iff OK
{
int w, h, x;
@@ -517,13 +526,13 @@ int Fl_PSfile_Device::start_postscript (int pagecount, enum Page_Format format,
return 0;
}
-void Fl_PSfile_Device::recover(){
+void Fl_PS_Device::recover(){
color(cr_,cg_,cb_);
line_style(linestyle_,linewidth_,linedash_);
font(font_,size_);
}
-void Fl_PSfile_Device::reset(){
+void Fl_PS_Device::reset(){
gap_=1;
clip_=0;
cr_=cg_=cb_=0;
@@ -542,7 +551,7 @@ void Fl_PSfile_Device::reset(){
}
-void Fl_PSfile_Device::page_policy(int p){
+void Fl_PS_Device::page_policy(int p){
page_policy_ = p;
if(lang_level_>=2)
fprintf(output,"<< /Policies << /Pagesize %i >> >> setpagedevice\n", p);
@@ -552,7 +561,7 @@ void Fl_PSfile_Device::page_policy(int p){
-void Fl_PSfile_Device::page(double pw, double ph, int media) {
+void Fl_PS_Device::page(double pw, double ph, int media) {
if (nPages){
fprintf(output, "CR\nGR\nGR\nGR\nSP\nrestore\n");
@@ -601,20 +610,20 @@ void Fl_PSfile_Device::page(double pw, double ph, int media) {
fprintf(output, "GS\nCS\n");
};
-void Fl_PSfile_Device::page(int format){
+void Fl_PS_Device::page(int format){
if(format & LANDSCAPE){
- ph_=Fl_PSfile_Device::page_formats[format & 0xFF].width;
- pw_=Fl_PSfile_Device::page_formats[format & 0xFF].height;
+ ph_=Fl_PS_Device::page_formats[format & 0xFF].width;
+ pw_=Fl_PS_Device::page_formats[format & 0xFF].height;
}else{
- pw_=Fl_PSfile_Device::page_formats[format & 0xFF].width;
- ph_=Fl_PSfile_Device::page_formats[format & 0xFF].height;
+ pw_=Fl_PS_Device::page_formats[format & 0xFF].width;
+ ph_=Fl_PS_Device::page_formats[format & 0xFF].height;
}
page(pw_,ph_,format & 0xFF00);//,orientation only;
};
-void Fl_PSfile_Device::rect(int x, int y, int w, int h) {
+void Fl_PS_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);
@@ -629,17 +638,17 @@ void Fl_PSfile_Device::rect(int x, int y, int w, int h) {
fprintf(output, "GR\n");
}
-void Fl_PSfile_Device::rectf(int x, int y, int w, int h) {
+void Fl_PS_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_PSfile_Device::line(int x1, int y1, int x2, int y2) {
+void Fl_PS_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_PSfile_Device::line(int x0, int y0, int x1, int y1, int x2, int y2) {
+void Fl_PS_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);
@@ -649,7 +658,7 @@ void Fl_PSfile_Device::line(int x0, int y0, int x1, int y1, int x2, int y2) {
fprintf(output, "GR\n");
}
-void Fl_PSfile_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, int x3){
fprintf(output, "GS\n");
fprintf(output,"BP\n");
fprintf(output, "%i %i MT\n", x , y );
@@ -661,7 +670,7 @@ void Fl_PSfile_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){
+void Fl_PS_Device::xyline(int x, int y, int x1, int y2){
fprintf(output, "GS\n");
fprintf(output,"BP\n");
@@ -672,7 +681,7 @@ void Fl_PSfile_Device::xyline(int x, int y, int x1, int y2){
fprintf(output, "GR\n");
};
-void Fl_PSfile_Device::xyline(int x, int y, int x1){
+void Fl_PS_Device::xyline(int x, int y, int x1){
fprintf(output, "GS\n");
fprintf(output,"BP\n");
fprintf(output, "%i %i MT\n", x , y);
@@ -682,7 +691,7 @@ void Fl_PSfile_Device::xyline(int x, int y, int x1){
fprintf(output, "GR\n");
};
-void Fl_PSfile_Device::yxline(int x, int y, int y1, int x2, int y3){
+void Fl_PS_Device::yxline(int x, int y, int y1, int x2, int y3){
fprintf(output, "GS\n");
fprintf(output,"BP\n");
@@ -694,7 +703,7 @@ void Fl_PSfile_Device::yxline(int x, int y, int y1, int x2, int y3){
fprintf(output, "GR\n");
};
-void Fl_PSfile_Device::yxline(int x, int y, int y1, int x2){
+void Fl_PS_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);
@@ -704,7 +713,7 @@ void Fl_PSfile_Device::yxline(int x, int y, int y1, int x2){
fprintf(output, "GR\n");
};
-void Fl_PSfile_Device::yxline(int x, int y, int y1){
+void Fl_PS_Device::yxline(int x, int y, int y1){
fprintf(output, "GS\n");
fprintf(output,"BP\n");
fprintf(output, "%i %i MT\n", x , y);
@@ -713,7 +722,7 @@ void Fl_PSfile_Device::yxline(int x, int y, int y1){
fprintf(output, "GR\n");
};
-void Fl_PSfile_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
+void Fl_PS_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);
@@ -723,7 +732,7 @@ void Fl_PSfile_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
fprintf(output, "GR\n");
}
-void Fl_PSfile_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
+void Fl_PS_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);
@@ -734,7 +743,7 @@ void Fl_PSfile_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2, int
fprintf(output, "GR\n");
}
-void Fl_PSfile_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
+void Fl_PS_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);
@@ -744,7 +753,7 @@ void Fl_PSfile_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
fprintf(output, "GR\n");
}
-void Fl_PSfile_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
+void Fl_PS_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 );
@@ -756,7 +765,7 @@ void Fl_PSfile_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2, i
fprintf(output, "GR\n");
}
-void Fl_PSfile_Device::point(int x, int y){
+void Fl_PS_Device::point(int x, int y){
rectf(x,y,1,1);
}
@@ -779,7 +788,7 @@ static double dashes_cap[5][7]={
};
-void Fl_PSfile_Device::line_style(int style, int width, char* dashes){
+void Fl_PS_Device::line_style(int style, int width, char* dashes){
//line_styled_=1;
linewidth_=width;
@@ -857,16 +866,16 @@ static const char *_fontNames[] = {
"ZapfDingbats"
};
-void Fl_PSfile_Device::font(int f, int s) {
+void Fl_PS_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);
- Fl_Device::display_device()->font(f,s); // Use display fonts for font measurement
+ display_device()->font(f,s); // Use display fonts for font measurement
font_ = f; size_ = s;
};
-void Fl_PSfile_Device::color(Fl_Color c) {
+void Fl_PS_Device::color(Fl_Color c) {
//colored_=1;
color_=c;
Fl::get_color(c, cr_, cg_, cb_);
@@ -883,7 +892,7 @@ void Fl_PSfile_Device::color(Fl_Color c) {
}
}
-void Fl_PSfile_Device::color(unsigned char r, unsigned char g, unsigned char b) {
+void Fl_PS_Device::color(unsigned char r, unsigned char g, unsigned char b) {
//colored_=1;
cr_=r;cg_=g;cb_=b;
if (r==g && g==b) {
@@ -898,14 +907,14 @@ void Fl_PSfile_Device::color(unsigned char r, unsigned char g, unsigned char b)
}
}
-void Fl_PSfile_Device::draw(int angle, const char *str, int n, int x, int y)
+void Fl_PS_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_PSfile_Device::transformed_draw(const char* str, int n, double x, double y){
+void Fl_PS_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;
@@ -930,18 +939,18 @@ void Fl_PSfile_Device::transformed_draw(const char* str, int n, double x, double
struct matrix {double a, b, c, d, x, y;};
extern matrix * fl_matrix;
-void Fl_PSfile_Device::concat(){
+void Fl_PS_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_PSfile_Device::reconcat(){
+void Fl_PS_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_PSfile_Device::begin_points(){
+void Fl_PS_Device::begin_points(){
fprintf(output, "GS\n");
concat();
@@ -950,7 +959,7 @@ void Fl_PSfile_Device::begin_points(){
shape_=POINTS;
};
-void Fl_PSfile_Device::begin_line(){
+void Fl_PS_Device::begin_line(){
fprintf(output, "GS\n");
concat();
fprintf(output, "BP\n");
@@ -958,7 +967,7 @@ void Fl_PSfile_Device::begin_line(){
shape_=LINE;
};
-void Fl_PSfile_Device::begin_loop(){
+void Fl_PS_Device::begin_loop(){
fprintf(output, "GS\n");
concat();
fprintf(output, "BP\n");
@@ -966,7 +975,7 @@ void Fl_PSfile_Device::begin_loop(){
shape_=LOOP;
};
-void Fl_PSfile_Device::begin_polygon(){
+void Fl_PS_Device::begin_polygon(){
fprintf(output, "GS\n");
concat();
fprintf(output, "BP\n");
@@ -974,7 +983,7 @@ void Fl_PSfile_Device::begin_polygon(){
shape_=POLYGON;
};
-void Fl_PSfile_Device::vertex(double x, double y){
+void Fl_PS_Device::vertex(double x, double y){
if(shape_==POINTS){
fprintf(output,"%g %g MT\n", x , y);
gap_=1;
@@ -987,7 +996,7 @@ void Fl_PSfile_Device::vertex(double x, double y){
fprintf(output, "%g %g LT\n", x , y);
};
-void Fl_PSfile_Device::curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3){
+void Fl_PS_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);
@@ -999,7 +1008,7 @@ void Fl_PSfile_Device::curve(double x, double y, double x1, double y1, double x2
};
-void Fl_PSfile_Device::circle(double x, double y, double r){
+void Fl_PS_Device::circle(double x, double y, double r){
if(shape_==NONE){
fprintf(output, "GS\n");
concat();
@@ -1014,7 +1023,7 @@ void Fl_PSfile_Device::circle(double x, double y, double r){
};
-void Fl_PSfile_Device::arc(double x, double y, double r, double start, double a){
+void Fl_PS_Device::arc(double x, double y, double r, double start, double a){
if(shape_==NONE) return;
gap_=0;
if(start>a)
@@ -1024,7 +1033,7 @@ void Fl_PSfile_Device::arc(double x, double y, double r, double start, double a)
};
-void Fl_PSfile_Device::arc(int x, int y, int w, int h, double a1, double a2) {
+void Fl_PS_Device::arc(int x, int y, int w, int h, double a1, double a2) {
fprintf(output, "GS\n");
//fprintf(output, "BP\n");
begin_line();
@@ -1043,7 +1052,7 @@ void Fl_PSfile_Device::arc(int x, int y, int w, int h, double a1, double a2) {
fprintf(output, "GR\n");
}
-void Fl_PSfile_Device::pie(int x, int y, int w, int h, double a1, double a2) {
+void Fl_PS_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);
@@ -1055,7 +1064,7 @@ void Fl_PSfile_Device::pie(int x, int y, int w, int h, double a1, double a2) {
fprintf(output, "GR\n");
}
-void Fl_PSfile_Device::end_points(){
+void Fl_PS_Device::end_points(){
gap_=1;
reconcat();
fprintf(output, "ELP\n"); //??
@@ -1063,14 +1072,14 @@ void Fl_PSfile_Device::end_points(){
shape_=NONE;
}
-void Fl_PSfile_Device::end_line(){
+void Fl_PS_Device::end_line(){
gap_=1;
reconcat();
fprintf(output, "ELP\n");
fprintf(output, "GR\n");
shape_=NONE;
}
-void Fl_PSfile_Device::end_loop(){
+void Fl_PS_Device::end_loop(){
gap_=1;
reconcat();
fprintf(output, "ECP\n");
@@ -1078,7 +1087,7 @@ void Fl_PSfile_Device::end_loop(){
shape_=NONE;
}
-void Fl_PSfile_Device::end_polygon(){
+void Fl_PS_Device::end_polygon(){
gap_=1;
reconcat();
@@ -1087,7 +1096,7 @@ void Fl_PSfile_Device::end_polygon(){
shape_=NONE;
}
-void Fl_PSfile_Device::transformed_vertex(double x, double y){
+void Fl_PS_Device::transformed_vertex(double x, double y){
reconcat();
if(gap_){
fprintf(output, "%g %g MT\n", x , y);
@@ -1099,7 +1108,7 @@ void Fl_PSfile_Device::transformed_vertex(double x, double y){
///////////////////////////// Clipping /////////////////////////////////////////////
-void Fl_PSfile_Device::push_clip(int x, int y, int w, int h) {
+void Fl_PS_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_;
@@ -1111,7 +1120,7 @@ void Fl_PSfile_Device::push_clip(int x, int y, int w, int h) {
}
-void Fl_PSfile_Device::push_no_clip() {
+void Fl_PS_Device::push_no_clip() {
Clip * c = new Clip();
c->prev=clip_;
clip_=c;
@@ -1121,7 +1130,7 @@ void Fl_PSfile_Device::push_no_clip() {
recover();
}
-void Fl_PSfile_Device::pop_clip() {
+void Fl_PS_Device::pop_clip() {
if(!clip_)return;
Clip * c=clip_;
clip_=clip_->prev;
@@ -1134,7 +1143,7 @@ void Fl_PSfile_Device::pop_clip() {
recover();
}
-int Fl_PSfile_Device::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H){
+int Fl_PS_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;
@@ -1170,7 +1179,7 @@ int Fl_PSfile_Device::clip_box(int x, int y, int w, int h, int &X, int &Y, int &
return ret;
};
-int Fl_PSfile_Device::not_clipped(int x, int y, int w, int h){
+int Fl_PS_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;
@@ -1342,7 +1351,7 @@ int Fl_Printer::start_job(int pages, int *firstpage, int *lastpage) {
return 1;
}
- return Fl_PSfile_Device::start_postscript(pages, format, layout); // start printing
+ return Fl_PS_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 d20132a35..a75b25a75 100644
--- a/src/Fl_Pixmap.cxx
+++ b/src/Fl_Pixmap.cxx
@@ -47,6 +47,7 @@
#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"
@@ -77,121 +78,161 @@ 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);
}
-void Fl_Pixmap::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int 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)
+{
// ignore empty or bad pixmap data:
- if (!data()) {
- draw_empty(XP, YP);
- return;
+ if (!pxm->data()) {
+ return 2;
}
- if (w()<0) measure();
- if (WP==-1) {
- WP = w();
- HP = h();
+ if (WP == -1) {
+ WP = w;
+ HP = h;
}
- if (!w()) {
- draw_empty(XP, YP);
- return;
+ if (!w) {
+ return 2;
}
// account for current clip region (faster on Irix):
- int X,Y,W,H; fl_clip_box(XP,YP,WP,HP,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;
+ 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;
- 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);
+ 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);
fl_end_offscreen();
-#else
- id_ = fl_create_offscreen(w(), h());
- fl_begin_offscreen((Fl_Offscreen)id_);
+ }
+ 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_);
uchar *bitmap = 0;
fl_mask_bitmap = &bitmap;
- fl_draw_pixmap(data(), 0, 0, FL_BLACK);
+ fl_draw_pixmap(pxm->data(), 0, 0, FL_BLACK);
fl_mask_bitmap = 0;
if (bitmap) {
- mask_ = fl_create_bitmask(w(), h(), bitmap);
+ pxm->mask_ = fl_create_bitmask(pxm->w(), pxm->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);
}
- 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) {
+ if (fl_device->type() == Fl_Printer::device_type) {
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(w(), h());
+ Fl_Offscreen tmp_id = fl_create_offscreen(pxm->w(), pxm->h());
fl_begin_offscreen(tmp_id);
uchar *bitmap = 0;
fl_mask_bitmap = &bitmap;
// draw pixmap to offscreen
- fl_draw_pixmap(data(), 0, 0);
+ fl_draw_pixmap(pxm->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, w(), h(), win_pixmap_bg_color );
+ 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);
fl_delete_offscreen(tmp_id);
}
else {
- fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id_, cx, cy);
+ fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
}
}
- else if (mask_) {
+ else if (pxm->mask_) {
HDC new_gc = CreateCompatibleDC(fl_gc);
int save = SaveDC(new_gc);
- SelectObject(new_gc, (void*)mask_);
+ SelectObject(new_gc, (void*)pxm->mask_);
BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND);
- SelectObject(new_gc, (void*)id_);
+ SelectObject(new_gc, (void*)pxm->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)id_, cx, cy);
+ fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
}
-#elif defined(__APPLE_QUARTZ__)
- fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id_, cx, cy);
-#else
-# error unsupported platform
-#endif
}
+#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;
+ }
+ 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();
+ }
+}
+
+#endif
+
/**
The destructor free all memory and server resources that are used by
the pixmap.
diff --git a/src/Fl_Printer.cxx b/src/Fl_Printer.cxx
index d6e8425b3..6072c8515 100644
--- a/src/Fl_Printer.cxx
+++ b/src/Fl_Printer.cxx
@@ -58,6 +58,20 @@ 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 874686d3a..3d1fc4877 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_ = quartz_printer;
+ type_ = device_type;
}
Fl_Printer::~Fl_Printer(void) {}
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 6a9654f75..2efbe55cc 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_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
+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
// 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,8 +2121,7 @@ void Fl_X::make(Fl_Window* w)
winstyle = NSBorderlessWindowMask;
}
} else if (w->modal()) {
- winstyle &= ~NSMiniaturizableWindowMask;
- // winstyle &= ~(NSResizableWindowMask | NSMiniaturizableWindowMask);
+ winstyle &= ~(NSResizableWindowMask | NSMiniaturizableWindowMask);
// winlevel = NSModalPanelWindowLevel;
}
else if (w->non_modal()) {
@@ -2999,6 +2998,7 @@ 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_Device::quartz_printer) return CGRectMake(x, y, w-1.5 , h-1.5 );
+ if ( Fl_Device::current()->type() == Fl_Printer::device_type ) 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 f26d639db..bcc07715c 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_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
+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
// 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() < 256) return CreateRectRgn(x,y,x+w,y+h);
+ if (Fl_Device::current()->type() == Fl_Display_Device::device_type) 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 1c81503f8..f80c11096 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_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
+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
////////////////////////////////////////////////////////////////
// interface to poll/select call:
@@ -136,9 +136,7 @@ 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) {
@@ -152,8 +150,8 @@ void Fl::remove_fd(int n, int events) {
if (!e) continue; // if no events left, delete this fd
fd[i].events = e;
}
- if (fd[i].fd > maxfd) maxfd = fd[i].fd;
# endif
+ if (fd[i].fd > maxfd) maxfd = fd[i].fd;
// move it down in the array if necessary:
if (j<i) {
fd[j] = fd[i];
@@ -1588,13 +1586,6 @@ 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 403dfd9fe..fd7ee64ea 100644
--- a/src/fl_draw_image_win32.cxx
+++ b/src/fl_draw_image_win32.cxx
@@ -46,6 +46,7 @@
#include <config.h>
#include <FL/Fl.H>
+#include <FL/Fl_Printer.H>
#include <FL/fl_draw.H>
#include <FL/x.H>
@@ -254,7 +255,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
}
}
}
- if(Fl_Device::current()->type() == Fl_Device::gdi_printer) {
+ if(Fl_Device::current()->type() == Fl_Printer::device_type) {
// 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 fd0e3fdbf..23521a678 100644
--- a/src/fl_font_win32.cxx
+++ b/src/fl_font_win32.cxx
@@ -24,6 +24,9 @@
//
// http://www.fltk.org/str.php
//
+
+#include <FL/Fl_Printer.H>
+
static int fl_angle_ = 0;
#ifndef FL_DOXYGEN
@@ -247,7 +250,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_Device::gdi_printer) { on_printer_extents_update(x,y,w,h); }
+ if (Fl_Device::current()->type() == Fl_Printer::device_type) { 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 e93f159ec..1dbea0a91 100644
--- a/src/fl_line_style.cxx
+++ b/src/fl_line_style.cxx
@@ -33,8 +33,10 @@
#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;
@@ -117,7 +119,9 @@ 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() == quartz_printer && style == FL_SOLID) fl_quartz_line_cap_ = kCGLineCapSquare;
+ if ( Fl_Device::current()->type() == Fl_Printer::device_type && style == FL_SOLID && dashes == NULL ) {
+ 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 df8cbef9a..c9bdf6c47 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -38,12 +38,13 @@
#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() == quartz_printer)
+#define USINGQUARTZPRINTER (Fl_Device::current()->type() == Fl_Printer::device_type)
#endif
void Fl_Device::rect(int x, int y, int w, int h) {
@@ -510,7 +511,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_Device::gdi_printer) { // in case of print context, convert coords from logical to device
+ if (Fl_Device::current()->type() == Fl_Printer::device_type) { // 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;
@@ -572,7 +573,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_Device::gdi_printer) { // if print context, convert coords from device to logical
+ if(Fl_Device::current()->type() == Fl_Printer::device_type) { // 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 61534238c..65e967755 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_PSfile_Device::alpha_mask(const uchar * data, int w, int h, int D, int LD){
+int Fl_PS_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,18 +182,27 @@ int Fl_PSfile_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};
-// bitwise inversion of a byte
-static inline uchar swap_byte(const uchar b){
- return (swapped[b & 0xF] << 4) | swapped[b >> 4];
- }
+
+// 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;
+}
+
extern uchar **fl_mask_bitmap;
-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) {
+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) {
if(D<3){ //mono
@@ -260,7 +269,7 @@ void Fl_PSfile_Device::draw_scaled_image(const uchar *data, double x, double y,
};
-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) {
+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) {
int level2_mask = 0;
fprintf(output,"save\n");
@@ -348,7 +357,7 @@ void Fl_PSfile_Device::draw_scaled_image(Fl_Draw_Image_Cb call, void *data, doub
delete[] rgbdata;
}
-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) {
+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) {
fprintf(output,"save\n");
@@ -409,7 +418,7 @@ void Fl_PSfile_Device::draw_scaled_image_mono(const uchar *data, double x, doubl
-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) {
+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) {
fprintf(output,"save\n");
int i,j,k;
@@ -458,7 +467,7 @@ void Fl_PSfile_Device::draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data,
////////////////////////////// Image classes //////////////////////
-void Fl_PSfile_Device::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy){
+void Fl_PS_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;
@@ -474,7 +483,7 @@ void Fl_PSfile_Device::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int
fl_mask_bitmap=0;
};
-void Fl_PSfile_Device::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy){
+void Fl_PS_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();
@@ -488,7 +497,7 @@ void Fl_PSfile_Device::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, i
mask=0;
};
-void Fl_PSfile_Device::draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy){
+void Fl_PS_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;