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

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,2004 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (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 GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXDCPrint.h,v 1.23 2004/02/08 17:17:33 fox Exp $                         *
00023 ********************************************************************************/
00024 #ifndef FXDCPRINT_H
00025 #define FXDCPRINT_H
00026 
00027 #ifndef FXDC_H
00028 #include "FXDC.h"
00029 #endif
00030 
00031 //////////////////////////////  UNDER DEVELOPMENT  //////////////////////////////
00032 
00033 namespace FX {
00034 
00035 class FXApp;
00036 class FXDrawable;
00037 class FXImage;
00038 class FXBitmap;
00039 class FXIcon;
00040 class FXFont;
00041 
00042 
00043 /// Printer flags
00044 enum FXPrintFlags {
00045   PRINT_DEST_PAPER        = 0,    /// Send print to paper
00046   PRINT_DEST_FILE         = 1,    /// Send print to file
00047   PRINT_PAGES_ALL         = 0,    /// Print all pages
00048   PRINT_PAGES_EVEN        = 2,    /// Print even pages only
00049   PRINT_PAGES_ODD         = 4,    /// Print odd pages only
00050   PRINT_PAGES_RANGE       = 8,    /// Print range of pages
00051   PRINT_COLLATE_NORMAL    = 0,    /// Normal collate order
00052   PRINT_COLLATE_REVERSED  = 16,   /// Reversed collate order
00053   PRINT_PORTRAIT          = 0,    /// Portrait orientation
00054   PRINT_LANDSCAPE         = 32,   /// Landscape orientation
00055   PRINT_BLACKANDWHITE     = 0,    /// Black and white output
00056   PRINT_COLOR             = 64,   /// Color output
00057   PRINT_NOBOUNDS          = 128   /// Must determine bounding box
00058   };
00059 
00060 
00061 /// Printer media size
00062 enum FXMediaSize {
00063   MEDIA_CUSTOM            = 0,    /// Custom paper size
00064   MEDIA_USLETTER          = 1,    /// US Letter size
00065   MEDIA_LEGAL             = 2,    /// US Legal size
00066   MEDIA_A4                = 3,    /// A4
00067   MEDIA_ENVELOPE          = 4     /// #10 Envelope
00068   };
00069 
00070 
00071 /// Bounding box
00072 struct FXPSBounds {
00073   FXdouble  xmin;
00074   FXdouble  xmax;
00075   FXdouble  ymin;
00076   FXdouble  ymax;
00077   };
00078 
00079 
00080 /// Describes printer
00081 struct FXAPI FXPrinter {
00082   FXString name;                          /// Printer name
00083   FXuint   firstpage;                     /// First page that can be printed
00084   FXuint   lastpage;                      /// Last page that can be printed
00085   FXuint   currentpage;                   /// Current page to print
00086   FXuint   frompage;                      /// On output, this is the first page to print
00087   FXuint   topage;                        /// On output, last page to print
00088   FXuint   mediasize;                     /// Media size index
00089   FXdouble mediawidth;                    /// Width of paper in points [1/72 of an inch]
00090   FXdouble mediaheight;                   /// Height of paper in points
00091   FXdouble leftmargin;                    /// Left margin
00092   FXdouble rightmargin;                   /// Right margin
00093   FXdouble topmargin;                     /// Top margin
00094   FXdouble bottommargin;                  /// Bottom margin
00095   FXuint   numcopies;                     /// Number of copies
00096   FXuint   flags;                         /// Flags
00097   };
00098 
00099 
00100 /// Postscript Printer Device Context
00101 class FXAPI FXDCPrint : public FXDC {
00102   friend class FXGLViewer; // This is TEMPORARY!!!
00103 protected:
00104   void      *psout;                   // File Stream for PS output
00105   FXFont    *font;
00106   FXuint     flags;
00107   FXint      Xr,Yr;
00108   FXdouble   mediawidth;              // Media width
00109   FXdouble   mediaheight;             // Media height
00110   FXPSBounds mediabb;                 // Media bounding box
00111   FXPSBounds docbb;                   // Document bounding box
00112   FXPSBounds pagebb;                  // Page bounding box
00113   FXint      pagecount;               // Number of pages printed
00114   FXint      nchars;                  // Number of characters on a line
00115   FXint      pxmin;                   // min X coord in content
00116   FXint      pymin;                   // min Y coord in content
00117   FXint      pxmax;                   // max X coord in content
00118   FXint      pymax;                   // max Y coord in content
00119 protected:
00120   void outhex(FXuint hex);
00121   void outf(const char* format,...);
00122   void bbox(FXfloat x,FXfloat y);
00123   void tfm(FXfloat& xo,FXfloat& yo,FXfloat xi,FXfloat yi);
00124 private:
00125   FXDCPrint();
00126   FXDCPrint(const FXDCPrint&);
00127   FXDCPrint &operator=(const FXDCPrint&);
00128 public:
00129 
00130   /// Construct
00131   FXDCPrint(FXApp* a);
00132 
00133   /// Generate print job prolog
00134   FXbool beginPrint(FXPrinter& job);
00135 
00136   /// Generate print job epilog
00137   FXbool endPrint();
00138 
00139   /// Generate begin of page
00140   FXbool beginPage(FXuint page=1);
00141 
00142   /// Generate end of page
00143   FXbool endPage();
00144 
00145   FXbool setContentRange(FXint pxmin, FXint pymin, FXint pxmax, FXint pymax);
00146 
00147   /// Draw points
00148   virtual void drawPoint(FXint x,FXint y);
00149   virtual void drawPoints(const FXPoint* points,FXuint npoints);
00150   virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
00151 
00152   /// Draw lines
00153   virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
00154   virtual void drawLines(const FXPoint* points,FXuint npoints);
00155   virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
00156   virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
00157 
00158   /// Draw rectangles
00159   virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
00160   virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00161 
00162   /// Draw arcs
00163   virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00164   virtual void drawArcs(const FXArc* arcs,FXuint narcs);
00165 
00166   /// Filled rectangles
00167   virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
00168   virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00169 
00170   /// Fill chord
00171   virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00172   virtual void fillChords(const FXArc* chords,FXuint nchords);
00173 
00174   /// Draw arcs
00175   virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00176   virtual void fillArcs(const FXArc* arcs,FXuint narcs);
00177 
00178   /// Filled polygon
00179   virtual void fillPolygon(const FXPoint* points,FXuint npoints);
00180   virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
00181   virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
00182 
00183   /// Filled polygon with relative points
00184   virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
00185   virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
00186   virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
00187 
00188   /// Draw hashed box
00189   virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
00190 
00191   /// Draw area from source
00192   virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
00193 
00194   /// Draw image
00195   virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
00196 
00197   /// Draw bitmap
00198   virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
00199 
00200   /// Draw icon
00201   virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
00202   virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
00203   virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
00204 
00205   /// Draw string
00206   virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
00207   virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
00208 
00209   /// Set foreground/background drawing color
00210   virtual void setForeground(FXColor clr);
00211   virtual void setBackground(FXColor clr);
00212 
00213   /// Set dash pattern
00214   virtual void setDashes(FXuint dashoffset,const FXchar *dashlist,FXuint n);
00215 
00216   /// Set line width
00217   virtual void setLineWidth(FXuint linewidth=0);
00218 
00219   /// Set line cap style
00220   virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
00221 
00222   /// Set line join style
00223   virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
00224 
00225   /// Set line style
00226   virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
00227 
00228   /// Set fill style
00229   virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
00230 
00231   /// Set fill rule
00232   virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
00233 
00234   /// Set blit function
00235   virtual void setFunction(FXFunction func=BLT_SRC);
00236 
00237   /// Set the tile
00238   virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0);
00239 
00240   /// Set the stipple pattern
00241   virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0);
00242 
00243   /// Set the stipple pattern
00244   virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0);
00245 
00246   /// Set clip rectangle
00247   virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
00248 
00249   /// Set clip rectangle
00250   virtual void setClipRectangle(const FXRectangle& rectangle);
00251 
00252   /// Clear clipping
00253   virtual void clearClipRectangle();
00254 
00255   /// Set clip mask
00256   virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0);
00257 
00258   /// Clear clip mask
00259   virtual void clearClipMask();
00260 
00261   /// Set font to draw text with
00262   virtual void setFont(FXFont *fnt);
00263 
00264   /// Clip drawing by child windows
00265   virtual void clipChildren(FXbool yes);
00266 
00267   /// Cleanup
00268   virtual ~FXDCPrint();
00269   };
00270 
00271 }
00272 
00273 #endif

Copyright © 1997-2004 Jeroen van der Zijp