Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXDCPrint.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * D e v i c e C o n t e x t F o r P r i n t i n g *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 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 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser 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 USA. *
21 *********************************************************************************
22 * $Id: FXDCPrint.h,v 1.30 2006/01/22 17:58:00 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXDCPRINT_H
25 #define FXDCPRINT_H
26 
27 #ifndef FXDC_H
28 #include "FXDC.h"
29 #endif
30 
31 ////////////////////////////// UNDER DEVELOPMENT //////////////////////////////
32 
33 namespace FX {
34 
35 class FXApp;
36 class FXDrawable;
37 class FXImage;
38 class FXBitmap;
39 class FXIcon;
40 class FXFont;
41 
42 
43 /// Printer flags
44 enum FXPrintFlags {
45  PRINT_DEST_PAPER = 0, /// Send print to paper
46  PRINT_DEST_FILE = 1, /// Send print to file
47  PRINT_PAGES_ALL = 0, /// Print all pages
48  PRINT_PAGES_EVEN = 2, /// Print even pages only
49  PRINT_PAGES_ODD = 4, /// Print odd pages only
50  PRINT_PAGES_RANGE = 8, /// Print range of pages
51  PRINT_COLLATE_NORMAL = 0, /// Normal collate order
52  PRINT_COLLATE_REVERSED = 16, /// Reversed collate order
53  PRINT_PORTRAIT = 0, /// Portrait orientation
54  PRINT_LANDSCAPE = 32, /// Landscape orientation
55  PRINT_BLACKANDWHITE = 0, /// Black and white output
56  PRINT_COLOR = 64, /// Color output
57  PRINT_NOBOUNDS = 128 /// Must determine bounding box
58  };
59 
60 
61 /// Printer media size
62 enum FXMediaSize {
63  MEDIA_CUSTOM = 0, /// Custom paper size
64  MEDIA_USLETTER = 1, /// US Letter size
65  MEDIA_LEGAL = 2, /// US Legal size
66  MEDIA_A4 = 3, /// A4
67  MEDIA_ENVELOPE = 4 /// #10 Envelope
68  };
69 
70 
71 /// Bounding box
72 struct FXPSBounds {
75  FXdouble ymin;
76  FXdouble ymax;
77  };
78 
79 
80 /// Describes printer
81 struct FXAPI FXPrinter {
82  FXString name; /// Printer name
83  FXuint firstpage; /// First page that can be printed
84  FXuint lastpage; /// Last page that can be printed
85  FXuint currentpage; /// Current page to print
86  FXuint frompage; /// On output, this is the first page to print
87  FXuint topage; /// On output, last page to print
88  FXuint mediasize; /// Media size index
89  FXdouble mediawidth; /// Width of paper in points [1/72 of an inch]
90  FXdouble mediaheight; /// Height of paper in points
91  FXdouble leftmargin; /// Left margin
92  FXdouble rightmargin; /// Right margin
93  FXdouble topmargin; /// Top margin
94  FXdouble bottommargin; /// Bottom margin
95  FXuint numcopies; /// Number of copies
96  FXuint flags; /// Flags
97  };
98 
99 
100 /// Postscript Printer Device Context
101 class FXAPI FXDCPrint : public FXDC {
102 // friend class FXGLViewer; // This is TEMPORARY!!!
103 protected:
104  void *psout; // File Stream for PS output
105  FXFont *font;
106  FXuint flags;
107  FXint Xr,Yr;
108  FXdouble mediawidth; // Media width
109  FXdouble mediaheight; // Media height
110  FXPSBounds mediabb; // Media bounding box
111  FXPSBounds docbb; // Document bounding box
112  FXPSBounds pagebb; // Page bounding box
113  FXint pagecount; // Number of pages printed
114  FXint nchars; // Number of characters on a line
115  FXint pxmin; // min X coord in content
116  FXint pymin; // min Y coord in content
117  FXint pxmax; // max X coord in content
118  FXint pymax; // max Y coord in content
119 protected:
120  void bbox(FXfloat x,FXfloat y);
121  void tfm(FXfloat& xo,FXfloat& yo,FXfloat xi,FXfloat yi);
122 private:
123  FXDCPrint();
124  FXDCPrint(const FXDCPrint&);
125  FXDCPrint &operator=(const FXDCPrint&);
126 public:
127 
128  /// Construct
129  FXDCPrint(FXApp* a);
130 
131  /// Generate print job prolog
132  FXbool beginPrint(FXPrinter& job);
133 
134  /// Generate print job epilog
135  FXbool endPrint();
136 
137  /// Generate begin of page
138  FXbool beginPage(FXuint page=1);
139 
140  /// Generate end of page
141  FXbool endPage();
142 
143  FXbool setContentRange(FXint pxmin, FXint pymin, FXint pxmax, FXint pymax);
144 
145  /// Draw points
146  virtual void drawPoint(FXint x,FXint y);
147  virtual void drawPoints(const FXPoint* points,FXuint npoints);
148  virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
149 
150  /// Draw lines
151  virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
152  virtual void drawLines(const FXPoint* points,FXuint npoints);
153  virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
154  virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
155 
156  /// Draw rectangles
157  virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
158  virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
159 
160  /// Draw rounded rectangle with ellipse with ew and ellips height eh
161  virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
162 
163  /// Draw arcs
164  virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
165  virtual void drawArcs(const FXArc* arcs,FXuint narcs);
166 
167  /// Draw ellipse
168  virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h);
169 
170  /// Filled rectangles
171  virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
172  virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
173 
174  /// Filled rounded rectangle with ellipse with ew and ellips height eh
175  virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
176 
177  /// Fill chord
178  virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
179  virtual void fillChords(const FXArc* chords,FXuint nchords);
180 
181  /// Draw arcs
182  virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
183  virtual void fillArcs(const FXArc* arcs,FXuint narcs);
184 
185  /// Fill ellipse
186  virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h);
187 
188  /// Filled polygon
189  virtual void fillPolygon(const FXPoint* points,FXuint npoints);
190  virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
191  virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
192 
193  /// Filled polygon with relative points
194  virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
195  virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
196  virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
197 
198  /// Draw hashed box
199  virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
200 
201  /// Draw area from source
202  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
203 
204  /// Draw area stretched area from source
205  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh);
206 
207  /// Draw image
208  virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
209 
210  /// Draw bitmap
211  virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
212 
213  /// Draw icon
214  virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
215  virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
216  virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
217 
218  /// Draw string with base line starting at x, y
219  virtual void drawText(FXint x,FXint y,const FXString& string);
220  virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
221 
222  /// Draw text starting at x, y over filled background
223  virtual void drawImageText(FXint x,FXint y,const FXString& string);
224  virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
225 
226  /// Set foreground/background drawing color
227  virtual void setForeground(FXColor clr);
228  virtual void setBackground(FXColor clr);
229 
230  /// Set dash pattern
231  virtual void setDashes(FXuint dashoffset,const FXchar *dashlist,FXuint n);
232 
233  /// Set line width
234  virtual void setLineWidth(FXuint linewidth=0);
235 
236  /// Set line cap style
237  virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
238 
239  /// Set line join style
240  virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
241 
242  /// Set line style
243  virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
244 
245  /// Set fill style
246  virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
247 
248  /// Set fill rule
249  virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
250 
251  /// Set blit function
252  virtual void setFunction(FXFunction func=BLT_SRC);
253 
254  /// Set the tile
255  virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0);
256 
257  /// Set the stipple pattern
258  virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0);
259 
260  /// Set the stipple pattern
261  virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0);
262 
263  /// Set clip rectangle
264  virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
265 
266  /// Set clip rectangle
267  virtual void setClipRectangle(const FXRectangle& rectangle);
268 
269  /// Clear clipping
270  virtual void clearClipRectangle();
271 
272  /// Set clip mask
273  virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0);
274 
275  /// Clear clip mask
276  virtual void clearClipMask();
277 
278  /// Set font to draw text with
279  virtual void setFont(FXFont *fnt);
280 
281  /// Clip drawing by child windows
282  virtual void clipChildren(FXbool yes);
283 
284  /// Temporarily public; do not rely on this!!
285  void outhex(FXuint hex);
286  void outf(const char* format,...);
287 
288  /// Cleanup
289  virtual ~FXDCPrint();
290  };
291 
292 }
293 
294 #endif
Must determine bounding box.
Definition: FXDCPrint.h:60
Even odd polygon filling.
Definition: FXDC.h:109
Reversed collate order.
Definition: FXDCPrint.h:55
FXPrintFlags
Printer flags.
Definition: FXDCPrint.h:47
A Bitmap is a rectangular array of pixels.
Definition: FXBitmap.h:64
char FXchar
Definition: fxdefs.h:387
Rectangle.
Definition: FXRectangle.h:37
Fill with solid color.
Definition: FXDC.h:96
unsigned int FXuint
Definition: fxdefs.h:396
FXFillRule
Fill Rules.
Definition: FXDC.h:108
FXJoinStyle
Line Join Styles.
Definition: FXDC.h:83
FXdouble ymax
Definition: FXDCPrint.h:84
Postscript Printer Device Context.
Definition: FXDCPrint.h:114
US Legal size.
Definition: FXDCPrint.h:72
Solid lines.
Definition: FXDC.h:59
Print odd pages only.
Definition: FXDCPrint.h:52
#define FXAPI
Definition: fxdefs.h:122
D := S.
Definition: FXDC.h:37
US Letter size.
Definition: FXDCPrint.h:71
FXuchar FXbool
Definition: fxdefs.h:393
FXCapStyle
Line Cap Styles.
Definition: FXDC.h:70
Application Object.
Definition: FXApp.h:158
FXdouble ymin
Definition: FXDCPrint.h:83
FXFillStyle
Fill Styles.
Definition: FXDC.h:95
Send print to paper.
Definition: FXDCPrint.h:48
FXuint FXColor
Definition: fxdefs.h:454
FXString name(const FXString &file)
Return name and extension part of the path name.
Describes printer.
Definition: FXDCPrint.h:89
Black and white output.
Definition: FXDCPrint.h:58
Arc.
Definition: FXDC.h:158
Line segment.
Definition: FXDC.h:152
Print all pages.
Definition: FXDCPrint.h:50
Abstract Device Context.
Definition: FXDC.h:191
FXdouble xmin
Definition: FXDCPrint.h:81
double FXdouble
Definition: fxdefs.h:399
A4.
Definition: FXDCPrint.h:73
FXLineStyle
Line Styles.
Definition: FXDC.h:58
int FXint
Definition: fxdefs.h:397
FXStipplePattern
Stipple/dither patterns.
Definition: FXDC.h:119
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
FXMediaSize
Printer media size.
Definition: FXDCPrint.h:69
Butting line end caps.
Definition: FXDC.h:72
Custom paper size.
Definition: FXDCPrint.h:70
FXdouble xmax
Definition: FXDCPrint.h:82
#10 Envelope
Definition: FXDCPrint.h:74
Print range of pages.
Definition: FXDCPrint.h:53
Point.
Definition: FXPoint.h:35
Print even pages only.
Definition: FXDCPrint.h:51
Mitered or pointy joints.
Definition: FXDC.h:84
Send print to file.
Definition: FXDCPrint.h:49
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
float FXfloat
Definition: fxdefs.h:398
FXFunction
Drawing (BITBLT) functions.
Definition: FXDC.h:33
Normal collate order.
Definition: FXDCPrint.h:54
Font class.
Definition: FXFont.h:142
Portrait orientation.
Definition: FXDCPrint.h:56
Landscape orientation.
Definition: FXDCPrint.h:57
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
Bounding box.
Definition: FXDCPrint.h:80
Drawable is an abstract base class for any surface that can be drawn upon, such as a FXWindow...
Definition: FXDrawable.h:41
Color output.
Definition: FXDCPrint.h:59

Copyright © 1997-2005 Jeroen van der Zijp