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

FXDC.h
Go to the documentation of this file.
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,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (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 GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXDC.h,v 1.37 2006/01/22 17:58:00 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXDC_H
25 #define FXDC_H
26 
27 namespace FX {
28 
29 /// Drawing (BITBLT) functions
30 enum FXFunction {
31  BLT_CLR, /// D := 0
32  BLT_SRC_AND_DST, /// D := S & D
33  BLT_SRC_AND_NOT_DST, /// D := S & ~D
34  BLT_SRC, /// D := S
35  BLT_NOT_SRC_AND_DST, /// D := ~S & D
36  BLT_DST, /// D := D
37  BLT_SRC_XOR_DST, /// D := S ^ D
38  BLT_SRC_OR_DST, /// D := S | D
39  BLT_NOT_SRC_AND_NOT_DST, /// D := ~S & ~D == D := ~(S | D)
40  BLT_NOT_SRC_XOR_DST, /// D := ~S ^ D
41  BLT_NOT_DST, /// D := ~D
42  BLT_SRC_OR_NOT_DST, /// D := S | ~D
43  BLT_NOT_SRC, /// D := ~S
44  BLT_NOT_SRC_OR_DST, /// D := ~S | D
45  BLT_NOT_SRC_OR_NOT_DST, /// D := ~S | ~D == ~(S & D)
46  BLT_SET /// D := 1
47  };
48 
49 
50 /// Line Styles
51 enum FXLineStyle {
52  LINE_SOLID, /// Solid lines
53  LINE_ONOFF_DASH, /// On-off dashed lines
54  LINE_DOUBLE_DASH /// Double dashed lines
55  };
56 
57 
58 /// Line Cap Styles
59 enum FXCapStyle {
60  CAP_NOT_LAST, /// Don't include last end cap
61  CAP_BUTT, /// Butting line end caps
62  CAP_ROUND, /// Round line end caps
63  CAP_PROJECTING /// Projecting line end caps
64  };
65 
66 
67 /// Line Join Styles
68 enum FXJoinStyle {
69  JOIN_MITER, /// Mitered or pointy joints
70  JOIN_ROUND, /// Round line joints
71  JOIN_BEVEL /// Beveled or flat joints
72  };
73 
74 
75 /// Fill Styles
76 enum FXFillStyle {
77  FILL_SOLID, /// Fill with solid color
78  FILL_TILED, /// Fill with tiled bitmap
79  FILL_STIPPLED, /// Fill where stipple mask is 1
80  FILL_OPAQUESTIPPLED /// Fill with foreground where mask is 1, background otherwise
81  };
82 
83 
84 /// Fill Rules
85 enum FXFillRule {
86  RULE_EVEN_ODD, /// Even odd polygon filling
87  RULE_WINDING /// Winding rule polygon filling
88  };
89 
90 
91 /// Stipple/dither patterns
92 enum FXStipplePattern {
93  STIPPLE_0 = 0,
94  STIPPLE_NONE = 0,
95  STIPPLE_BLACK = 0, /// All ones
96  STIPPLE_1 = 1,
97  STIPPLE_2 = 2,
98  STIPPLE_3 = 3,
99  STIPPLE_4 = 4,
100  STIPPLE_5 = 5,
101  STIPPLE_6 = 6,
102  STIPPLE_7 = 7,
103  STIPPLE_8 = 8,
104  STIPPLE_GRAY = 8, /// 50% gray
105  STIPPLE_9 = 9,
106  STIPPLE_10 = 10,
107  STIPPLE_11 = 11,
111  STIPPLE_15 = 15,
112  STIPPLE_16 = 16,
113  STIPPLE_WHITE = 16, /// All zeroes
114  STIPPLE_HORZ = 17, /// Horizontal hatch pattern
115  STIPPLE_VERT = 18, /// Vertical hatch pattern
116  STIPPLE_CROSS = 19, /// Cross-hatch pattern
117  STIPPLE_DIAG = 20, /// Diagonal // hatch pattern
118  STIPPLE_REVDIAG = 21, /// Reverse diagonal \\ hatch pattern
119  STIPPLE_CROSSDIAG = 22 /// Cross-diagonal hatch pattern
120  };
123 /// Line segment
124 struct FXSegment {
126  };
129 /// Arc
130 struct FXArc {
132  };
135 class FXApp;
136 class FXImage;
137 class FXBitmap;
138 class FXIcon;
139 class FXFont;
141 class FXRegion;
144 /**
145 * Abstract Device Context
146 *
147 * A Device Context is used to maintain the state of the graphics drawing system.
148 * Defining your drawing code in terms of the Abstract Device Context allows the
149 * drawing commands to be rendered on different types of surfaces, such as windows
150 * and images (FXDCWindow), or on paper (FXDCPrint).
151 * WYSYWYG may be obtained by using the same identical drawing code in your
152 * application regardless of the actual device surface being utilized.
153 */
154 class FXAPI FXDC {
155  friend class FXFont;
156 private:
157  FXApp *app; // Application
158 protected:
159  void *ctx; // Context handle
160  FXFont *font; // Drawing font
161  FXStipplePattern pattern; // Stipple pattern
162  FXBitmap *stipple; // Stipple bitmap
163  FXImage *tile; // Tile image
164  FXBitmap *mask; // Mask bitmap
165  FXRectangle clip; // Clip rectangle
166  FXColor fg; // Foreground color
167  FXColor bg; // Background color
168  FXuint width; // Line width
169  FXCapStyle cap; // Line cap style
170  FXJoinStyle join; // Line join style
171  FXLineStyle style; // Line style
172  FXFillStyle fill; // Fill style
173  FXFillRule rule; // Fill rule
174  FXFunction rop; // RasterOp
175  FXchar dashpat[32]; // Line dash pattern data
176  FXuint dashlen; // Line dash pattern length
177  FXuint dashoff; // Line dash pattern offset
178  FXint tx; // Tile dx
179  FXint ty; // Tile dy
180  FXint cx; // Clip x
181  FXint cy; // Clip y
182 private:
183  FXDC();
184  FXDC(const FXDC&);
185  FXDC &operator=(const FXDC&);
186 public:
187 
188  /// Construct dummy DC
189  FXDC(FXApp* a);
190 
191  /// Get application
192  FXApp* getApp() const { return app; }
193 
194  /// Get context handle
195  void* context() const { return ctx; }
196 
197  /// Read back pixel
198  virtual FXColor readPixel(FXint x,FXint y);
200  /// Draw points
201  virtual void drawPoint(FXint x,FXint y);
202  virtual void drawPoints(const FXPoint* points,FXuint npoints);
203  virtual void drawPointsRel(const FXPoint* points,FXuint npoints);
204 
205  /// Draw lines
206  virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2);
207  virtual void drawLines(const FXPoint* points,FXuint npoints);
208  virtual void drawLinesRel(const FXPoint* points,FXuint npoints);
209  virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments);
210 
211  /// Draw rectangles
212  virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h);
213  virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles);
214 
215  /// Draw rounded rectangle with ellipse with ew and ellips height eh
216  virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
217 
218  /**
219  * Draw arcs.
220  * The argument ang1 specifies the start of the arc relative to the
221  * three-o'clock position from the center, in units of degrees*64.
222  * The argument ang2 specifies the path and extent of the arc relative
223  * to the start of the arc, in units of degrees*64.
224  * The arguments x,y,w,h specify the bounding rectangle.
225  */
226  virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
227  virtual void drawArcs(const FXArc* arcs,FXuint narcs);
228 
229  /// Draw ellipse
230  virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h);
231 
232  /// Filled rectangles
233  virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h);
234  virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles);
235 
236  /// Filled rounded rectangle with ellipse with ew and ellips height eh
237  virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh);
238 
239  /// Fill chord
240  virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
241  virtual void fillChords(const FXArc* chords,FXuint nchords);
242 
243  /// Fill arcs
244  virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2);
245  virtual void fillArcs(const FXArc* arcs,FXuint narcs);
246 
247  /// Fill ellipse
248  virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h);
249 
250  /// Filled polygon
251  virtual void fillPolygon(const FXPoint* points,FXuint npoints);
252  virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints);
253  virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints);
254 
255  /// Filled polygon with relative points
256  virtual void fillPolygonRel(const FXPoint* points,FXuint npoints);
257  virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints);
258  virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints);
259 
260  /// Draw hashed box
261  virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1);
262 
263  /// Draw focus rectangle
264  virtual void drawFocusRectangle(FXint x,FXint y,FXint w,FXint h);
265 
266  /// Draw area from source
267  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy);
268 
269  /// Draw area stretched area from source
270  virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh);
271 
272  /// Draw image
273  virtual void drawImage(const FXImage* image,FXint dx,FXint dy);
274 
275  /// Draw bitmap
276  virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy);
277 
278  /// Draw icon
279  virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy);
280  virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy);
281  virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy);
282 
283  /// Draw string with base line starting at x, y
284  virtual void drawText(FXint x,FXint y,const FXString& string);
285  virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length);
286 
287  /// Draw text starting at x, y over filled background
288  virtual void drawImageText(FXint x,FXint y,const FXString& string);
289  virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length);
290 
291  /// Set foreground drawing color
292  virtual void setForeground(FXColor clr);
293 
294  /// Get foreground drawing color
295  FXColor getForeground() const { return fg; }
296 
297  /// Set background drawing color
298  virtual void setBackground(FXColor clr);
299 
300  /// Get background drawing color
301  FXColor getBackground() const { return bg; }
303  /**
304  * Set dash pattern and dash offset.
305  * A dash pattern of [1 2 3 4] is a repeating pattern of 1 foreground pixel,
306  * 2 background pixels, 3 foreground pixels, and 4 background pixels.
307  * The offset is where in the pattern the system will start counting.
308  * The maximum length of the dash pattern is 32.
309  */
310  virtual void setDashes(FXuint dashoffset,const FXchar *dashpattern,FXuint dashlength);
311 
312  /// Get dash pattern
313  const FXchar* getDashPattern() const { return dashpat; }
314 
315  /// Get dash offset
316  FXuint getDashOffset() const { return dashoff; }
317 
318  /// Get dash length
319  FXuint getDashLength() const { return dashlen; }
321  /// Set line width:- 0 means thinnest/fastest possible
322  virtual void setLineWidth(FXuint linewidth=0);
324  /// Get line width
325  FXuint getLineWidth() const { return width; }
327  /// Set line cap style
328  virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT);
329 
330  /// Get line cap style
331  FXCapStyle getLineCap() const { return cap; }
333  /// Set line join style
334  virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER);
335 
336  /// Get line join style
337  FXJoinStyle getLineJoin() const { return join; }
339  /// Set line style
340  virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID);
341 
342  /// Get line style
343  FXLineStyle getLineStyle() const { return style; }
345  /// Set fill style
346  virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID);
347 
348  /// Get fill style
349  FXFillStyle getFillStyle() const { return fill; }
351  /// Set fill rule
352  virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD);
353 
354  /// Get fill rule
355  FXFillRule getFillRule() const { return rule; }
357  /// Set rasterop function
358  virtual void setFunction(FXFunction func=BLT_SRC);
359 
360  /// Get rasterop function
361  FXFunction getFunction() const { return rop; }
363  /// Set the tile image
364  virtual void setTile(FXImage* image,FXint dx=0,FXint dy=0);
365 
366  /// Get the tile image
367  FXImage *getTile() const { return tile; }
369  /// Set the stipple pattern
370  virtual void setStipple(FXBitmap *bitmap,FXint dx=0,FXint dy=0);
371 
372  /// Get stipple bitmap
373  FXBitmap *getStippleBitmap() const { return stipple; }
375  /// Set the stipple pattern
376  virtual void setStipple(FXStipplePattern pat,FXint dx=0,FXint dy=0);
377 
378  /// Get pattern
379  FXStipplePattern getStipplePattern() const { return pattern; }
381  /// Set clip region
382  virtual void setClipRegion(const FXRegion& region);
383 
384  /// Set clip rectangle
385  virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h);
387  /// Change clip rectangle
388  virtual void setClipRectangle(const FXRectangle& rectangle);
389 
390  /// Return clip rectangle
391  const FXRectangle& getClipRectangle() const { return clip; }
392 
393  /// Return clip x
394  FXint getClipX() const { return clip.x; }
395 
396  /// Return clip y
397  FXint getClipY() const { return clip.y; }
399  /// Return clip width
400  FXint getClipWidth() const { return clip.w; }
402  /// Return clip height
403  FXint getClipHeight() const { return clip.h; }
405  /// Clear clipping
406  virtual void clearClipRectangle();
408  /// Set clip mask
409  virtual void setClipMask(FXBitmap* bitmap,FXint dx=0,FXint dy=0);
411  /// Clear clip mask
412  virtual void clearClipMask();
413 
414  /// Set font to draw text with
415  virtual void setFont(FXFont *fnt);
416 
417  /// Get text font
418  FXFont* getFont() const { return font; }
419 
420  /// Clip against child windows
421  virtual void clipChildren(FXbool yes);
422 
423  /// Destructor
424  virtual ~FXDC();
425  };
426 
427 }
428 
429 #endif
Vertical hatch pattern.
Definition: FXDC.h:142
D := 1.
Definition: FXDC.h:49
Double dashed lines.
Definition: FXDC.h:61
Even odd polygon filling.
Definition: FXDC.h:109
A Bitmap is a rectangular array of pixels.
Definition: FXBitmap.h:64
All ones.
Definition: FXDC.h:122
char FXchar
Definition: fxdefs.h:387
FXshort x
Definition: FXRectangle.h:39
Definition: FXDC.h:127
Rectangle.
Definition: FXRectangle.h:37
Fill with solid color.
Definition: FXDC.h:96
Definition: FXDC.h:120
D := S & ~D.
Definition: FXDC.h:36
Fill with foreground where mask is 1, background otherwise.
Definition: FXDC.h:99
FXshort y1
Definition: FXDC.h:153
Cross-hatch pattern.
Definition: FXDC.h:143
FXshort y2
Definition: FXDC.h:153
short FXshort
Definition: fxdefs.h:395
Horizontal hatch pattern.
Definition: FXDC.h:141
D := ~S ^ D.
Definition: FXDC.h:43
unsigned int FXuint
Definition: fxdefs.h:396
FXFillRule
Fill Rules.
Definition: FXDC.h:108
Definition: FXDC.h:136
FXJoinStyle
Line Join Styles.
Definition: FXDC.h:83
D := ~D.
Definition: FXDC.h:44
D := 0.
Definition: FXDC.h:34
Solid lines.
Definition: FXDC.h:59
#define FXAPI
Definition: fxdefs.h:122
D := S.
Definition: FXDC.h:37
FXuchar FXbool
Definition: fxdefs.h:393
Round line end caps.
Definition: FXDC.h:73
FXCapStyle
Line Cap Styles.
Definition: FXDC.h:70
Application Object.
Definition: FXApp.h:158
Definition: FXDC.h:132
All zeroes.
Definition: FXDC.h:140
On-off dashed lines.
Definition: FXDC.h:60
FXFillStyle
Fill Styles.
Definition: FXDC.h:95
D := S | ~D.
Definition: FXDC.h:45
FXuint FXColor
Definition: fxdefs.h:454
50% gray
Definition: FXDC.h:131
Winding rule polygon filling.
Definition: FXDC.h:110
FXshort y
Definition: FXDC.h:159
D := ~S & ~D == D := ~(S | D)
Definition: FXDC.h:42
Definition: FXDC.h:121
Arc.
Definition: FXDC.h:158
Definition: FXDC.h:135
Definition: FXDC.h:128
Line segment.
Definition: FXDC.h:152
Definition: FXDC.h:133
Abstract Device Context.
Definition: FXDC.h:191
Definition: FXDC.h:137
Definition: FXDC.h:130
Definition: FXDC.h:138
FXLineStyle
Line Styles.
Definition: FXDC.h:58
Definition: FXDC.h:129
int FXint
Definition: fxdefs.h:397
Round line joints.
Definition: FXDC.h:85
FXStipplePattern
Stipple/dither patterns.
Definition: FXDC.h:119
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
Cross-diagonal hatch pattern.
Definition: FXDC.h:146
D := S & D.
Definition: FXDC.h:35
FXshort b
Definition: FXDC.h:159
D := ~S | ~D == ~(S & D)
Definition: FXDC.h:48
FXshort x
Definition: FXDC.h:159
Butting line end caps.
Definition: FXDC.h:72
Definition: FXDC.h:139
FXshort h
Definition: FXDC.h:159
D := ~S & D.
Definition: FXDC.h:38
Definition: FXDC.h:123
D := ~S | D.
Definition: FXDC.h:47
Beveled or flat joints.
Definition: FXDC.h:86
Point.
Definition: FXPoint.h:35
D := S | D.
Definition: FXDC.h:41
Reverse diagonal \ hatch pattern.
Definition: FXDC.h:145
FXshort x2
Definition: FXDC.h:153
Mitered or pointy joints.
Definition: FXDC.h:84
Fill where stipple mask is 1.
Definition: FXDC.h:98
D := S ^ D.
Definition: FXDC.h:40
Definition: FXDC.h:126
Region.
Definition: FXRegion.h:30
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
Projecting line end caps.
Definition: FXDC.h:74
FXFunction
Drawing (BITBLT) functions.
Definition: FXDC.h:33
Definition: FXDC.h:125
D := D.
Definition: FXDC.h:39
FXshort a
Definition: FXDC.h:159
FXshort w
Definition: FXDC.h:159
Fill with tiled bitmap.
Definition: FXDC.h:97
Diagonal // hatch pattern.
Definition: FXDC.h:144
D := ~S.
Definition: FXDC.h:46
Definition: FXDC.h:134
Font class.
Definition: FXFont.h:142
Definition: FXDC.h:124
FXshort x1
Definition: FXDC.h:153
Don't include last end cap.
Definition: FXDC.h:71
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
Drawable is an abstract base class for any surface that can be drawn upon, such as a FXWindow...
Definition: FXDrawable.h:41

Copyright © 1997-2005 Jeroen van der Zijp