diff options
| author | Manolo Gouy <Manolo> | 2010-05-27 17:20:18 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2010-05-27 17:20:18 +0000 |
| commit | 26049351e09d75bdf8b35273a76cf65202583fa7 (patch) | |
| tree | 010685555b9f83d071a14262e8ce346c7388f254 /FL/Fl_Printer.H | |
| parent | 0a280ce591046f6834f1233087a72fa6bdd97bad (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/Fl_Printer.H')
| -rw-r--r-- | FL/Fl_Printer.H | 215 |
1 files changed, 136 insertions, 79 deletions
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 |
