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,2017 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 // friend class FXGLViewer; // This is TEMPORARY!!!
100 protected:
101  void *psout; // File Stream for PS output
102  FXFont *font;
103  FXuint flags;
104  FXint Xr,Yr;
105  FXdouble mediawidth; // Media width
106  FXdouble mediaheight; // Media height
107  FXPSBounds mediabb; // Media bounding box
108  FXPSBounds docbb; // Document bounding box
109  FXPSBounds pagebb; // Page bounding box
110  FXint pagecount; // Number of pages printed
111  FXint nchars; // Number of characters on a line
112  FXint pxmin; // min X coord in content
113  FXint pymin; // min Y coord in content
114  FXint pxmax; // max X coord in content
115  FXint pymax; // max Y coord in content
116 protected:
117  void bbox(FXfloat x,FXfloat y);
118  void tfm(FXfloat& xo,FXfloat& yo,FXfloat xi,FXfloat yi);
119 private:
120  FXDCPrint();
121  FXDCPrint(const FXDCPrint&);
122  FXDCPrint &operator=(const FXDCPrint&);
123 public:
124 
126  FXDCPrint(FXApp* a);
127 
129  FXbool beginPrint(FXPrinter& job);
130 
132  FXbool endPrint();
133 
135  FXbool beginPage(FXuint page=1);
136 
138  FXbool endPage();
139 
140  FXbool setContentRange(FXint pxmin,FXint pymin,FXint pxmax,FXint pymax);
141 
143  virtual void drawPoint(FXint x,FXint y);
144  virtual void drawPoints(const FXPoint* points,FXuint npoints);
145  virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
146 
148  virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
149  virtual void drawLines(const FXPoint* points,FXuint npoints);
150  virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
151  virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
152 
154  virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
155  virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
156 
158  virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
159 
161  virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
162  virtual void drawArcs(const FXArc* arcs,FXuint narcs);
163 
165  virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h);
166 
168  virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
169  virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
170 
172  virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
173 
175  virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
176  virtual void fillChords(const FXArc* chords,FXuint nchords);
177 
179  virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
180  virtual void fillArcs(const FXArc* arcs,FXuint narcs);
181 
183  virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h);
184 
186  virtual void fillPolygon(const FXPoint* points,FXuint npoints);
187  virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
188  virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
189 
191  virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
192  virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
193  virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
194 
196  virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
197 
199  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
200 
202  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh);
203 
205  virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
206 
208  virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
209 
211  virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
212  virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
213  virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
214 
216  virtual void drawText(FXint x,FXint y,const FXString& string);
217  virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
218 
220  virtual void drawImageText(FXint x,FXint y,const FXString& string);
221  virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
222 
224  virtual void setForeground(FXColor clr);
225  virtual void setBackground(FXColor clr);
226 
228  virtual void setDashes(FXuint dashoffset,const FXchar *dashlist,FXuint n);
229 
231  virtual void setLineWidth(FXuint linewidth=0);
232 
234  virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
235 
237  virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
238 
240  virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
241 
243  virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
244 
246  virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
247 
249  virtual void setFunction(FXFunction func=BLT_SRC);
250 
252  virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0);
253 
255  virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0);
256 
258  virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0);
259 
261  virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
262 
264  virtual void setClipRectangle(const FXRectangle& rectangle);
265 
267  virtual void clearClipRectangle();
268 
270  virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0);
271 
273  virtual void clearClipMask();
274 
276  virtual void setFont(FXFont *fnt);
277 
279  virtual void clipChildren(FXbool yes);
280 
282  void outhex(FXuint hex);
283  void outf(const char* format,...);
284 
286  virtual ~FXDCPrint();
287  };
288 
289 }
290 
291 #endif

Copyright © 1997-2016 Jeroen van der Zijp