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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXDCPrint.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *           D e v i c e   C o n t e x t   F o r   P r i n t i n g               *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXDCPRINT_H
00022 #define FXDCPRINT_H
00023 
00024 #ifndef FXDC_H
00025 #include "FXDC.h"
00026 #endif
00027 
00029 
00030 namespace FX {
00031 
00032 class FXApp;
00033 class FXDrawable;
00034 class FXImage;
00035 class FXBitmap;
00036 class FXIcon;
00037 class FXFont;
00038 
00039 
00041 enum FXPrintFlags {
00042   PRINT_DEST_PAPER        = 0,    
00043   PRINT_DEST_FILE         = 1,    
00044   PRINT_PAGES_ALL         = 0,    
00045   PRINT_PAGES_EVEN        = 2,    
00046   PRINT_PAGES_ODD         = 4,    
00047   PRINT_PAGES_RANGE       = 8,    
00048   PRINT_COLLATE_NORMAL    = 0,    
00049   PRINT_COLLATE_REVERSED  = 16,   
00050   PRINT_PORTRAIT          = 0,    
00051   PRINT_LANDSCAPE         = 32,   
00052   PRINT_BLACKANDWHITE     = 0,    
00053   PRINT_COLOR             = 64,   
00054   PRINT_NOBOUNDS          = 128   
00055   };
00056 
00057 
00059 enum FXMediaSize {
00060   MEDIA_CUSTOM            = 0,    
00061   MEDIA_USLETTER          = 1,    
00062   MEDIA_LEGAL             = 2,    
00063   MEDIA_A4                = 3,    
00064   MEDIA_ENVELOPE          = 4     
00065   };
00066 
00067 
00069 struct FXPSBounds {
00070   FXdouble  xmin;
00071   FXdouble  xmax;
00072   FXdouble  ymin;
00073   FXdouble  ymax;
00074   };
00075 
00076 
00078 struct FXAPI FXPrinter {
00079   FXString name;                          
00080   FXuint   firstpage;                     
00081   FXuint   lastpage;                      
00082   FXuint   currentpage;                   
00083   FXuint   frompage;                      
00084   FXuint   topage;                        
00085   FXuint   mediasize;                     
00086   FXdouble mediawidth;                    
00087   FXdouble mediaheight;                   
00088   FXdouble leftmargin;                    
00089   FXdouble rightmargin;                   
00090   FXdouble topmargin;                     
00091   FXdouble bottommargin;                  
00092   FXuint   numcopies;                     
00093   FXuint   flags;                         
00094   };
00095 
00096 
00098 class FXAPI FXDCPrint : public FXDC {
00099 //  friend class FXGLViewer; // This is TEMPORARY!!!
00100 protected:
00101   void      *psout;                   // File Stream for PS output
00102   FXFont    *font;
00103   FXuint     flags;
00104   FXint      Xr,Yr;
00105   FXdouble   mediawidth;              // Media width
00106   FXdouble   mediaheight;             // Media height
00107   FXPSBounds mediabb;                 // Media bounding box
00108   FXPSBounds docbb;                   // Document bounding box
00109   FXPSBounds pagebb;                  // Page bounding box
00110   FXint      pagecount;               // Number of pages printed
00111   FXint      nchars;                  // Number of characters on a line
00112   FXint      pxmin;                   // min X coord in content
00113   FXint      pymin;                   // min Y coord in content
00114   FXint      pxmax;                   // max X coord in content
00115   FXint      pymax;                   // max Y coord in content
00116 protected:
00117   void bbox(FXfloat x,FXfloat y);
00118   void tfm(FXfloat& xo,FXfloat& yo,FXfloat xi,FXfloat yi);
00119 private:
00120   FXDCPrint();
00121   FXDCPrint(const FXDCPrint&);
00122   FXDCPrint &operator=(const FXDCPrint&);
00123 public:
00124 
00126   FXDCPrint(FXApp* a);
00127 
00129   FXbool beginPrint(FXPrinter& job);
00130 
00132   FXbool endPrint();
00133 
00135   FXbool beginPage(FXuint page=1);
00136 
00138   FXbool endPage();
00139 
00140   FXbool setContentRange(FXint pxmin,FXint pymin,FXint pxmax,FXint pymax);
00141 
00143   virtual void drawPoint(FXint x,FXint y);
00144   virtual void drawPoints(const FXPoint* points,FXuint npoints);
00145   virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
00146 
00148   virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
00149   virtual void drawLines(const FXPoint* points,FXuint npoints);
00150   virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
00151   virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
00152 
00154   virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
00155   virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00156 
00158   virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
00159 
00161   virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00162   virtual void drawArcs(const FXArc* arcs,FXuint narcs);
00163 
00165   virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h);
00166 
00168   virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
00169   virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00170 
00172   virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
00173 
00175   virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00176   virtual void fillChords(const FXArc* chords,FXuint nchords);
00177 
00179   virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00180   virtual void fillArcs(const FXArc* arcs,FXuint narcs);
00181 
00183   virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h);
00184 
00186   virtual void fillPolygon(const FXPoint* points,FXuint npoints);
00187   virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
00188   virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
00189 
00191   virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
00192   virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
00193   virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
00194 
00196   virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
00197 
00199   virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
00200 
00202   virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh);
00203 
00205   virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
00206 
00208   virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
00209 
00211   virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
00212   virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
00213   virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
00214 
00216   virtual void drawText(FXint x,FXint y,const FXString& string);
00217   virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
00218 
00220   virtual void drawImageText(FXint x,FXint y,const FXString& string);
00221   virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
00222 
00224   virtual void setForeground(FXColor clr);
00225   virtual void setBackground(FXColor clr);
00226 
00228   virtual void setDashes(FXuint dashoffset,const FXchar *dashlist,FXuint n);
00229 
00231   virtual void setLineWidth(FXuint linewidth=0);
00232 
00234   virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
00235 
00237   virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
00238 
00240   virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
00241 
00243   virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
00244 
00246   virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
00247 
00249   virtual void setFunction(FXFunction func=BLT_SRC);
00250 
00252   virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0);
00253 
00255   virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0);
00256 
00258   virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0);
00259 
00261   virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
00262 
00264   virtual void setClipRectangle(const FXRectangle& rectangle);
00265 
00267   virtual void clearClipRectangle();
00268 
00270   virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0);
00271 
00273   virtual void clearClipMask();
00274 
00276   virtual void setFont(FXFont *fnt);
00277 
00279   virtual void clipChildren(FXbool yes);
00280 
00282   void outhex(FXuint hex);
00283   void outf(const char* format,...);
00284 
00286   virtual ~FXDCPrint();
00287   };
00288 
00289 }
00290 
00291 #endif

Copyright © 1997-2011 Jeroen van der Zijp