1 // 2 // "$Id: Fl_Paged_Device.H 8699 2011-05-20 16:39:06Z manolo $" 3 // 4 // Printing support for the Fast Light Tool Kit (FLTK). 5 // 6 // Copyright 2010 by Bill Spitzak and others. 7 // 8 // This library is free software; you can redistribute it and/or 9 // modify it under the terms of the GNU Library General Public 10 // License as published by the Free Software Foundation; either 11 // version 2 of the License, or (at your option) any later version. 12 // 13 // This library is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 // Library General Public License for more details. 17 // 18 // You should have received a copy of the GNU Library General Public 19 // License along with this library; if not, write to the Free Software 20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 21 // USA. 22 // 23 // Please report all bugs and problems on the following page: 24 // 25 // http://www.fltk.org/str.php 26 // 27 28 /** \file Fl_Paged_Device.H 29 \brief declaration of class Fl_Paged_Device. 30 */ 31 32 #ifndef Fl_Paged_Device_H 33 #define Fl_Paged_Device_H 34 35 #include <FL/Fl_Device.H> 36 #include <FL/Fl_Window.H> 37 38 /** \brief Number of elements in enum Page_Format */ 39 #define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */ 40 41 /** 42 \brief Represents page-structured drawing surfaces. 43 * 44 This class has no public constructor: don't instantiate it; use Fl_Printer 45 or Fl_PostScript_File_Device instead. 46 */ 47 class FL_EXPORT Fl_Paged_Device : public Fl_Surface_Device { 48 public: 49 /** 50 \brief Possible page formats. 51 52 All paper formats with pre-defined width and height. 53 */ 54 enum Page_Format { 55 A0 = 0, /**< A0 format */ 56 A1, 57 A2, 58 A3, 59 A4, /**< A4 format */ 60 A5, 61 A6, 62 A7, 63 A8, 64 A9, 65 B0, 66 B1, 67 B2, 68 B3, 69 B4, 70 B5, 71 B6, 72 B7, 73 B8, 74 B9, 75 B10, 76 C5E, 77 DLE, 78 EXECUTIVE, 79 FOLIO, 80 LEDGER, 81 LEGAL, 82 LETTER, /**< Letter format */ 83 TABLOID, 84 ENVELOPE, 85 MEDIA = 0x1000 86 }; 87 /** 88 \brief Possible page layouts. 89 */ 90 enum Page_Layout { 91 PORTRAIT = 0, /**< Portrait orientation */ 92 LANDSCAPE = 0x100, /**< Landscape orientation */ 93 REVERSED = 0x200, /**< Reversed orientation */ 94 ORIENTATION = 0x300 /**< orientation */ 95 }; 96 97 /** \brief width, height and name of a page format 98 */ 99 typedef struct { 100 /** \brief width in points */ 101 int width; 102 /** \brief height in points */ 103 int height; 104 /** \brief format name */ 105 const char *name; 106 } page_format; 107 /** \brief width, height and name of all elements of the enum \ref Page_Format. 108 */ 109 static const page_format page_formats[NO_PAGE_FORMATS]; 110 private: 111 void traverse(Fl_Widget *widget); // finds subwindows of widget and prints them 112 protected: 113 /** \brief horizontal offset to the origin of graphics coordinates */ 114 int x_offset; 115 /** \brief vertical offset to the origin of graphics coordinates */ 116 int y_offset; 117 /** \brief The constructor */ Fl_Paged_Device()118 Fl_Paged_Device() : Fl_Surface_Device(NULL) {}; 119 /** \brief The destructor */ ~Fl_Paged_Device()120 virtual ~Fl_Paged_Device() {}; 121 public: 122 static const char *class_id; class_name()123 const char *class_name() {return class_id;}; 124 virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); 125 virtual int start_page(void); 126 virtual int printable_rect(int *w, int *h); 127 virtual void margins(int *left, int *top, int *right, int *bottom); 128 virtual void origin(int x, int y); 129 virtual void origin(int *x, int *y); 130 virtual void scale(float scale_x, float scale_y = 0.); 131 virtual void rotate(float angle); 132 virtual void translate(int x, int y); 133 virtual void untranslate(void); 134 virtual void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0); 135 /** Prints a window with its title bar and frame if any. 136 137 \p x_offset and \p y_offset are optional coordinates of where to position the window top left. 138 Equivalent to print_widget() if \p win is a subwindow or has no border. 139 Use Fl_Window::decorated_w() and Fl_Window::decorated_h() to get the size of the 140 printed window. 141 */ 142 void print_window(Fl_Window *win, int x_offset = 0, int y_offset = 0); 143 virtual void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x = 0, int delta_y = 0); 144 virtual int end_page (void); 145 virtual void end_job (void); 146 }; 147 148 #endif // Fl_Paged_Device_H 149 150 // 151 // End of "$Id: Fl_Paged_Device.H 8699 2011-05-20 16:39:06Z manolo $" 152 // 153 154