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,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: FXDCWindow.h,v 1.31 2002/08/29 19:27:42 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 #else
00062   FXID        oldpalette;
00063   FXID        oldbrush;
00064   FXID        oldpen;
00065   FXPixel     devfg;          // Device foreground pixel value
00066   FXPixel     devbg;          // Device background pixel value
00067   FXbool      needsNewBrush;
00068   FXbool      needsNewPen;
00069   FXbool      needsPath;
00070 #endif
00071 private:
00072 #ifdef WIN32
00073   void updateBrush();
00074   void updatePen();
00075 #endif
00076 private:
00077   FXDCWindow();
00078   FXDCWindow(const FXDCWindow&);
00079   FXDCWindow &operator=(const FXDCWindow&);
00080 public:
00081 
00082   /// Construct for painting in response to expose;
00083   /// This sets the clip rectangle to the exposed rectangle
00084   FXDCWindow(FXDrawable* drawable,FXEvent* event);
00085 
00086   /// Construct for normal drawing;
00087   /// This sets clip rectangle to the whole drawable
00088   FXDCWindow(FXDrawable* drawable);
00089 
00090   /// Begin locks in a drawable surface
00091   void begin(FXDrawable *drawable);
00092 
00093   /// End unlock the drawable surface
00094   void end();
00095 
00096   /// Read back pixel
00097   virtual FXColor readPixel(FXint x,FXint y);
00098 
00099   /// Draw points
00100   virtual void drawPoint(FXint x,FXint y);
00101   virtual void drawPoints(const FXPoint* points,FXuint npoints);
00102   virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
00103 
00104   /// Draw lines
00105   virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
00106   virtual void drawLines(const FXPoint* points,FXuint npoints);
00107   virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
00108   virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
00109 
00110   /// Draw rectangles
00111   virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
00112   virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00113 
00114   /// Draw arcs
00115   virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00116   virtual void drawArcs(const FXArc* arcs,FXuint narcs);
00117 
00118   /// Filled rectangles
00119   virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
00120   virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
00121 
00122   /// Fill chord
00123   virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00124   virtual void fillChords(const FXArc* chords,FXuint nchords);
00125 
00126   /// Draw arcs
00127   virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
00128   virtual void fillArcs(const FXArc* arcs,FXuint narcs);
00129 
00130   /// Filled polygon
00131   virtual void fillPolygon(const FXPoint* points,FXuint npoints);
00132   virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
00133   virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
00134 
00135   /// Filled polygon with relative points
00136   virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
00137   virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
00138   virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
00139 
00140   /// Draw hashed box
00141   virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
00142 
00143   /// Draw focus rectangle
00144   virtual void drawFocusRectangle(FXint x,FXint y,FXint w,FXint h);
00145 
00146   /// Draw area from source
00147   virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
00148 
00149   /// Draw image
00150   virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
00151 
00152   /// Draw bitmap
00153   virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
00154 
00155   /// Draw icon
00156   virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
00157   virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
00158   virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
00159 
00160   /// Draw string
00161   virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
00162   virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
00163 
00164   /// Set foreground/background drawing color
00165   virtual void setForeground(FXColor clr);
00166   virtual void setBackground(FXColor clr);
00167 
00168   /// Set dash pattern
00169   virtual void setDashes(FXuint dashoffset,const FXchar *dashpattern,FXuint dashlength);
00170 
00171   /// Set line width
00172   virtual void setLineWidth(FXuint linewidth=0);
00173 
00174   /// Set line cap style
00175   virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
00176 
00177   /// Set line join style
00178   virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
00179 
00180   /// Set line style
00181   virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
00182 
00183   /// Set fill style
00184   virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
00185 
00186   /// Set fill rule
00187   virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
00188 
00189   /// Set blit function
00190   virtual void setFunction(FXFunction func=BLT_SRC);
00191 
00192   /// Set the tile
00193   virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0);
00194 
00195   /// Set the stipple pattern
00196   virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0);
00197 
00198   /// Set the stipple pattern
00199   virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0);
00200 
00201   /// Set clip region
00202   virtual void setClipRegion(const FXRegion& region);
00203 
00204   /// Set clip rectangle
00205   virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
00206 
00207   /// Set clip rectangle
00208   virtual void setClipRectangle(const FXRectangle& rectangle);
00209 
00210   /// Clear clipping
00211   virtual void clearClipRectangle();
00212 
00213   /// Set clip mask
00214   virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0);
00215 
00216   /// Clear clip mask
00217   virtual void clearClipMask();
00218 
00219   /// Set font to draw text with
00220   virtual void setTextFont(FXFont *fnt);
00221 
00222   /// Clip against child windows
00223   virtual void clipChildren(FXbool yes);
00224 
00225   /// Destructor
00226   virtual ~FXDCWindow();
00227   };
00228 
00229 }
00230 
00231 #endif