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