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