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