FXDC.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *               D e v i c e   C o n t e x t   B a s e   C l a s s               *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,2006 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: FXDC.h,v 1.37 2006/01/22 17:58:00 fox Exp $                              *
00023 ********************************************************************************/
00024 #ifndef FXDC_H
00025 #define FXDC_H
00026 
00027 namespace FX {
00028 
00030 enum FXFunction {
00031   BLT_CLR,                        
00032   BLT_SRC_AND_DST,                
00033   BLT_SRC_AND_NOT_DST,            
00034   BLT_SRC,                        
00035   BLT_NOT_SRC_AND_DST,            
00036   BLT_DST,                        
00037   BLT_SRC_XOR_DST,                
00038   BLT_SRC_OR_DST,                 
00039   BLT_NOT_SRC_AND_NOT_DST,        
00040   BLT_NOT_SRC_XOR_DST,            
00041   BLT_NOT_DST,                    
00042   BLT_SRC_OR_NOT_DST,             
00043   BLT_NOT_SRC,                    
00044   BLT_NOT_SRC_OR_DST,             
00045   BLT_NOT_SRC_OR_NOT_DST,         
00046   BLT_SET                         
00047   };
00048 
00049 
00051 enum FXLineStyle {
00052   LINE_SOLID,                     
00053   LINE_ONOFF_DASH,                
00054   LINE_DOUBLE_DASH                
00055   };
00056 
00057 
00059 enum FXCapStyle {
00060   CAP_NOT_LAST,                   
00061   CAP_BUTT,                       
00062   CAP_ROUND,                      
00063   CAP_PROJECTING                  
00064   };
00065 
00066 
00068 enum FXJoinStyle {
00069   JOIN_MITER,                     
00070   JOIN_ROUND,                     
00071   JOIN_BEVEL                      
00072   };
00073 
00074 
00076 enum FXFillStyle {
00077   FILL_SOLID,                     
00078   FILL_TILED,                     
00079   FILL_STIPPLED,                  
00080   FILL_OPAQUESTIPPLED             
00081   };
00082 
00083 
00085 enum FXFillRule {
00086   RULE_EVEN_ODD,                  
00087   RULE_WINDING                    
00088   };
00089 
00090 
00092 enum FXStipplePattern {
00093   STIPPLE_0         = 0,
00094   STIPPLE_NONE      = 0,
00095   STIPPLE_BLACK     = 0,            
00096   STIPPLE_1         = 1,
00097   STIPPLE_2         = 2,
00098   STIPPLE_3         = 3,
00099   STIPPLE_4         = 4,
00100   STIPPLE_5         = 5,
00101   STIPPLE_6         = 6,
00102   STIPPLE_7         = 7,
00103   STIPPLE_8         = 8,
00104   STIPPLE_GRAY      = 8,            
00105   STIPPLE_9         = 9,
00106   STIPPLE_10        = 10,
00107   STIPPLE_11        = 11,
00108   STIPPLE_12        = 12,
00109   STIPPLE_13        = 13,
00110   STIPPLE_14        = 14,
00111   STIPPLE_15        = 15,
00112   STIPPLE_16        = 16,
00113   STIPPLE_WHITE     = 16,           
00114   STIPPLE_HORZ      = 17,           
00115   STIPPLE_VERT      = 18,           
00116   STIPPLE_CROSS     = 19,           
00117   STIPPLE_DIAG      = 20,           
00118   STIPPLE_REVDIAG   = 21,           
00119   STIPPLE_CROSSDIAG = 22            
00120   };
00121 
00122 
00124 struct FXSegment {
00125   FXshort x1,y1,x2,y2;
00126   };
00127 
00128 
00130 struct FXArc {
00131   FXshort x,y,w,h,a,b;
00132   };
00133 
00134 
00135 class FXApp;
00136 class FXImage;
00137 class FXBitmap;
00138 class FXIcon;
00139 class FXFont;
00140 class FXDrawable;
00141 class FXRegion;
00142 
00143 
00154 class FXAPI FXDC {
00155   friend class FXFont;
00156 private:
00157   FXApp           *app;         // Application
00158 protected:
00159   void            *ctx;         // Context handle
00160   FXFont          *font;        // Drawing font
00161   FXStipplePattern pattern;     // Stipple pattern
00162   FXBitmap        *stipple;     // Stipple bitmap
00163   FXImage         *tile;        // Tile image
00164   FXBitmap        *mask;        // Mask bitmap
00165   FXRectangle      clip;        // Clip rectangle
00166   FXColor          fg;          // Foreground color
00167   FXColor          bg;          // Background color
00168   FXuint           width;       // Line width
00169   FXCapStyle       cap;         // Line cap style
00170   FXJoinStyle      join;        // Line join style
00171   FXLineStyle      style;       // Line style
00172   FXFillStyle      fill;        // Fill style
00173   FXFillRule       rule;        // Fill rule
00174   FXFunction       rop;         // RasterOp
00175   FXchar           dashpat[32]; // Line dash pattern data
00176   FXuint           dashlen;     // Line dash pattern length
00177   FXuint           dashoff;     // Line dash pattern offset
00178   FXint            tx;          // Tile dx
00179   FXint            ty;          // Tile dy
00180   FXint            cx;          // Clip x
00181   FXint            cy;          // Clip y
00182 private:
00183   FXDC();
00184   FXDC(const FXDC&);
00185   FXDC &operator=(const FXDC&);
00186 public:
00187 
00189   FXDC(FXApp* a);
00190 
00192   FXApp* getApp() const { return app; }
00193 
00195   void* context() const { return ctx; }
00196 
00198   virtual FXColor readPixel(FXint x,FXint y);
00199 
00201   virtual void drawPoint(FXint x,FXint y);
00202   virtual void drawPoints(const FXPoint* points,FXuint npoints);
00203   virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
00204 
00206   virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
00207   virtual void drawLines(const FXPoint* points,FXuint npoints);
00208   virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
00209   virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
00210 
00212   virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
00213   virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00214 
00216   virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
00217 
00226   virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00227   virtual void drawArcs(const FXArc* arcs,FXuint narcs);
00228 
00230   virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h);
00231 
00233   virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
00234   virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00235 
00237   virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
00238 
00240   virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00241   virtual void fillChords(const FXArc* chords,FXuint nchords);
00242 
00244   virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00245   virtual void fillArcs(const FXArc* arcs,FXuint narcs);
00246 
00248   virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h);
00249 
00251   virtual void fillPolygon(const FXPoint* points,FXuint npoints);
00252   virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
00253   virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
00254 
00256   virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
00257   virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
00258   virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
00259 
00261   virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
00262 
00264   virtual void drawFocusRectangle(FXint x,FXint y,FXint w,FXint h);
00265 
00267   virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
00268 
00270   virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh);
00271 
00273   virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
00274 
00276   virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
00277 
00279   virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
00280   virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
00281   virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
00282 
00284   virtual void drawText(FXint x,FXint y,const FXString& string);
00285   virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
00286 
00288   virtual void drawImageText(FXint x,FXint y,const FXString& string);
00289   virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
00290 
00292   virtual void setForeground(FXColor clr);
00293 
00295   FXColor getForeground() const { return fg; }
00296 
00298   virtual void setBackground(FXColor clr);
00299 
00301   FXColor getBackground() const { return bg; }
00302 
00310   virtual void setDashes(FXuint dashoffset,const FXchar *dashpattern,FXuint dashlength);
00311 
00313   const FXchar* getDashPattern() const { return dashpat; }
00314 
00316   FXuint getDashOffset() const { return dashoff; }
00317 
00319   FXuint getDashLength() const { return dashlen; }
00320 
00322   virtual void setLineWidth(FXuint linewidth=0);
00323 
00325   FXuint getLineWidth() const { return width; }
00326 
00328   virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
00329 
00331   FXCapStyle getLineCap() const { return cap; }
00332 
00334   virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
00335 
00337   FXJoinStyle getLineJoin() const { return join; }
00338 
00340   virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
00341 
00343   FXLineStyle getLineStyle() const { return style; }
00344 
00346   virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
00347 
00349   FXFillStyle getFillStyle() const { return fill; }
00350 
00352   virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
00353 
00355   FXFillRule getFillRule() const { return rule; }
00356 
00358   virtual void setFunction(FXFunction func=BLT_SRC);
00359 
00361   FXFunction getFunction() const { return rop; }
00362 
00364   virtual void setTile(FXImage* image,FXint dx=0,FXint dy=0);
00365 
00367   FXImage *getTile() const { return tile; }
00368 
00370   virtual void setStipple(FXBitmap *bitmap,FXint dx=0,FXint dy=0);
00371 
00373   FXBitmap *getStippleBitmap() const { return stipple; }
00374 
00376   virtual void setStipple(FXStipplePattern pat,FXint dx=0,FXint dy=0);
00377 
00379   FXStipplePattern getStipplePattern() const { return pattern; }
00380 
00382   virtual void setClipRegion(const FXRegion& region);
00383 
00385   virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
00386 
00388   virtual void setClipRectangle(const FXRectangle& rectangle);
00389 
00391   const FXRectangle& getClipRectangle() const { return clip; }
00392 
00394   FXint getClipX() const { return clip.x; }
00395 
00397   FXint getClipY() const { return clip.y; }
00398 
00400   FXint getClipWidth() const { return clip.w; }
00401 
00403   FXint getClipHeight() const { return clip.h; }
00404 
00406   virtual void clearClipRectangle();
00407 
00409   virtual void setClipMask(FXBitmap* bitmap,FXint dx=0,FXint dy=0);
00410 
00412   virtual void clearClipMask();
00413 
00415   virtual void setFont(FXFont *fnt);
00416 
00418   FXFont* getFont() const { return font; }
00419 
00421   virtual void clipChildren(FXbool yes);
00422 
00424   virtual ~FXDC();
00425   };
00426 
00427 }
00428 
00429 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:20 2009 for TnFOX by doxygen v1.4.7