summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-05-27 17:20:18 +0000
committerManolo Gouy <Manolo>2010-05-27 17:20:18 +0000
commit26049351e09d75bdf8b35273a76cf65202583fa7 (patch)
tree010685555b9f83d071a14262e8ce346c7388f254 /FL
parent0a280ce591046f6834f1233087a72fa6bdd97bad (diff)
Better device hierarchy with surfaces and graphics drivers.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7617 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
-rw-r--r--FL/Fl_Bitmap.H7
-rw-r--r--FL/Fl_Device.H205
-rw-r--r--FL/Fl_Image.H7
-rw-r--r--FL/Fl_Paged_Device.H92
-rw-r--r--FL/Fl_Pixmap.H5
-rw-r--r--FL/Fl_PostScript.H293
-rw-r--r--FL/Fl_Printer.H215
7 files changed, 667 insertions, 157 deletions
diff --git a/FL/Fl_Bitmap.H b/FL/Fl_Bitmap.H
index d47a82acf..33f1914a6 100644
--- a/FL/Fl_Bitmap.H
+++ b/FL/Fl_Bitmap.H
@@ -40,8 +40,10 @@ 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_Quartz_Graphics_Driver;
+ friend class Fl_GDI_Graphics_Driver;
+ friend class Fl_Xlib_Graphics_Driver;
+public:
/** pointer to raw bitmap data */
const uchar *array;
@@ -58,7 +60,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..21251f6c6 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_Graphics_Driver, Fl_Surface_Device, Fl_Display_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_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device.
*/
#ifndef Fl_Device_H
@@ -45,14 +45,15 @@
#include <stdio.h>
#endif
-class Fl_Widget;
-class Fl_Device;
-class Fl_Display;
-class Fl_Abstract_Printer;
-/** \brief Points to the device that currently receives all graphics requests */
-FL_EXPORT extern Fl_Device *fl_device;
-/** \brief Points to the platform's display device */
-FL_EXPORT extern Fl_Display *fl_display_device;
+class Fl_Graphics_Driver;
+class Fl_Display_Device;
+class Fl_Surface_Device;
+/** \brief Points to the driver that currently receives all graphics requests */
+extern Fl_Graphics_Driver *fl_device;
+/** \brief Points to the surface that currently receives all graphics requests */
+extern Fl_Surface_Device *fl_surface;
+/** \brief Points to the platform's display */
+extern Fl_Display_Device *fl_display_device;
/**
signature of image generation callback function.
@@ -65,33 +66,56 @@ FL_EXPORT extern Fl_Display *fl_display_device;
typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf);
/**
- \brief A pure virtual class subclassed to send the output of drawing functions to display, printers, or local files.
+ \brief All graphical output devices and all graphics systems.
+ */
+class Fl_Device {
+protected:
+ /** \brief The device type */
+ const char *type_;
+ /** \brief A string that identifies each subclass of Fl_Device.
+ *
+ Function type() applied to a device of this class returns this string.
+ */
+ static const char *device_type;
+public:
+ /**
+ @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 ( instance->type() == Fl_Printer::device_type ) { ... }
+ \endcode
+ */
+ inline const char *type() {return type_;};
+};
+
+/**
+ \brief A virtual class subclassed for each graphics driver FLTK uses.
*
- The protected virtual methods of this class are those that a device should implement to
+ The protected virtual methods of this class are those that a graphics driver should implement to
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
- 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:
+ <br> Alternatively, methods of the Fl_Graphics_Driver class can be called
+ using the global variable Fl_Graphics_Driver * \ref fl_device that points at all time to the single driver
+ (an instance of an Fl_Graphics_Driver 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_Graphics_Driver 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 {
+class Fl_Graphics_Driver : public Fl_Device {
protected:
- /** \brief The device type */
- int type_;
- /** \brief red color for background and/or mixing if device does not support masking or alpha */
+/* ** \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 */
+ ** \brief green color for background and/or mixing if device does not support masking or alpha *
uchar bg_g_;
- /** \brief blue color for background and/or mixing if device does not support masking or alpha */
- uchar bg_b_;
+ ** \brief blue color for background and/or mixing if device does not support masking or alpha *
+ uchar bg_b_; */
friend class Fl_Pixmap;
friend class Fl_Bitmap;
friend class Fl_RGB_Image;
+ friend class Fl_PostScript_Graphics_Driver;
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);
@@ -141,6 +165,8 @@ protected:
friend void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D);
friend FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D);
+ /** \brief The constructor. */
+ Fl_Graphics_Driver() {};
/** \brief see fl_rect(int x, int y, int w, int h). */
virtual void rect(int x, int y, int w, int h);
/** \brief see fl_rectf(int x, int y, int w, int h). */
@@ -239,74 +265,113 @@ 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.
*/
- 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
+ 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.
*/
- 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.
+ 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.
*/
- static Fl_Display *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;
+ virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {};
+
+public:
+ static const char *device_type;
+ /** \brief The destructor */
+ virtual ~Fl_Graphics_Driver() {};
};
#if defined(__APPLE__) || defined(FL_DOXYGEN)
/**
- @brief The Mac OS X-specific display graphics class.
+ \brief The Mac OS X-specific graphics class.
+ *
+ This class is implemented only on the Mac OS X platform.
*/
-class Fl_Quartz_Display : public Fl_Display {
+class Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver {
public:
- Fl_Quartz_Display() { type_ = quartz_display; };
+ Fl_Quartz_Graphics_Driver() { type_ = device_type; };
+ 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)
/**
- @brief The MSWindows-specific display graphics class.
+ \brief The MSWindows-specific graphics class.
+ *
+ This class is implemented only on the MSWindows platform.
*/
-class Fl_GDI_Display : public Fl_Display {
+class Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver {
public:
- Fl_GDI_Display() { type_ = gdi_display; };
+ Fl_GDI_Graphics_Driver() { type_ = device_type; };
+ 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(__APPLE__) || defined(WIN32)) || defined(FL_DOXYGEN)
+#if !(defined(__APPLE__) || defined(WIN32))
/**
- @brief The X11-specific display graphics class.
+ \brief The Xlib-specific graphics class.
+ *
+ This class is implemented only on the Xlib platform.
*/
-class Fl_Xlib_Display : public Fl_Display {
+class Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver {
public:
- Fl_Xlib_Display() { type_ = xlib_display; };
+ Fl_Xlib_Graphics_Driver() { type_ = device_type; };
+ 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
+/**
+ \brief A surface that's susceptible to receive graphical output.
+ */
+class Fl_Surface_Device : public Fl_Device {
+ /** \brief The graphics driver in use by this surface. */
+ Fl_Graphics_Driver *_driver;
+protected:
+ /** \brief Constructor that sets the graphics driver to use for the created surface. */
+ Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver; };
+public:
+ static const char *device_type;
+ virtual void set_current(void);
+ /** \brief Sets the graphics driver of this drawing surface. */
+ inline void driver(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver;};
+ /** \brief Returns the graphics driver of this drawing surface. */
+ inline Fl_Graphics_Driver *driver() {return _driver; };
+ /** \brief the surface that currently receives graphics output */
+ static Fl_Surface_Device *surface() {return fl_surface; };
+ /** \brief The destructor. */
+ virtual ~Fl_Surface_Device() {}
+};
+
+/**
+ \brief A display to which the computer can draw.
+ */
+class Fl_Display_Device : public Fl_Surface_Device {
+public:
+ static const char *device_type;
+ /** \brief A constructor that sets the graphics driver used by the display */
+ Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device( graphics_driver) { type_ = device_type; };
+ /**
+ @brief Returns the platform's display device.
+ */
+ static Fl_Display_Device *display_device() { return fl_display_device; };
+};
+
#endif // Fl_Device_H
//
diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H
index ff10b1ef6..329f3fa44 100644
--- a/FL/Fl_Image.H
+++ b/FL/Fl_Image.H
@@ -188,9 +188,10 @@ 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);
- public:
+ friend class Fl_Quartz_Graphics_Driver;
+ friend class Fl_GDI_Graphics_Driver;
+ friend class Fl_Xlib_Graphics_Driver;
+public:
const uchar *array;
int alloc_array; // Non-zero if array was allocated
diff --git a/FL/Fl_Paged_Device.H b/FL/Fl_Paged_Device.H
new file mode 100644
index 000000000..41d1a5f00
--- /dev/null
+++ b/FL/Fl_Paged_Device.H
@@ -0,0 +1,92 @@
+//
+// "$Id: Fl_Paged_Device.H 7556 2010-04-27 21:33:44Z manolo $"
+//
+// Printing support for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 2010 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+/** \file Fl_Paged_Device.H
+ \brief declaration of class Fl_Paged_Device.
+ */
+
+#ifndef Fl_Paged_Device_H
+#define Fl_Paged_Device_H
+
+#include <FL/Fl_Device.H>
+
+/**
+ \brief Represents page-structured drawing surfaces.
+ *
+ This class has no public constructor: don't instantiate it; use Fl_Printer
+ or Fl_PostScript_File_Device instead.
+ */
+class Fl_Paged_Device : public Fl_Surface_Device {
+private:
+#ifdef __APPLE__
+ struct chain_elt {
+ Fl_Image *image;
+ const uchar *data;
+ struct chain_elt *next;
+ };
+ void add_image(Fl_Image *image, const uchar *data); // adds an image to the page image list
+#endif
+ void traverse(Fl_Widget *widget); // finds subwindows of widget and prints them
+protected:
+ /** \brief horizontal offset to the origin of graphics coordinates */
+ int x_offset;
+ /** \brief vertical offset to the origin of graphics coordinates */
+ int y_offset;
+ /** \brief chained list of Fl_Image's used in this page */
+ struct chain_elt *image_list_;
+#ifdef __APPLE__
+ /** \brief deletes the page image list */
+ void delete_image_list();
+#endif
+ /** \brief The constructor */
+ Fl_Paged_Device() : Fl_Surface_Device(NULL) {type_ = device_type;};
+ /** \brief The destructor */
+ virtual ~Fl_Paged_Device() {};
+public:
+ static const char *device_type;
+ 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);
+ virtual void margins(int *left, int *top, int *right, int *bottom);
+ virtual void origin(int x, int y);
+ void origin(int *x, int *y);
+ virtual void scale(float scale_x, float scale_y);
+ virtual void rotate(float angle);
+ virtual void translate(int x, int y);
+ virtual void untranslate(void);
+ void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0);
+ void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x = 0, int delta_y = 0);
+ virtual int end_page (void);
+ virtual void end_job (void);
+};
+
+#endif // Fl_Paged_Device_H
+
+//
+// End of "$Id: Fl_Paged_Device.H 7556 2010-04-27 21:33:44Z manolo $"
+//
+
diff --git a/FL/Fl_Pixmap.H b/FL/Fl_Pixmap.H
index 8cab445a5..7391e8341 100644
--- a/FL/Fl_Pixmap.H
+++ b/FL/Fl_Pixmap.H
@@ -45,7 +45,9 @@ struct Fl_Menu_Item;
(pixmap) images, including transparency.
*/
class FL_EXPORT Fl_Pixmap : public Fl_Image {
- friend class Fl_Device;
+ friend class Fl_Quartz_Graphics_Driver;
+ friend class Fl_GDI_Graphics_Driver;
+ friend class Fl_Xlib_Graphics_Driver;
void copy_data();
void delete_data();
void set_data(const char * const *p);
@@ -67,7 +69,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_PostScript.H b/FL/Fl_PostScript.H
new file mode 100644
index 000000000..8d16dc1c6
--- /dev/null
+++ b/FL/Fl_PostScript.H
@@ -0,0 +1,293 @@
+//
+// "$Id: Fl_PostScript.H 7556 2010-04-27 21:33:44Z manolo $"
+//
+// Support for graphics output to PostScript file for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 2010 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+/** \file Fl_PostScript.H
+ \brief declaration of classes Fl_PostScript_Graphics_Driver, Fl_PostScript_File_Device.
+ */
+
+
+#ifndef Fl_PostScript_H
+#define Fl_PostScript_H
+
+#include <FL/Fl_Paged_Device.H>
+#include <FL/fl_draw.H>
+
+#define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */
+
+/**
+ \brief PostScript graphical backend.
+ *
+ 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.
+ */
+class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
+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};
+
+#ifndef FL_DOXYGEN
+public:
+ enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
+
+typedef struct page_format {
+ int width;
+ int height;
+ const char *name;
+} page_format;
+
+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 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;
+ 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:
+ 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_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
+ //Fl_PostScript_Graphics_Driver(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
+ Fl_PostScript_Graphics_Driver();
+ ~Fl_PostScript_Graphics_Driver();
+};
+
+/**
+ \brief To send graphical output to a PostScript file.
+ */
+class Fl_PostScript_File_Device : public Fl_Paged_Device {
+#ifdef __APPLE__
+ CGContextRef gc;
+#endif
+protected:
+ Fl_PostScript_Graphics_Driver *driver();
+public:
+ static const char *device_type;
+ Fl_PostScript_File_Device();
+ ~Fl_PostScript_File_Device();
+ int start_job(int pagecount, enum Fl_PostScript_Graphics_Driver::Page_Format format = Fl_PostScript_Graphics_Driver::A4,
+ enum Fl_PostScript_Graphics_Driver::Page_Layout layout = Fl_PostScript_Graphics_Driver::PORTRAIT);
+ int start_job(FILE *ps_output, int pagecount, enum Fl_PostScript_Graphics_Driver::Page_Format format = Fl_PostScript_Graphics_Driver::A4,
+ enum Fl_PostScript_Graphics_Driver::Page_Layout layout = Fl_PostScript_Graphics_Driver::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);
+#ifdef __APPLE__
+ void set_current() { fl_gc = gc; Fl_Paged_Device::set_current(); }
+#endif
+
+ static const char *file_chooser_title;
+};
+
+#endif // Fl_PostScript_H
+
+//
+// End of "$Id: Fl_PostScript.H 7556 2010-04-27 21:33:44Z manolo $"
+//
diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H
index 8aba8dc81..07b7b5ff3 100644
--- a/FL/Fl_Printer.H
+++ b/FL/Fl_Printer.H
@@ -25,55 +25,34 @@
// http://www.fltk.org/str.php
//
/** \file Fl_Printer.H
- \brief declaration of classes Fl_Printer, Fl_Device_Plugin.
+ \brief declaration of classes Fl_System_Printer, Fl_PostScript_Printer, Fl_Printer, Fl_Device_Plugin.
*/
#ifndef Fl_Printer_H
#define Fl_Printer_H
-#include <FL/Fl_Abstract_Printer.H>
+#include <FL/Fl_Paged_Device.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Pixmap.H>
#include <FL/Fl_RGB_Image.H>
#include <FL/Fl_Bitmap.H>
#include <stdio.h>
+#if !(defined(__APPLE__) || defined(WIN32))
+#include <FL/Fl_PostScript.H>
+#endif
#if defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN)
/**
- * @brief Provides an OS-independent interface to printing.
- *
- It allows to use all FLTK drawing, color, text, and clip functions, and to have them operate
- on printed page(s). There are two main, non exclusive, ways to use it.
- <ul><li>Print any widget (standard, custom, Fl_Window, Fl_Gl_Window) as it appears
- on screen, with optional translation and scaling. This is done by calling print_widget()
- or print_window_part().
- <li>Use a series of FLTK graphics commands (e.g., font, text, lines, colors, clip) to
- compose a page appropriately shaped for printing.
- </ul>
- In both cases, begin by start_job(), start_page(), printable_rect() and origin() calls
- and finish by end_page() and end_job() calls.
- <p><b>Platform specifics</b>
- <ul>
- <li>Xlib-based platforms (<i>e.g.</i>, Linux, Unix): this class is implemented as
- a subclass of Fl_PSfile_Device.
- Use the static public attributes of this class to set the print dialog to other languages
- than English. For example, the "Printer:" dialog item Fl_Printer::dialog_printer can be set to French with:
- \code
- Fl_Printer::dialog_printer = "Imprimante:";
- Fl_Printer myprinter;
- myprinter.start_job();
- \endcode
- Use Fl_PSfile_Device::file_chooser_title to customize the title of the file chooser dialog that opens
- when using the "Print To File" option of the print dialog.
- Class Fl_RGB_Image prints but loses its transparency if it has one.
- <li>MSWindows platform: Transparent Fl_RGB_Image 's don't print with exact transparency on most printers.
- Fl_RGB_Image 's don't rotate() well.
- A workaround is to use the print_window_part() call.
- <li>Mac OS X platform: all graphics requests print as on display.
- </ul>
+ \brief Print support under MSWindows and Mac OS X.
+*
+ Use Fl_Printer instead that is cross-platform and has the same API.
+ Fl_Printer is typedef'ed to Fl_System_Printer under MSWindows and Mac OS X.
*/
-class Fl_Printer : public Fl_Abstract_Printer {
+class Fl_System_Printer : public Fl_Paged_Device {
private:
+ /** \brief the printer's graphics context, if there's one, NULL otherwise */
+ void *gc;
+ void set_current();
#ifdef __APPLE__
float scale_x;
float scale_y;
@@ -91,96 +70,174 @@ private:
void absolute_printable_rect(int *x, int *y, int *w, int *h);
#endif
public:
+ static const char *device_type;
/**
@brief The constructor.
*/
- Fl_Printer(void);
+ Fl_System_Printer(void);
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
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);
-#ifdef FL_DOXYGEN
- void origin(int *x, int *y);
-#endif
void scale (float scale_x, float scale_y);
void rotate(float angle);
void translate(int x, int y);
void untranslate(void);
-#ifdef FL_DOXYGEN
- void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0);
- void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x = 0, int delta_y = 0);
-#endif
int end_page (void);
void end_job (void);
/**
@brief The destructor.
*/
- ~Fl_Printer(void);
-
-#else // Xlib (Linux/Unix)
-
-#include <FL/Fl_PSfile_Device.H>
-
-class Fl_Printer : public Fl_PSfile_Device {
-
+ ~Fl_System_Printer(void);
+#ifndef FL_DOXYGEN
public:
+ static const char *dialog_title;
+ static const char *dialog_printer;
+ static const char *dialog_range;
+ static const char *dialog_copies;
+ static const char *dialog_all;
+ static const char *dialog_pages;
+ static const char *dialog_from;
+ static const char *dialog_to;
+ static const char *dialog_properties;
+ static const char *dialog_copyNo;
+ static const char *dialog_print_button;
+ static const char *dialog_cancel_button;
+ static const char *dialog_print_to_file;
+ static const char *property_title;
+ static const char *property_pagesize;
+ static const char *property_mode;
+ static const char *property_use;
+ static const char *property_save;
+ static const char *property_cancel;
+#endif // FL_DOXYGEN
+}; // class Fl_System_Printer
- Fl_Printer(void) {};
- ~Fl_Printer(void) {};
+/** \brief OS-independant class name */
+typedef Fl_System_Printer Fl_Printer;
+#endif
+
+#if !(defined(__APPLE__) || defined(WIN32))
+/**
+ \brief Print support under Unix/Linux.
+ *
+ Use Fl_Printer instead that is cross-platform and has the same API.
+ Fl_Printer is typedef'ed to Fl_PostScript_Printer under Unix/Linux.
+ */
+class Fl_PostScript_Printer : public Fl_PostScript_File_Device {
+private:
+ void set_current();
+public:
+ static const char *device_type;
int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
-#endif // Fl_Printer (platform-dependent)
-
- // Fl_Printer:: common for all platforms
+#ifndef FL_DOXYGEN
+ static const char *dialog_title;
+ static const char *dialog_printer;
+ static const char *dialog_range;
+ static const char *dialog_copies;
+ static const char *dialog_all;
+ static const char *dialog_pages;
+ static const char *dialog_from;
+ static const char *dialog_to;
+ static const char *dialog_properties;
+ static const char *dialog_copyNo;
+ static const char *dialog_print_button;
+ static const char *dialog_cancel_button;
+ static const char *dialog_print_to_file;
+ static const char *property_title;
+ static const char *property_pagesize;
+ static const char *property_mode;
+ static const char *property_use;
+ static const char *property_save;
+ static const char *property_cancel;
+#endif // FL_DOXYGEN
+};
-public: // just to be sure ...
+/** \brief OS-independant class name */
+typedef Fl_PostScript_Printer Fl_Printer;
+#endif
- /** \name These attributes apply to the Xlib platform only.
+/**
+ * @brief OS-independent print support.
+ *
+ Fl_Printer allows to use all FLTK drawing, color, text, and clip functions, and to have them operate
+ on printed page(s). There are two main, non exclusive, ways to use it.
+ <ul><li>Print any widget (standard, custom, Fl_Window, Fl_Gl_Window) as it appears
+ on screen, with optional translation and scaling. This is done by calling print_widget()
+ or print_window_part().
+ <li>Use a series of FLTK graphics commands (e.g., font, text, lines, colors, clip) to
+ compose a page appropriately shaped for printing.
+ </ul>
+ In both cases, begin by start_job(), start_page(), printable_rect() and origin() calls
+ and finish by end_page() and end_job() calls.
+ <p><b>Platform specifics</b>
+ <br>Fl_Printer is typedef'ed to Fl_PostScript_Printer under Unix/Linux
+ and to Fl_System_Printer otherwise. Both classes have the same API.
+ <ul>
+ <li>Unix/Linux platforms:
+ Use the static public attributes of this class to set the print dialog to other languages
+ than English. For example, the "Printer:" dialog item Fl_Printer::dialog_printer can be set to French with:
+ \code
+ Fl_Printer::dialog_printer = "Imprimante:";
+ Fl_Printer myprinter;
+ myprinter.start_job();
+ \endcode
+ Use Fl_PostScript_File_Device::file_chooser_title to customize the title of the file chooser dialog that opens
+ when using the "Print To File" option of the print dialog.
+ Class Fl_RGB_Image prints but loses its transparency if it has one.
+ <li>MSWindows platform: Transparent Fl_RGB_Image 's don't print with exact transparency on most printers.
+ Fl_RGB_Image 's don't rotate() well.
+ A workaround is to use the print_window_part() call.
+ <li>Mac OS X platform: all graphics requests print as on display.
+ </ul>
+ */
+#ifdef FL_DOXYGEN
+// this class is NOT compiled. It's here for Doxygen documentation purpose only
+class Fl_Printer : public Fl_System_Printer, Fl_PostScript_Printer {
+public:
+ static const char *device_type;
+ Fl_Printer(void);
+ int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
+ 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);
+ ~Fl_Printer(void);
+
+ /** \name These attributes are effective under the Xlib platform only.
\{
*/
- /** [this text may be customized at run-time] */
static const char *dialog_title;
- /** [this text may be customized at run-time] */
static const char *dialog_printer;
- /** [this text may be customized at run-time] */
static const char *dialog_range;
- /** [this text may be customized at run-time] */
static const char *dialog_copies;
- /** [this text may be customized at run-time] */
static const char *dialog_all;
- /** [this text may be customized at run-time] */
static const char *dialog_pages;
- /** [this text may be customized at run-time] */
static const char *dialog_from;
- /** [this text may be customized at run-time] */
static const char *dialog_to;
- /** "Properties..." [this text may be customized at run-time] */
static const char *dialog_properties;
- /** [this text may be customized at run-time] */
static const char *dialog_copyNo;
- /** [this text may be customized at run-time] */
static const char *dialog_print_button;
- /** [this text may be customized at run-time] */
static const char *dialog_cancel_button;
- /** [this text may be customized at run-time] */
static const char *dialog_print_to_file;
- /** [this text may be customized at run-time] */
static const char *property_title;
- /** [this text may be customized at run-time] */
static const char *property_pagesize;
- /** [this text may be customized at run-time] */
static const char *property_mode;
- /** [this text may be customized at run-time] */
static const char *property_use;
- /** [this text may be customized at run-time] */
static const char *property_save;
- /** [this text may be customized at run-time] */
static const char *property_cancel;
- /** \} */
-
-}; // class Fl_Printer
+ /** \} */
+};
+#endif
/**
This plugin socket allows the integration of new device drivers for special