]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dc.h
Illustrate usage of wxDataViewListCtrl
[wxWidgets.git] / interface / wx / dc.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.h
e54c96f1 3// Purpose: interface of wxDC
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
97929f6b
FM
9
10/**
11 Logical raster operations which can be used with wxDC::SetLogicalFunction
12 and some other wxDC functions (e.g. wxDC::Blit and wxDC::StretchBlit).
13
14 The description of the values below refer to how a generic @e src source pixel
15 and the corresponding @e dst destination pixel gets combined together to produce
16 the final pixel. E.g. @c wxCLEAR and @c wxSET completely ignore the source
17 and the destination pixel and always put zeroes or ones in the final surface.
18*/
19enum wxRasterOperationMode
20{
21 wxCLEAR, //!< 0
22 wxXOR, //!< @e src XOR @e dst
23 wxINVERT, //!< NOT @e dst
24 wxOR_REVERSE, //!< @e src OR (NOT @e dst)
25 wxAND_REVERSE, //!< @e src AND (NOT @e dst)
26 wxCOPY, //!< @e src
27 wxAND, //!< @e src AND @e dst
28 wxAND_INVERT, //!< (NOT @e src) AND @e dst
29 wxNO_OP, //!< @e dst
30 wxNOR, //!< (NOT @e src) AND (NOT @e dst)
31 wxEQUIV, //!< (NOT @e src) XOR @e dst
32 wxSRC_INVERT, //!< (NOT @e src)
33 wxOR_INVERT, //!< (NOT @e src) OR @e dst
34 wxNAND, //!< (NOT @e src) OR (NOT @e dst)
35 wxOR, //!< @e src OR @e dst
36 wxSET //!< 1
37};
38
39/**
40 Flood styles used by wxDC::FloodFill.
41*/
42enum wxFloodFillStyle
43{
44 /** The flooding occurs until a colour other than the given colour is encountered. */
45 wxFLOOD_SURFACE = 1,
46
47 /** The area to be flooded is bounded by the given colour. */
48 wxFLOOD_BORDER
49};
50
51/**
52 The mapping mode which can be used with wxDC::SetMapMode.
53*/
54enum wxMappingMode
55{
56 /** Each logical unit is 1 device pixel. */
57 wxMM_TEXT = 1,
58
59 wxMM_LOMETRIC,
60 wxMM_HIMETRIC,
61
62 /** Each logical unit is 1/10 of a mm. */
63 wxMM_LOENGLISH,
64
65 wxMM_HIENGLISH,
66
67 /** Each logical unit is 1/20 of a point, or 1/1440 of an inch. */
68 wxMM_TWIPS,
69
70 wxMM_ISOTROPIC,
71 wxMM_ANISOTROPIC,
72
73 /** Each logical unit is a point, or 1/72 of an inch. */
74 wxMM_POINTS,
75
76 /** Each logical unit is 1 mm. */
77 wxMM_METRIC
78};
79
23324ae1
FM
80/**
81 @class wxDC
7c913512 82
f09b5681 83 A wxDC is a @e "device context" onto which graphics and text can be drawn.
318b0bd5
RR
84 It is intended to represent different output devices and offers a common
85 abstract API for drawing on any of them.
edc51344 86
318b0bd5 87 wxWidgets offers an alternative drawing API based on the modern drawing
12133c3b 88 backends GDI+, CoreGraphics and Cairo. See wxGraphicsContext, wxGraphicsRenderer
6d99a337
RR
89 and related classes. There is also a wxGCDC linking the APIs by offering
90 the wxDC API ontop of a wxGraphicsContext.
7c913512 91
318b0bd5
RR
92 wxDC is an abstract base class and cannot be created directly.
93 Use wxPaintDC, wxClientDC, wxWindowDC, wxScreenDC, wxMemoryDC or
edc51344
VZ
94 wxPrinterDC. Notice that device contexts which are associated with windows
95 (i.e. wxClientDC, wxWindowDC and wxPaintDC) use the window font and colours
96 by default (starting with wxWidgets 2.9.0) but the other device context
97 classes use system-default values so you always must set the appropriate
98 fonts and colours before using them.
f09b5681 99
318b0bd5
RR
100 In addition to the versions of the methods documented below, there
101 are also versions which accept single wxPoint parameter instead
102 of the two wxCoord ones or wxPoint and wxSize instead of the four
103 wxCoord parameters.
f09b5681 104
318b0bd5
RR
105 Beginning with wxWidgets 2.9.0 the entire wxDC code has been
106 reorganized. All platform dependent code (actually all drawing code)
107 has been moved into backend classes which derive from a common
108 wxDCImpl class. The user-visible classes such as wxClientDC and
109 wxPaintDC merely forward all calls to the backend implementation.
f09b5681 110
318b0bd5
RR
111 On Mac OS X colours with alpha channel are supported. Instances wxPen
112 or wxBrush that are built from wxColour use the colour's alpha values
113 when stroking or filling.
7c913512 114
23324ae1 115 @library{wxcore}
c0cc7004 116 @category{dc,gdi}
7c913512 117
382f12e4
FM
118 @see @ref overview_dc, wxGraphicsContext, wxDCFontChanger, wxDCTextColourChanger,
119 wxDCPenChanger, wxDCBrushChanger, wxDCClipper
f09b5681
BP
120
121 @todo Precise definition of default/initial state.
122 @todo Pixelwise definition of operations (e.g. last point of a line not
123 drawn).
124 @todo Coordinates: state clearly which type of coordinates are returned by
125 the various Get*Point() or similar functions - often they are client
126 coordinates but not always.
23324ae1
FM
127*/
128class wxDC : public wxObject
129{
130public:
131 /**
132 Copy from a source DC to this DC, specifying the destination
133 coordinates, size of area to copy, source DC, source coordinates,
f09b5681
BP
134 logical function, whether to use a bitmap mask, and mask source
135 position.
3c4f71cc 136
7c913512 137 @param xdest
4cc4bfaf 138 Destination device context x position.
7c913512 139 @param ydest
4cc4bfaf 140 Destination device context y position.
7c913512 141 @param width
4cc4bfaf 142 Width of source area to be copied.
7c913512 143 @param height
4cc4bfaf 144 Height of source area to be copied.
7c913512 145 @param source
4cc4bfaf 146 Source device context.
7c913512 147 @param xsrc
4cc4bfaf 148 Source device context x position.
7c913512 149 @param ysrc
4cc4bfaf 150 Source device context y position.
7c913512 151 @param logicalFunc
f09b5681 152 Logical function to use, see SetLogicalFunction().
7c913512 153 @param useMask
f09b5681
BP
154 If @true, Blit does a transparent blit using the mask that is
155 associated with the bitmap selected into the source device context.
156 The Windows implementation does the following if MaskBlt cannot be
157 used:
158 <ol>
159 <li>Creates a temporary bitmap and copies the destination area into
160 it.</li>
161 <li>Copies the source area into the temporary bitmap using the
162 specified logical function.</li>
163 <li>Sets the masked area in the temporary bitmap to BLACK by ANDing
164 the mask bitmap with the temp bitmap with the foreground colour
165 set to WHITE and the bg colour set to BLACK.</li>
166 <li>Sets the unmasked area in the destination area to BLACK by
167 ANDing the mask bitmap with the destination area with the
168 foreground colour set to BLACK and the background colour set to
169 WHITE.</li>
170 <li>ORs the temporary bitmap with the destination area.</li>
171 <li>Deletes the temporary bitmap.</li>
172 </ol>
173 This sequence of operations ensures that the source's transparent
174 area need not be black, and logical functions are supported.
175 @n @b Note: on Windows, blitting with masks can be speeded up
176 considerably by compiling wxWidgets with the wxUSE_DC_CACHE option
177 enabled. You can also influence whether MaskBlt or the explicit
178 mask blitting code above is used, by using wxSystemOptions and
179 setting the @c no-maskblt option to 1.
7c913512 180 @param xsrcMask
f09b5681 181 Source x position on the mask. If both xsrcMask and ysrcMask are
89efaf2b 182 @c -1, xsrc and ysrc will be assumed for the mask source position.
f09b5681 183 Currently only implemented on Windows.
7c913512 184 @param ysrcMask
f09b5681 185 Source y position on the mask. If both xsrcMask and ysrcMask are
89efaf2b 186 @c -1, xsrc and ysrc will be assumed for the mask source position.
f09b5681 187 Currently only implemented on Windows.
3c4f71cc 188
f09b5681 189 @remarks There is partial support for Blit() in wxPostScriptDC, under X.
3c4f71cc 190
4cc4bfaf 191 @see StretchBlit(), wxMemoryDC, wxBitmap, wxMask
23324ae1
FM
192 */
193 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width,
f09b5681 194 wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc,
89efaf2b 195 wxRasterOperationMode logicalFunc = wxCOPY, bool useMask = false,
408776d0 196 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
23324ae1
FM
197
198 /**
f09b5681
BP
199 Adds the specified point to the bounding box which can be retrieved
200 with MinX(), MaxX() and MinY(), MaxY() functions.
3c4f71cc 201
4cc4bfaf 202 @see ResetBoundingBox()
23324ae1
FM
203 */
204 void CalcBoundingBox(wxCoord x, wxCoord y);
205
206 /**
207 Clears the device context using the current background brush.
208 */
209 void Clear();
210
23324ae1 211 /**
f09b5681
BP
212 Displays a cross hair using the current pen. This is a vertical and
213 horizontal line the height and width of the window, centred on the
214 given point.
23324ae1
FM
215 */
216 void CrossHair(wxCoord x, wxCoord y);
217
218 /**
219 Destroys the current clipping region so that none of the DC is clipped.
f09b5681
BP
220
221 @see SetClippingRegion()
23324ae1
FM
222 */
223 void DestroyClippingRegion();
224
225 /**
226 Convert device X coordinate to logical coordinate, using the current
63408203 227 mapping mode, user scale factor, device origin and axis orientation.
23324ae1 228 */
adaaa686 229 wxCoord DeviceToLogicalX(wxCoord x) const;
23324ae1
FM
230
231 /**
f09b5681 232 Convert device X coordinate to relative logical coordinate, using the
63408203
VZ
233 current mapping mode and user scale factor but ignoring the
234 axis orientation. Use this for converting a width, for example.
23324ae1 235 */
adaaa686 236 wxCoord DeviceToLogicalXRel(wxCoord x) const;
23324ae1
FM
237
238 /**
239 Converts device Y coordinate to logical coordinate, using the current
63408203 240 mapping mode, user scale factor, device origin and axis orientation.
23324ae1 241 */
adaaa686 242 wxCoord DeviceToLogicalY(wxCoord y) const;
23324ae1
FM
243
244 /**
f09b5681 245 Convert device Y coordinate to relative logical coordinate, using the
63408203
VZ
246 current mapping mode and user scale factor but ignoring the
247 axis orientation. Use this for converting a height, for example.
23324ae1 248 */
adaaa686 249 wxCoord DeviceToLogicalYRel(wxCoord y) const;
23324ae1
FM
250
251 /**
f09b5681
BP
252 Draws an arc of a circle, centred on (@a xc, @a yc), with starting
253 point (@a x1, @a y1) and ending at (@a x2, @a y2). The current pen is
254 used for the outline and the current brush for filling the shape.
255
256 The arc is drawn in a counter-clockwise direction from the start point
257 to the end point.
23324ae1
FM
258 */
259 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
f09b5681 260 wxCoord xc, wxCoord yc);
23324ae1
FM
261
262 /**
f09b5681
BP
263 Draw a bitmap on the device context at the specified point. If
264 @a transparent is @true and the bitmap has a transparency mask, the
265 bitmap will be drawn transparently.
266
267 When drawing a mono-bitmap, the current text foreground colour will be
268 used to draw the foreground of the bitmap (all bits set to 1), and the
269 current text background colour to draw the background (all bits set to
270 0).
271
272 @see SetTextForeground(), SetTextBackground(), wxMemoryDC
23324ae1
FM
273 */
274 void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y,
408776d0 275 bool useMask = false);
23324ae1
FM
276
277 //@{
278 /**
279 Draws a check mark inside the given rectangle.
280 */
f09b5681 281 void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
4cc4bfaf 282 void DrawCheckMark(const wxRect& rect);
23324ae1
FM
283 //@}
284
285 //@{
286 /**
287 Draws a circle with the given centre and radius.
3c4f71cc 288
4cc4bfaf 289 @see DrawEllipse()
23324ae1
FM
290 */
291 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
7c913512 292 void DrawCircle(const wxPoint& pt, wxCoord radius);
23324ae1
FM
293 //@}
294
295 //@{
296 /**
f09b5681
BP
297 Draws an ellipse contained in the rectangle specified either with the
298 given top left corner and the given size or directly. The current pen
299 is used for the outline and the current brush for filling the shape.
3c4f71cc 300
4cc4bfaf 301 @see DrawCircle()
23324ae1 302 */
f09b5681 303 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
7c913512
FM
304 void DrawEllipse(const wxPoint& pt, const wxSize& size);
305 void DrawEllipse(const wxRect& rect);
23324ae1
FM
306 //@}
307
308 /**
f09b5681
BP
309 Draws an arc of an ellipse. The current pen is used for drawing the arc
310 and the current brush is used for drawing the pie.
311
312 @a x and @a y specify the x and y coordinates of the upper-left corner
313 of the rectangle that contains the ellipse.
314
315 @a width and @a height specify the width and height of the rectangle
316 that contains the ellipse.
317
318 @a start and @a end specify the start and end of the arc relative to
319 the three-o'clock position from the center of the rectangle. Angles are
320 specified in degrees (360 is a complete circle). Positive values mean
321 counter-clockwise motion. If @a start is equal to @e end, a complete
322 ellipse will be drawn.
23324ae1 323 */
f09b5681
BP
324 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
325 double start, double end);
23324ae1
FM
326
327 /**
f09b5681
BP
328 Draw an icon on the display (does nothing if the device context is
329 PostScript). This can be the simplest way of drawing bitmaps on a
330 window.
23324ae1
FM
331 */
332 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
333
334 //@{
335 /**
f09b5681
BP
336 Draw optional bitmap and the text into the given rectangle and aligns
337 it as specified by alignment parameter; it also will emphasize the
338 character with the given index if it is != -1 and return the bounding
339 rectangle if required.
23324ae1 340 */
882678eb
FM
341 void DrawLabel(const wxString& text, const wxBitmap& image,
342 const wxRect& rect,
343 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
344 int indexAccel = -1, wxRect* rectBounding = NULL);
7c913512
FM
345 void DrawLabel(const wxString& text, const wxRect& rect,
346 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
347 int indexAccel = -1);
23324ae1
FM
348 //@}
349
350 /**
f09b5681
BP
351 Draws a line from the first point to the second. The current pen is
352 used for drawing the line. Note that the point (@a x2, @a y2) is not
353 part of the line and is not drawn by this function (this is consistent
354 with the behaviour of many other toolkits).
23324ae1
FM
355 */
356 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
357
23324ae1 358 /**
f09b5681
BP
359 Draws lines using an array of points of size @a n adding the optional
360 offset coordinate. The current pen is used for drawing the lines.
361
362 @beginWxPythonOnly
363 The wxPython version of this method accepts a Python list of wxPoint
364 objects.
365 @endWxPythonOnly
23324ae1
FM
366 */
367 void DrawLines(int n, wxPoint points[], wxCoord xoffset = 0,
368 wxCoord yoffset = 0);
f09b5681
BP
369 /**
370 This method uses a list of wxPoints, adding the optional offset
371 coordinate. The programmer is responsible for deleting the list of
372 points.
373
374 @beginWxPythonOnly
375 The wxPython version of this method accepts a Python list of wxPoint
376 objects.
377 @endWxPythonOnly
378 */
4cc4bfaf 379 void DrawLines(const wxPointList* points,
f09b5681 380 wxCoord xoffset = 0, wxCoord yoffset = 0);
23324ae1
FM
381
382 /**
383 Draws a point using the color of the current pen. Note that the other
f09b5681 384 properties of the pen are not used, such as width.
23324ae1
FM
385 */
386 void DrawPoint(wxCoord x, wxCoord y);
387
388 /**
f09b5681
BP
389 Draws a filled polygon using an array of points of size @a n, adding
390 the optional offset coordinate. The first and last points are
391 automatically closed.
23324ae1 392
f09b5681
BP
393 The last argument specifies the fill rule: @b wxODDEVEN_RULE (the
394 default) or @b wxWINDING_RULE.
395
396 The current pen is used for drawing the outline, and the current brush
397 for filling the shape. Using a transparent brush suppresses filling.
398 */
399 void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0,
89efaf2b
FM
400 wxCoord yoffset = 0,
401 wxPolygonFillMode fill_style = wxODDEVEN_RULE);
23324ae1 402 /**
f09b5681
BP
403 This method draws a filled polygon using a list of wxPoints, adding the
404 optional offset coordinate. The first and last points are automatically
405 closed.
406
23324ae1
FM
407 The last argument specifies the fill rule: @b wxODDEVEN_RULE (the
408 default) or @b wxWINDING_RULE.
f09b5681 409
23324ae1 410 The current pen is used for drawing the outline, and the current brush
f09b5681
BP
411 for filling the shape. Using a transparent brush suppresses filling.
412
23324ae1 413 The programmer is responsible for deleting the list of points.
f09b5681
BP
414
415 @beginWxPythonOnly
416 The wxPython version of this method accepts a Python list of wxPoint
417 objects.
418 @endWxPythonOnly
23324ae1 419 */
4cc4bfaf 420 void DrawPolygon(const wxPointList* points,
f09b5681 421 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 422 wxPolygonFillMode fill_style = wxODDEVEN_RULE);
f09b5681
BP
423
424 /**
425 Draws two or more filled polygons using an array of @a points, adding
426 the optional offset coordinates.
427
428 Notice that for the platforms providing a native implementation of this
429 function (Windows and PostScript-based wxDC currently), this is more
430 efficient than using DrawPolygon() in a loop.
431
432 @a n specifies the number of polygons to draw, the array @e count of
433 size @a n specifies the number of points in each of the polygons in the
434 @a points array.
435
436 The last argument specifies the fill rule: @b wxODDEVEN_RULE (the
437 default) or @b wxWINDING_RULE.
438
439 The current pen is used for drawing the outline, and the current brush
440 for filling the shape. Using a transparent brush suppresses filling.
441
442 The polygons maybe disjoint or overlapping. Each polygon specified in a
443 call to DrawPolyPolygon() must be closed. Unlike polygons created by
444 the DrawPolygon() member function, the polygons created by this
445 method are not closed automatically.
446
447 @beginWxPythonOnly
448 Not implemented yet.
449 @endWxPythonOnly
450 */
451 void DrawPolyPolygon(int n, int count[], wxPoint points[],
452 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 453 wxPolygonFillMode fill_style = wxODDEVEN_RULE);
23324ae1
FM
454
455 /**
456 Draws a rectangle with the given top left corner, and with the given
457 size. The current pen is used for the outline and the current brush
458 for filling the shape.
459 */
f09b5681 460 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
23324ae1
FM
461
462 /**
4cc4bfaf 463 Draws the text rotated by @a angle degrees.
f09b5681 464
1f1d2182 465 @note Under Win9x only TrueType fonts can be drawn by this function. In
f09b5681
BP
466 particular, a font different from @c wxNORMAL_FONT should be used
467 as the latter is not a TrueType font. @c wxSWISS_FONT is an
468 example of a font which is.
3c4f71cc 469
4cc4bfaf 470 @see DrawText()
23324ae1
FM
471 */
472 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
473 double angle);
474
475 /**
476 Draws a rectangle with the given top left corner, and with the given
f09b5681 477 size. The corners are quarter-circles using the given radius. The
23324ae1
FM
478 current pen is used for the outline and the current brush for filling
479 the shape.
f09b5681
BP
480
481 If @a radius is positive, the value is assumed to be the radius of the
482 rounded corner. If @a radius is negative, the absolute value is assumed
483 to be the @e proportion of the smallest dimension of the rectangle.
484 This means that the corner can be a sensible size relative to the size
485 of the rectangle, and also avoids the strange effects X produces when
486 the corners are too big for the rectangle.
23324ae1
FM
487 */
488 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width,
f09b5681 489 wxCoord height, double radius);
23324ae1
FM
490
491 //@{
492 /**
f09b5681
BP
493 Draws a spline between all given points using the current pen.
494
495 @beginWxPythonOnly
496 The wxPython version of this method accepts a Python list of wxPoint
497 objects.
498 @endWxPythonOnly
23324ae1
FM
499 */
500 void DrawSpline(int n, wxPoint points[]);
4cc4bfaf 501 void DrawSpline(const wxPointList* points);
f09b5681
BP
502 void DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
503 wxCoord x3, wxCoord y3);
23324ae1
FM
504 //@}
505
506 /**
f09b5681
BP
507 Draws a text string at the specified point, using the current text
508 font, and the current text foreground and background colours.
509
23324ae1 510 The coordinates refer to the top-left corner of the rectangle bounding
f09b5681
BP
511 the string. See GetTextExtent() for how to get the dimensions of a text
512 string, which can be used to position the text more precisely.
513
408776d0 514 @note The current @ref GetLogicalFunction() "logical function" is
e928566f 515 ignored by this function.
23324ae1
FM
516 */
517 void DrawText(const wxString& text, wxCoord x, wxCoord y);
518
519 /**
520 Ends a document (only relevant when outputting to a printer).
521 */
522 void EndDoc();
523
524 /**
525 Ends a document page (only relevant when outputting to a printer).
526 */
527 void EndPage();
528
529 /**
530 Flood fills the device context starting from the given point, using
f09b5681
BP
531 the current brush colour, and using a style:
532
533 - wxFLOOD_SURFACE: The flooding occurs until a colour other than the
534 given colour is encountered.
535 - wxFLOOD_BORDER: The area to be flooded is bounded by the given
536 colour.
537
d29a9a8a 538 @return @false if the operation failed.
f09b5681
BP
539
540 @note The present implementation for non-Windows platforms may fail to
541 find colour borders if the pixels do not match the colour
542 exactly. However the function will still return @true.
23324ae1
FM
543 */
544 bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour,
89efaf2b 545 wxFloodFillStyle style = wxFLOOD_SURFACE);
23324ae1
FM
546
547 /**
f09b5681
BP
548 Gets the brush used for painting the background.
549
550 @see wxDC::SetBackground()
23324ae1 551 */
b91c4601 552 const wxBrush& GetBackground() const;
23324ae1
FM
553
554 /**
555 Returns the current background mode: @c wxSOLID or @c wxTRANSPARENT.
3c4f71cc 556
4cc4bfaf 557 @see SetBackgroundMode()
23324ae1 558 */
328f5751 559 int GetBackgroundMode() const;
23324ae1
FM
560
561 /**
f09b5681
BP
562 Gets the current brush.
563
564 @see wxDC::SetBrush()
23324ae1 565 */
b91c4601 566 const wxBrush& GetBrush() const;
23324ae1
FM
567
568 /**
569 Gets the character height of the currently set font.
570 */
adaaa686 571 wxCoord GetCharHeight() const;
23324ae1
FM
572
573 /**
574 Gets the average character width of the currently set font.
575 */
adaaa686 576 wxCoord GetCharWidth() const;
23324ae1
FM
577
578 /**
579 Gets the rectangle surrounding the current clipping region.
f09b5681
BP
580
581 @beginWxPythonOnly
582 No arguments are required and the four values defining the rectangle
583 are returned as a tuple.
584 @endWxPythonOnly
23324ae1 585 */
408776d0 586 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height) const;
23324ae1
FM
587
588 /**
589 Returns the depth (number of bits/pixel) of this DC.
3c4f71cc 590
e54c96f1 591 @see wxDisplayDepth()
23324ae1 592 */
328f5751 593 int GetDepth() const;
23324ae1
FM
594
595 /**
f09b5681
BP
596 Gets the current font. Notice that even although each device context
597 object has some default font after creation, this method would return a
598 wxNullFont initially and only after calling SetFont() a valid font is
599 returned.
23324ae1 600 */
b91c4601 601 const wxFont& GetFont() const;
23324ae1
FM
602
603 /**
f09b5681
BP
604 Gets the current layout direction of the device context. On platforms
605 where RTL layout is supported, the return value will either be
606 @c wxLayout_LeftToRight or @c wxLayout_RightToLeft. If RTL layout is
607 not supported, the return value will be @c wxLayout_Default.
3c4f71cc 608
4cc4bfaf 609 @see SetLayoutDirection()
23324ae1 610 */
328f5751 611 wxLayoutDirection GetLayoutDirection() const;
23324ae1
FM
612
613 /**
f09b5681
BP
614 Gets the current logical function.
615
616 @see SetLogicalFunction()
23324ae1 617 */
89efaf2b 618 wxRasterOperationMode GetLogicalFunction() const;
23324ae1
FM
619
620 /**
f09b5681
BP
621 Gets the mapping mode for the device context.
622
623 @see SetMapMode()
23324ae1 624 */
89efaf2b 625 wxMappingMode GetMapMode() const;
23324ae1 626
23324ae1
FM
627 /**
628 Gets the dimensions of the string using the currently selected font.
4cc4bfaf 629 @a string is the text string to measure, @e heightLine, if non @NULL,
23324ae1 630 is where to store the height of a single line.
f09b5681
BP
631
632 The text extent is set in the given @a w and @a h pointers.
633
634 If the optional parameter @a font is specified and valid, then it is
635 used for the text extent calculation, otherwise the currently selected
636 font is used.
637
638 @note This function works with both single-line and multi-line strings.
3c4f71cc 639
4cc4bfaf 640 @see wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent()
23324ae1 641 */
4cc4bfaf
FM
642 void GetMultiLineTextExtent(const wxString& string, wxCoord* w,
643 wxCoord* h,
644 wxCoord* heightLine = NULL,
408776d0 645 const wxFont* font = NULL) const;
23324ae1 646 /**
f09b5681
BP
647 Gets the dimensions of the string using the currently selected font.
648 @a string is the text string to measure, @e heightLine, if non @NULL,
649 is where to store the height of a single line.
650
d29a9a8a 651 @return The text extent as a wxSize object.
f09b5681
BP
652
653 @note This function works with both single-line and multi-line strings.
654
655 @see wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent()
23324ae1 656 */
408776d0 657 wxSize GetMultiLineTextExtent(const wxString& string) const;
23324ae1
FM
658
659 /**
f09b5681
BP
660 Fills the @a widths array with the widths from the beginning of @a text
661 to the corresponding character of @a text. The generic version simply
662 builds a running total of the widths of each character using
663 GetTextExtent(), however if the various platforms have a native API
664 function that is faster or more accurate than the generic
665 implementation then it should be used instead.
666
667 @beginWxPythonOnly
668 This method only takes the @a text parameter and returns a Python list
669 of integers.
670 @endWxPythonOnly
3c4f71cc 671
4cc4bfaf 672 @see GetMultiLineTextExtent(), GetTextExtent()
23324ae1
FM
673 */
674 bool GetPartialTextExtents(const wxString& text,
328f5751 675 wxArrayInt& widths) const;
23324ae1
FM
676
677 /**
f09b5681
BP
678 Gets the current pen.
679
680 @see SetPen()
23324ae1 681 */
b91c4601 682 const wxPen& GetPen() const;
23324ae1
FM
683
684 /**
f09b5681
BP
685 Gets in @a colour the colour at the specified location. Not available
686 for wxPostScriptDC or wxMetafileDC.
687
688 @note Setting a pixel can be done using DrawPoint().
689
690 @beginWxPythonOnly
691 The wxColour value is returned and is not required as a parameter.
692 @endWxPythonOnly
23324ae1 693 */
adaaa686 694 bool GetPixel(wxCoord x, wxCoord y, wxColour* colour) const;
23324ae1 695
23324ae1 696 /**
f09b5681
BP
697 Returns the resolution of the device in pixels per inch.
698 */
699 wxSize GetPPI() const;
3c4f71cc 700
f09b5681
BP
701 //@{
702 /**
703 This gets the horizontal and vertical resolution in device units. It
704 can be used to scale graphics to fit the page.
3c4f71cc 705
f09b5681
BP
706 For example, if @e maxX and @e maxY represent the maximum horizontal
707 and vertical 'pixel' values used in your application, the following
708 code will scale the graphic to fit on the printer page:
3c4f71cc 709
f09b5681
BP
710 @code
711 wxCoord w, h;
712 dc.GetSize(&w, &h);
713 double scaleX = (double)(maxX / w);
714 double scaleY = (double)(maxY / h);
715 dc.SetUserScale(min(scaleX, scaleY),min(scaleX, scaleY));
716 @endcode
3c4f71cc 717
f09b5681
BP
718 @beginWxPythonOnly
719 In place of a single overloaded method name, wxPython implements the
720 following methods:
721 - GetSize() - Returns a wxSize.
722 - GetSizeWH() - Returns a 2-tuple (width, height).
723 @endWxPythonOnly
23324ae1 724 */
328f5751 725 void GetSize(wxCoord* width, wxCoord* height) const;
382f12e4 726 wxSize GetSize() const;
23324ae1
FM
727 //@}
728
729 //@{
730 /**
731 Returns the horizontal and vertical resolution in millimetres.
732 */
328f5751 733 void GetSizeMM(wxCoord* width, wxCoord* height) const;
382f12e4 734 wxSize GetSizeMM() const;
23324ae1
FM
735 //@}
736
737 /**
f09b5681
BP
738 Gets the current text background colour.
739
740 @see SetTextBackground()
23324ae1 741 */
b91c4601 742 const wxColour& GetTextBackground() const;
23324ae1
FM
743
744 //@{
745 /**
746 Gets the dimensions of the string using the currently selected font.
f09b5681
BP
747 @a string is the text string to measure, @a descent is the dimension
748 from the baseline of the font to the bottom of the descender, and
749 @a externalLeading is any extra vertical space added to the font by the
750 font designer (usually is zero).
751
752 The text extent is returned in @a w and @a h pointers or as a wxSize
753 object depending on which version of this function is used.
754
755 If the optional parameter @a font is specified and valid, then it is
756 used for the text extent calculation. Otherwise the currently selected
757 font is.
758
759 @note This function only works with single-line strings.
760
761 @beginWxPythonOnly
762 The following methods are implemented in wxPython:
763 - GetTextExtent(string) - Returns a 2-tuple, (width, height).
764 - GetFullTextExtent(string, font=NULL) -
765 Returns a 4-tuple, (width, height, descent, externalLeading).
766 @endWxPythonOnly
3c4f71cc 767
4cc4bfaf
FM
768 @see wxFont, SetFont(), GetPartialTextExtents(),
769 GetMultiLineTextExtent()
770 */
f09b5681 771 void GetTextExtent(const wxString& string, wxCoord* w, wxCoord* h,
4cc4bfaf
FM
772 wxCoord* descent = NULL,
773 wxCoord* externalLeading = NULL,
328f5751 774 const wxFont* font = NULL) const;
382f12e4 775 wxSize GetTextExtent(const wxString& string) const;
23324ae1
FM
776 //@}
777
778 /**
f09b5681
BP
779 Gets the current text foreground colour.
780
781 @see SetTextForeground()
23324ae1 782 */
b91c4601 783 const wxColour& GetTextForeground() const;
23324ae1
FM
784
785 /**
f09b5681
BP
786 Gets the current user scale factor.
787
788 @see SetUserScale()
23324ae1 789 */
b91c4601 790 void GetUserScale(double* x, double* y) const;
23324ae1
FM
791
792 //@{
793 /**
7c913512 794 Fill the area specified by rect with a radial gradient, starting from
f09b5681
BP
795 @a initialColour at the centre of the circle and fading to
796 @a destColour on the circle outside.
797
4cc4bfaf 798 @a circleCenter are the relative coordinates of centre of the circle in
f09b5681 799 the specified @e rect. If not specified, the circle is placed at the
23324ae1 800 centre of rect.
f09b5681
BP
801
802 @note Currently this function is very slow, don't use it for real-time
803 drawing.
23324ae1
FM
804 */
805 void GradientFillConcentric(const wxRect& rect,
806 const wxColour& initialColour,
807 const wxColour& destColour);
7c913512
FM
808 void GradientFillConcentric(const wxRect& rect,
809 const wxColour& initialColour,
810 const wxColour& destColour,
811 const wxPoint& circleCenter);
23324ae1
FM
812 //@}
813
814 /**
f09b5681
BP
815 Fill the area specified by @a rect with a linear gradient, starting
816 from @a initialColour and eventually fading to @e destColour. The
817 @a nDirection specifies the direction of the colour change, default is
818 to use @a initialColour on the left part of the rectangle and
4cc4bfaf 819 @a destColour on the right one.
23324ae1 820 */
b91c4601 821 void GradientFillLinear(const wxRect& rect, const wxColour& initialColour,
23324ae1 822 const wxColour& destColour,
b91c4601 823 wxDirection nDirection = wxRIGHT);
23324ae1
FM
824
825 /**
826 Returns @true if the DC is ok to use.
827 */
4ccf0566 828 bool IsOk() const;
23324ae1
FM
829
830 /**
831 Converts logical X coordinate to device coordinate, using the current
63408203 832 mapping mode, user scale factor, device origin and axis orientation.
23324ae1 833 */
adaaa686 834 wxCoord LogicalToDeviceX(wxCoord x) const;
23324ae1
FM
835
836 /**
f09b5681 837 Converts logical X coordinate to relative device coordinate, using the
63408203
VZ
838 current mapping mode and user scale factor but ignoring the
839 axis orientation. Use this for converting a width, for example.
23324ae1 840 */
adaaa686 841 wxCoord LogicalToDeviceXRel(wxCoord x) const;
23324ae1
FM
842
843 /**
844 Converts logical Y coordinate to device coordinate, using the current
63408203 845 mapping mode, user scale factor, device origin and axis orientation.
23324ae1 846 */
adaaa686 847 wxCoord LogicalToDeviceY(wxCoord y) const;
23324ae1
FM
848
849 /**
f09b5681 850 Converts logical Y coordinate to relative device coordinate, using the
63408203
VZ
851 current mapping mode and user scale factor but ignoring the
852 axis orientation. Use this for converting a height, for example.
23324ae1 853 */
adaaa686 854 wxCoord LogicalToDeviceYRel(wxCoord y) const;
23324ae1
FM
855
856 /**
857 Gets the maximum horizontal extent used in drawing commands so far.
858 */
adaaa686 859 wxCoord MaxX() const;
23324ae1
FM
860
861 /**
862 Gets the maximum vertical extent used in drawing commands so far.
863 */
adaaa686 864 wxCoord MaxY() const;
23324ae1
FM
865
866 /**
867 Gets the minimum horizontal extent used in drawing commands so far.
868 */
adaaa686 869 wxCoord MinX() const;
23324ae1
FM
870
871 /**
872 Gets the minimum vertical extent used in drawing commands so far.
873 */
adaaa686 874 wxCoord MinY() const;
23324ae1
FM
875
876 /**
f09b5681
BP
877 Resets the bounding box: after a call to this function, the bounding
878 box doesn't contain anything.
3c4f71cc 879
4cc4bfaf 880 @see CalcBoundingBox()
23324ae1
FM
881 */
882 void ResetBoundingBox();
883
884 /**
885 Sets the x and y axis orientation (i.e., the direction from lowest to
f09b5681
BP
886 highest values on the axis). The default orientation is x axis from
887 left to right and y axis from top down.
3c4f71cc 888
7c913512 889 @param xLeftRight
f09b5681
BP
890 True to set the x axis orientation to the natural left to right
891 orientation, @false to invert it.
7c913512 892 @param yBottomUp
f09b5681
BP
893 True to set the y axis orientation to the natural bottom up
894 orientation, @false to invert it.
23324ae1
FM
895 */
896 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
897
898 /**
899 Sets the current background brush for the DC.
900 */
901 void SetBackground(const wxBrush& brush);
902
903 /**
f09b5681
BP
904 @a mode may be one of wxSOLID and wxTRANSPARENT. This setting
905 determines whether text will be drawn with a background colour or not.
23324ae1
FM
906 */
907 void SetBackgroundMode(int mode);
908
909 /**
910 Sets the current brush for the DC.
f09b5681
BP
911
912 If the argument is wxNullBrush, the current brush is selected out of
913 the device context (leaving wxDC without any valid brush), allowing the
914 current brush to be destroyed safely.
915
916 @see wxBrush, wxMemoryDC (for the interpretation of colours when
917 drawing into a monochrome bitmap)
23324ae1
FM
918 */
919 void SetBrush(const wxBrush& brush);
920
921 //@{
922 /**
f09b5681
BP
923 Sets the clipping region for this device context to the intersection of
924 the given region described by the parameters of this method and the
925 previously set clipping region. You should call DestroyClippingRegion()
926 if you want to set the clipping region exactly to the region specified.
927
928 The clipping region is an area to which drawing is restricted. Possible
929 uses for the clipping region are for clipping text or for speeding up
930 window redraws when only a known area of the screen is damaged.
3c4f71cc 931
4cc4bfaf 932 @see DestroyClippingRegion(), wxRegion
23324ae1
FM
933 */
934 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width,
935 wxCoord height);
7c913512
FM
936 void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
937 void SetClippingRegion(const wxRect& rect);
23324ae1
FM
938 //@}
939
fdaad94e
VZ
940 /**
941 Sets the clipping region for this device context.
942
943 Unlike SetClippingRegion(), this function works with physical
944 coordinates and not with the logical ones.
945 */
946 void SetDeviceClippingRegion(const wxRegion& region);
947
23324ae1 948 /**
f09b5681
BP
949 Sets the device origin (i.e., the origin in pixels after scaling has
950 been applied). This function may be useful in Windows printing
23324ae1
FM
951 operations for placing a graphic on a page.
952 */
953 void SetDeviceOrigin(wxCoord x, wxCoord y);
954
955 /**
f09b5681
BP
956 Sets the current font for the DC. It must be a valid font, in
957 particular you should not pass wxNullFont to this method.
958
959 @see wxFont
23324ae1
FM
960 */
961 void SetFont(const wxFont& font);
962
963 /**
f09b5681
BP
964 Sets the current layout direction for the device context. @a dir may be
965 either @c wxLayout_Default, @c wxLayout_LeftToRight or
966 @c wxLayout_RightToLeft.
3c4f71cc 967
4cc4bfaf 968 @see GetLayoutDirection()
23324ae1
FM
969 */
970 void SetLayoutDirection(wxLayoutDirection dir);
971
972 /**
97929f6b
FM
973 Sets the current logical function for the device context.
974 It determines how a @e source pixel (from a pen or brush colour, or source
975 device context if using Blit()) combines with a @e destination pixel in
f09b5681 976 the current device context.
e928566f 977 Text drawing is not affected by this function.
f09b5681 978
97929f6b
FM
979 See ::wxRasterOperationMode enumeration values for more info.
980
981 The default is @c wxCOPY, which simply draws with the current colour.
982 The others combine the current colour and the background using a logical
983 operation. @c wxINVERT is commonly used for drawing rubber bands or moving
f09b5681 984 outlines, since drawing twice reverts to the original colour.
23324ae1 985 */
89efaf2b 986 void SetLogicalFunction(wxRasterOperationMode function);
23324ae1
FM
987
988 /**
f09b5681 989 The mapping mode of the device context defines the unit of measurement
97929f6b
FM
990 used to convert logical units to device units.
991
992 Note that in X, text drawing isn't handled consistently with the mapping mode;
993 a font is always specified in point size. However, setting the user scale (see
f09b5681
BP
994 SetUserScale()) scales the text appropriately. In Windows, scalable
995 TrueType fonts are always used; in X, results depend on availability of
996 fonts, but usually a reasonable match is found.
3c4f71cc 997
f09b5681 998 The coordinate origin is always at the top left of the screen/printer.
3c4f71cc 999
f09b5681
BP
1000 Drawing to a Windows printer device context uses the current mapping
1001 mode, but mapping mode is currently ignored for PostScript output.
23324ae1 1002 */
89efaf2b 1003 void SetMapMode(wxMappingMode mode);
23324ae1
FM
1004
1005 /**
f09b5681
BP
1006 If this is a window DC or memory DC, assigns the given palette to the
1007 window or bitmap associated with the DC. If the argument is
1008 wxNullPalette, the current palette is selected out of the device
1009 context, and the original palette restored.
1010
1011 @see wxPalette
23324ae1
FM
1012 */
1013 void SetPalette(const wxPalette& palette);
1014
1015 /**
f09b5681
BP
1016 Sets the current pen for the DC. If the argument is wxNullPen, the
1017 current pen is selected out of the device context (leaving wxDC without
1018 any valid pen), allowing the current brush to be destroyed safely.
1019
1020 @see wxMemoryDC for the interpretation of colours when drawing into a
1021 monochrome bitmap.
23324ae1
FM
1022 */
1023 void SetPen(const wxPen& pen);
1024
1025 /**
1026 Sets the current text background colour for the DC.
1027 */
1028 void SetTextBackground(const wxColour& colour);
1029
1030 /**
1031 Sets the current text foreground colour for the DC.
f09b5681
BP
1032
1033 @see wxMemoryDC for the interpretation of colours when drawing into a
1034 monochrome bitmap.
23324ae1
FM
1035 */
1036 void SetTextForeground(const wxColour& colour);
1037
1038 /**
1039 Sets the user scaling factor, useful for applications which require
1040 'zooming'.
1041 */
1042 void SetUserScale(double xScale, double yScale);
1043
1044 /**
1045 Starts a document (only relevant when outputting to a printer).
f09b5681 1046 @a message is a message to show while printing.
23324ae1
FM
1047 */
1048 bool StartDoc(const wxString& message);
1049
1050 /**
1051 Starts a document page (only relevant when outputting to a printer).
1052 */
b91c4601 1053 void StartPage();
23324ae1
FM
1054
1055 /**
1056 Copy from a source DC to this DC, specifying the destination
f09b5681
BP
1057 coordinates, destination size, source DC, source coordinates, size of
1058 source area to copy, logical function, whether to use a bitmap mask,
23324ae1 1059 and mask source position.
3c4f71cc 1060
7c913512 1061 @param xdest
4cc4bfaf 1062 Destination device context x position.
7c913512 1063 @param ydest
4cc4bfaf 1064 Destination device context y position.
7c913512 1065 @param dstWidth
4cc4bfaf 1066 Width of destination area.
7c913512 1067 @param dstHeight
4cc4bfaf 1068 Height of destination area.
7c913512 1069 @param source
4cc4bfaf 1070 Source device context.
7c913512 1071 @param xsrc
4cc4bfaf 1072 Source device context x position.
7c913512 1073 @param ysrc
4cc4bfaf 1074 Source device context y position.
7c913512 1075 @param srcWidth
4cc4bfaf 1076 Width of source area to be copied.
7c913512 1077 @param srcHeight
4cc4bfaf 1078 Height of source area to be copied.
7c913512 1079 @param logicalFunc
f09b5681 1080 Logical function to use, see SetLogicalFunction().
7c913512 1081 @param useMask
f09b5681
BP
1082 If @true, Blit does a transparent blit using the mask that is
1083 associated with the bitmap selected into the source device context.
1084 The Windows implementation does the following if MaskBlt cannot be
1085 used:
1086 <ol>
1087 <li>Creates a temporary bitmap and copies the destination area into
1088 it.</li>
1089 <li>Copies the source area into the temporary bitmap using the
1090 specified logical function.</li>
1091 <li>Sets the masked area in the temporary bitmap to BLACK by ANDing
1092 the mask bitmap with the temp bitmap with the foreground colour
1093 set to WHITE and the bg colour set to BLACK.</li>
1094 <li>Sets the unmasked area in the destination area to BLACK by
1095 ANDing the mask bitmap with the destination area with the
1096 foreground colour set to BLACK and the background colour set to
1097 WHITE.</li>
1098 <li>ORs the temporary bitmap with the destination area.</li>
1099 <li>Deletes the temporary bitmap.</li>
1100 </ol>
1101 This sequence of operations ensures that the source's transparent
1102 area need not be black, and logical functions are supported.
1103 @n @b Note: on Windows, blitting with masks can be speeded up
1104 considerably by compiling wxWidgets with the wxUSE_DC_CACHE option
1105 enabled. You can also influence whether MaskBlt or the explicit
1106 mask blitting code above is used, by using wxSystemOptions and
1107 setting the @c no-maskblt option to 1.
7c913512 1108 @param xsrcMask
f09b5681 1109 Source x position on the mask. If both xsrcMask and ysrcMask are
408776d0
FM
1110 wxDefaultCoord, @a xsrc and @a ysrc will be assumed for the mask
1111 source position. Currently only implemented on Windows.
7c913512 1112 @param ysrcMask
f09b5681 1113 Source y position on the mask. If both xsrcMask and ysrcMask are
408776d0
FM
1114 wxDefaultCoord, @a xsrc and @a ysrc will be assumed for the mask
1115 source position. Currently only implemented on Windows.
f09b5681
BP
1116
1117 There is partial support for Blit() in wxPostScriptDC, under X.
1118
1119 StretchBlit() is only implemented under wxMAC and wxMSW.
1120
1121 See wxMemoryDC for typical usage.
1122
1e24c2af 1123 @since 2.9.0
f09b5681
BP
1124
1125 @see Blit(), wxMemoryDC, wxBitmap, wxMask
1126 */
1127 bool StretchBlit(wxCoord xdest, wxCoord ydest,
1128 wxCoord dstWidth, wxCoord dstHeight,
1129 wxDC* source, wxCoord xsrc, wxCoord ysrc,
1130 wxCoord srcWidth, wxCoord srcHeight,
89efaf2b 1131 wxRasterOperationMode logicalFunc = wxCOPY,
4cc4bfaf 1132 bool useMask = false,
408776d0
FM
1133 wxCoord xsrcMask = wxDefaultCoord,
1134 wxCoord ysrcMask = wxDefaultCoord);
23324ae1
FM
1135};
1136
1137
e54c96f1 1138
23324ae1
FM
1139/**
1140 @class wxDCClipper
7c913512 1141
f09b5681
BP
1142 wxDCClipper is a small helper class for setting a clipping region on a wxDC
1143 and unsetting it automatically. An object of wxDCClipper class is typically
1144 created on the stack so that it is automatically destroyed when the object
1145 goes out of scope. A typical usage example:
7c913512 1146
23324ae1
FM
1147 @code
1148 void MyFunction(wxDC& dc)
f09b5681
BP
1149 {
1150 wxDCClipper clip(dc, rect);
1151 // ... drawing functions here are affected by clipping rect ...
1152 }
1153
1154 void OtherFunction()
1155 {
1156 wxDC dc;
1157 MyFunction(dc);
1158 // ... drawing functions here are not affected by clipping rect ...
1159 }
23324ae1 1160 @endcode
7c913512 1161
23324ae1
FM
1162 @library{wxcore}
1163 @category{gdi}
7c913512 1164
382f12e4
FM
1165 @see wxDC::SetClippingRegion(), wxDCFontChanger, wxDCTextColourChanger, wxDCPenChanger,
1166 wxDCBrushChanger
23324ae1 1167*/
7c913512 1168class wxDCClipper
23324ae1
FM
1169{
1170public:
1171 //@{
1172 /**
f09b5681
BP
1173 Sets the clipping region to the specified region/coordinates.
1174
23324ae1
FM
1175 The clipping region is automatically unset when this object is destroyed.
1176 */
1177 wxDCClipper(wxDC& dc, const wxRegion& r);
7c913512 1178 wxDCClipper(wxDC& dc, const wxRect& rect);
882678eb 1179 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h);
23324ae1 1180 //@}
c48d6cdf
FM
1181
1182 /**
1183 Destroys the clipping region associated with the DC passed to the ctor.
1184 */
1185 ~wxDCClipper();
1186};
1187
1188
1189/**
1190 @class wxDCBrushChanger
1191
1192 wxDCBrushChanger is a small helper class for setting a brush on a wxDC
1193 and unsetting it automatically in the destructor, restoring the previous one.
1194
1195 @library{wxcore}
1196 @category{gdi}
1197
382f12e4
FM
1198 @see wxDC::SetBrush(), wxDCFontChanger, wxDCTextColourChanger, wxDCPenChanger,
1199 wxDCClipper
c48d6cdf
FM
1200*/
1201class wxDCBrushChanger
1202{
1203public:
1204 /**
1205 Sets @a brush on the given @a dc, storing the old one.
1206
1207 @param dc
1208 The DC where the brush must be temporary set.
1209 @param brush
1210 The brush to set.
1211 */
1212 wxDCBrushChanger(wxDC& dc, const wxBrush& brush);
1213
1214 /**
1215 Restores the brush originally selected in the DC passed to the ctor.
1216 */
1217 ~wxDCBrushChanger();
1218};
1219
1220
1221/**
1222 @class wxDCPenChanger
1223
1224 wxDCPenChanger is a small helper class for setting a pen on a wxDC
1225 and unsetting it automatically in the destructor, restoring the previous one.
1226
1227 @library{wxcore}
1228 @category{gdi}
1229
382f12e4
FM
1230 @see wxDC::SetPen(), wxDCFontChanger, wxDCTextColourChanger, wxDCBrushChanger,
1231 wxDCClipper
c48d6cdf
FM
1232*/
1233class wxDCPenChanger
1234{
1235public:
1236 /**
1237 Sets @a pen on the given @a dc, storing the old one.
1238
1239 @param dc
1240 The DC where the pen must be temporary set.
1241 @param pen
1242 The pen to set.
1243 */
1244 wxDCPenChanger(wxDC& dc, const wxPen& pen);
1245
1246 /**
1247 Restores the pen originally selected in the DC passed to the ctor.
1248 */
1249 ~wxDCPenChanger();
1250};
1251
1252
1253
1254/**
1255 @class wxDCTextColourChanger
1256
1257 wxDCTextColourChanger is a small helper class for setting a foreground
1258 text colour on a wxDC and unsetting it automatically in the destructor,
1259 restoring the previous one.
1260
1261 @library{wxcore}
1262 @category{gdi}
1263
382f12e4
FM
1264 @see wxDC::SetTextForeground(), wxDCFontChanger, wxDCPenChanger, wxDCBrushChanger,
1265 wxDCClipper
c48d6cdf
FM
1266*/
1267class wxDCTextColourChanger
1268{
1269public:
1270 /**
1271 Sets @a col on the given @a dc, storing the old one.
1272
1273 @param dc
1274 The DC where the colour must be temporary set.
1275 @param col
1276 The colour to set.
1277 */
1278 wxDCTextColourChanger(wxDC& dc, const wxColour& col);
1279
1280 /**
1281 Restores the colour originally selected in the DC passed to the ctor.
1282 */
1283 ~wxDCTextColourChanger();
1284};
1285
1286
1287
1288/**
1289 @class wxDCFontChanger
1290
1291 wxDCFontChanger is a small helper class for setting a font on a wxDC and
1292 unsetting it automatically in the destructor, restoring the previous one.
1293
1294 @since 2.9.0
1295
1296 @library{wxcore}
1297 @category{gdi}
1298
382f12e4
FM
1299 @see wxDC::SetFont(), wxDCTextColourChanger, wxDCPenChanger, wxDCBrushChanger,
1300 wxDCClipper
c48d6cdf
FM
1301*/
1302class wxDCFontChanger
1303{
1304public:
1305 /**
1306 Sets @a font on the given @a dc, storing the old one.
1307
1308 @param dc
1309 The DC where the font must be temporary set.
1310 @param font
1311 The font to set.
1312 */
1313 wxDCFontChanger(wxDC& dc, const wxFont& font);
1314
1315 /**
1316 Restores the colour originally selected in the DC passed to the ctor.
1317 */
1318 ~wxDCFontChanger();
23324ae1 1319};
e54c96f1 1320