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

FXDCWindow.h

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

Copyright © 1997-2004 Jeroen van der Zijp