]>
Commit | Line | Data |
---|---|---|
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 | */ | |
19 | enum 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 | */ | |
42 | enum 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 | /** | |
e65a6cc1 FM |
52 | The mapping used to transform @e logical units to @e device units. |
53 | See wxDC::SetMapMode. | |
97929f6b FM |
54 | */ |
55 | enum wxMappingMode | |
56 | { | |
e65a6cc1 FM |
57 | /** |
58 | Each logical unit is 1 device pixel. | |
59 | This is the default mapping mode for all wxDC-derived classes. | |
60 | */ | |
97929f6b FM |
61 | wxMM_TEXT = 1, |
62 | ||
e65a6cc1 FM |
63 | /** Each logical unit is 1 millimeter. */ |
64 | wxMM_METRIC, | |
97929f6b | 65 | |
e65a6cc1 FM |
66 | /** Each logical unit is 1/10 of a millimeter. */ |
67 | wxMM_LOMETRIC, | |
97929f6b | 68 | |
e65a6cc1 FM |
69 | /** |
70 | Each logical unit is 1/20 of a @e "printer point", or 1/1440 of an inch | |
71 | (also known as "twip"). Equivalent to about 17.64 micrometers. | |
72 | */ | |
97929f6b FM |
73 | wxMM_TWIPS, |
74 | ||
e65a6cc1 FM |
75 | /** |
76 | Each logical unit is a @e "printer point" i.e. 1/72 of an inch. | |
77 | Equivalent to about 353 micrometers. | |
78 | */ | |
79 | wxMM_POINTS | |
80 | }; | |
97929f6b | 81 | |
97929f6b | 82 | |
97929f6b | 83 | |
23324ae1 FM |
84 | /** |
85 | @class wxDC | |
7c913512 | 86 | |
f09b5681 | 87 | A wxDC is a @e "device context" onto which graphics and text can be drawn. |
318b0bd5 RR |
88 | It is intended to represent different output devices and offers a common |
89 | abstract API for drawing on any of them. | |
edc51344 | 90 | |
318b0bd5 | 91 | wxWidgets offers an alternative drawing API based on the modern drawing |
12133c3b | 92 | backends GDI+, CoreGraphics and Cairo. See wxGraphicsContext, wxGraphicsRenderer |
6d99a337 RR |
93 | and related classes. There is also a wxGCDC linking the APIs by offering |
94 | the wxDC API ontop of a wxGraphicsContext. | |
7c913512 | 95 | |
318b0bd5 RR |
96 | wxDC is an abstract base class and cannot be created directly. |
97 | Use wxPaintDC, wxClientDC, wxWindowDC, wxScreenDC, wxMemoryDC or | |
edc51344 VZ |
98 | wxPrinterDC. Notice that device contexts which are associated with windows |
99 | (i.e. wxClientDC, wxWindowDC and wxPaintDC) use the window font and colours | |
100 | by default (starting with wxWidgets 2.9.0) but the other device context | |
101 | classes use system-default values so you always must set the appropriate | |
102 | fonts and colours before using them. | |
f09b5681 | 103 | |
318b0bd5 RR |
104 | In addition to the versions of the methods documented below, there |
105 | are also versions which accept single wxPoint parameter instead | |
106 | of the two wxCoord ones or wxPoint and wxSize instead of the four | |
107 | wxCoord parameters. | |
f09b5681 | 108 | |
318b0bd5 RR |
109 | Beginning with wxWidgets 2.9.0 the entire wxDC code has been |
110 | reorganized. All platform dependent code (actually all drawing code) | |
111 | has been moved into backend classes which derive from a common | |
112 | wxDCImpl class. The user-visible classes such as wxClientDC and | |
113 | wxPaintDC merely forward all calls to the backend implementation. | |
f09b5681 | 114 | |
e65a6cc1 FM |
115 | |
116 | @section dc_units Device and logical units | |
117 | ||
118 | In the wxDC context there is a distinction between @e logical units and @e device units. | |
119 | ||
120 | @b Device units are the units native to the particular device; e.g. for a screen, | |
121 | a device unit is a @e pixel. For a printer, the device unit is defined by the | |
122 | resolution of the printer (usually given in @c DPI: dot-per-inch). | |
123 | ||
124 | All wxDC functions use instead @b logical units, unless where explicitely | |
125 | stated. Logical units are arbitrary units mapped to device units using | |
126 | the current mapping mode (see wxDC::SetMapMode). | |
127 | ||
128 | This mechanism allows to reuse the same code which prints on e.g. a window | |
129 | on the screen to print on e.g. a paper. | |
130 | ||
131 | ||
e3995493 FM |
132 | @section dc_alpha_support Support for Transparency / Alpha Channel |
133 | ||
134 | On Mac OS X colours with alpha channel are supported. Instances of wxPen | |
135 | or wxBrush that are built from wxColour use the colour's alpha values | |
136 | when stroking or filling. | |
137 | ||
138 | ||
23324ae1 | 139 | @library{wxcore} |
c0cc7004 | 140 | @category{dc,gdi} |
7c913512 | 141 | |
382f12e4 FM |
142 | @see @ref overview_dc, wxGraphicsContext, wxDCFontChanger, wxDCTextColourChanger, |
143 | wxDCPenChanger, wxDCBrushChanger, wxDCClipper | |
f09b5681 BP |
144 | |
145 | @todo Precise definition of default/initial state. | |
146 | @todo Pixelwise definition of operations (e.g. last point of a line not | |
147 | drawn). | |
23324ae1 FM |
148 | */ |
149 | class wxDC : public wxObject | |
150 | { | |
151 | public: | |
152 | /** | |
e3995493 | 153 | @name Coordinate conversion functions |
23324ae1 | 154 | */ |
e3995493 | 155 | //@{ |
23324ae1 FM |
156 | |
157 | /** | |
e3995493 FM |
158 | Convert @e device X coordinate to logical coordinate, using the current |
159 | mapping mode, user scale factor, device origin and axis orientation. | |
23324ae1 | 160 | */ |
e3995493 | 161 | wxCoord DeviceToLogicalX(wxCoord x) const; |
23324ae1 FM |
162 | |
163 | /** | |
e3995493 FM |
164 | Convert @e device X coordinate to relative logical coordinate, using the |
165 | current mapping mode and user scale factor but ignoring the | |
166 | axis orientation. Use this for converting a width, for example. | |
23324ae1 | 167 | */ |
e3995493 | 168 | wxCoord DeviceToLogicalXRel(wxCoord x) const; |
23324ae1 | 169 | |
23324ae1 | 170 | /** |
e3995493 FM |
171 | Converts @e device Y coordinate to logical coordinate, using the current |
172 | mapping mode, user scale factor, device origin and axis orientation. | |
23324ae1 | 173 | */ |
e3995493 | 174 | wxCoord DeviceToLogicalY(wxCoord y) const; |
23324ae1 FM |
175 | |
176 | /** | |
e3995493 FM |
177 | Convert @e device Y coordinate to relative logical coordinate, using the |
178 | current mapping mode and user scale factor but ignoring the | |
179 | axis orientation. Use this for converting a height, for example. | |
23324ae1 | 180 | */ |
e3995493 | 181 | wxCoord DeviceToLogicalYRel(wxCoord y) const; |
23324ae1 FM |
182 | |
183 | /** | |
e3995493 | 184 | Converts logical X coordinate to device coordinate, using the current |
63408203 | 185 | mapping mode, user scale factor, device origin and axis orientation. |
23324ae1 | 186 | */ |
e3995493 | 187 | wxCoord LogicalToDeviceX(wxCoord x) const; |
23324ae1 FM |
188 | |
189 | /** | |
e3995493 | 190 | Converts logical X coordinate to relative device coordinate, using the |
63408203 VZ |
191 | current mapping mode and user scale factor but ignoring the |
192 | axis orientation. Use this for converting a width, for example. | |
23324ae1 | 193 | */ |
e3995493 | 194 | wxCoord LogicalToDeviceXRel(wxCoord x) const; |
23324ae1 FM |
195 | |
196 | /** | |
e3995493 | 197 | Converts logical Y coordinate to device coordinate, using the current |
63408203 | 198 | mapping mode, user scale factor, device origin and axis orientation. |
23324ae1 | 199 | */ |
e3995493 | 200 | wxCoord LogicalToDeviceY(wxCoord y) const; |
23324ae1 FM |
201 | |
202 | /** | |
e3995493 | 203 | Converts logical Y coordinate to relative device coordinate, using the |
63408203 VZ |
204 | current mapping mode and user scale factor but ignoring the |
205 | axis orientation. Use this for converting a height, for example. | |
23324ae1 | 206 | */ |
e3995493 FM |
207 | wxCoord LogicalToDeviceYRel(wxCoord y) const; |
208 | ||
209 | //@} | |
210 | ||
211 | ||
212 | ||
213 | /** | |
214 | @name Drawing functions | |
215 | */ | |
216 | //@{ | |
217 | ||
218 | /** | |
219 | Clears the device context using the current background brush. | |
220 | */ | |
221 | void Clear(); | |
23324ae1 FM |
222 | |
223 | /** | |
f09b5681 | 224 | Draws an arc of a circle, centred on (@a xc, @a yc), with starting |
12194090 FM |
225 | point (@a xStart, @a yStart) and ending at (@a xEnd, @a yEnd). |
226 | The current pen is used for the outline and the current brush for | |
227 | filling the shape. | |
f09b5681 BP |
228 | |
229 | The arc is drawn in a counter-clockwise direction from the start point | |
230 | to the end point. | |
23324ae1 | 231 | */ |
12194090 | 232 | void DrawArc(wxCoord xStart, wxCoord yStart, wxCoord xEnd, wxCoord yEnd, |
e3995493 | 233 | wxCoord xc, wxCoord yc); |
23324ae1 | 234 | |
83b4d26c VZ |
235 | /** |
236 | @overload | |
237 | */ | |
12194090 | 238 | void DrawArc(const wxPoint& ptStart, const wxPoint& ptEnd, const wxPoint& centre); |
83b4d26c | 239 | |
23324ae1 | 240 | /** |
f09b5681 BP |
241 | Draw a bitmap on the device context at the specified point. If |
242 | @a transparent is @true and the bitmap has a transparency mask, the | |
243 | bitmap will be drawn transparently. | |
244 | ||
245 | When drawing a mono-bitmap, the current text foreground colour will be | |
246 | used to draw the foreground of the bitmap (all bits set to 1), and the | |
247 | current text background colour to draw the background (all bits set to | |
248 | 0). | |
249 | ||
250 | @see SetTextForeground(), SetTextBackground(), wxMemoryDC | |
23324ae1 FM |
251 | */ |
252 | void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, | |
408776d0 | 253 | bool useMask = false); |
23324ae1 | 254 | |
83b4d26c VZ |
255 | /** |
256 | @overload | |
257 | */ | |
258 | void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, | |
259 | bool useMask = false); | |
260 | ||
23324ae1 FM |
261 | /** |
262 | Draws a check mark inside the given rectangle. | |
263 | */ | |
f09b5681 | 264 | void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
e3995493 FM |
265 | |
266 | /** | |
267 | @overload | |
268 | */ | |
4cc4bfaf | 269 | void DrawCheckMark(const wxRect& rect); |
23324ae1 | 270 | |
23324ae1 FM |
271 | /** |
272 | Draws a circle with the given centre and radius. | |
3c4f71cc | 273 | |
4cc4bfaf | 274 | @see DrawEllipse() |
23324ae1 FM |
275 | */ |
276 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); | |
e3995493 FM |
277 | |
278 | /** | |
279 | @overload | |
280 | */ | |
7c913512 | 281 | void DrawCircle(const wxPoint& pt, wxCoord radius); |
23324ae1 | 282 | |
23324ae1 | 283 | /** |
f09b5681 BP |
284 | Draws an ellipse contained in the rectangle specified either with the |
285 | given top left corner and the given size or directly. The current pen | |
286 | is used for the outline and the current brush for filling the shape. | |
3c4f71cc | 287 | |
4cc4bfaf | 288 | @see DrawCircle() |
23324ae1 | 289 | */ |
f09b5681 | 290 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
e3995493 FM |
291 | |
292 | /** | |
293 | @overload | |
294 | */ | |
7c913512 | 295 | void DrawEllipse(const wxPoint& pt, const wxSize& size); |
e3995493 FM |
296 | |
297 | /** | |
298 | @overload | |
299 | */ | |
7c913512 | 300 | void DrawEllipse(const wxRect& rect); |
23324ae1 FM |
301 | |
302 | /** | |
f09b5681 BP |
303 | Draws an arc of an ellipse. The current pen is used for drawing the arc |
304 | and the current brush is used for drawing the pie. | |
305 | ||
306 | @a x and @a y specify the x and y coordinates of the upper-left corner | |
307 | of the rectangle that contains the ellipse. | |
308 | ||
309 | @a width and @a height specify the width and height of the rectangle | |
310 | that contains the ellipse. | |
311 | ||
312 | @a start and @a end specify the start and end of the arc relative to | |
313 | the three-o'clock position from the center of the rectangle. Angles are | |
314 | specified in degrees (360 is a complete circle). Positive values mean | |
315 | counter-clockwise motion. If @a start is equal to @e end, a complete | |
316 | ellipse will be drawn. | |
23324ae1 | 317 | */ |
f09b5681 BP |
318 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height, |
319 | double start, double end); | |
23324ae1 | 320 | |
83b4d26c VZ |
321 | /** |
322 | @overload | |
323 | */ | |
324 | void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, | |
325 | double sa, double ea); | |
326 | ||
23324ae1 | 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 | ||
83b4d26c VZ |
334 | /** |
335 | @overload | |
336 | */ | |
337 | void DrawIcon(const wxIcon& icon, const wxPoint& pt); | |
338 | ||
23324ae1 | 339 | /** |
f09b5681 BP |
340 | Draw optional bitmap and the text into the given rectangle and aligns |
341 | it as specified by alignment parameter; it also will emphasize the | |
342 | character with the given index if it is != -1 and return the bounding | |
343 | rectangle if required. | |
23324ae1 | 344 | */ |
882678eb FM |
345 | void DrawLabel(const wxString& text, const wxBitmap& image, |
346 | const wxRect& rect, | |
347 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
348 | int indexAccel = -1, wxRect* rectBounding = NULL); | |
e3995493 FM |
349 | |
350 | /** | |
351 | @overload | |
352 | */ | |
7c913512 FM |
353 | void DrawLabel(const wxString& text, const wxRect& rect, |
354 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
355 | int indexAccel = -1); | |
23324ae1 FM |
356 | |
357 | /** | |
f09b5681 BP |
358 | Draws a line from the first point to the second. The current pen is |
359 | used for drawing the line. Note that the point (@a x2, @a y2) is not | |
360 | part of the line and is not drawn by this function (this is consistent | |
361 | with the behaviour of many other toolkits). | |
23324ae1 FM |
362 | */ |
363 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
364 | ||
83b4d26c VZ |
365 | /** |
366 | @overload | |
367 | */ | |
368 | void DrawLine(const wxPoint& pt1, const wxPoint& pt2); | |
369 | ||
23324ae1 | 370 | /** |
f09b5681 BP |
371 | Draws lines using an array of points of size @a n adding the optional |
372 | offset coordinate. The current pen is used for drawing the lines. | |
373 | ||
374 | @beginWxPythonOnly | |
375 | The wxPython version of this method accepts a Python list of wxPoint | |
376 | objects. | |
377 | @endWxPythonOnly | |
1058f652 MB |
378 | |
379 | @beginWxPerlOnly | |
380 | Not supported by wxPerl. | |
381 | @endWxPerlOnly | |
23324ae1 FM |
382 | */ |
383 | void DrawLines(int n, wxPoint points[], wxCoord xoffset = 0, | |
384 | wxCoord yoffset = 0); | |
f09b5681 BP |
385 | /** |
386 | This method uses a list of wxPoints, adding the optional offset | |
387 | coordinate. The programmer is responsible for deleting the list of | |
388 | points. | |
389 | ||
390 | @beginWxPythonOnly | |
391 | The wxPython version of this method accepts a Python list of wxPoint | |
392 | objects. | |
393 | @endWxPythonOnly | |
1058f652 MB |
394 | |
395 | @beginWxPerlOnly | |
396 | The wxPerl version of this method accepts | |
397 | as its first parameter a reference to an array | |
398 | of wxPoint objects. | |
399 | @endWxPerlOnly | |
f09b5681 | 400 | */ |
4cc4bfaf | 401 | void DrawLines(const wxPointList* points, |
f09b5681 | 402 | wxCoord xoffset = 0, wxCoord yoffset = 0); |
23324ae1 FM |
403 | |
404 | /** | |
405 | Draws a point using the color of the current pen. Note that the other | |
f09b5681 | 406 | properties of the pen are not used, such as width. |
23324ae1 FM |
407 | */ |
408 | void DrawPoint(wxCoord x, wxCoord y); | |
409 | ||
83b4d26c VZ |
410 | /** |
411 | @overload | |
412 | */ | |
413 | void DrawPoint(const wxPoint& pt); | |
414 | ||
23324ae1 | 415 | /** |
f09b5681 BP |
416 | Draws a filled polygon using an array of points of size @a n, adding |
417 | the optional offset coordinate. The first and last points are | |
418 | automatically closed. | |
23324ae1 | 419 | |
f09b5681 BP |
420 | The last argument specifies the fill rule: @b wxODDEVEN_RULE (the |
421 | default) or @b wxWINDING_RULE. | |
422 | ||
423 | The current pen is used for drawing the outline, and the current brush | |
424 | for filling the shape. Using a transparent brush suppresses filling. | |
1058f652 MB |
425 | |
426 | @beginWxPerlOnly | |
427 | Not supported by wxPerl. | |
428 | @endWxPerlOnly | |
f09b5681 BP |
429 | */ |
430 | void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, | |
89efaf2b FM |
431 | wxCoord yoffset = 0, |
432 | wxPolygonFillMode fill_style = wxODDEVEN_RULE); | |
23324ae1 | 433 | /** |
f09b5681 BP |
434 | This method draws a filled polygon using a list of wxPoints, adding the |
435 | optional offset coordinate. The first and last points are automatically | |
436 | closed. | |
437 | ||
23324ae1 FM |
438 | The last argument specifies the fill rule: @b wxODDEVEN_RULE (the |
439 | default) or @b wxWINDING_RULE. | |
f09b5681 | 440 | |
23324ae1 | 441 | The current pen is used for drawing the outline, and the current brush |
f09b5681 BP |
442 | for filling the shape. Using a transparent brush suppresses filling. |
443 | ||
23324ae1 | 444 | The programmer is responsible for deleting the list of points. |
f09b5681 BP |
445 | |
446 | @beginWxPythonOnly | |
447 | The wxPython version of this method accepts a Python list of wxPoint | |
448 | objects. | |
449 | @endWxPythonOnly | |
1058f652 MB |
450 | |
451 | @beginWxPerlOnly | |
452 | The wxPerl version of this method accepts | |
453 | as its first parameter a reference to an array | |
454 | of wxPoint objects. | |
455 | @endWxPerlOnly | |
23324ae1 | 456 | */ |
4cc4bfaf | 457 | void DrawPolygon(const wxPointList* points, |
f09b5681 | 458 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
89efaf2b | 459 | wxPolygonFillMode fill_style = wxODDEVEN_RULE); |
f09b5681 BP |
460 | |
461 | /** | |
462 | Draws two or more filled polygons using an array of @a points, adding | |
463 | the optional offset coordinates. | |
464 | ||
465 | Notice that for the platforms providing a native implementation of this | |
466 | function (Windows and PostScript-based wxDC currently), this is more | |
467 | efficient than using DrawPolygon() in a loop. | |
468 | ||
469 | @a n specifies the number of polygons to draw, the array @e count of | |
470 | size @a n specifies the number of points in each of the polygons in the | |
471 | @a points array. | |
472 | ||
473 | The last argument specifies the fill rule: @b wxODDEVEN_RULE (the | |
474 | default) or @b wxWINDING_RULE. | |
475 | ||
476 | The current pen is used for drawing the outline, and the current brush | |
477 | for filling the shape. Using a transparent brush suppresses filling. | |
478 | ||
479 | The polygons maybe disjoint or overlapping. Each polygon specified in a | |
480 | call to DrawPolyPolygon() must be closed. Unlike polygons created by | |
481 | the DrawPolygon() member function, the polygons created by this | |
482 | method are not closed automatically. | |
483 | ||
484 | @beginWxPythonOnly | |
485 | Not implemented yet. | |
486 | @endWxPythonOnly | |
487 | */ | |
488 | void DrawPolyPolygon(int n, int count[], wxPoint points[], | |
489 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
89efaf2b | 490 | wxPolygonFillMode fill_style = wxODDEVEN_RULE); |
23324ae1 FM |
491 | |
492 | /** | |
493 | Draws a rectangle with the given top left corner, and with the given | |
494 | size. The current pen is used for the outline and the current brush | |
495 | for filling the shape. | |
496 | */ | |
f09b5681 | 497 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
23324ae1 | 498 | |
83b4d26c VZ |
499 | /** |
500 | @overload | |
501 | */ | |
502 | void DrawRectangle(const wxPoint& pt, const wxSize& sz); | |
503 | ||
504 | /** | |
505 | @overload | |
506 | */ | |
507 | void DrawRectangle(const wxRect& rect); | |
508 | ||
23324ae1 | 509 | /** |
aff647c1 FM |
510 | Draws the text rotated by @a angle degrees |
511 | (positive angles are counterclockwise; the full angle is 360 degrees). | |
f09b5681 | 512 | |
1f1d2182 | 513 | @note Under Win9x only TrueType fonts can be drawn by this function. In |
f09b5681 BP |
514 | particular, a font different from @c wxNORMAL_FONT should be used |
515 | as the latter is not a TrueType font. @c wxSWISS_FONT is an | |
516 | example of a font which is. | |
3c4f71cc | 517 | |
4cc4bfaf | 518 | @see DrawText() |
23324ae1 FM |
519 | */ |
520 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
521 | double angle); | |
522 | ||
83b4d26c VZ |
523 | /** |
524 | @overload | |
525 | */ | |
526 | void DrawRotatedText(const wxString& text, const wxPoint&, | |
527 | double angle); | |
528 | ||
23324ae1 FM |
529 | /** |
530 | Draws a rectangle with the given top left corner, and with the given | |
f09b5681 | 531 | size. The corners are quarter-circles using the given radius. The |
23324ae1 FM |
532 | current pen is used for the outline and the current brush for filling |
533 | the shape. | |
f09b5681 BP |
534 | |
535 | If @a radius is positive, the value is assumed to be the radius of the | |
536 | rounded corner. If @a radius is negative, the absolute value is assumed | |
537 | to be the @e proportion of the smallest dimension of the rectangle. | |
538 | This means that the corner can be a sensible size relative to the size | |
539 | of the rectangle, and also avoids the strange effects X produces when | |
540 | the corners are too big for the rectangle. | |
23324ae1 FM |
541 | */ |
542 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, | |
f09b5681 | 543 | wxCoord height, double radius); |
23324ae1 | 544 | |
83b4d26c VZ |
545 | /** |
546 | @overload | |
547 | */ | |
548 | void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, | |
549 | double radius); | |
550 | ||
551 | /** | |
552 | @overload | |
553 | */ | |
554 | void DrawRoundedRectangle(const wxRect& rect, double radius); | |
555 | ||
23324ae1 | 556 | /** |
f09b5681 BP |
557 | Draws a spline between all given points using the current pen. |
558 | ||
559 | @beginWxPythonOnly | |
560 | The wxPython version of this method accepts a Python list of wxPoint | |
561 | objects. | |
562 | @endWxPythonOnly | |
1058f652 MB |
563 | |
564 | @beginWxPerlOnly | |
565 | Not supported by wxPerl. | |
566 | @endWxPerlOnly | |
23324ae1 FM |
567 | */ |
568 | void DrawSpline(int n, wxPoint points[]); | |
e3995493 FM |
569 | |
570 | /** | |
571 | @overload | |
1058f652 MB |
572 | |
573 | ||
574 | @beginWxPerlOnly | |
575 | The wxPerl version of this method accepts | |
576 | as its first parameter a reference to an array | |
577 | of wxPoint objects. | |
578 | @endWxPerlOnly | |
e3995493 | 579 | */ |
4cc4bfaf | 580 | void DrawSpline(const wxPointList* points); |
e3995493 FM |
581 | |
582 | /** | |
583 | @overload | |
1058f652 MB |
584 | |
585 | ||
586 | @beginWxPerlOnly | |
587 | Not supported by wxPerl. | |
588 | @endWxPerlOnly | |
e3995493 | 589 | */ |
f09b5681 BP |
590 | void DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, |
591 | wxCoord x3, wxCoord y3); | |
23324ae1 FM |
592 | |
593 | /** | |
f09b5681 BP |
594 | Draws a text string at the specified point, using the current text |
595 | font, and the current text foreground and background colours. | |
596 | ||
23324ae1 | 597 | The coordinates refer to the top-left corner of the rectangle bounding |
f09b5681 BP |
598 | the string. See GetTextExtent() for how to get the dimensions of a text |
599 | string, which can be used to position the text more precisely. | |
600 | ||
408776d0 | 601 | @note The current @ref GetLogicalFunction() "logical function" is |
e928566f | 602 | ignored by this function. |
23324ae1 FM |
603 | */ |
604 | void DrawText(const wxString& text, wxCoord x, wxCoord y); | |
605 | ||
83b4d26c VZ |
606 | /** |
607 | @overload | |
608 | */ | |
609 | void DrawText(const wxString& text, const wxPoint& pt); | |
610 | ||
23324ae1 | 611 | /** |
e3995493 FM |
612 | Fill the area specified by rect with a radial gradient, starting from |
613 | @a initialColour at the centre of the circle and fading to | |
614 | @a destColour on the circle outside. | |
615 | ||
616 | The circle is placed at the centre of @a rect. | |
617 | ||
618 | @note Currently this function is very slow, don't use it for real-time | |
619 | drawing. | |
23324ae1 | 620 | */ |
e3995493 FM |
621 | void GradientFillConcentric(const wxRect& rect, |
622 | const wxColour& initialColour, | |
623 | const wxColour& destColour); | |
23324ae1 FM |
624 | |
625 | /** | |
e3995493 FM |
626 | Fill the area specified by rect with a radial gradient, starting from |
627 | @a initialColour at the centre of the circle and fading to | |
628 | @a destColour on the circle outside. | |
629 | ||
630 | @a circleCenter are the relative coordinates of centre of the circle in | |
631 | the specified @a rect. | |
632 | ||
633 | @note Currently this function is very slow, don't use it for real-time | |
634 | drawing. | |
23324ae1 | 635 | */ |
e3995493 FM |
636 | void GradientFillConcentric(const wxRect& rect, |
637 | const wxColour& initialColour, | |
638 | const wxColour& destColour, | |
639 | const wxPoint& circleCenter); | |
640 | ||
641 | /** | |
642 | Fill the area specified by @a rect with a linear gradient, starting | |
643 | from @a initialColour and eventually fading to @e destColour. | |
644 | ||
645 | The @a nDirection specifies the direction of the colour change, default is | |
646 | to use @a initialColour on the left part of the rectangle and | |
647 | @a destColour on the right one. | |
648 | */ | |
649 | void GradientFillLinear(const wxRect& rect, const wxColour& initialColour, | |
650 | const wxColour& destColour, | |
651 | wxDirection nDirection = wxRIGHT); | |
23324ae1 FM |
652 | |
653 | /** | |
654 | Flood fills the device context starting from the given point, using | |
f09b5681 BP |
655 | the current brush colour, and using a style: |
656 | ||
657 | - wxFLOOD_SURFACE: The flooding occurs until a colour other than the | |
658 | given colour is encountered. | |
659 | - wxFLOOD_BORDER: The area to be flooded is bounded by the given | |
660 | colour. | |
661 | ||
d29a9a8a | 662 | @return @false if the operation failed. |
f09b5681 BP |
663 | |
664 | @note The present implementation for non-Windows platforms may fail to | |
665 | find colour borders if the pixels do not match the colour | |
666 | exactly. However the function will still return @true. | |
23324ae1 FM |
667 | */ |
668 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, | |
89efaf2b | 669 | wxFloodFillStyle style = wxFLOOD_SURFACE); |
23324ae1 | 670 | |
83b4d26c VZ |
671 | /** |
672 | @overload | |
673 | */ | |
674 | bool FloodFill(const wxPoint& pt, const wxColour& col, | |
675 | int style = wxFLOOD_SURFACE); | |
676 | ||
23324ae1 | 677 | /** |
e3995493 FM |
678 | Displays a cross hair using the current pen. This is a vertical and |
679 | horizontal line the height and width of the window, centred on the | |
680 | given point. | |
23324ae1 | 681 | */ |
e3995493 | 682 | void CrossHair(wxCoord x, wxCoord y); |
23324ae1 | 683 | |
83b4d26c VZ |
684 | /** |
685 | @overload | |
686 | */ | |
687 | void CrossHair(const wxPoint& pt); | |
688 | ||
e3995493 | 689 | //@} |
3c4f71cc | 690 | |
23324ae1 FM |
691 | |
692 | /** | |
e3995493 | 693 | @name Clipping region functions |
23324ae1 | 694 | */ |
e3995493 | 695 | //@{ |
23324ae1 FM |
696 | |
697 | /** | |
e3995493 | 698 | Destroys the current clipping region so that none of the DC is clipped. |
23324ae1 | 699 | |
e3995493 | 700 | @see SetClippingRegion() |
23324ae1 | 701 | */ |
e3995493 | 702 | void DestroyClippingRegion(); |
23324ae1 FM |
703 | |
704 | /** | |
705 | Gets the rectangle surrounding the current clipping region. | |
f09b5681 BP |
706 | |
707 | @beginWxPythonOnly | |
708 | No arguments are required and the four values defining the rectangle | |
709 | are returned as a tuple. | |
710 | @endWxPythonOnly | |
23324ae1 | 711 | */ |
408776d0 | 712 | void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height) const; |
23324ae1 FM |
713 | |
714 | /** | |
e3995493 FM |
715 | Sets the clipping region for this device context to the intersection of |
716 | the given region described by the parameters of this method and the | |
3821ccfa | 717 | previously set clipping region. |
3c4f71cc | 718 | |
e3995493 FM |
719 | The clipping region is an area to which drawing is restricted. Possible |
720 | uses for the clipping region are for clipping text or for speeding up | |
721 | window redraws when only a known area of the screen is damaged. | |
23324ae1 | 722 | |
3821ccfa VZ |
723 | Notice that you need to call DestroyClippingRegion() if you want to set |
724 | the clipping region exactly to the region specified. | |
725 | ||
726 | Also note that if the clipping region is empty, any previously set | |
727 | clipping region is destroyed, i.e. it is equivalent to calling | |
728 | DestroyClippingRegion(), and not to clipping out all drawing on the DC | |
729 | as might be expected. | |
730 | ||
e3995493 | 731 | @see DestroyClippingRegion(), wxRegion |
23324ae1 | 732 | */ |
e3995493 | 733 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
23324ae1 FM |
734 | |
735 | /** | |
e3995493 | 736 | @overload |
23324ae1 | 737 | */ |
e3995493 | 738 | void SetClippingRegion(const wxPoint& pt, const wxSize& sz); |
23324ae1 FM |
739 | |
740 | /** | |
e3995493 | 741 | @overload |
23324ae1 | 742 | */ |
e3995493 | 743 | void SetClippingRegion(const wxRect& rect); |
23324ae1 FM |
744 | |
745 | /** | |
e3995493 | 746 | Sets the clipping region for this device context. |
f09b5681 | 747 | |
e3995493 FM |
748 | Unlike SetClippingRegion(), this function works with physical |
749 | coordinates and not with the logical ones. | |
750 | */ | |
751 | void SetDeviceClippingRegion(const wxRegion& region); | |
752 | ||
753 | //@} | |
754 | ||
755 | ||
756 | /** | |
757 | @name Text/character extent functions | |
23324ae1 | 758 | */ |
e3995493 FM |
759 | //@{ |
760 | ||
761 | /** | |
762 | Gets the character height of the currently set font. | |
763 | */ | |
764 | wxCoord GetCharHeight() const; | |
765 | ||
766 | /** | |
767 | Gets the average character width of the currently set font. | |
768 | */ | |
769 | wxCoord GetCharWidth() const; | |
23324ae1 | 770 | |
23324ae1 FM |
771 | /** |
772 | Gets the dimensions of the string using the currently selected font. | |
4cc4bfaf | 773 | @a string is the text string to measure, @e heightLine, if non @NULL, |
23324ae1 | 774 | is where to store the height of a single line. |
f09b5681 BP |
775 | |
776 | The text extent is set in the given @a w and @a h pointers. | |
777 | ||
778 | If the optional parameter @a font is specified and valid, then it is | |
779 | used for the text extent calculation, otherwise the currently selected | |
780 | font is used. | |
781 | ||
782 | @note This function works with both single-line and multi-line strings. | |
3c4f71cc | 783 | |
1058f652 MB |
784 | @beginWxPerlOnly |
785 | In wxPerl this method is implemented as | |
786 | GetMultiLineTextExtent(string, font = undef) returning a | |
787 | 3-element list (width, height, line_height) | |
788 | @endWxPerlOnly | |
789 | ||
4cc4bfaf | 790 | @see wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent() |
23324ae1 | 791 | */ |
4cc4bfaf FM |
792 | void GetMultiLineTextExtent(const wxString& string, wxCoord* w, |
793 | wxCoord* h, | |
794 | wxCoord* heightLine = NULL, | |
408776d0 | 795 | const wxFont* font = NULL) const; |
23324ae1 | 796 | /** |
f09b5681 BP |
797 | Gets the dimensions of the string using the currently selected font. |
798 | @a string is the text string to measure, @e heightLine, if non @NULL, | |
799 | is where to store the height of a single line. | |
800 | ||
d29a9a8a | 801 | @return The text extent as a wxSize object. |
f09b5681 BP |
802 | |
803 | @note This function works with both single-line and multi-line strings. | |
804 | ||
1058f652 MB |
805 | @beginWxPerlOnly |
806 | Not supported by wxPerl. | |
807 | @endWxPerlOnly | |
808 | ||
f09b5681 | 809 | @see wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent() |
23324ae1 | 810 | */ |
408776d0 | 811 | wxSize GetMultiLineTextExtent(const wxString& string) const; |
23324ae1 FM |
812 | |
813 | /** | |
f09b5681 BP |
814 | Fills the @a widths array with the widths from the beginning of @a text |
815 | to the corresponding character of @a text. The generic version simply | |
816 | builds a running total of the widths of each character using | |
817 | GetTextExtent(), however if the various platforms have a native API | |
818 | function that is faster or more accurate than the generic | |
819 | implementation then it should be used instead. | |
820 | ||
821 | @beginWxPythonOnly | |
822 | This method only takes the @a text parameter and returns a Python list | |
823 | of integers. | |
824 | @endWxPythonOnly | |
3c4f71cc | 825 | |
1058f652 MB |
826 | @beginWxPerlOnly |
827 | In wxPerl this method only takes the @a text parameter and | |
828 | returns the widths as a list of integers. | |
829 | @endWxPerlOnly | |
830 | ||
4cc4bfaf | 831 | @see GetMultiLineTextExtent(), GetTextExtent() |
23324ae1 FM |
832 | */ |
833 | bool GetPartialTextExtents(const wxString& text, | |
328f5751 | 834 | wxArrayInt& widths) const; |
23324ae1 | 835 | |
23324ae1 FM |
836 | /** |
837 | Gets the dimensions of the string using the currently selected font. | |
f09b5681 BP |
838 | @a string is the text string to measure, @a descent is the dimension |
839 | from the baseline of the font to the bottom of the descender, and | |
840 | @a externalLeading is any extra vertical space added to the font by the | |
841 | font designer (usually is zero). | |
842 | ||
843 | The text extent is returned in @a w and @a h pointers or as a wxSize | |
844 | object depending on which version of this function is used. | |
845 | ||
846 | If the optional parameter @a font is specified and valid, then it is | |
847 | used for the text extent calculation. Otherwise the currently selected | |
848 | font is. | |
849 | ||
850 | @note This function only works with single-line strings. | |
851 | ||
852 | @beginWxPythonOnly | |
853 | The following methods are implemented in wxPython: | |
854 | - GetTextExtent(string) - Returns a 2-tuple, (width, height). | |
855 | - GetFullTextExtent(string, font=NULL) - | |
856 | Returns a 4-tuple, (width, height, descent, externalLeading). | |
857 | @endWxPythonOnly | |
3c4f71cc | 858 | |
1058f652 MB |
859 | @beginWxPerlOnly |
860 | In wxPerl this method is implemented as GetTextExtent(string, | |
861 | font = undef) returning a 4-element list (width, height, | |
862 | descent, externalLeading) | |
863 | @endWxPerlOnly | |
864 | ||
4cc4bfaf FM |
865 | @see wxFont, SetFont(), GetPartialTextExtents(), |
866 | GetMultiLineTextExtent() | |
867 | */ | |
f09b5681 | 868 | void GetTextExtent(const wxString& string, wxCoord* w, wxCoord* h, |
4cc4bfaf FM |
869 | wxCoord* descent = NULL, |
870 | wxCoord* externalLeading = NULL, | |
328f5751 | 871 | const wxFont* font = NULL) const; |
e3995493 FM |
872 | |
873 | /** | |
874 | @overload | |
1058f652 MB |
875 | |
876 | ||
877 | @beginWxPerlOnly | |
878 | Not supported by wxPerl. | |
879 | @endWxPerlOnly | |
e3995493 | 880 | */ |
382f12e4 | 881 | wxSize GetTextExtent(const wxString& string) const; |
e3995493 | 882 | |
23324ae1 FM |
883 | //@} |
884 | ||
e3995493 | 885 | |
23324ae1 | 886 | /** |
e3995493 FM |
887 | @name Text properties functions |
888 | */ | |
889 | //@{ | |
f09b5681 | 890 | |
e3995493 FM |
891 | /** |
892 | Returns the current background mode: @c wxSOLID or @c wxTRANSPARENT. | |
893 | ||
894 | @see SetBackgroundMode() | |
23324ae1 | 895 | */ |
e3995493 | 896 | int GetBackgroundMode() const; |
23324ae1 FM |
897 | |
898 | /** | |
ac55e6b0 FM |
899 | Gets the current font. |
900 | ||
901 | Notice that even although each device context object has some default font | |
902 | after creation, this method would return a ::wxNullFont initially and only | |
903 | after calling SetFont() a valid font is returned. | |
e3995493 FM |
904 | */ |
905 | const wxFont& GetFont() const; | |
f09b5681 | 906 | |
e3995493 FM |
907 | /** |
908 | Gets the current layout direction of the device context. On platforms | |
909 | where RTL layout is supported, the return value will either be | |
910 | @c wxLayout_LeftToRight or @c wxLayout_RightToLeft. If RTL layout is | |
911 | not supported, the return value will be @c wxLayout_Default. | |
912 | ||
913 | @see SetLayoutDirection() | |
23324ae1 | 914 | */ |
e3995493 | 915 | wxLayoutDirection GetLayoutDirection() const; |
23324ae1 | 916 | |
23324ae1 | 917 | /** |
e3995493 | 918 | Gets the current text background colour. |
f09b5681 | 919 | |
e3995493 FM |
920 | @see SetTextBackground() |
921 | */ | |
922 | const wxColour& GetTextBackground() const; | |
f09b5681 | 923 | |
e3995493 FM |
924 | /** |
925 | Gets the current text foreground colour. | |
926 | ||
927 | @see SetTextForeground() | |
23324ae1 | 928 | */ |
e3995493 | 929 | const wxColour& GetTextForeground() const; |
23324ae1 FM |
930 | |
931 | /** | |
ac55e6b0 FM |
932 | @a mode may be one of @c wxSOLID and @c wxTRANSPARENT. |
933 | ||
934 | This setting determines whether text will be drawn with a background | |
935 | colour or not. | |
23324ae1 | 936 | */ |
e3995493 | 937 | void SetBackgroundMode(int mode); |
23324ae1 FM |
938 | |
939 | /** | |
ac55e6b0 FM |
940 | Sets the current font for the DC. |
941 | ||
942 | If the argument is ::wxNullFont (or another invalid font; see wxFont::IsOk), | |
943 | the current font is selected out of the device context (leaving wxDC without | |
944 | any valid font), allowing the current font to be destroyed safely. | |
e3995493 FM |
945 | |
946 | @see wxFont | |
23324ae1 | 947 | */ |
e3995493 | 948 | void SetFont(const wxFont& font); |
23324ae1 FM |
949 | |
950 | /** | |
e3995493 | 951 | Sets the current text background colour for the DC. |
23324ae1 | 952 | */ |
e3995493 | 953 | void SetTextBackground(const wxColour& colour); |
23324ae1 FM |
954 | |
955 | /** | |
e3995493 FM |
956 | Sets the current text foreground colour for the DC. |
957 | ||
958 | @see wxMemoryDC for the interpretation of colours when drawing into a | |
959 | monochrome bitmap. | |
23324ae1 | 960 | */ |
e3995493 | 961 | void SetTextForeground(const wxColour& colour); |
23324ae1 FM |
962 | |
963 | /** | |
ac55e6b0 FM |
964 | Sets the current layout direction for the device context. |
965 | ||
966 | @param dir | |
967 | May be either @c wxLayout_Default, @c wxLayout_LeftToRight or | |
968 | @c wxLayout_RightToLeft. | |
e3995493 FM |
969 | |
970 | @see GetLayoutDirection() | |
23324ae1 | 971 | */ |
e3995493 FM |
972 | void SetLayoutDirection(wxLayoutDirection dir); |
973 | ||
974 | //@} | |
975 | ||
23324ae1 FM |
976 | |
977 | /** | |
e3995493 | 978 | @name Bounding box functions |
23324ae1 | 979 | */ |
e3995493 FM |
980 | //@{ |
981 | ||
982 | /** | |
983 | Adds the specified point to the bounding box which can be retrieved | |
984 | with MinX(), MaxX() and MinY(), MaxY() functions. | |
985 | ||
986 | @see ResetBoundingBox() | |
987 | */ | |
988 | void CalcBoundingBox(wxCoord x, wxCoord y); | |
23324ae1 FM |
989 | |
990 | /** | |
991 | Gets the maximum horizontal extent used in drawing commands so far. | |
992 | */ | |
adaaa686 | 993 | wxCoord MaxX() const; |
23324ae1 FM |
994 | |
995 | /** | |
996 | Gets the maximum vertical extent used in drawing commands so far. | |
997 | */ | |
adaaa686 | 998 | wxCoord MaxY() const; |
23324ae1 FM |
999 | |
1000 | /** | |
1001 | Gets the minimum horizontal extent used in drawing commands so far. | |
1002 | */ | |
adaaa686 | 1003 | wxCoord MinX() const; |
23324ae1 FM |
1004 | |
1005 | /** | |
1006 | Gets the minimum vertical extent used in drawing commands so far. | |
1007 | */ | |
adaaa686 | 1008 | wxCoord MinY() const; |
23324ae1 FM |
1009 | |
1010 | /** | |
f09b5681 BP |
1011 | Resets the bounding box: after a call to this function, the bounding |
1012 | box doesn't contain anything. | |
3c4f71cc | 1013 | |
4cc4bfaf | 1014 | @see CalcBoundingBox() |
23324ae1 FM |
1015 | */ |
1016 | void ResetBoundingBox(); | |
1017 | ||
e3995493 | 1018 | //@} |
3c4f71cc | 1019 | |
23324ae1 FM |
1020 | |
1021 | /** | |
e3995493 | 1022 | @name Page and document start/end functions |
23324ae1 | 1023 | */ |
e3995493 | 1024 | //@{ |
23324ae1 FM |
1025 | |
1026 | /** | |
e3995493 FM |
1027 | Starts a document (only relevant when outputting to a printer). |
1028 | @a message is a message to show while printing. | |
23324ae1 | 1029 | */ |
e3995493 | 1030 | bool StartDoc(const wxString& message); |
23324ae1 FM |
1031 | |
1032 | /** | |
e3995493 | 1033 | Starts a document page (only relevant when outputting to a printer). |
23324ae1 | 1034 | */ |
e3995493 | 1035 | void StartPage(); |
23324ae1 | 1036 | |
23324ae1 | 1037 | /** |
e3995493 FM |
1038 | Ends a document (only relevant when outputting to a printer). |
1039 | */ | |
1040 | void EndDoc(); | |
3c4f71cc | 1041 | |
e3995493 FM |
1042 | /** |
1043 | Ends a document page (only relevant when outputting to a printer). | |
23324ae1 | 1044 | */ |
e3995493 FM |
1045 | void EndPage(); |
1046 | ||
23324ae1 FM |
1047 | //@} |
1048 | ||
23324ae1 FM |
1049 | |
1050 | /** | |
e3995493 | 1051 | @name Bit-Block Transfer operations (blit) |
23324ae1 | 1052 | */ |
e3995493 | 1053 | //@{ |
23324ae1 FM |
1054 | |
1055 | /** | |
e3995493 FM |
1056 | Copy from a source DC to this DC, specifying the destination |
1057 | coordinates, size of area to copy, source DC, source coordinates, | |
1058 | logical function, whether to use a bitmap mask, and mask source | |
1059 | position. | |
23324ae1 | 1060 | |
e3995493 FM |
1061 | @param xdest |
1062 | Destination device context x position. | |
1063 | @param ydest | |
1064 | Destination device context y position. | |
1065 | @param width | |
1066 | Width of source area to be copied. | |
1067 | @param height | |
1068 | Height of source area to be copied. | |
1069 | @param source | |
1070 | Source device context. | |
1071 | @param xsrc | |
1072 | Source device context x position. | |
1073 | @param ysrc | |
1074 | Source device context y position. | |
1075 | @param logicalFunc | |
1076 | Logical function to use, see SetLogicalFunction(). | |
1077 | @param useMask | |
1078 | If @true, Blit does a transparent blit using the mask that is | |
1079 | associated with the bitmap selected into the source device context. | |
1080 | The Windows implementation does the following if MaskBlt cannot be | |
1081 | used: | |
1082 | <ol> | |
1083 | <li>Creates a temporary bitmap and copies the destination area into | |
1084 | it.</li> | |
1085 | <li>Copies the source area into the temporary bitmap using the | |
1086 | specified logical function.</li> | |
1087 | <li>Sets the masked area in the temporary bitmap to BLACK by ANDing | |
1088 | the mask bitmap with the temp bitmap with the foreground colour | |
1089 | set to WHITE and the bg colour set to BLACK.</li> | |
1090 | <li>Sets the unmasked area in the destination area to BLACK by | |
1091 | ANDing the mask bitmap with the destination area with the | |
1092 | foreground colour set to BLACK and the background colour set to | |
1093 | WHITE.</li> | |
1094 | <li>ORs the temporary bitmap with the destination area.</li> | |
1095 | <li>Deletes the temporary bitmap.</li> | |
1096 | </ol> | |
1097 | This sequence of operations ensures that the source's transparent | |
1098 | area need not be black, and logical functions are supported. | |
1099 | @n @b Note: on Windows, blitting with masks can be speeded up | |
1100 | considerably by compiling wxWidgets with the wxUSE_DC_CACHE option | |
1101 | enabled. You can also influence whether MaskBlt or the explicit | |
1102 | mask blitting code above is used, by using wxSystemOptions and | |
1103 | setting the @c no-maskblt option to 1. | |
1104 | @param xsrcMask | |
1105 | Source x position on the mask. If both xsrcMask and ysrcMask are | |
1106 | @c -1, xsrc and ysrc will be assumed for the mask source position. | |
1107 | Currently only implemented on Windows. | |
1108 | @param ysrcMask | |
1109 | Source y position on the mask. If both xsrcMask and ysrcMask are | |
1110 | @c -1, xsrc and ysrc will be assumed for the mask source position. | |
1111 | Currently only implemented on Windows. | |
23324ae1 | 1112 | |
e3995493 | 1113 | @remarks There is partial support for Blit() in wxPostScriptDC, under X. |
23324ae1 | 1114 | |
e3995493 | 1115 | @see StretchBlit(), wxMemoryDC, wxBitmap, wxMask |
23324ae1 | 1116 | */ |
e3995493 FM |
1117 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, |
1118 | wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, | |
1119 | wxRasterOperationMode logicalFunc = wxCOPY, bool useMask = false, | |
1120 | wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); | |
23324ae1 FM |
1121 | |
1122 | /** | |
1123 | Copy from a source DC to this DC, specifying the destination | |
f09b5681 BP |
1124 | coordinates, destination size, source DC, source coordinates, size of |
1125 | source area to copy, logical function, whether to use a bitmap mask, | |
23324ae1 | 1126 | and mask source position. |
3c4f71cc | 1127 | |
7c913512 | 1128 | @param xdest |
4cc4bfaf | 1129 | Destination device context x position. |
7c913512 | 1130 | @param ydest |
4cc4bfaf | 1131 | Destination device context y position. |
7c913512 | 1132 | @param dstWidth |
4cc4bfaf | 1133 | Width of destination area. |
7c913512 | 1134 | @param dstHeight |
4cc4bfaf | 1135 | Height of destination area. |
7c913512 | 1136 | @param source |
4cc4bfaf | 1137 | Source device context. |
7c913512 | 1138 | @param xsrc |
4cc4bfaf | 1139 | Source device context x position. |
7c913512 | 1140 | @param ysrc |
4cc4bfaf | 1141 | Source device context y position. |
7c913512 | 1142 | @param srcWidth |
4cc4bfaf | 1143 | Width of source area to be copied. |
7c913512 | 1144 | @param srcHeight |
4cc4bfaf | 1145 | Height of source area to be copied. |
7c913512 | 1146 | @param logicalFunc |
f09b5681 | 1147 | Logical function to use, see SetLogicalFunction(). |
7c913512 | 1148 | @param useMask |
f09b5681 BP |
1149 | If @true, Blit does a transparent blit using the mask that is |
1150 | associated with the bitmap selected into the source device context. | |
1151 | The Windows implementation does the following if MaskBlt cannot be | |
1152 | used: | |
1153 | <ol> | |
1154 | <li>Creates a temporary bitmap and copies the destination area into | |
1155 | it.</li> | |
1156 | <li>Copies the source area into the temporary bitmap using the | |
1157 | specified logical function.</li> | |
1158 | <li>Sets the masked area in the temporary bitmap to BLACK by ANDing | |
1159 | the mask bitmap with the temp bitmap with the foreground colour | |
1160 | set to WHITE and the bg colour set to BLACK.</li> | |
1161 | <li>Sets the unmasked area in the destination area to BLACK by | |
1162 | ANDing the mask bitmap with the destination area with the | |
1163 | foreground colour set to BLACK and the background colour set to | |
1164 | WHITE.</li> | |
1165 | <li>ORs the temporary bitmap with the destination area.</li> | |
1166 | <li>Deletes the temporary bitmap.</li> | |
1167 | </ol> | |
1168 | This sequence of operations ensures that the source's transparent | |
1169 | area need not be black, and logical functions are supported. | |
1170 | @n @b Note: on Windows, blitting with masks can be speeded up | |
1171 | considerably by compiling wxWidgets with the wxUSE_DC_CACHE option | |
1172 | enabled. You can also influence whether MaskBlt or the explicit | |
1173 | mask blitting code above is used, by using wxSystemOptions and | |
1174 | setting the @c no-maskblt option to 1. | |
7c913512 | 1175 | @param xsrcMask |
f09b5681 | 1176 | Source x position on the mask. If both xsrcMask and ysrcMask are |
408776d0 FM |
1177 | wxDefaultCoord, @a xsrc and @a ysrc will be assumed for the mask |
1178 | source position. Currently only implemented on Windows. | |
7c913512 | 1179 | @param ysrcMask |
f09b5681 | 1180 | Source y position on the mask. If both xsrcMask and ysrcMask are |
408776d0 FM |
1181 | wxDefaultCoord, @a xsrc and @a ysrc will be assumed for the mask |
1182 | source position. Currently only implemented on Windows. | |
f09b5681 BP |
1183 | |
1184 | There is partial support for Blit() in wxPostScriptDC, under X. | |
1185 | ||
1186 | StretchBlit() is only implemented under wxMAC and wxMSW. | |
1187 | ||
1188 | See wxMemoryDC for typical usage. | |
1189 | ||
1e24c2af | 1190 | @since 2.9.0 |
f09b5681 BP |
1191 | |
1192 | @see Blit(), wxMemoryDC, wxBitmap, wxMask | |
1193 | */ | |
1194 | bool StretchBlit(wxCoord xdest, wxCoord ydest, | |
1195 | wxCoord dstWidth, wxCoord dstHeight, | |
1196 | wxDC* source, wxCoord xsrc, wxCoord ysrc, | |
1197 | wxCoord srcWidth, wxCoord srcHeight, | |
89efaf2b | 1198 | wxRasterOperationMode logicalFunc = wxCOPY, |
4cc4bfaf | 1199 | bool useMask = false, |
408776d0 FM |
1200 | wxCoord xsrcMask = wxDefaultCoord, |
1201 | wxCoord ysrcMask = wxDefaultCoord); | |
e3995493 FM |
1202 | //@} |
1203 | ||
1204 | ||
1205 | /** | |
1206 | @name Background/foreground brush and pen | |
1207 | */ | |
1208 | //@{ | |
1209 | ||
1210 | /** | |
1211 | Gets the brush used for painting the background. | |
1212 | ||
1213 | @see wxDC::SetBackground() | |
1214 | */ | |
1215 | const wxBrush& GetBackground() const; | |
1216 | ||
1217 | /** | |
1218 | Gets the current brush. | |
1219 | ||
1220 | @see wxDC::SetBrush() | |
1221 | */ | |
1222 | const wxBrush& GetBrush() const; | |
1223 | ||
1224 | /** | |
1225 | Gets the current pen. | |
1226 | ||
1227 | @see SetPen() | |
1228 | */ | |
1229 | const wxPen& GetPen() const; | |
1230 | ||
1231 | /** | |
1232 | Sets the current background brush for the DC. | |
1233 | */ | |
1234 | void SetBackground(const wxBrush& brush); | |
1235 | ||
1236 | /** | |
1237 | Sets the current brush for the DC. | |
1238 | ||
ac55e6b0 FM |
1239 | If the argument is ::wxNullBrush (or another invalid brush; see wxBrush::IsOk), |
1240 | the current brush is selected out of the device context (leaving wxDC without | |
1241 | any valid brush), allowing the current brush to be destroyed safely. | |
e3995493 FM |
1242 | |
1243 | @see wxBrush, wxMemoryDC (for the interpretation of colours when | |
1244 | drawing into a monochrome bitmap) | |
1245 | */ | |
1246 | void SetBrush(const wxBrush& brush); | |
1247 | ||
1248 | /** | |
ac55e6b0 FM |
1249 | Sets the current pen for the DC. |
1250 | ||
1251 | If the argument is ::wxNullPen (or another invalid pen; see wxPen::IsOk), | |
1252 | the current pen is selected out of the device context (leaving wxDC without any | |
1253 | valid pen), allowing the current pen to be destroyed safely. | |
e3995493 FM |
1254 | |
1255 | @see wxMemoryDC for the interpretation of colours when drawing into a | |
1256 | monochrome bitmap. | |
1257 | */ | |
1258 | void SetPen(const wxPen& pen); | |
1259 | ||
1260 | //@} | |
1261 | ||
1262 | ||
4feecbb9 VZ |
1263 | /** |
1264 | Copy attributes from another DC. | |
1265 | ||
1266 | The copied attributes currently are: | |
1267 | - Font | |
1268 | - Text foreground and background colours | |
1269 | - Background brush | |
1270 | - Layout direction | |
1271 | ||
1272 | @param dc | |
1273 | A valid (i.e. its IsOk() must return @true) source device context. | |
1274 | */ | |
1275 | void CopyAttributes(const wxDC& dc); | |
e3995493 FM |
1276 | |
1277 | /** | |
1278 | Returns the depth (number of bits/pixel) of this DC. | |
1279 | ||
1280 | @see wxDisplayDepth() | |
1281 | */ | |
1282 | int GetDepth() const; | |
1283 | ||
1284 | /** | |
1285 | Returns the current device origin. | |
1286 | ||
1287 | @see SetDeviceOrigin() | |
1288 | */ | |
1289 | wxPoint GetDeviceOrigin() const; | |
1290 | ||
1291 | /** | |
1292 | Gets the current logical function. | |
1293 | ||
1294 | @see SetLogicalFunction() | |
1295 | */ | |
1296 | wxRasterOperationMode GetLogicalFunction() const; | |
1297 | ||
1298 | /** | |
1299 | Gets the current mapping mode for the device context. | |
1300 | ||
1301 | @see SetMapMode() | |
1302 | */ | |
1303 | wxMappingMode GetMapMode() const; | |
1304 | ||
1305 | /** | |
1306 | Gets in @a colour the colour at the specified location. Not available | |
1307 | for wxPostScriptDC or wxMetafileDC. | |
1308 | ||
1309 | @note Setting a pixel can be done using DrawPoint(). | |
1310 | ||
1311 | @beginWxPythonOnly | |
1312 | The wxColour value is returned and is not required as a parameter. | |
1313 | @endWxPythonOnly | |
1314 | */ | |
1315 | bool GetPixel(wxCoord x, wxCoord y, wxColour* colour) const; | |
1316 | ||
1317 | /** | |
1318 | Returns the resolution of the device in pixels per inch. | |
1319 | */ | |
1320 | wxSize GetPPI() const; | |
1321 | ||
1322 | /** | |
1323 | Gets the horizontal and vertical extent of this device context in @e device units. | |
1324 | It can be used to scale graphics to fit the page. | |
1325 | ||
1326 | For example, if @e maxX and @e maxY represent the maximum horizontal | |
1327 | and vertical 'pixel' values used in your application, the following | |
1328 | code will scale the graphic to fit on the printer page: | |
1329 | ||
1330 | @code | |
1331 | wxCoord w, h; | |
1332 | dc.GetSize(&w, &h); | |
1333 | double scaleX = (double)(maxX / w); | |
1334 | double scaleY = (double)(maxY / h); | |
1335 | dc.SetUserScale(min(scaleX, scaleY),min(scaleX, scaleY)); | |
1336 | @endcode | |
1337 | ||
1338 | @beginWxPythonOnly | |
1339 | In place of a single overloaded method name, wxPython implements the | |
1340 | following methods: | |
1341 | - GetSize() - Returns a wxSize. | |
1342 | - GetSizeWH() - Returns a 2-tuple (width, height). | |
1343 | @endWxPythonOnly | |
1058f652 MB |
1344 | |
1345 | @beginWxPerlOnly | |
1346 | In wxPerl there are two methods instead of a single overloaded | |
1347 | method: | |
1348 | - GetSize(): returns a Wx::Size object. | |
1349 | - GetSizeWH(): returns a 2-element list (width, height). | |
1350 | @endWxPerlOnly | |
e3995493 FM |
1351 | */ |
1352 | void GetSize(wxCoord* width, wxCoord* height) const; | |
1353 | ||
1354 | /** | |
1355 | @overload | |
1356 | */ | |
1357 | wxSize GetSize() const; | |
1358 | ||
1359 | /** | |
1360 | Returns the horizontal and vertical resolution in millimetres. | |
1361 | */ | |
1362 | void GetSizeMM(wxCoord* width, wxCoord* height) const; | |
1363 | ||
1364 | /** | |
1365 | @overload | |
1366 | */ | |
1367 | wxSize GetSizeMM() const; | |
1368 | ||
1369 | /** | |
1370 | Gets the current user scale factor. | |
1371 | ||
1058f652 MB |
1372 | @beginWxPerlOnly |
1373 | In wxPerl this method takes no arguments and return a two | |
1374 | element array (x, y). | |
1375 | @endWxPerlOnly | |
1376 | ||
e3995493 FM |
1377 | @see SetUserScale() |
1378 | */ | |
1379 | void GetUserScale(double* x, double* y) const; | |
1380 | ||
1381 | /** | |
1382 | Returns @true if the DC is ok to use. | |
1383 | */ | |
1384 | bool IsOk() const; | |
1385 | ||
1386 | /** | |
1387 | Sets the x and y axis orientation (i.e., the direction from lowest to | |
1388 | highest values on the axis). The default orientation is x axis from | |
1389 | left to right and y axis from top down. | |
1390 | ||
1391 | @param xLeftRight | |
1392 | True to set the x axis orientation to the natural left to right | |
1393 | orientation, @false to invert it. | |
1394 | @param yBottomUp | |
1395 | True to set the y axis orientation to the natural bottom up | |
1396 | orientation, @false to invert it. | |
1397 | */ | |
1398 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
1399 | ||
1400 | /** | |
1401 | Sets the device origin (i.e., the origin in pixels after scaling has | |
1402 | been applied). This function may be useful in Windows printing | |
1403 | operations for placing a graphic on a page. | |
1404 | */ | |
1405 | void SetDeviceOrigin(wxCoord x, wxCoord y); | |
1406 | ||
1407 | /** | |
1408 | Sets the current logical function for the device context. | |
1409 | It determines how a @e source pixel (from a pen or brush colour, or source | |
1410 | device context if using Blit()) combines with a @e destination pixel in | |
1411 | the current device context. | |
1412 | Text drawing is not affected by this function. | |
1413 | ||
1414 | See ::wxRasterOperationMode enumeration values for more info. | |
1415 | ||
1416 | The default is @c wxCOPY, which simply draws with the current colour. | |
1417 | The others combine the current colour and the background using a logical | |
1418 | operation. @c wxINVERT is commonly used for drawing rubber bands or moving | |
1419 | outlines, since drawing twice reverts to the original colour. | |
1420 | */ | |
1421 | void SetLogicalFunction(wxRasterOperationMode function); | |
1422 | ||
1423 | /** | |
1424 | The mapping mode of the device context defines the unit of measurement | |
1425 | used to convert @e logical units to @e device units. | |
1426 | ||
1427 | Note that in X, text drawing isn't handled consistently with the mapping mode; | |
1428 | a font is always specified in point size. However, setting the user scale (see | |
1429 | SetUserScale()) scales the text appropriately. In Windows, scalable | |
1430 | TrueType fonts are always used; in X, results depend on availability of | |
1431 | fonts, but usually a reasonable match is found. | |
1432 | ||
1433 | The coordinate origin is always at the top left of the screen/printer. | |
1434 | ||
1435 | Drawing to a Windows printer device context uses the current mapping | |
1436 | mode, but mapping mode is currently ignored for PostScript output. | |
1437 | */ | |
1438 | void SetMapMode(wxMappingMode mode); | |
1439 | ||
1440 | /** | |
1441 | If this is a window DC or memory DC, assigns the given palette to the | |
1442 | window or bitmap associated with the DC. If the argument is | |
1443 | ::wxNullPalette, the current palette is selected out of the device | |
1444 | context, and the original palette restored. | |
1445 | ||
1446 | @see wxPalette | |
1447 | */ | |
1448 | void SetPalette(const wxPalette& palette); | |
1449 | ||
1450 | /** | |
1451 | Sets the user scaling factor, useful for applications which require | |
1452 | 'zooming'. | |
1453 | */ | |
1454 | void SetUserScale(double xScale, double yScale); | |
23324ae1 FM |
1455 | }; |
1456 | ||
1457 | ||
e54c96f1 | 1458 | |
23324ae1 FM |
1459 | /** |
1460 | @class wxDCClipper | |
7c913512 | 1461 | |
f09b5681 BP |
1462 | wxDCClipper is a small helper class for setting a clipping region on a wxDC |
1463 | and unsetting it automatically. An object of wxDCClipper class is typically | |
1464 | created on the stack so that it is automatically destroyed when the object | |
1465 | goes out of scope. A typical usage example: | |
7c913512 | 1466 | |
23324ae1 FM |
1467 | @code |
1468 | void MyFunction(wxDC& dc) | |
f09b5681 BP |
1469 | { |
1470 | wxDCClipper clip(dc, rect); | |
1471 | // ... drawing functions here are affected by clipping rect ... | |
1472 | } | |
1473 | ||
1474 | void OtherFunction() | |
1475 | { | |
1476 | wxDC dc; | |
1477 | MyFunction(dc); | |
1478 | // ... drawing functions here are not affected by clipping rect ... | |
1479 | } | |
23324ae1 | 1480 | @endcode |
7c913512 | 1481 | |
23324ae1 FM |
1482 | @library{wxcore} |
1483 | @category{gdi} | |
7c913512 | 1484 | |
382f12e4 FM |
1485 | @see wxDC::SetClippingRegion(), wxDCFontChanger, wxDCTextColourChanger, wxDCPenChanger, |
1486 | wxDCBrushChanger | |
23324ae1 | 1487 | */ |
7c913512 | 1488 | class wxDCClipper |
23324ae1 FM |
1489 | { |
1490 | public: | |
1491 | //@{ | |
1492 | /** | |
f09b5681 BP |
1493 | Sets the clipping region to the specified region/coordinates. |
1494 | ||
23324ae1 FM |
1495 | The clipping region is automatically unset when this object is destroyed. |
1496 | */ | |
1497 | wxDCClipper(wxDC& dc, const wxRegion& r); | |
7c913512 | 1498 | wxDCClipper(wxDC& dc, const wxRect& rect); |
882678eb | 1499 | wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h); |
23324ae1 | 1500 | //@} |
c48d6cdf FM |
1501 | |
1502 | /** | |
1503 | Destroys the clipping region associated with the DC passed to the ctor. | |
1504 | */ | |
1505 | ~wxDCClipper(); | |
1506 | }; | |
1507 | ||
1508 | ||
1509 | /** | |
1510 | @class wxDCBrushChanger | |
1511 | ||
1512 | wxDCBrushChanger is a small helper class for setting a brush on a wxDC | |
1513 | and unsetting it automatically in the destructor, restoring the previous one. | |
1514 | ||
1515 | @library{wxcore} | |
1516 | @category{gdi} | |
1517 | ||
382f12e4 FM |
1518 | @see wxDC::SetBrush(), wxDCFontChanger, wxDCTextColourChanger, wxDCPenChanger, |
1519 | wxDCClipper | |
c48d6cdf FM |
1520 | */ |
1521 | class wxDCBrushChanger | |
1522 | { | |
1523 | public: | |
1524 | /** | |
1525 | Sets @a brush on the given @a dc, storing the old one. | |
1526 | ||
1527 | @param dc | |
1528 | The DC where the brush must be temporary set. | |
1529 | @param brush | |
1530 | The brush to set. | |
1531 | */ | |
1532 | wxDCBrushChanger(wxDC& dc, const wxBrush& brush); | |
1533 | ||
1534 | /** | |
1535 | Restores the brush originally selected in the DC passed to the ctor. | |
1536 | */ | |
1537 | ~wxDCBrushChanger(); | |
1538 | }; | |
1539 | ||
1540 | ||
1541 | /** | |
1542 | @class wxDCPenChanger | |
1543 | ||
1544 | wxDCPenChanger is a small helper class for setting a pen on a wxDC | |
1545 | and unsetting it automatically in the destructor, restoring the previous one. | |
1546 | ||
1547 | @library{wxcore} | |
1548 | @category{gdi} | |
1549 | ||
382f12e4 FM |
1550 | @see wxDC::SetPen(), wxDCFontChanger, wxDCTextColourChanger, wxDCBrushChanger, |
1551 | wxDCClipper | |
c48d6cdf FM |
1552 | */ |
1553 | class wxDCPenChanger | |
1554 | { | |
1555 | public: | |
1556 | /** | |
1557 | Sets @a pen on the given @a dc, storing the old one. | |
1558 | ||
1559 | @param dc | |
1560 | The DC where the pen must be temporary set. | |
1561 | @param pen | |
1562 | The pen to set. | |
1563 | */ | |
1564 | wxDCPenChanger(wxDC& dc, const wxPen& pen); | |
1565 | ||
1566 | /** | |
1567 | Restores the pen originally selected in the DC passed to the ctor. | |
1568 | */ | |
1569 | ~wxDCPenChanger(); | |
1570 | }; | |
1571 | ||
1572 | ||
1573 | ||
1574 | /** | |
1575 | @class wxDCTextColourChanger | |
1576 | ||
1577 | wxDCTextColourChanger is a small helper class for setting a foreground | |
1578 | text colour on a wxDC and unsetting it automatically in the destructor, | |
1579 | restoring the previous one. | |
1580 | ||
1581 | @library{wxcore} | |
1582 | @category{gdi} | |
1583 | ||
382f12e4 FM |
1584 | @see wxDC::SetTextForeground(), wxDCFontChanger, wxDCPenChanger, wxDCBrushChanger, |
1585 | wxDCClipper | |
c48d6cdf FM |
1586 | */ |
1587 | class wxDCTextColourChanger | |
1588 | { | |
1589 | public: | |
489cc69b VZ |
1590 | /** |
1591 | Trivial constructor not changing anything. | |
1592 | ||
1593 | This constructor is useful if you don't know beforehand if the colour | |
1594 | needs to be changed or not. It simply creates the object which won't do | |
1595 | anything in its destructor unless Set() is called -- in which case it | |
1596 | would reset the previous colour. | |
1597 | */ | |
1598 | wxDCTextColourChanger(wxDC& dc); | |
1599 | ||
c48d6cdf FM |
1600 | /** |
1601 | Sets @a col on the given @a dc, storing the old one. | |
1602 | ||
1603 | @param dc | |
1604 | The DC where the colour must be temporary set. | |
1605 | @param col | |
1606 | The colour to set. | |
1607 | */ | |
1608 | wxDCTextColourChanger(wxDC& dc, const wxColour& col); | |
1609 | ||
489cc69b VZ |
1610 | /** |
1611 | Set the colour to use. | |
1612 | ||
1613 | This method is meant to be called once only and only on the objects | |
1614 | created with the constructor overload not taking wxColour argument and | |
1615 | has the same effect as the other constructor, i.e. sets the colour to | |
1616 | the given @a col and ensures that the old value is restored when this | |
1617 | object is destroyed. | |
1618 | */ | |
1619 | void Set(const wxColour& col); | |
1620 | ||
c48d6cdf FM |
1621 | /** |
1622 | Restores the colour originally selected in the DC passed to the ctor. | |
1623 | */ | |
1624 | ~wxDCTextColourChanger(); | |
1625 | }; | |
1626 | ||
1627 | ||
1628 | ||
1629 | /** | |
1630 | @class wxDCFontChanger | |
1631 | ||
1632 | wxDCFontChanger is a small helper class for setting a font on a wxDC and | |
1633 | unsetting it automatically in the destructor, restoring the previous one. | |
1634 | ||
1635 | @since 2.9.0 | |
1636 | ||
1637 | @library{wxcore} | |
1638 | @category{gdi} | |
1639 | ||
382f12e4 FM |
1640 | @see wxDC::SetFont(), wxDCTextColourChanger, wxDCPenChanger, wxDCBrushChanger, |
1641 | wxDCClipper | |
c48d6cdf FM |
1642 | */ |
1643 | class wxDCFontChanger | |
1644 | { | |
1645 | public: | |
ca4adfd0 VZ |
1646 | /** |
1647 | Trivial constructor not changing anything. | |
1648 | ||
1649 | This constructor is useful if you don't know beforehand if the font | |
1650 | needs to be changed or not. It simply creates the object which won't do | |
1651 | anything in its destructor unless Set() is called -- in which case it | |
1652 | would reset the previous font. | |
1653 | ||
1654 | @since 2.9.1 | |
1655 | */ | |
1656 | wxDCFontChanger(wxDC& dc); | |
1657 | ||
c48d6cdf FM |
1658 | /** |
1659 | Sets @a font on the given @a dc, storing the old one. | |
1660 | ||
1661 | @param dc | |
1662 | The DC where the font must be temporary set. | |
1663 | @param font | |
1664 | The font to set. | |
1665 | */ | |
1666 | wxDCFontChanger(wxDC& dc, const wxFont& font); | |
1667 | ||
1668 | /** | |
ca4adfd0 VZ |
1669 | Set the font to use. |
1670 | ||
1671 | This method is meant to be called once only and only on the objects | |
1672 | created with the constructor overload not taking wxColour argument and | |
1673 | has the same effect as the other constructor, i.e. sets the font to | |
1674 | the given @a font and ensures that the old value is restored when this | |
1675 | object is destroyed. | |
1676 | */ | |
1677 | void Set(const wxFont& font); | |
1678 | ||
1679 | /** | |
1680 | Restores the font originally selected in the DC passed to the ctor. | |
c48d6cdf FM |
1681 | */ |
1682 | ~wxDCFontChanger(); | |
23324ae1 | 1683 | }; |
e54c96f1 | 1684 |