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

FXDCWindow.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *  D e v i c e   C o n t e x t   F o r   W i n d o w s   a n d   I m a g e s    *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,2010 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 FXDCWINDOW_H
00022 #define FXDCWINDOW_H
00023 
00024 #ifndef FXDC_H
00025 #include "FXDC.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00031 class FXApp;
00032 class FXDrawable;
00033 class FXImage;
00034 class FXBitmap;
00035 class FXIcon;
00036 class FXFont;
00037 
00038 
00039 /**
00040 * Window Device Context
00041 *
00042 * The Window Device Context allows drawing into an FXDrawable, such as an
00043 * on-screen window (FXWindow and derivatives) or an off-screen image (FXImage
00044 * and its derivatives).
00045 * Because certain hardware resources are locked down, only one FXDCWindow may be
00046 * locked on a drawable at any one time.
00047 */
00048 class FXAPI FXDCWindow : public FXDC {
00049   friend class FXFont;
00050 protected:
00051   FXDrawable *surface;        // Drawable surface
00052   FXRectangle rect;           // Paint rectangle inside drawable
00053   FXPixel     devfg;          // Device foreground pixel value
00054   FXPixel     devbg;          // Device background pixel value
00055 #ifdef WIN32
00056   FXID        oldpalette;
00057   FXID        oldbrush;
00058   FXID        oldpen;
00059   FXbool      needsNewBrush;
00060   FXbool      needsNewPen;
00061   FXbool      needsPath;
00062   FXbool      needsClipReset;
00063 #else
00064   void       *xftDraw;
00065   FXuint      flags;
00066 #endif
00067 private:
00068 #ifdef WIN32
00069   void updateBrush();
00070   void updatePen();
00071 #endif
00072 private:
00073   FXDCWindow();
00074   FXDCWindow(const FXDCWindow&);
00075   FXDCWindow &operator=(const FXDCWindow&);
00076 public:
00077 
00078   /// Construct for painting in response to expose;
00079   /// This sets the clip rectangle to the exposed rectangle
00080   FXDCWindow(FXDrawable* draw,FXEvent* event);
00081 
00082   /// Construct for normal drawing;
00083   /// This sets clip rectangle to the whole drawable
00084   FXDCWindow(FXDrawable* draw);
00085 
00086   /// Return active drawable
00087   FXDrawable *drawable() const { return surface; }
00088 
00089   /// Begin locks in a drawable surface
00090   void begin(FXDrawable *draw);
00091 
00092   /// End unlock the drawable surface
00093   void end();
00094 
00095   /// Read back pixel
00096   virtual FXColor readPixel(FXint x,FXint y);
00097 
00098   /// Draw points
00099   virtual void drawPoint(FXint x,FXint y);
00100   virtual void drawPoints(const FXPoint* points,FXuint npoints);
00101   virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
00102 
00103   /// Draw lines
00104   virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
00105   virtual void drawLines(const FXPoint* points,FXuint npoints);
00106   virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
00107   virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
00108 
00109   /// Draw rectangles
00110   virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
00111   virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00112 
00113   /// Draw rounded rectangle with ellipse with ew and ellips height eh
00114   virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
00115 
00116   /// Draw arcs
00117   virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00118   virtual void drawArcs(const FXArc* arcs,FXuint narcs);
00119 
00120   /// Draw ellipse
00121   virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h);
00122 
00123   /// Filled rectangles
00124   virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
00125   virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00126 
00127   /// Filled rounded rectangle with ellipse with ew and ellips height eh
00128   virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
00129 
00130   /// Fill chord
00131   virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00132   virtual void fillChords(const FXArc* chords,FXuint nchords);
00133 
00134   /// Draw arcs
00135   virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00136   virtual void fillArcs(const FXArc* arcs,FXuint narcs);
00137 
00138   /// Fill ellipse
00139   virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h);
00140 
00141   /// Filled polygon
00142   virtual void fillPolygon(const FXPoint* points,FXuint npoints);
00143   virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
00144   virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
00145 
00146   /// Filled polygon with relative points
00147   virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
00148   virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
00149   virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
00150 
00151   /// Fill vertical gradient rectangle
00152   virtual void fillVerticalGradient(FXint x,FXint y,FXint w,FXint h,FXColor top,FXColor bottom);
00153 
00154   /// Fill horizontal gradient rectangle
00155   virtual void fillHorizontalGradient(FXint x,FXint y,FXint w,FXint h,FXColor left,FXColor right);
00156 
00157   /// Draw hashed box
00158   virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
00159 
00160   /// Draw focus rectangle
00161   virtual void drawFocusRectangle(FXint x,FXint y,FXint w,FXint h);
00162 
00163   /// Draw area from source
00164   virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
00165 
00166   /// Draw area stretched area from source
00167   virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh);
00168 
00169   /// Draw image
00170   virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
00171 
00172   /// Draw bitmap
00173   virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
00174 
00175   /// Draw icon
00176   virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
00177   virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
00178   virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
00179 
00180   /// Draw string with base line starting at x, y
00181   virtual void drawText(FXint x,FXint y,const FXString& string);
00182   virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
00183 
00184   /// Draw text starting at x, y over filled background
00185   virtual void drawImageText(FXint x,FXint y,const FXString& string);
00186   virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
00187 
00188   /// Set foreground/background drawing color
00189   virtual void setForeground(FXColor clr);
00190   virtual void setBackground(FXColor clr);
00191 
00192   /// Set dash pattern
00193   virtual void setDashes(FXuint dashoffset,const FXchar *dashpattern,FXuint dashlength);
00194 
00195   /// Set line width
00196   virtual void setLineWidth(FXuint linewidth=0);
00197 
00198   /// Set line cap style
00199   virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
00200 
00201   /// Set line join style
00202   virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
00203 
00204   /// Set line style
00205   virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
00206 
00207   /// Set fill style
00208   virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
00209 
00210   /// Set fill rule
00211   virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
00212 
00213   /// Set blit function
00214   virtual void setFunction(FXFunction func=BLT_SRC);
00215 
00216   /// Set the tile
00217   virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0);
00218 
00219   /// Set the stipple pattern
00220   virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0);
00221 
00222   /// Set the stipple pattern
00223   virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0);
00224 
00225   /// Set clip region
00226   virtual void setClipRegion(const FXRegion& region);
00227 
00228   /// Set clip rectangle
00229   virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
00230 
00231   /// Set clip rectangle
00232   virtual void setClipRectangle(const FXRectangle& rectangle);
00233 
00234   /// Clear clipping
00235   virtual void clearClipRectangle();
00236 
00237   /// Set clip mask
00238   virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0);
00239 
00240   /// Clear clip mask
00241   virtual void clearClipMask();
00242 
00243   /// Set font to draw text with
00244   virtual void setFont(FXFont *fnt);
00245 
00246   /// Clip against child windows
00247   virtual void clipChildren(FXbool yes);
00248 
00249   /// Destructor
00250   virtual ~FXDCWindow();
00251   };
00252 
00253 }
00254 
00255 #endif

Copyright © 1997-2010 Jeroen van der Zijp