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

FXDCPrint.h
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,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXDCPRINT_H
22 #define FXDCPRINT_H
23 
24 #ifndef FXDC_H
25 #include "FXDC.h"
26 #endif
27 
29 
30 namespace FX {
31 
32 class FXApp;
33 class FXDrawable;
34 class FXImage;
35 class FXBitmap;
36 class FXIcon;
37 class FXFont;
38 
39 
41 enum FXPrintFlags {
42  PRINT_DEST_PAPER = 0,
43  PRINT_DEST_FILE = 1,
44  PRINT_PAGES_ALL = 0,
45  PRINT_PAGES_EVEN = 2,
46  PRINT_PAGES_ODD = 4,
47  PRINT_PAGES_RANGE = 8,
48  PRINT_COLLATE_NORMAL = 0,
49  PRINT_COLLATE_REVERSED = 16,
50  PRINT_PORTRAIT = 0,
51  PRINT_LANDSCAPE = 32,
52  PRINT_BLACKANDWHITE = 0,
53  PRINT_COLOR = 64,
54  PRINT_NOBOUNDS = 128
55  };
56 
57 
59 enum FXMediaSize {
60  MEDIA_CUSTOM = 0,
61  MEDIA_USLETTER = 1,
62  MEDIA_LEGAL = 2,
63  MEDIA_A4 = 3,
64  MEDIA_ENVELOPE = 4
65  };
66 
67 
69 struct FXPSBounds {
70  FXdouble xmin;
71  FXdouble xmax;
72  FXdouble ymin;
73  FXdouble ymax;
74  };
75 
76 
78 struct FXAPI FXPrinter {
79  FXString name;
80  FXuint firstpage;
81  FXuint lastpage;
82  FXuint currentpage;
83  FXuint frompage;
84  FXuint topage;
85  FXuint mediasize;
86  FXdouble mediawidth;
87  FXdouble mediaheight;
88  FXdouble leftmargin;
89  FXdouble rightmargin;
90  FXdouble topmargin;
91  FXdouble bottommargin;
92  FXuint numcopies;
93  FXuint flags;
94  };
95 
96 
98 class FXAPI FXDCPrint : public FXDC {
99 protected:
100  void *psout; // File Stream for PS output
101  FXFont *font;
102  FXuint flags;
103  FXint Xr,Yr;
104  FXdouble mediawidth; // Media width
105  FXdouble mediaheight; // Media height
106  FXPSBounds mediabb; // Media bounding box
107  FXPSBounds docbb; // Document bounding box
108  FXPSBounds pagebb; // Page bounding box
109  FXint pagecount; // Number of pages printed
110  FXint nchars; // Number of characters on a line
111  FXint pxmin; // min X coord in content
112  FXint pymin; // min Y coord in content
113  FXint pxmax; // max X coord in content
114  FXint pymax; // max Y coord in content
115 protected:
116  void bbox(FXdouble x,FXdouble y);
117  void tfm(FXdouble& xo,FXdouble& yo,FXdouble xi,FXdouble yi);
118 private:
119  FXDCPrint();
120  FXDCPrint(const FXDCPrint&);
121  FXDCPrint &operator=(const FXDCPrint&);
122 public:
123 
125  FXDCPrint(FXApp* a);
126 
128  FXbool beginPrint(FXPrinter& job);
129 
131  FXbool endPrint();
132 
134  FXbool beginPage(FXuint page=1);
135 
137  FXbool endPage();
138 
139  FXbool setContentRange(FXint pxmin,FXint pymin,FXint pxmax,FXint pymax);
140 
142  virtual void drawPoint(FXint x,FXint y);
143  virtual void drawPoints(const FXPoint* points,FXuint npoints);
144  virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
145 
147  virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
148  virtual void drawLines(const FXPoint* points,FXuint npoints);
149  virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
150  virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
151 
153  virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
154  virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
155 
157  virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
158 
160  virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
161  virtual void drawArcs(const FXArc* arcs,FXuint narcs);
162 
164  virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h);
165 
167  virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
168  virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
169 
171  virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
172 
174  virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
175  virtual void fillChords(const FXArc* chords,FXuint nchords);
176 
178  virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
179  virtual void fillArcs(const FXArc* arcs,FXuint narcs);
180 
182  virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h);
183 
185  virtual void fillPolygon(const FXPoint* points,FXuint npoints);
186  virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
187  virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
188 
190  virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
191  virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
192  virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
193 
195  virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
196 
198  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
199 
201  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh);
202 
204  virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
205 
207  virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
208 
210  virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
211  virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
212  virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
213 
215  virtual void drawText(FXint x,FXint y,const FXString& string);
216  virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
217 
219  virtual void drawImageText(FXint x,FXint y,const FXString& string);
220  virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
221 
223  virtual void setForeground(FXColor clr);
224  virtual void setBackground(FXColor clr);
225 
227  virtual void setDashes(FXuint dashoffset,const FXuchar *dashlist,FXuint n);
228 
230  virtual void setLineWidth(FXuint linewidth=0);
231 
233  virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
234 
236  virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
237 
239  virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
240 
242  virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
243 
245  virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
246 
248  virtual void setFunction(FXFunction func=BLT_SRC);
249 
251  virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0);
252 
254  virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0);
255 
257  virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0);
258 
260  virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
261 
263  virtual void setClipRectangle(const FXRectangle& rectangle);
264 
266  virtual void clearClipRectangle();
267 
269  virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0);
270 
272  virtual void clearClipMask();
273 
275  virtual void setFont(FXFont *fnt);
276 
278  virtual void clipChildren(FXbool yes);
279 
281  void outhex(FXuint hex);
282  void outf(const char* format,...);
283 
285  virtual ~FXDCPrint();
286  };
287 
288 }
289 
290 #endif
FXdouble rightmargin
Left margin.
Definition: FXDCPrint.h:89
FXuint frompage
Current page to print.
Definition: FXDCPrint.h:83
A Bitmap is a rectangular array of pixels.
Definition: FXBitmap.h:55
Rectangle.
Definition: FXRectangle.h:32
FXdouble mediawidth
Media size index.
Definition: FXDCPrint.h:86
FXuint lastpage
First page that can be printed.
Definition: FXDCPrint.h:81
Postscript Printer Device Context.
Definition: FXDCPrint.h:98
The Application object is the central point of a FOX user-interface.
Definition: FXApp.h:134
Describes printer.
Definition: FXDCPrint.h:78
Arc.
Definition: FXDC.h:129
Line segment.
Definition: FXDC.h:123
FXuint topage
On output, this is the first page to print.
Definition: FXDCPrint.h:84
Abstract Device Context.
Definition: FXDC.h:153
Definition: FX4Splitter.h:28
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
FXuint currentpage
Last page that can be printed.
Definition: FXDCPrint.h:82
FXdouble topmargin
Right margin.
Definition: FXDCPrint.h:90
FXuint flags
Number of copies.
Definition: FXDCPrint.h:93
FXuint firstpage
Printer name.
Definition: FXDCPrint.h:80
FXdouble leftmargin
Height of paper in points.
Definition: FXDCPrint.h:88
FXdouble mediaheight
Width of paper in points [1/72 of an inch].
Definition: FXDCPrint.h:87
Point.
Definition: FXPoint.h:32
FXuint mediasize
On output, last page to print.
Definition: FXDCPrint.h:85
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
FXdouble bottommargin
Top margin.
Definition: FXDCPrint.h:91
FXuint numcopies
Bottom margin.
Definition: FXDCPrint.h:92
Font class.
Definition: FXFont.h:137
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42
Bounding box.
Definition: FXDCPrint.h:69
Drawable is an abstract base class for any surface that can be drawn upon, such as a FXWindow...
Definition: FXDrawable.h:38

Copyright © 1997-2022 Jeroen van der Zijp