]>
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 BP |
224 | Draws an arc of a circle, centred on (@a xc, @a yc), with starting |
225 | point (@a x1, @a y1) and ending at (@a x2, @a y2). The current pen is | |
226 | used for the outline and the current brush for filling the shape. | |
227 | ||
228 | The arc is drawn in a counter-clockwise direction from the start point | |
229 | to the end point. | |
23324ae1 FM |
230 | */ |
231 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, | |
e3995493 | 232 | wxCoord xc, wxCoord yc); |
23324ae1 FM |
233 | |
234 | /** | |
f09b5681 BP |
235 | Draw a bitmap on the device context at the specified point. If |
236 | @a transparent is @true and the bitmap has a transparency mask, the | |
237 | bitmap will be drawn transparently. | |
238 | ||
239 | When drawing a mono-bitmap, the current text foreground colour will be | |
240 | used to draw the foreground of the bitmap (all bits set to 1), and the | |
241 | current text background colour to draw the background (all bits set to | |
242 | 0). | |
243 | ||
244 | @see SetTextForeground(), SetTextBackground(), wxMemoryDC | |
23324ae1 FM |
245 | */ |
246 | void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, | |
408776d0 | 247 | bool useMask = false); |
23324ae1 | 248 | |
23324ae1 FM |
249 | /** |
250 | Draws a check mark inside the given rectangle. | |
251 | */ | |
f09b5681 | 252 | void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
e3995493 FM |
253 | |
254 | /** | |
255 | @overload | |
256 | */ | |
4cc4bfaf | 257 | void DrawCheckMark(const wxRect& rect); |
23324ae1 | 258 | |
23324ae1 FM |
259 | /** |
260 | Draws a circle with the given centre and radius. | |
3c4f71cc | 261 | |
4cc4bfaf | 262 | @see DrawEllipse() |
23324ae1 FM |
263 | */ |
264 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); | |
e3995493 FM |
265 | |
266 | /** | |
267 | @overload | |
268 | */ | |
7c913512 | 269 | void DrawCircle(const wxPoint& pt, wxCoord radius); |
23324ae1 | 270 | |
23324ae1 | 271 | /** |
f09b5681 BP |
272 | Draws an ellipse contained in the rectangle specified either with the |
273 | given top left corner and the given size or directly. The current pen | |
274 | is used for the outline and the current brush for filling the shape. | |
3c4f71cc | 275 | |
4cc4bfaf | 276 | @see DrawCircle() |
23324ae1 | 277 | */ |
f09b5681 | 278 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
e3995493 FM |
279 | |
280 | /** | |
281 | @overload | |
282 | */ | |
7c913512 | 283 | void DrawEllipse(const wxPoint& pt, const wxSize& size); |
e3995493 FM |
284 | |
285 | /** | |
286 | @overload | |
287 | */ | |
7c913512 | 288 | void DrawEllipse(const wxRect& rect); |
23324ae1 FM |
289 | |
290 | /** | |
f09b5681 BP |
291 | Draws an arc of an ellipse. The current pen is used for drawing the arc |
292 | and the current brush is used for drawing the pie. | |
293 | ||
294 | @a x and @a y specify the x and y coordinates of the upper-left corner | |
295 | of the rectangle that contains the ellipse. | |
296 | ||
297 | @a width and @a height specify the width and height of the rectangle | |
298 | that contains the ellipse. | |
299 | ||
300 | @a start and @a end specify the start and end of the arc relative to | |
301 | the three-o'clock position from the center of the rectangle. Angles are | |
302 | specified in degrees (360 is a complete circle). Positive values mean | |
303 | counter-clockwise motion. If @a start is equal to @e end, a complete | |
304 | ellipse will be drawn. | |
23324ae1 | 305 | */ |
f09b5681 BP |
306 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height, |
307 | double start, double end); | |
23324ae1 FM |
308 | |
309 | /** | |
f09b5681 BP |
310 | Draw an icon on the display (does nothing if the device context is |
311 | PostScript). This can be the simplest way of drawing bitmaps on a | |
312 | window. | |
23324ae1 FM |
313 | */ |
314 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
315 | ||
23324ae1 | 316 | /** |
f09b5681 BP |
317 | Draw optional bitmap and the text into the given rectangle and aligns |
318 | it as specified by alignment parameter; it also will emphasize the | |
319 | character with the given index if it is != -1 and return the bounding | |
320 | rectangle if required. | |
23324ae1 | 321 | */ |
882678eb FM |
322 | void DrawLabel(const wxString& text, const wxBitmap& image, |
323 | const wxRect& rect, | |
324 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
325 | int indexAccel = -1, wxRect* rectBounding = NULL); | |
e3995493 FM |
326 | |
327 | /** | |
328 | @overload | |
329 | */ | |
7c913512 FM |
330 | void DrawLabel(const wxString& text, const wxRect& rect, |
331 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
332 | int indexAccel = -1); | |
23324ae1 FM |
333 | |
334 | /** | |
f09b5681 BP |
335 | Draws a line from the first point to the second. The current pen is |
336 | used for drawing the line. Note that the point (@a x2, @a y2) is not | |
337 | part of the line and is not drawn by this function (this is consistent | |
338 | with the behaviour of many other toolkits). | |
23324ae1 FM |
339 | */ |
340 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
341 | ||
23324ae1 | 342 | /** |
f09b5681 BP |
343 | Draws lines using an array of points of size @a n adding the optional |
344 | offset coordinate. The current pen is used for drawing the lines. | |
345 | ||
346 | @beginWxPythonOnly | |
347 | The wxPython version of this method accepts a Python list of wxPoint | |
348 | objects. | |
349 | @endWxPythonOnly | |
23324ae1 FM |
350 | */ |
351 | void DrawLines(int n, wxPoint points[], wxCoord xoffset = 0, | |
352 | wxCoord yoffset = 0); | |
f09b5681 BP |
353 | /** |
354 | This method uses a list of wxPoints, adding the optional offset | |
355 | coordinate. The programmer is responsible for deleting the list of | |
356 | points. | |
357 | ||
358 | @beginWxPythonOnly | |
359 | The wxPython version of this method accepts a Python list of wxPoint | |
360 | objects. | |
361 | @endWxPythonOnly | |
362 | */ | |
4cc4bfaf | 363 | void DrawLines(const wxPointList* points, |
f09b5681 | 364 | wxCoord xoffset = 0, wxCoord yoffset = 0); |
23324ae1 FM |
365 | |
366 | /** | |
367 | Draws a point using the color of the current pen. Note that the other | |
f09b5681 | 368 | properties of the pen are not used, such as width. |
23324ae1 FM |
369 | */ |
370 | void DrawPoint(wxCoord x, wxCoord y); | |
371 | ||
372 | /** | |
f09b5681 BP |
373 | Draws a filled polygon using an array of points of size @a n, adding |
374 | the optional offset coordinate. The first and last points are | |
375 | automatically closed. | |
23324ae1 | 376 | |
f09b5681 BP |
377 | The last argument specifies the fill rule: @b wxODDEVEN_RULE (the |
378 | default) or @b wxWINDING_RULE. | |
379 | ||
380 | The current pen is used for drawing the outline, and the current brush | |
381 | for filling the shape. Using a transparent brush suppresses filling. | |
382 | */ | |
383 | void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, | |
89efaf2b FM |
384 | wxCoord yoffset = 0, |
385 | wxPolygonFillMode fill_style = wxODDEVEN_RULE); | |
23324ae1 | 386 | /** |
f09b5681 BP |
387 | This method draws a filled polygon using a list of wxPoints, adding the |
388 | optional offset coordinate. The first and last points are automatically | |
389 | closed. | |
390 | ||
23324ae1 FM |
391 | The last argument specifies the fill rule: @b wxODDEVEN_RULE (the |
392 | default) or @b wxWINDING_RULE. | |
f09b5681 | 393 | |
23324ae1 | 394 | The current pen is used for drawing the outline, and the current brush |
f09b5681 BP |
395 | for filling the shape. Using a transparent brush suppresses filling. |
396 | ||
23324ae1 | 397 | The programmer is responsible for deleting the list of points. |
f09b5681 BP |
398 | |
399 | @beginWxPythonOnly | |
400 | The wxPython version of this method accepts a Python list of wxPoint | |
401 | objects. | |
402 | @endWxPythonOnly | |
23324ae1 | 403 | */ |
4cc4bfaf | 404 | void DrawPolygon(const wxPointList* points, |
f09b5681 | 405 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
89efaf2b | 406 | wxPolygonFillMode fill_style = wxODDEVEN_RULE); |
f09b5681 BP |
407 | |
408 | /** | |
409 | Draws two or more filled polygons using an array of @a points, adding | |
410 | the optional offset coordinates. | |
411 | ||
412 | Notice that for the platforms providing a native implementation of this | |
413 | function (Windows and PostScript-based wxDC currently), this is more | |
414 | efficient than using DrawPolygon() in a loop. | |
415 | ||
416 | @a n specifies the number of polygons to draw, the array @e count of | |
417 | size @a n specifies the number of points in each of the polygons in the | |
418 | @a points array. | |
419 | ||
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. | |
425 | ||
426 | The polygons maybe disjoint or overlapping. Each polygon specified in a | |
427 | call to DrawPolyPolygon() must be closed. Unlike polygons created by | |
428 | the DrawPolygon() member function, the polygons created by this | |
429 | method are not closed automatically. | |
430 | ||
431 | @beginWxPythonOnly | |
432 | Not implemented yet. | |
433 | @endWxPythonOnly | |
434 | */ | |
435 | void DrawPolyPolygon(int n, int count[], wxPoint points[], | |
436 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
89efaf2b | 437 | wxPolygonFillMode fill_style = wxODDEVEN_RULE); |
23324ae1 FM |
438 | |
439 | /** | |
440 | Draws a rectangle with the given top left corner, and with the given | |
441 | size. The current pen is used for the outline and the current brush | |
442 | for filling the shape. | |
443 | */ | |
f09b5681 | 444 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
23324ae1 FM |
445 | |
446 | /** | |
aff647c1 FM |
447 | Draws the text rotated by @a angle degrees |
448 | (positive angles are counterclockwise; the full angle is 360 degrees). | |
f09b5681 | 449 | |
1f1d2182 | 450 | @note Under Win9x only TrueType fonts can be drawn by this function. In |
f09b5681 BP |
451 | particular, a font different from @c wxNORMAL_FONT should be used |
452 | as the latter is not a TrueType font. @c wxSWISS_FONT is an | |
453 | example of a font which is. | |
3c4f71cc | 454 | |
4cc4bfaf | 455 | @see DrawText() |
23324ae1 FM |
456 | */ |
457 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
458 | double angle); | |
459 | ||
460 | /** | |
461 | Draws a rectangle with the given top left corner, and with the given | |
f09b5681 | 462 | size. The corners are quarter-circles using the given radius. The |
23324ae1 FM |
463 | current pen is used for the outline and the current brush for filling |
464 | the shape. | |
f09b5681 BP |
465 | |
466 | If @a radius is positive, the value is assumed to be the radius of the | |
467 | rounded corner. If @a radius is negative, the absolute value is assumed | |
468 | to be the @e proportion of the smallest dimension of the rectangle. | |
469 | This means that the corner can be a sensible size relative to the size | |
470 | of the rectangle, and also avoids the strange effects X produces when | |
471 | the corners are too big for the rectangle. | |
23324ae1 FM |
472 | */ |
473 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, | |
f09b5681 | 474 | wxCoord height, double radius); |
23324ae1 | 475 | |
23324ae1 | 476 | /** |
f09b5681 BP |
477 | Draws a spline between all given points using the current pen. |
478 | ||
479 | @beginWxPythonOnly | |
480 | The wxPython version of this method accepts a Python list of wxPoint | |
481 | objects. | |
482 | @endWxPythonOnly | |
23324ae1 FM |
483 | */ |
484 | void DrawSpline(int n, wxPoint points[]); | |
e3995493 FM |
485 | |
486 | /** | |
487 | @overload | |
488 | */ | |
4cc4bfaf | 489 | void DrawSpline(const wxPointList* points); |
e3995493 FM |
490 | |
491 | /** | |
492 | @overload | |
493 | */ | |
f09b5681 BP |
494 | void DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, |
495 | wxCoord x3, wxCoord y3); | |
23324ae1 FM |
496 | |
497 | /** | |
f09b5681 BP |
498 | Draws a text string at the specified point, using the current text |
499 | font, and the current text foreground and background colours. | |
500 | ||
23324ae1 | 501 | The coordinates refer to the top-left corner of the rectangle bounding |
f09b5681 BP |
502 | the string. See GetTextExtent() for how to get the dimensions of a text |
503 | string, which can be used to position the text more precisely. | |
504 | ||
408776d0 | 505 | @note The current @ref GetLogicalFunction() "logical function" is |
e928566f | 506 | ignored by this function. |
23324ae1 FM |
507 | */ |
508 | void DrawText(const wxString& text, wxCoord x, wxCoord y); | |
509 | ||
510 | /** | |
e3995493 FM |
511 | Fill the area specified by rect with a radial gradient, starting from |
512 | @a initialColour at the centre of the circle and fading to | |
513 | @a destColour on the circle outside. | |
514 | ||
515 | The circle is placed at the centre of @a rect. | |
516 | ||
517 | @note Currently this function is very slow, don't use it for real-time | |
518 | drawing. | |
23324ae1 | 519 | */ |
e3995493 FM |
520 | void GradientFillConcentric(const wxRect& rect, |
521 | const wxColour& initialColour, | |
522 | const wxColour& destColour); | |
23324ae1 FM |
523 | |
524 | /** | |
e3995493 FM |
525 | Fill the area specified by rect with a radial gradient, starting from |
526 | @a initialColour at the centre of the circle and fading to | |
527 | @a destColour on the circle outside. | |
528 | ||
529 | @a circleCenter are the relative coordinates of centre of the circle in | |
530 | the specified @a rect. | |
531 | ||
532 | @note Currently this function is very slow, don't use it for real-time | |
533 | drawing. | |
23324ae1 | 534 | */ |
e3995493 FM |
535 | void GradientFillConcentric(const wxRect& rect, |
536 | const wxColour& initialColour, | |
537 | const wxColour& destColour, | |
538 | const wxPoint& circleCenter); | |
539 | ||
540 | /** | |
541 | Fill the area specified by @a rect with a linear gradient, starting | |
542 | from @a initialColour and eventually fading to @e destColour. | |
543 | ||
544 | The @a nDirection specifies the direction of the colour change, default is | |
545 | to use @a initialColour on the left part of the rectangle and | |
546 | @a destColour on the right one. | |
547 | */ | |
548 | void GradientFillLinear(const wxRect& rect, const wxColour& initialColour, | |
549 | const wxColour& destColour, | |
550 | wxDirection nDirection = wxRIGHT); | |
23324ae1 FM |
551 | |
552 | /** | |
553 | Flood fills the device context starting from the given point, using | |
f09b5681 BP |
554 | the current brush colour, and using a style: |
555 | ||
556 | - wxFLOOD_SURFACE: The flooding occurs until a colour other than the | |
557 | given colour is encountered. | |
558 | - wxFLOOD_BORDER: The area to be flooded is bounded by the given | |
559 | colour. | |
560 | ||
d29a9a8a | 561 | @return @false if the operation failed. |
f09b5681 BP |
562 | |
563 | @note The present implementation for non-Windows platforms may fail to | |
564 | find colour borders if the pixels do not match the colour | |
565 | exactly. However the function will still return @true. | |
23324ae1 FM |
566 | */ |
567 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, | |
89efaf2b | 568 | wxFloodFillStyle style = wxFLOOD_SURFACE); |
23324ae1 FM |
569 | |
570 | /** | |
e3995493 FM |
571 | Displays a cross hair using the current pen. This is a vertical and |
572 | horizontal line the height and width of the window, centred on the | |
573 | given point. | |
23324ae1 | 574 | */ |
e3995493 | 575 | void CrossHair(wxCoord x, wxCoord y); |
23324ae1 | 576 | |
e3995493 | 577 | //@} |
3c4f71cc | 578 | |
23324ae1 FM |
579 | |
580 | /** | |
e3995493 | 581 | @name Clipping region functions |
23324ae1 | 582 | */ |
e3995493 | 583 | //@{ |
23324ae1 FM |
584 | |
585 | /** | |
e3995493 | 586 | Destroys the current clipping region so that none of the DC is clipped. |
23324ae1 | 587 | |
e3995493 | 588 | @see SetClippingRegion() |
23324ae1 | 589 | */ |
e3995493 | 590 | void DestroyClippingRegion(); |
23324ae1 FM |
591 | |
592 | /** | |
593 | Gets the rectangle surrounding the current clipping region. | |
f09b5681 BP |
594 | |
595 | @beginWxPythonOnly | |
596 | No arguments are required and the four values defining the rectangle | |
597 | are returned as a tuple. | |
598 | @endWxPythonOnly | |
23324ae1 | 599 | */ |
408776d0 | 600 | void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height) const; |
23324ae1 FM |
601 | |
602 | /** | |
e3995493 FM |
603 | Sets the clipping region for this device context to the intersection of |
604 | the given region described by the parameters of this method and the | |
605 | previously set clipping region. You should call DestroyClippingRegion() | |
606 | if you want to set the clipping region exactly to the region specified. | |
3c4f71cc | 607 | |
e3995493 FM |
608 | The clipping region is an area to which drawing is restricted. Possible |
609 | uses for the clipping region are for clipping text or for speeding up | |
610 | window redraws when only a known area of the screen is damaged. | |
23324ae1 | 611 | |
e3995493 | 612 | @see DestroyClippingRegion(), wxRegion |
23324ae1 | 613 | */ |
e3995493 | 614 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
23324ae1 FM |
615 | |
616 | /** | |
e3995493 | 617 | @overload |
23324ae1 | 618 | */ |
e3995493 | 619 | void SetClippingRegion(const wxPoint& pt, const wxSize& sz); |
23324ae1 FM |
620 | |
621 | /** | |
e3995493 | 622 | @overload |
23324ae1 | 623 | */ |
e3995493 | 624 | void SetClippingRegion(const wxRect& rect); |
23324ae1 FM |
625 | |
626 | /** | |
e3995493 | 627 | Sets the clipping region for this device context. |
f09b5681 | 628 | |
e3995493 FM |
629 | Unlike SetClippingRegion(), this function works with physical |
630 | coordinates and not with the logical ones. | |
631 | */ | |
632 | void SetDeviceClippingRegion(const wxRegion& region); | |
633 | ||
634 | //@} | |
635 | ||
636 | ||
637 | /** | |
638 | @name Text/character extent functions | |
23324ae1 | 639 | */ |
e3995493 FM |
640 | //@{ |
641 | ||
642 | /** | |
643 | Gets the character height of the currently set font. | |
644 | */ | |
645 | wxCoord GetCharHeight() const; | |
646 | ||
647 | /** | |
648 | Gets the average character width of the currently set font. | |
649 | */ | |
650 | wxCoord GetCharWidth() const; | |
23324ae1 | 651 | |
23324ae1 FM |
652 | /** |
653 | Gets the dimensions of the string using the currently selected font. | |
4cc4bfaf | 654 | @a string is the text string to measure, @e heightLine, if non @NULL, |
23324ae1 | 655 | is where to store the height of a single line. |
f09b5681 BP |
656 | |
657 | The text extent is set in the given @a w and @a h pointers. | |
658 | ||
659 | If the optional parameter @a font is specified and valid, then it is | |
660 | used for the text extent calculation, otherwise the currently selected | |
661 | font is used. | |
662 | ||
663 | @note This function works with both single-line and multi-line strings. | |
3c4f71cc | 664 | |
4cc4bfaf | 665 | @see wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent() |
23324ae1 | 666 | */ |
4cc4bfaf FM |
667 | void GetMultiLineTextExtent(const wxString& string, wxCoord* w, |
668 | wxCoord* h, | |
669 | wxCoord* heightLine = NULL, | |
408776d0 | 670 | const wxFont* font = NULL) const; |
23324ae1 | 671 | /** |
f09b5681 BP |
672 | Gets the dimensions of the string using the currently selected font. |
673 | @a string is the text string to measure, @e heightLine, if non @NULL, | |
674 | is where to store the height of a single line. | |
675 | ||
d29a9a8a | 676 | @return The text extent as a wxSize object. |
f09b5681 BP |
677 | |
678 | @note This function works with both single-line and multi-line strings. | |
679 | ||
680 | @see wxFont, SetFont(), GetPartialTextExtents(), GetTextExtent() | |
23324ae1 | 681 | */ |
408776d0 | 682 | wxSize GetMultiLineTextExtent(const wxString& string) const; |
23324ae1 FM |
683 | |
684 | /** | |
f09b5681 BP |
685 | Fills the @a widths array with the widths from the beginning of @a text |
686 | to the corresponding character of @a text. The generic version simply | |
687 | builds a running total of the widths of each character using | |
688 | GetTextExtent(), however if the various platforms have a native API | |
689 | function that is faster or more accurate than the generic | |
690 | implementation then it should be used instead. | |
691 | ||
692 | @beginWxPythonOnly | |
693 | This method only takes the @a text parameter and returns a Python list | |
694 | of integers. | |
695 | @endWxPythonOnly | |
3c4f71cc | 696 | |
4cc4bfaf | 697 | @see GetMultiLineTextExtent(), GetTextExtent() |
23324ae1 FM |
698 | */ |
699 | bool GetPartialTextExtents(const wxString& text, | |
328f5751 | 700 | wxArrayInt& widths) const; |
23324ae1 | 701 | |
23324ae1 FM |
702 | /** |
703 | Gets the dimensions of the string using the currently selected font. | |
f09b5681 BP |
704 | @a string is the text string to measure, @a descent is the dimension |
705 | from the baseline of the font to the bottom of the descender, and | |
706 | @a externalLeading is any extra vertical space added to the font by the | |
707 | font designer (usually is zero). | |
708 | ||
709 | The text extent is returned in @a w and @a h pointers or as a wxSize | |
710 | object depending on which version of this function is used. | |
711 | ||
712 | If the optional parameter @a font is specified and valid, then it is | |
713 | used for the text extent calculation. Otherwise the currently selected | |
714 | font is. | |
715 | ||
716 | @note This function only works with single-line strings. | |
717 | ||
718 | @beginWxPythonOnly | |
719 | The following methods are implemented in wxPython: | |
720 | - GetTextExtent(string) - Returns a 2-tuple, (width, height). | |
721 | - GetFullTextExtent(string, font=NULL) - | |
722 | Returns a 4-tuple, (width, height, descent, externalLeading). | |
723 | @endWxPythonOnly | |
3c4f71cc | 724 | |
4cc4bfaf FM |
725 | @see wxFont, SetFont(), GetPartialTextExtents(), |
726 | GetMultiLineTextExtent() | |
727 | */ | |
f09b5681 | 728 | void GetTextExtent(const wxString& string, wxCoord* w, wxCoord* h, |
4cc4bfaf FM |
729 | wxCoord* descent = NULL, |
730 | wxCoord* externalLeading = NULL, | |
328f5751 | 731 | const wxFont* font = NULL) const; |
e3995493 FM |
732 | |
733 | /** | |
734 | @overload | |
735 | */ | |
382f12e4 | 736 | wxSize GetTextExtent(const wxString& string) const; |
e3995493 | 737 | |
23324ae1 FM |
738 | //@} |
739 | ||
e3995493 | 740 | |
23324ae1 | 741 | /** |
e3995493 FM |
742 | @name Text properties functions |
743 | */ | |
744 | //@{ | |
f09b5681 | 745 | |
e3995493 FM |
746 | /** |
747 | Returns the current background mode: @c wxSOLID or @c wxTRANSPARENT. | |
748 | ||
749 | @see SetBackgroundMode() | |
23324ae1 | 750 | */ |
e3995493 | 751 | int GetBackgroundMode() const; |
23324ae1 FM |
752 | |
753 | /** | |
e3995493 FM |
754 | Gets the current font. Notice that even although each device context |
755 | object has some default font after creation, this method would return a | |
756 | ::wxNullFont initially and only after calling SetFont() a valid font is | |
757 | returned. | |
758 | */ | |
759 | const wxFont& GetFont() const; | |
f09b5681 | 760 | |
e3995493 FM |
761 | /** |
762 | Gets the current layout direction of the device context. On platforms | |
763 | where RTL layout is supported, the return value will either be | |
764 | @c wxLayout_LeftToRight or @c wxLayout_RightToLeft. If RTL layout is | |
765 | not supported, the return value will be @c wxLayout_Default. | |
766 | ||
767 | @see SetLayoutDirection() | |
23324ae1 | 768 | */ |
e3995493 | 769 | wxLayoutDirection GetLayoutDirection() const; |
23324ae1 | 770 | |
23324ae1 | 771 | /** |
e3995493 | 772 | Gets the current text background colour. |
f09b5681 | 773 | |
e3995493 FM |
774 | @see SetTextBackground() |
775 | */ | |
776 | const wxColour& GetTextBackground() const; | |
f09b5681 | 777 | |
e3995493 FM |
778 | /** |
779 | Gets the current text foreground colour. | |
780 | ||
781 | @see SetTextForeground() | |
23324ae1 | 782 | */ |
e3995493 | 783 | const wxColour& GetTextForeground() const; |
23324ae1 FM |
784 | |
785 | /** | |
e3995493 FM |
786 | @a mode may be one of wxSOLID and wxTRANSPARENT. This setting |
787 | determines whether text will be drawn with a background colour or not. | |
23324ae1 | 788 | */ |
e3995493 | 789 | void SetBackgroundMode(int mode); |
23324ae1 FM |
790 | |
791 | /** | |
e3995493 FM |
792 | Sets the current font for the DC. It must be a valid font, in |
793 | particular you should not pass wxNullFont to this method. | |
794 | ||
795 | @see wxFont | |
23324ae1 | 796 | */ |
e3995493 | 797 | void SetFont(const wxFont& font); |
23324ae1 FM |
798 | |
799 | /** | |
e3995493 | 800 | Sets the current text background colour for the DC. |
23324ae1 | 801 | */ |
e3995493 | 802 | void SetTextBackground(const wxColour& colour); |
23324ae1 FM |
803 | |
804 | /** | |
e3995493 FM |
805 | Sets the current text foreground colour for the DC. |
806 | ||
807 | @see wxMemoryDC for the interpretation of colours when drawing into a | |
808 | monochrome bitmap. | |
23324ae1 | 809 | */ |
e3995493 | 810 | void SetTextForeground(const wxColour& colour); |
23324ae1 FM |
811 | |
812 | /** | |
e3995493 FM |
813 | Sets the current layout direction for the device context. @a dir may be |
814 | either @c wxLayout_Default, @c wxLayout_LeftToRight or | |
815 | @c wxLayout_RightToLeft. | |
816 | ||
817 | @see GetLayoutDirection() | |
23324ae1 | 818 | */ |
e3995493 FM |
819 | void SetLayoutDirection(wxLayoutDirection dir); |
820 | ||
821 | //@} | |
822 | ||
23324ae1 FM |
823 | |
824 | /** | |
e3995493 | 825 | @name Bounding box functions |
23324ae1 | 826 | */ |
e3995493 FM |
827 | //@{ |
828 | ||
829 | /** | |
830 | Adds the specified point to the bounding box which can be retrieved | |
831 | with MinX(), MaxX() and MinY(), MaxY() functions. | |
832 | ||
833 | @see ResetBoundingBox() | |
834 | */ | |
835 | void CalcBoundingBox(wxCoord x, wxCoord y); | |
23324ae1 FM |
836 | |
837 | /** | |
838 | Gets the maximum horizontal extent used in drawing commands so far. | |
839 | */ | |
adaaa686 | 840 | wxCoord MaxX() const; |
23324ae1 FM |
841 | |
842 | /** | |
843 | Gets the maximum vertical extent used in drawing commands so far. | |
844 | */ | |
adaaa686 | 845 | wxCoord MaxY() const; |
23324ae1 FM |
846 | |
847 | /** | |
848 | Gets the minimum horizontal extent used in drawing commands so far. | |
849 | */ | |
adaaa686 | 850 | wxCoord MinX() const; |
23324ae1 FM |
851 | |
852 | /** | |
853 | Gets the minimum vertical extent used in drawing commands so far. | |
854 | */ | |
adaaa686 | 855 | wxCoord MinY() const; |
23324ae1 FM |
856 | |
857 | /** | |
f09b5681 BP |
858 | Resets the bounding box: after a call to this function, the bounding |
859 | box doesn't contain anything. | |
3c4f71cc | 860 | |
4cc4bfaf | 861 | @see CalcBoundingBox() |
23324ae1 FM |
862 | */ |
863 | void ResetBoundingBox(); | |
864 | ||
e3995493 | 865 | //@} |
3c4f71cc | 866 | |
23324ae1 FM |
867 | |
868 | /** | |
e3995493 | 869 | @name Page and document start/end functions |
23324ae1 | 870 | */ |
e3995493 | 871 | //@{ |
23324ae1 FM |
872 | |
873 | /** | |
e3995493 FM |
874 | Starts a document (only relevant when outputting to a printer). |
875 | @a message is a message to show while printing. | |
23324ae1 | 876 | */ |
e3995493 | 877 | bool StartDoc(const wxString& message); |
23324ae1 FM |
878 | |
879 | /** | |
e3995493 | 880 | Starts a document page (only relevant when outputting to a printer). |
23324ae1 | 881 | */ |
e3995493 | 882 | void StartPage(); |
23324ae1 | 883 | |
23324ae1 | 884 | /** |
e3995493 FM |
885 | Ends a document (only relevant when outputting to a printer). |
886 | */ | |
887 | void EndDoc(); | |
3c4f71cc | 888 | |
e3995493 FM |
889 | /** |
890 | Ends a document page (only relevant when outputting to a printer). | |
23324ae1 | 891 | */ |
e3995493 FM |
892 | void EndPage(); |
893 | ||
23324ae1 FM |
894 | //@} |
895 | ||
23324ae1 FM |
896 | |
897 | /** | |
e3995493 | 898 | @name Bit-Block Transfer operations (blit) |
23324ae1 | 899 | */ |
e3995493 | 900 | //@{ |
23324ae1 FM |
901 | |
902 | /** | |
e3995493 FM |
903 | Copy from a source DC to this DC, specifying the destination |
904 | coordinates, size of area to copy, source DC, source coordinates, | |
905 | logical function, whether to use a bitmap mask, and mask source | |
906 | position. | |
23324ae1 | 907 | |
e3995493 FM |
908 | @param xdest |
909 | Destination device context x position. | |
910 | @param ydest | |
911 | Destination device context y position. | |
912 | @param width | |
913 | Width of source area to be copied. | |
914 | @param height | |
915 | Height of source area to be copied. | |
916 | @param source | |
917 | Source device context. | |
918 | @param xsrc | |
919 | Source device context x position. | |
920 | @param ysrc | |
921 | Source device context y position. | |
922 | @param logicalFunc | |
923 | Logical function to use, see SetLogicalFunction(). | |
924 | @param useMask | |
925 | If @true, Blit does a transparent blit using the mask that is | |
926 | associated with the bitmap selected into the source device context. | |
927 | The Windows implementation does the following if MaskBlt cannot be | |
928 | used: | |
929 | <ol> | |
930 | <li>Creates a temporary bitmap and copies the destination area into | |
931 | it.</li> | |
932 | <li>Copies the source area into the temporary bitmap using the | |
933 | specified logical function.</li> | |
934 | <li>Sets the masked area in the temporary bitmap to BLACK by ANDing | |
935 | the mask bitmap with the temp bitmap with the foreground colour | |
936 | set to WHITE and the bg colour set to BLACK.</li> | |
937 | <li>Sets the unmasked area in the destination area to BLACK by | |
938 | ANDing the mask bitmap with the destination area with the | |
939 | foreground colour set to BLACK and the background colour set to | |
940 | WHITE.</li> | |
941 | <li>ORs the temporary bitmap with the destination area.</li> | |
942 | <li>Deletes the temporary bitmap.</li> | |
943 | </ol> | |
944 | This sequence of operations ensures that the source's transparent | |
945 | area need not be black, and logical functions are supported. | |
946 | @n @b Note: on Windows, blitting with masks can be speeded up | |
947 | considerably by compiling wxWidgets with the wxUSE_DC_CACHE option | |
948 | enabled. You can also influence whether MaskBlt or the explicit | |
949 | mask blitting code above is used, by using wxSystemOptions and | |
950 | setting the @c no-maskblt option to 1. | |
951 | @param xsrcMask | |
952 | Source x position on the mask. If both xsrcMask and ysrcMask are | |
953 | @c -1, xsrc and ysrc will be assumed for the mask source position. | |
954 | Currently only implemented on Windows. | |
955 | @param ysrcMask | |
956 | Source y position on the mask. If both xsrcMask and ysrcMask are | |
957 | @c -1, xsrc and ysrc will be assumed for the mask source position. | |
958 | Currently only implemented on Windows. | |
23324ae1 | 959 | |
e3995493 | 960 | @remarks There is partial support for Blit() in wxPostScriptDC, under X. |
23324ae1 | 961 | |
e3995493 | 962 | @see StretchBlit(), wxMemoryDC, wxBitmap, wxMask |
23324ae1 | 963 | */ |
e3995493 FM |
964 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, |
965 | wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, | |
966 | wxRasterOperationMode logicalFunc = wxCOPY, bool useMask = false, | |
967 | wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); | |
23324ae1 FM |
968 | |
969 | /** | |
970 | Copy from a source DC to this DC, specifying the destination | |
f09b5681 BP |
971 | coordinates, destination size, source DC, source coordinates, size of |
972 | source area to copy, logical function, whether to use a bitmap mask, | |
23324ae1 | 973 | and mask source position. |
3c4f71cc | 974 | |
7c913512 | 975 | @param xdest |
4cc4bfaf | 976 | Destination device context x position. |
7c913512 | 977 | @param ydest |
4cc4bfaf | 978 | Destination device context y position. |
7c913512 | 979 | @param dstWidth |
4cc4bfaf | 980 | Width of destination area. |
7c913512 | 981 | @param dstHeight |
4cc4bfaf | 982 | Height of destination area. |
7c913512 | 983 | @param source |
4cc4bfaf | 984 | Source device context. |
7c913512 | 985 | @param xsrc |
4cc4bfaf | 986 | Source device context x position. |
7c913512 | 987 | @param ysrc |
4cc4bfaf | 988 | Source device context y position. |
7c913512 | 989 | @param srcWidth |
4cc4bfaf | 990 | Width of source area to be copied. |
7c913512 | 991 | @param srcHeight |
4cc4bfaf | 992 | Height of source area to be copied. |
7c913512 | 993 | @param logicalFunc |
f09b5681 | 994 | Logical function to use, see SetLogicalFunction(). |
7c913512 | 995 | @param useMask |
f09b5681 BP |
996 | If @true, Blit does a transparent blit using the mask that is |
997 | associated with the bitmap selected into the source device context. | |
998 | The Windows implementation does the following if MaskBlt cannot be | |
999 | used: | |
1000 | <ol> | |
1001 | <li>Creates a temporary bitmap and copies the destination area into | |
1002 | it.</li> | |
1003 | <li>Copies the source area into the temporary bitmap using the | |
1004 | specified logical function.</li> | |
1005 | <li>Sets the masked area in the temporary bitmap to BLACK by ANDing | |
1006 | the mask bitmap with the temp bitmap with the foreground colour | |
1007 | set to WHITE and the bg colour set to BLACK.</li> | |
1008 | <li>Sets the unmasked area in the destination area to BLACK by | |
1009 | ANDing the mask bitmap with the destination area with the | |
1010 | foreground colour set to BLACK and the background colour set to | |
1011 | WHITE.</li> | |
1012 | <li>ORs the temporary bitmap with the destination area.</li> | |
1013 | <li>Deletes the temporary bitmap.</li> | |
1014 | </ol> | |
1015 | This sequence of operations ensures that the source's transparent | |
1016 | area need not be black, and logical functions are supported. | |
1017 | @n @b Note: on Windows, blitting with masks can be speeded up | |
1018 | considerably by compiling wxWidgets with the wxUSE_DC_CACHE option | |
1019 | enabled. You can also influence whether MaskBlt or the explicit | |
1020 | mask blitting code above is used, by using wxSystemOptions and | |
1021 | setting the @c no-maskblt option to 1. | |
7c913512 | 1022 | @param xsrcMask |
f09b5681 | 1023 | Source x position on the mask. If both xsrcMask and ysrcMask are |
408776d0 FM |
1024 | wxDefaultCoord, @a xsrc and @a ysrc will be assumed for the mask |
1025 | source position. Currently only implemented on Windows. | |
7c913512 | 1026 | @param ysrcMask |
f09b5681 | 1027 | Source y position on the mask. If both xsrcMask and ysrcMask are |
408776d0 FM |
1028 | wxDefaultCoord, @a xsrc and @a ysrc will be assumed for the mask |
1029 | source position. Currently only implemented on Windows. | |
f09b5681 BP |
1030 | |
1031 | There is partial support for Blit() in wxPostScriptDC, under X. | |
1032 | ||
1033 | StretchBlit() is only implemented under wxMAC and wxMSW. | |
1034 | ||
1035 | See wxMemoryDC for typical usage. | |
1036 | ||
1e24c2af | 1037 | @since 2.9.0 |
f09b5681 BP |
1038 | |
1039 | @see Blit(), wxMemoryDC, wxBitmap, wxMask | |
1040 | */ | |
1041 | bool StretchBlit(wxCoord xdest, wxCoord ydest, | |
1042 | wxCoord dstWidth, wxCoord dstHeight, | |
1043 | wxDC* source, wxCoord xsrc, wxCoord ysrc, | |
1044 | wxCoord srcWidth, wxCoord srcHeight, | |
89efaf2b | 1045 | wxRasterOperationMode logicalFunc = wxCOPY, |
4cc4bfaf | 1046 | bool useMask = false, |
408776d0 FM |
1047 | wxCoord xsrcMask = wxDefaultCoord, |
1048 | wxCoord ysrcMask = wxDefaultCoord); | |
e3995493 FM |
1049 | //@} |
1050 | ||
1051 | ||
1052 | /** | |
1053 | @name Background/foreground brush and pen | |
1054 | */ | |
1055 | //@{ | |
1056 | ||
1057 | /** | |
1058 | Gets the brush used for painting the background. | |
1059 | ||
1060 | @see wxDC::SetBackground() | |
1061 | */ | |
1062 | const wxBrush& GetBackground() const; | |
1063 | ||
1064 | /** | |
1065 | Gets the current brush. | |
1066 | ||
1067 | @see wxDC::SetBrush() | |
1068 | */ | |
1069 | const wxBrush& GetBrush() const; | |
1070 | ||
1071 | /** | |
1072 | Gets the current pen. | |
1073 | ||
1074 | @see SetPen() | |
1075 | */ | |
1076 | const wxPen& GetPen() const; | |
1077 | ||
1078 | /** | |
1079 | Sets the current background brush for the DC. | |
1080 | */ | |
1081 | void SetBackground(const wxBrush& brush); | |
1082 | ||
1083 | /** | |
1084 | Sets the current brush for the DC. | |
1085 | ||
1086 | If the argument is wxNullBrush, the current brush is selected out of | |
1087 | the device context (leaving wxDC without any valid brush), allowing the | |
1088 | current brush to be destroyed safely. | |
1089 | ||
1090 | @see wxBrush, wxMemoryDC (for the interpretation of colours when | |
1091 | drawing into a monochrome bitmap) | |
1092 | */ | |
1093 | void SetBrush(const wxBrush& brush); | |
1094 | ||
1095 | /** | |
1096 | Sets the current pen for the DC. If the argument is wxNullPen, the | |
1097 | current pen is selected out of the device context (leaving wxDC without | |
1098 | any valid pen), allowing the current brush to be destroyed safely. | |
1099 | ||
1100 | @see wxMemoryDC for the interpretation of colours when drawing into a | |
1101 | monochrome bitmap. | |
1102 | */ | |
1103 | void SetPen(const wxPen& pen); | |
1104 | ||
1105 | //@} | |
1106 | ||
1107 | ||
1108 | ||
1109 | /** | |
1110 | Returns the depth (number of bits/pixel) of this DC. | |
1111 | ||
1112 | @see wxDisplayDepth() | |
1113 | */ | |
1114 | int GetDepth() const; | |
1115 | ||
1116 | /** | |
1117 | Returns the current device origin. | |
1118 | ||
1119 | @see SetDeviceOrigin() | |
1120 | */ | |
1121 | wxPoint GetDeviceOrigin() const; | |
1122 | ||
1123 | /** | |
1124 | Gets the current logical function. | |
1125 | ||
1126 | @see SetLogicalFunction() | |
1127 | */ | |
1128 | wxRasterOperationMode GetLogicalFunction() const; | |
1129 | ||
1130 | /** | |
1131 | Gets the current mapping mode for the device context. | |
1132 | ||
1133 | @see SetMapMode() | |
1134 | */ | |
1135 | wxMappingMode GetMapMode() const; | |
1136 | ||
1137 | /** | |
1138 | Gets in @a colour the colour at the specified location. Not available | |
1139 | for wxPostScriptDC or wxMetafileDC. | |
1140 | ||
1141 | @note Setting a pixel can be done using DrawPoint(). | |
1142 | ||
1143 | @beginWxPythonOnly | |
1144 | The wxColour value is returned and is not required as a parameter. | |
1145 | @endWxPythonOnly | |
1146 | */ | |
1147 | bool GetPixel(wxCoord x, wxCoord y, wxColour* colour) const; | |
1148 | ||
1149 | /** | |
1150 | Returns the resolution of the device in pixels per inch. | |
1151 | */ | |
1152 | wxSize GetPPI() const; | |
1153 | ||
1154 | /** | |
1155 | Gets the horizontal and vertical extent of this device context in @e device units. | |
1156 | It can be used to scale graphics to fit the page. | |
1157 | ||
1158 | For example, if @e maxX and @e maxY represent the maximum horizontal | |
1159 | and vertical 'pixel' values used in your application, the following | |
1160 | code will scale the graphic to fit on the printer page: | |
1161 | ||
1162 | @code | |
1163 | wxCoord w, h; | |
1164 | dc.GetSize(&w, &h); | |
1165 | double scaleX = (double)(maxX / w); | |
1166 | double scaleY = (double)(maxY / h); | |
1167 | dc.SetUserScale(min(scaleX, scaleY),min(scaleX, scaleY)); | |
1168 | @endcode | |
1169 | ||
1170 | @beginWxPythonOnly | |
1171 | In place of a single overloaded method name, wxPython implements the | |
1172 | following methods: | |
1173 | - GetSize() - Returns a wxSize. | |
1174 | - GetSizeWH() - Returns a 2-tuple (width, height). | |
1175 | @endWxPythonOnly | |
1176 | */ | |
1177 | void GetSize(wxCoord* width, wxCoord* height) const; | |
1178 | ||
1179 | /** | |
1180 | @overload | |
1181 | */ | |
1182 | wxSize GetSize() const; | |
1183 | ||
1184 | /** | |
1185 | Returns the horizontal and vertical resolution in millimetres. | |
1186 | */ | |
1187 | void GetSizeMM(wxCoord* width, wxCoord* height) const; | |
1188 | ||
1189 | /** | |
1190 | @overload | |
1191 | */ | |
1192 | wxSize GetSizeMM() const; | |
1193 | ||
1194 | /** | |
1195 | Gets the current user scale factor. | |
1196 | ||
1197 | @see SetUserScale() | |
1198 | */ | |
1199 | void GetUserScale(double* x, double* y) const; | |
1200 | ||
1201 | /** | |
1202 | Returns @true if the DC is ok to use. | |
1203 | */ | |
1204 | bool IsOk() const; | |
1205 | ||
1206 | /** | |
1207 | Sets the x and y axis orientation (i.e., the direction from lowest to | |
1208 | highest values on the axis). The default orientation is x axis from | |
1209 | left to right and y axis from top down. | |
1210 | ||
1211 | @param xLeftRight | |
1212 | True to set the x axis orientation to the natural left to right | |
1213 | orientation, @false to invert it. | |
1214 | @param yBottomUp | |
1215 | True to set the y axis orientation to the natural bottom up | |
1216 | orientation, @false to invert it. | |
1217 | */ | |
1218 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
1219 | ||
1220 | /** | |
1221 | Sets the device origin (i.e., the origin in pixels after scaling has | |
1222 | been applied). This function may be useful in Windows printing | |
1223 | operations for placing a graphic on a page. | |
1224 | */ | |
1225 | void SetDeviceOrigin(wxCoord x, wxCoord y); | |
1226 | ||
1227 | /** | |
1228 | Sets the current logical function for the device context. | |
1229 | It determines how a @e source pixel (from a pen or brush colour, or source | |
1230 | device context if using Blit()) combines with a @e destination pixel in | |
1231 | the current device context. | |
1232 | Text drawing is not affected by this function. | |
1233 | ||
1234 | See ::wxRasterOperationMode enumeration values for more info. | |
1235 | ||
1236 | The default is @c wxCOPY, which simply draws with the current colour. | |
1237 | The others combine the current colour and the background using a logical | |
1238 | operation. @c wxINVERT is commonly used for drawing rubber bands or moving | |
1239 | outlines, since drawing twice reverts to the original colour. | |
1240 | */ | |
1241 | void SetLogicalFunction(wxRasterOperationMode function); | |
1242 | ||
1243 | /** | |
1244 | The mapping mode of the device context defines the unit of measurement | |
1245 | used to convert @e logical units to @e device units. | |
1246 | ||
1247 | Note that in X, text drawing isn't handled consistently with the mapping mode; | |
1248 | a font is always specified in point size. However, setting the user scale (see | |
1249 | SetUserScale()) scales the text appropriately. In Windows, scalable | |
1250 | TrueType fonts are always used; in X, results depend on availability of | |
1251 | fonts, but usually a reasonable match is found. | |
1252 | ||
1253 | The coordinate origin is always at the top left of the screen/printer. | |
1254 | ||
1255 | Drawing to a Windows printer device context uses the current mapping | |
1256 | mode, but mapping mode is currently ignored for PostScript output. | |
1257 | */ | |
1258 | void SetMapMode(wxMappingMode mode); | |
1259 | ||
1260 | /** | |
1261 | If this is a window DC or memory DC, assigns the given palette to the | |
1262 | window or bitmap associated with the DC. If the argument is | |
1263 | ::wxNullPalette, the current palette is selected out of the device | |
1264 | context, and the original palette restored. | |
1265 | ||
1266 | @see wxPalette | |
1267 | */ | |
1268 | void SetPalette(const wxPalette& palette); | |
1269 | ||
1270 | /** | |
1271 | Sets the user scaling factor, useful for applications which require | |
1272 | 'zooming'. | |
1273 | */ | |
1274 | void SetUserScale(double xScale, double yScale); | |
23324ae1 FM |
1275 | }; |
1276 | ||
1277 | ||
e54c96f1 | 1278 | |
23324ae1 FM |
1279 | /** |
1280 | @class wxDCClipper | |
7c913512 | 1281 | |
f09b5681 BP |
1282 | wxDCClipper is a small helper class for setting a clipping region on a wxDC |
1283 | and unsetting it automatically. An object of wxDCClipper class is typically | |
1284 | created on the stack so that it is automatically destroyed when the object | |
1285 | goes out of scope. A typical usage example: | |
7c913512 | 1286 | |
23324ae1 FM |
1287 | @code |
1288 | void MyFunction(wxDC& dc) | |
f09b5681 BP |
1289 | { |
1290 | wxDCClipper clip(dc, rect); | |
1291 | // ... drawing functions here are affected by clipping rect ... | |
1292 | } | |
1293 | ||
1294 | void OtherFunction() | |
1295 | { | |
1296 | wxDC dc; | |
1297 | MyFunction(dc); | |
1298 | // ... drawing functions here are not affected by clipping rect ... | |
1299 | } | |
23324ae1 | 1300 | @endcode |
7c913512 | 1301 | |
23324ae1 FM |
1302 | @library{wxcore} |
1303 | @category{gdi} | |
7c913512 | 1304 | |
382f12e4 FM |
1305 | @see wxDC::SetClippingRegion(), wxDCFontChanger, wxDCTextColourChanger, wxDCPenChanger, |
1306 | wxDCBrushChanger | |
23324ae1 | 1307 | */ |
7c913512 | 1308 | class wxDCClipper |
23324ae1 FM |
1309 | { |
1310 | public: | |
1311 | //@{ | |
1312 | /** | |
f09b5681 BP |
1313 | Sets the clipping region to the specified region/coordinates. |
1314 | ||
23324ae1 FM |
1315 | The clipping region is automatically unset when this object is destroyed. |
1316 | */ | |
1317 | wxDCClipper(wxDC& dc, const wxRegion& r); | |
7c913512 | 1318 | wxDCClipper(wxDC& dc, const wxRect& rect); |
882678eb | 1319 | wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h); |
23324ae1 | 1320 | //@} |
c48d6cdf FM |
1321 | |
1322 | /** | |
1323 | Destroys the clipping region associated with the DC passed to the ctor. | |
1324 | */ | |
1325 | ~wxDCClipper(); | |
1326 | }; | |
1327 | ||
1328 | ||
1329 | /** | |
1330 | @class wxDCBrushChanger | |
1331 | ||
1332 | wxDCBrushChanger is a small helper class for setting a brush on a wxDC | |
1333 | and unsetting it automatically in the destructor, restoring the previous one. | |
1334 | ||
1335 | @library{wxcore} | |
1336 | @category{gdi} | |
1337 | ||
382f12e4 FM |
1338 | @see wxDC::SetBrush(), wxDCFontChanger, wxDCTextColourChanger, wxDCPenChanger, |
1339 | wxDCClipper | |
c48d6cdf FM |
1340 | */ |
1341 | class wxDCBrushChanger | |
1342 | { | |
1343 | public: | |
1344 | /** | |
1345 | Sets @a brush on the given @a dc, storing the old one. | |
1346 | ||
1347 | @param dc | |
1348 | The DC where the brush must be temporary set. | |
1349 | @param brush | |
1350 | The brush to set. | |
1351 | */ | |
1352 | wxDCBrushChanger(wxDC& dc, const wxBrush& brush); | |
1353 | ||
1354 | /** | |
1355 | Restores the brush originally selected in the DC passed to the ctor. | |
1356 | */ | |
1357 | ~wxDCBrushChanger(); | |
1358 | }; | |
1359 | ||
1360 | ||
1361 | /** | |
1362 | @class wxDCPenChanger | |
1363 | ||
1364 | wxDCPenChanger is a small helper class for setting a pen on a wxDC | |
1365 | and unsetting it automatically in the destructor, restoring the previous one. | |
1366 | ||
1367 | @library{wxcore} | |
1368 | @category{gdi} | |
1369 | ||
382f12e4 FM |
1370 | @see wxDC::SetPen(), wxDCFontChanger, wxDCTextColourChanger, wxDCBrushChanger, |
1371 | wxDCClipper | |
c48d6cdf FM |
1372 | */ |
1373 | class wxDCPenChanger | |
1374 | { | |
1375 | public: | |
1376 | /** | |
1377 | Sets @a pen on the given @a dc, storing the old one. | |
1378 | ||
1379 | @param dc | |
1380 | The DC where the pen must be temporary set. | |
1381 | @param pen | |
1382 | The pen to set. | |
1383 | */ | |
1384 | wxDCPenChanger(wxDC& dc, const wxPen& pen); | |
1385 | ||
1386 | /** | |
1387 | Restores the pen originally selected in the DC passed to the ctor. | |
1388 | */ | |
1389 | ~wxDCPenChanger(); | |
1390 | }; | |
1391 | ||
1392 | ||
1393 | ||
1394 | /** | |
1395 | @class wxDCTextColourChanger | |
1396 | ||
1397 | wxDCTextColourChanger is a small helper class for setting a foreground | |
1398 | text colour on a wxDC and unsetting it automatically in the destructor, | |
1399 | restoring the previous one. | |
1400 | ||
1401 | @library{wxcore} | |
1402 | @category{gdi} | |
1403 | ||
382f12e4 FM |
1404 | @see wxDC::SetTextForeground(), wxDCFontChanger, wxDCPenChanger, wxDCBrushChanger, |
1405 | wxDCClipper | |
c48d6cdf FM |
1406 | */ |
1407 | class wxDCTextColourChanger | |
1408 | { | |
1409 | public: | |
1410 | /** | |
1411 | Sets @a col on the given @a dc, storing the old one. | |
1412 | ||
1413 | @param dc | |
1414 | The DC where the colour must be temporary set. | |
1415 | @param col | |
1416 | The colour to set. | |
1417 | */ | |
1418 | wxDCTextColourChanger(wxDC& dc, const wxColour& col); | |
1419 | ||
1420 | /** | |
1421 | Restores the colour originally selected in the DC passed to the ctor. | |
1422 | */ | |
1423 | ~wxDCTextColourChanger(); | |
1424 | }; | |
1425 | ||
1426 | ||
1427 | ||
1428 | /** | |
1429 | @class wxDCFontChanger | |
1430 | ||
1431 | wxDCFontChanger is a small helper class for setting a font on a wxDC and | |
1432 | unsetting it automatically in the destructor, restoring the previous one. | |
1433 | ||
1434 | @since 2.9.0 | |
1435 | ||
1436 | @library{wxcore} | |
1437 | @category{gdi} | |
1438 | ||
382f12e4 FM |
1439 | @see wxDC::SetFont(), wxDCTextColourChanger, wxDCPenChanger, wxDCBrushChanger, |
1440 | wxDCClipper | |
c48d6cdf FM |
1441 | */ |
1442 | class wxDCFontChanger | |
1443 | { | |
1444 | public: | |
1445 | /** | |
1446 | Sets @a font on the given @a dc, storing the old one. | |
1447 | ||
1448 | @param dc | |
1449 | The DC where the font must be temporary set. | |
1450 | @param font | |
1451 | The font to set. | |
1452 | */ | |
1453 | wxDCFontChanger(wxDC& dc, const wxFont& font); | |
1454 | ||
1455 | /** | |
1456 | Restores the colour originally selected in the DC passed to the ctor. | |
1457 | */ | |
1458 | ~wxDCFontChanger(); | |
23324ae1 | 1459 | }; |
e54c96f1 | 1460 |