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