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,2005 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.27 2005/01/16 16:06:06 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 { 73 FXdouble xmin; 74 FXdouble xmax; 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 image 205 virtual void drawImage(const FXImage* image,FXint dx,FXint dy); 206 207 /// Draw bitmap 208 virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy); 209 210 /// Draw icon 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 215 /// Draw string 216 virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length); 217 virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length); 218 219 /// Set foreground/background drawing color 220 virtual void setForeground(FXColor clr); 221 virtual void setBackground(FXColor clr); 222 223 /// Set dash pattern 224 virtual void setDashes(FXuint dashoffset,const FXchar *dashlist,FXuint n); 225 226 /// Set line width 227 virtual void setLineWidth(FXuint linewidth=0); 228 229 /// Set line cap style 230 virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT); 231 232 /// Set line join style 233 virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER); 234 235 /// Set line style 236 virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID); 237 238 /// Set fill style 239 virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID); 240 241 /// Set fill rule 242 virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD); 243 244 /// Set blit function 245 virtual void setFunction(FXFunction func=BLT_SRC); 246 247 /// Set the tile 248 virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0); 249 250 /// Set the stipple pattern 251 virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0); 252 253 /// Set the stipple pattern 254 virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0); 255 256 /// Set clip rectangle 257 virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h); 258 259 /// Set clip rectangle 260 virtual void setClipRectangle(const FXRectangle& rectangle); 261 262 /// Clear clipping 263 virtual void clearClipRectangle(); 264 265 /// Set clip mask 266 virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0); 267 268 /// Clear clip mask 269 virtual void clearClipMask(); 270 271 /// Set font to draw text with 272 virtual void setFont(FXFont *fnt); 273 274 /// Clip drawing by child windows 275 virtual void clipChildren(FXbool yes); 276 277 /// Temporarily public; do not rely on this!! 278 void outhex(FXuint hex); 279 void outf(const char* format,...); 280 281 /// Cleanup 282 virtual ~FXDCPrint(); 283 }; 284 285 } 286 287 #endif 288