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