You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.4KB

  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. /** \file Fl_Paged_Device.H
  28. \brief declaration of class Fl_Paged_Device.
  29. */
  30. #ifndef Fl_Paged_Device_H
  31. #define Fl_Paged_Device_H
  32. #include <FL/Fl_Device.H>
  33. #include <FL/Fl_Window.H>
  34. /** \brief Number of elements in enum Page_Format */
  35. #define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */
  36. /**
  37. \brief Represents page-structured drawing surfaces.
  38. *
  39. This class has no public constructor: don't instantiate it; use Fl_Printer
  40. or Fl_PostScript_File_Device instead.
  41. */
  42. class FL_EXPORT Fl_Paged_Device : public Fl_Surface_Device {
  43. public:
  44. /**
  45. \brief Possible page formats.
  46. All paper formats with pre-defined width and height.
  47. */
  48. enum Page_Format {
  49. A0 = 0, /**< A0 format */
  50. A1,
  51. A2,
  52. A3,
  53. A4, /**< A4 format */
  54. A5,
  55. A6,
  56. A7,
  57. A8,
  58. A9,
  59. B0,
  60. B1,
  61. B2,
  62. B3,
  63. B4,
  64. B5,
  65. B6,
  66. B7,
  67. B8,
  68. B9,
  69. B10,
  70. C5E,
  71. DLE,
  72. EXECUTIVE,
  73. FOLIO,
  74. LEDGER,
  75. LEGAL,
  76. LETTER, /**< Letter format */
  77. TABLOID,
  78. ENVELOPE,
  79. MEDIA = 0x1000
  80. };
  81. /**
  82. \brief Possible page layouts.
  83. */
  84. enum Page_Layout {
  85. PORTRAIT = 0, /**< Portrait orientation */
  86. LANDSCAPE = 0x100, /**< Landscape orientation */
  87. REVERSED = 0x200, /**< Reversed orientation */
  88. ORIENTATION = 0x300 /**< orientation */
  89. };
  90. /** \brief width, height and name of a page format
  91. */
  92. typedef struct {
  93. /** \brief width in points */
  94. int width;
  95. /** \brief height in points */
  96. int height;
  97. /** \brief format name */
  98. const char *name;
  99. } page_format;
  100. /** \brief width, height and name of all elements of the enum \ref Page_Format.
  101. */
  102. static const page_format page_formats[NO_PAGE_FORMATS];
  103. private:
  104. void traverse(Fl_Widget *widget); // finds subwindows of widget and prints them
  105. protected:
  106. /** \brief horizontal offset to the origin of graphics coordinates */
  107. int x_offset;
  108. /** \brief vertical offset to the origin of graphics coordinates */
  109. int y_offset;
  110. /** \brief The constructor */
  111. Fl_Paged_Device() : Fl_Surface_Device(NULL) {};
  112. /** \brief The destructor */
  113. virtual ~Fl_Paged_Device() {};
  114. public:
  115. static const char *class_id;
  116. const char *class_name() {return class_id;};
  117. virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
  118. virtual int start_page(void);
  119. virtual int printable_rect(int *w, int *h);
  120. virtual void margins(int *left, int *top, int *right, int *bottom);
  121. virtual void origin(int x, int y);
  122. virtual void origin(int *x, int *y);
  123. virtual void scale(float scale_x, float scale_y = 0.);
  124. virtual void rotate(float angle);
  125. virtual void translate(int x, int y);
  126. virtual void untranslate(void);
  127. virtual void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0);
  128. /** Prints a window with its title bar and frame if any.
  129. \p x_offset and \p y_offset are optional coordinates of where to position the window top left.
  130. Equivalent to print_widget() if \p win is a subwindow or has no border.
  131. Use Fl_Window::decorated_w() and Fl_Window::decorated_h() to get the size of the
  132. printed window.
  133. */
  134. void print_window(Fl_Window *win, int x_offset = 0, int y_offset = 0);
  135. virtual void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x = 0, int delta_y = 0);
  136. virtual int end_page (void);
  137. virtual void end_job (void);
  138. };
  139. #endif // Fl_Paged_Device_H
  140. //
  141. // End of "$Id: Fl_Paged_Device.H 8699 2011-05-20 16:39:06Z manolo $"
  142. //