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

FXDC.h
1 /********************************************************************************
2 * *
3 * D e v i c e C o n t e x t B a s e C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1999,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXDC_H
22 #define FXDC_H
23 
24 
25 namespace FX {
26 
27 
29 enum FXFunction {
30  BLT_CLR,
31  BLT_SRC_AND_DST,
32  BLT_SRC_AND_NOT_DST,
33  BLT_SRC,
34  BLT_NOT_SRC_AND_DST,
35  BLT_DST,
36  BLT_SRC_XOR_DST,
37  BLT_SRC_OR_DST,
38  BLT_NOT_SRC_AND_NOT_DST,
39  BLT_NOT_SRC_XOR_DST,
40  BLT_NOT_DST,
41  BLT_SRC_OR_NOT_DST,
42  BLT_NOT_SRC,
43  BLT_NOT_SRC_OR_DST,
44  BLT_NOT_SRC_OR_NOT_DST,
45  BLT_SET
46  };
47 
48 
50 enum FXLineStyle {
51  LINE_SOLID,
52  LINE_ONOFF_DASH,
53  LINE_DOUBLE_DASH
54  };
55 
56 
58 enum FXCapStyle {
59  CAP_NOT_LAST,
60  CAP_BUTT,
61  CAP_ROUND,
62  CAP_PROJECTING
63  };
64 
65 
67 enum FXJoinStyle {
68  JOIN_MITER,
69  JOIN_ROUND,
70  JOIN_BEVEL
71  };
72 
73 
75 enum FXFillStyle {
76  FILL_SOLID,
77  FILL_TILED,
78  FILL_STIPPLED,
79  FILL_OPAQUESTIPPLED
80  };
81 
82 
84 enum FXFillRule {
85  RULE_EVEN_ODD,
86  RULE_WINDING
87  };
88 
89 
91 enum FXStipplePattern {
92  STIPPLE_0 = 0,
93  STIPPLE_NONE = 0,
94  STIPPLE_BLACK = 0,
95  STIPPLE_1 = 1,
96  STIPPLE_2 = 2,
97  STIPPLE_3 = 3,
98  STIPPLE_4 = 4,
99  STIPPLE_5 = 5,
100  STIPPLE_6 = 6,
101  STIPPLE_7 = 7,
102  STIPPLE_8 = 8,
103  STIPPLE_GRAY = 8,
104  STIPPLE_9 = 9,
105  STIPPLE_10 = 10,
106  STIPPLE_11 = 11,
107  STIPPLE_12 = 12,
108  STIPPLE_13 = 13,
109  STIPPLE_14 = 14,
110  STIPPLE_15 = 15,
111  STIPPLE_16 = 16,
112  STIPPLE_WHITE = 16,
113  STIPPLE_HORZ = 17,
114  STIPPLE_VERT = 18,
115  STIPPLE_CROSS = 19,
116  STIPPLE_DIAG = 20,
117  STIPPLE_REVDIAG = 21,
118  STIPPLE_CROSSDIAG = 22
119  };
120 
121 
123 struct FXSegment {
124  FXshort x1,y1,x2,y2;
125  };
126 
127 
129 struct FXArc {
130  FXshort x,y,w,h,a,b;
131  };
132 
133 
134 class FXApp;
135 class FXImage;
136 class FXBitmap;
137 class FXIcon;
138 class FXFont;
139 class FXDrawable;
140 class FXRegion;
141 
142 
153 class FXAPI FXDC {
154  friend class FXFont;
155 private:
156  FXApp *app; // Application
157 protected:
158  void *ctx; // Context handle
159  FXFont *font; // Drawing font
160  FXStipplePattern pattern; // Stipple pattern
161  FXBitmap *stipple; // Stipple bitmap
162  FXImage *tile; // Tile image
163  FXBitmap *mask; // Mask bitmap
164  FXRectangle clip; // Clip rectangle
165  FXColor fg; // Foreground color
166  FXColor bg; // Background color
167  FXuint width; // Line width
168  FXCapStyle cap; // Line cap style
169  FXJoinStyle join; // Line join style
170  FXLineStyle style; // Line style
171  FXFillStyle fill; // Fill style
172  FXFillRule rule; // Fill rule
173  FXFunction rop; // RasterOp
174  FXuchar dashpat[32]; // Line dash pattern data
175  FXuint dashlen; // Line dash pattern length
176  FXuint dashoff; // Line dash pattern offset
177  FXint tx; // Tile dx
178  FXint ty; // Tile dy
179  FXint cx; // Clip x
180  FXint cy; // Clip y
181 private:
182  FXDC();
183  FXDC(const FXDC&);
184  FXDC &operator=(const FXDC&);
185 public:
186 
188  FXDC(FXApp* a);
189 
191  FXApp* getApp() const { return app; }
192 
194  void* context() const { return ctx; }
195 
197  virtual FXColor readPixel(FXint x,FXint y);
198 
200  virtual void drawPoint(FXint x,FXint y);
201  virtual void drawPoints(const FXPoint* points,FXuint npoints);
202  virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
203 
205  virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
206  virtual void drawLines(const FXPoint* points,FXuint npoints);
207  virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
208  virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
209 
211  virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
212  virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
213 
215  virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
216 
225  virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
226  virtual void drawArcs(const FXArc* arcs,FXuint narcs);
227 
229  virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h);
230 
232  virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
233  virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
234 
236  virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
237 
239  virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
240  virtual void fillChords(const FXArc* chords,FXuint nchords);
241 
243  virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
244  virtual void fillArcs(const FXArc* arcs,FXuint narcs);
245 
247  virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h);
248 
250  virtual void fillPolygon(const FXPoint* points,FXuint npoints);
251  virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
252  virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
253 
255  virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
256  virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
257  virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
258 
260  virtual void fillVerticalGradient(FXint x,FXint y,FXint w,FXint h,FXColor top,FXColor bottom);
261 
263  virtual void fillHorizontalGradient(FXint x,FXint y,FXint w,FXint h,FXColor left,FXColor right);
264 
266  virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
267 
269  virtual void drawFocusRectangle(FXint x,FXint y,FXint w,FXint h);
270 
272  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
273 
275  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh);
276 
278  virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
279 
281  virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
282 
284  virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
285  virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
286  virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
287 
289  virtual void drawText(FXint x,FXint y,const FXString& string);
290  virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
291 
293  virtual void drawImageText(FXint x,FXint y,const FXString& string);
294  virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
295 
297  virtual void setForeground(FXColor clr);
298 
300  FXColor getForeground() const { return fg; }
301 
303  virtual void setBackground(FXColor clr);
304 
306  FXColor getBackground() const { return bg; }
307 
315  virtual void setDashes(FXuint dashoffset,const FXuchar *dashpattern,FXuint dashlength);
316 
318  const FXuchar* getDashPattern() const { return dashpat; }
319 
321  FXuint getDashOffset() const { return dashoff; }
322 
324  FXuint getDashLength() const { return dashlen; }
325 
327  virtual void setLineWidth(FXuint linewidth=0);
328 
330  FXuint getLineWidth() const { return width; }
331 
333  virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
334 
336  FXCapStyle getLineCap() const { return cap; }
337 
339  virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
340 
342  FXJoinStyle getLineJoin() const { return join; }
343 
345  virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
346 
348  FXLineStyle getLineStyle() const { return style; }
349 
351  virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
352 
354  FXFillStyle getFillStyle() const { return fill; }
355 
357  virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
358 
360  FXFillRule getFillRule() const { return rule; }
361 
363  virtual void setFunction(FXFunction func=BLT_SRC);
364 
366  FXFunction getFunction() const { return rop; }
367 
369  virtual void setTile(FXImage* image,FXint dx=0,FXint dy=0);
370 
372  FXImage *getTile() const { return tile; }
373 
375  virtual void setStipple(FXBitmap *bitmap,FXint dx=0,FXint dy=0);
376 
378  FXBitmap *getStippleBitmap() const { return stipple; }
379 
381  virtual void setStipple(FXStipplePattern pat,FXint dx=0,FXint dy=0);
382 
384  FXStipplePattern getStipplePattern() const { return pattern; }
385 
387  virtual void setClipRegion(const FXRegion& region);
388 
390  virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
391 
393  virtual void setClipRectangle(const FXRectangle& rectangle);
394 
396  const FXRectangle& getClipRectangle() const { return clip; }
397 
399  FXint getClipX() const { return clip.x; }
400 
402  FXint getClipY() const { return clip.y; }
403 
405  FXint getClipWidth() const { return clip.w; }
406 
408  FXint getClipHeight() const { return clip.h; }
409 
411  virtual void clearClipRectangle();
412 
414  virtual void setClipMask(FXBitmap* bitmap,FXint dx=0,FXint dy=0);
415 
417  virtual void clearClipMask();
418 
420  virtual void setFont(FXFont *fnt);
421 
423  FXFont* getFont() const { return font; }
424 
426  virtual void clipChildren(FXbool yes);
427 
429  virtual ~FXDC();
430  };
431 
432 }
433 
434 #endif
FXCapStyle getLineCap() const
Get line cap style.
Definition: FXDC.h:336
FXStipplePattern getStipplePattern() const
Get pattern.
Definition: FXDC.h:384
FXuint getDashLength() const
Get dash length.
Definition: FXDC.h:324
A Bitmap is a rectangular array of pixels.
Definition: FXBitmap.h:55
FXint getClipX() const
Return clip x.
Definition: FXDC.h:399
void * context() const
Get context handle.
Definition: FXDC.h:194
Rectangle.
Definition: FXRectangle.h:32
FXint getClipWidth() const
Return clip width.
Definition: FXDC.h:405
const FXRectangle & getClipRectangle() const
Return clip rectangle.
Definition: FXDC.h:396
FXColor getForeground() const
Get foreground drawing color.
Definition: FXDC.h:300
const FXuchar * getDashPattern() const
Get dash pattern.
Definition: FXDC.h:318
The Application object is the central point of a FOX user-interface.
Definition: FXApp.h:134
FXLineStyle getLineStyle() const
Get line style.
Definition: FXDC.h:348
FXFont * getFont() const
Get text font.
Definition: FXDC.h:423
FXint getClipHeight() const
Return clip height.
Definition: FXDC.h:408
Arc.
Definition: FXDC.h:129
Line segment.
Definition: FXDC.h:123
FXApp * getApp() const
Get application.
Definition: FXDC.h:191
FXuint getDashOffset() const
Get dash offset.
Definition: FXDC.h:321
Abstract Device Context.
Definition: FXDC.h:153
Definition: FX4Splitter.h:28
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
FXint getClipY() const
Return clip y.
Definition: FXDC.h:402
FXJoinStyle getLineJoin() const
Get line join style.
Definition: FXDC.h:342
FXuint getLineWidth() const
Get line width.
Definition: FXDC.h:330
FXBitmap * getStippleBitmap() const
Get stipple bitmap.
Definition: FXDC.h:378
Point.
Definition: FXPoint.h:32
Region.
Definition: FXRegion.h:28
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
FXColor getBackground() const
Get background drawing color.
Definition: FXDC.h:306
FXImage * getTile() const
Get the tile image.
Definition: FXDC.h:372
Font class.
Definition: FXFont.h:137
FXFunction getFunction() const
Get rasterop function.
Definition: FXDC.h:366
FXFillStyle getFillStyle() const
Get fill style.
Definition: FXDC.h:354
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42
Drawable is an abstract base class for any surface that can be drawn upon, such as a FXWindow...
Definition: FXDrawable.h:38
FXFillRule getFillRule() const
Get fill rule.
Definition: FXDC.h:360

Copyright © 1997-2022 Jeroen van der Zijp