]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _dc.i | |
3 | // Purpose: SWIG interface defs for wxDC and releated classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7-July-1997 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
4942342c | 16 | |
d14a1e28 RD |
17 | //--------------------------------------------------------------------------- |
18 | ||
19 | %{ | |
20 | #include "wx/wxPython/pydrawxxx.h" | |
21 | %} | |
22 | ||
23 | // TODO: 1. wrappers for wxDrawObject and wxDC::DrawObject | |
24 | ||
25 | ||
26 | //--------------------------------------------------------------------------- | |
27 | ||
28 | %typemap(in) (int points, wxPoint* points_array ) { | |
29 | $2 = wxPoint_LIST_helper($input, &$1); | |
30 | if ($2 == NULL) SWIG_fail; | |
31 | } | |
32 | %typemap(freearg) (int points, wxPoint* points_array ) { | |
33 | if ($2) delete [] $2; | |
34 | } | |
35 | ||
36 | ||
37 | //--------------------------------------------------------------------------- | |
38 | %newgroup; | |
39 | ||
40 | ||
70794ec5 RD |
41 | DocStr(wxDC, |
42 | "A wx.DC is a device context onto which graphics and text can be | |
43 | drawn. It is intended to represent a number of output devices in a | |
44 | generic way, so a window can have a device context associated with it, | |
45 | and a printer also has a device context. In this way, the same piece | |
46 | of code may write to a number of different devices, if the device | |
47 | context is used as a parameter. | |
48 | ||
49 | Derived types of wxDC have documentation for specific features only, | |
50 | so refer to this section for most device context information. | |
51 | ||
52 | The wx.DC class is abstract and can not be instantiated, you must use | |
53 | one of the derived classes instead. Which one will depend on the | |
54 | situation in which it is used.", ""); | |
55 | ||
d14a1e28 RD |
56 | class wxDC : public wxObject { |
57 | public: | |
58 | // wxDC(); **** abstract base class, can't instantiate. | |
59 | ~wxDC(); | |
60 | ||
61 | ||
22b549f2 RD |
62 | %pythoncode { |
63 | %# These have been deprecated in wxWidgets. Since they never | |
64 | %# really did anything to begin with, just make them be NOPs. | |
65 | def BeginDrawing(self): pass | |
66 | def EndDrawing(self): pass | |
67 | } | |
70794ec5 | 68 | |
70794ec5 | 69 | |
22b549f2 | 70 | |
70794ec5 | 71 | // TODO virtual void DrawObject(wxDrawObject* drawobject); |
d14a1e28 RD |
72 | |
73 | ||
70794ec5 RD |
74 | DocStr( |
75 | FloodFill, | |
76 | "Flood fills the device context starting from the given point, using | |
77 | the current brush colour, and using a style: | |
d14a1e28 | 78 | |
70794ec5 RD |
79 | - **wxFLOOD_SURFACE**: the flooding occurs until a colour other than |
80 | the given colour is encountered. | |
d14a1e28 | 81 | |
70794ec5 RD |
82 | - **wxFLOOD_BORDER**: the area to be flooded is bounded by the given |
83 | colour. | |
d14a1e28 | 84 | |
70794ec5 | 85 | Returns False if the operation failed. |
d14a1e28 | 86 | |
70794ec5 RD |
87 | Note: The present implementation for non-Windows platforms may fail to |
88 | find colour borders if the pixels do not match the colour | |
89 | exactly. However the function will still return true.", ""); | |
d14a1e28 | 90 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); |
1b8c7ba6 | 91 | %Rename(FloodFillPoint, bool, FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE)); |
dce2bd22 | 92 | |
ddbb966d RD |
93 | // fill the area specified by rect with a radial gradient, starting from |
94 | // initialColour in the centre of the cercle and fading to destColour. | |
95 | ||
96 | DocDeclStr( | |
97 | void , GradientFillConcentric(const wxRect& rect, | |
98 | const wxColour& initialColour, | |
99 | const wxColour& destColour, | |
100 | const wxPoint& circleCenter), | |
101 | "Fill the area specified by rect with a radial gradient, starting from | |
102 | initialColour in the center of the circle and fading to destColour on | |
103 | the outside of the circle. The circleCenter argument is the relative | |
104 | coordinants of the center of the circle in the specified rect. | |
105 | ||
106 | Note: Currently this function is very slow, don't use it for real-time | |
107 | drawing.", ""); | |
108 | ||
109 | ||
110 | DocDeclStr( | |
111 | void , GradientFillLinear(const wxRect& rect, | |
112 | const wxColour& initialColour, | |
113 | const wxColour& destColour, | |
114 | wxDirection nDirection = wxEAST), | |
115 | "Fill the area specified by rect with a linear gradient, starting from | |
116 | initialColour and eventually fading to destColour. The nDirection | |
117 | parameter specifies the direction of the colour change, default is to | |
118 | use initialColour on the left part of the rectangle and destColour on | |
119 | the right side.", ""); | |
120 | ||
121 | ||
70794ec5 RD |
122 | |
123 | DocStr( | |
124 | GetPixel, | |
125 | "Gets the colour at the specified location on the DC.",""); | |
d14a1e28 RD |
126 | %extend { |
127 | wxColour GetPixel(wxCoord x, wxCoord y) { | |
128 | wxColour col; | |
129 | self->GetPixel(x, y, &col); | |
130 | return col; | |
131 | } | |
dce2bd22 RD |
132 | wxColour GetPixelPoint(const wxPoint& pt) { |
133 | wxColour col; | |
134 | self->GetPixel(pt, &col); | |
135 | return col; | |
136 | } | |
d14a1e28 | 137 | } |
70794ec5 | 138 | |
dce2bd22 | 139 | |
70794ec5 RD |
140 | DocStr( |
141 | DrawLine, | |
142 | "Draws a line from the first point to the second. The current pen is | |
143 | used for drawing the line. Note that the second point is *not* part of | |
144 | the line and is not drawn by this function (this is consistent with | |
145 | the behaviour of many other toolkits).", ""); | |
d14a1e28 | 146 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); |
1b8c7ba6 | 147 | %Rename(DrawLinePoint, void, DrawLine(const wxPoint& pt1, const wxPoint& pt2)); |
dce2bd22 | 148 | |
70794ec5 RD |
149 | |
150 | DocStr( | |
151 | CrossHair, | |
152 | "Displays a cross hair using the current pen. This is a vertical and | |
153 | horizontal line the height and width of the window, centred on the | |
154 | given point.", ""); | |
d14a1e28 | 155 | void CrossHair(wxCoord x, wxCoord y); |
1b8c7ba6 | 156 | %Rename(CrossHairPoint, void, CrossHair(const wxPoint& pt)); |
dce2bd22 | 157 | |
70794ec5 RD |
158 | |
159 | DocStr( | |
160 | DrawArc, | |
161 | "Draws an arc of a circle, centred on the *center* point (xc, yc), from | |
162 | the first point to the second. The current pen is used for the outline | |
163 | and the current brush for filling the shape. | |
164 | ||
165 | The arc is drawn in an anticlockwise direction from the start point to | |
166 | the end point.", ""); | |
d14a1e28 | 167 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc); |
1b8c7ba6 | 168 | %Rename(DrawArcPoint, void, DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& center)); |
dce2bd22 | 169 | |
70794ec5 RD |
170 | |
171 | DocStr( | |
172 | DrawCheckMark, | |
173 | "Draws a check mark inside the given rectangle.", ""); | |
d14a1e28 | 174 | void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
1b8c7ba6 | 175 | %Rename(DrawCheckMarkRect, void, DrawCheckMark(const wxRect& rect)); |
dce2bd22 | 176 | |
70794ec5 RD |
177 | DocStr( |
178 | DrawEllipticArc, | |
179 | "Draws an arc of an ellipse, with the given rectangle defining the | |
180 | bounds of the ellipse. The current pen is used for drawing the arc and | |
181 | the current brush is used for drawing the pie. | |
182 | ||
183 | The *start* and *end* parameters specify the start and end of the arc | |
184 | relative to the three-o'clock position from the center of the | |
185 | rectangle. Angles are specified in degrees (360 is a complete | |
186 | circle). Positive values mean counter-clockwise motion. If start is | |
187 | equal to end, a complete ellipse will be drawn.", ""); | |
188 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double start, double end); | |
1b8c7ba6 | 189 | %Rename(DrawEllipticArcPointSize, void, DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double start, double end)); |
70794ec5 | 190 | |
dce2bd22 | 191 | |
70794ec5 RD |
192 | DocStr( |
193 | DrawPoint, | |
194 | "Draws a point using the current pen.", ""); | |
d14a1e28 | 195 | void DrawPoint(wxCoord x, wxCoord y); |
1b8c7ba6 | 196 | %Rename(DrawPointPoint, void, DrawPoint(const wxPoint& pt)); |
dce2bd22 | 197 | |
70794ec5 RD |
198 | |
199 | DocStr( | |
200 | DrawRectangle, | |
201 | "Draws a rectangle with the given top left corner, and with the given | |
202 | size. The current pen is used for the outline and the current brush | |
203 | for filling the shape.", ""); | |
d14a1e28 | 204 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
1b8c7ba6 RD |
205 | %Rename(DrawRectangleRect,void, DrawRectangle(const wxRect& rect)); |
206 | %Rename(DrawRectanglePointSize, void, DrawRectangle(const wxPoint& pt, const wxSize& sz)); | |
dce2bd22 | 207 | |
70794ec5 RD |
208 | |
209 | DocStr( | |
210 | DrawRoundedRectangle, | |
211 | "Draws a rectangle with the given top left corner, and with the given | |
212 | size. The corners are quarter-circles using the given radius. The | |
213 | current pen is used for the outline and the current brush for filling | |
214 | the shape. | |
215 | ||
216 | If radius is positive, the value is assumed to be the radius of the | |
217 | rounded corner. If radius is negative, the absolute value is assumed | |
218 | to be the proportion of the smallest dimension of the rectangle. This | |
219 | means that the corner can be a sensible size relative to the size of | |
220 | the rectangle, and also avoids the strange effects X produces when the | |
221 | corners are too big for the rectangle.", ""); | |
d14a1e28 | 222 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius); |
1b8c7ba6 RD |
223 | %Rename(DrawRoundedRectangleRect, void, DrawRoundedRectangle(const wxRect& r, double radius)); |
224 | %Rename(DrawRoundedRectanglePointSize, void, DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius)); | |
dce2bd22 | 225 | |
70794ec5 RD |
226 | |
227 | DocStr( | |
228 | DrawCircle, | |
229 | "Draws a circle with the given center point and radius. The current | |
230 | pen is used for the outline and the current brush for filling the | |
231 | shape.", " | |
232 | ||
233 | :see: `DrawEllipse`"); | |
d14a1e28 | 234 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); |
1b8c7ba6 | 235 | %Rename(DrawCirclePoint, void, DrawCircle(const wxPoint& pt, wxCoord radius)); |
dce2bd22 | 236 | |
70794ec5 RD |
237 | |
238 | DocStr( | |
239 | DrawEllipse, | |
240 | "Draws an ellipse contained in the specified rectangle. The current pen | |
241 | is used for the outline and the current brush for filling the shape.", " | |
242 | ||
243 | :see: `DrawCircle`"); | |
d14a1e28 | 244 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
1b8c7ba6 RD |
245 | %Rename(DrawEllipseRect, void, DrawEllipse(const wxRect& rect)); |
246 | %Rename(DrawEllipsePointSize, void, DrawEllipse(const wxPoint& pt, const wxSize& sz)); | |
dce2bd22 | 247 | |
70794ec5 RD |
248 | |
249 | DocStr( | |
250 | DrawIcon, | |
251 | "Draw an icon on the display (does nothing if the device context is | |
252 | PostScript). This can be the simplest way of drawing bitmaps on a | |
253 | window.", ""); | |
d14a1e28 | 254 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); |
1b8c7ba6 | 255 | %Rename(DrawIconPoint, void, DrawIcon(const wxIcon& icon, const wxPoint& pt)); |
dce2bd22 | 256 | |
d14a1e28 | 257 | |
70794ec5 RD |
258 | DocStr( |
259 | DrawBitmap, | |
260 | "Draw a bitmap on the device context at the specified point. If | |
261 | *transparent* is true and the bitmap has a transparency mask, (or | |
262 | alpha channel on the platforms that support it) then the bitmap will | |
263 | be drawn transparently.", " | |
4942342c | 264 | |
70794ec5 RD |
265 | When drawing a mono-bitmap, the current text foreground colour will be |
266 | used to draw the foreground of the bitmap (all bits set to 1), and the | |
267 | current text background colour to draw the background (all bits set to | |
268 | 0). | |
d14a1e28 | 269 | |
70794ec5 | 270 | :see: `SetTextForeground`, `SetTextBackground` and `wx.MemoryDC`"); |
a72f4631 | 271 | void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = false); |
1b8c7ba6 | 272 | %Rename(DrawBitmapPoint, void, DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = false)); |
d14a1e28 | 273 | |
d14a1e28 | 274 | |
70794ec5 RD |
275 | DocStr( |
276 | DrawText, | |
277 | "Draws a text string at the specified point, using the current text | |
278 | font, and the current text foreground and background colours. | |
d14a1e28 | 279 | |
70794ec5 RD |
280 | The coordinates refer to the top-left corner of the rectangle bounding |
281 | the string. See `GetTextExtent` for how to get the dimensions of a | |
282 | text string, which can be used to position the text more precisely. | |
d14a1e28 | 283 | |
70794ec5 RD |
284 | **NOTE**: under wxGTK the current logical function is used by this |
285 | function but it is ignored by wxMSW. Thus, you should avoid using | |
286 | logical functions with this function in portable programs.", " | |
d14a1e28 | 287 | |
70794ec5 RD |
288 | :see: `DrawRotatedText`"); |
289 | void DrawText(const wxString& text, wxCoord x, wxCoord y); | |
1b8c7ba6 | 290 | %Rename(DrawTextPoint, void, DrawText(const wxString& text, const wxPoint& pt)); |
d14a1e28 | 291 | |
d14a1e28 | 292 | |
70794ec5 RD |
293 | DocStr( |
294 | DrawRotatedText, | |
295 | "Draws the text rotated by *angle* degrees, if supported by the platform. | |
d14a1e28 | 296 | |
70794ec5 RD |
297 | **NOTE**: Under Win9x only TrueType fonts can be drawn by this |
298 | function. In particular, a font different from ``wx.NORMAL_FONT`` | |
299 | should be used as the it is not normally a TrueType | |
300 | font. ``wx.SWISS_FONT`` is an example of a font which is."," | |
d14a1e28 | 301 | |
70794ec5 RD |
302 | :see: `DrawText`"); |
303 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); | |
1b8c7ba6 | 304 | %Rename(DrawRotatedTextPoint, void, DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)); |
d14a1e28 | 305 | |
d14a1e28 | 306 | |
70794ec5 RD |
307 | DocDeclStr( |
308 | bool , Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
309 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
a72f4631 | 310 | int rop = wxCOPY, bool useMask = false, |
70794ec5 RD |
311 | wxCoord xsrcMask = -1, wxCoord ysrcMask = -1), |
312 | "Copy from a source DC to this DC. Parameters specify the destination | |
313 | coordinates, size of area to copy, source DC, source coordinates, | |
314 | logical function, whether to use a bitmap mask, and mask source | |
315 | position.", " | |
316 | ||
317 | :param xdest: Destination device context x position. | |
318 | :param ydest: Destination device context y position. | |
319 | :param width: Width of source area to be copied. | |
320 | :param height: Height of source area to be copied. | |
321 | :param source: Source device context. | |
322 | :param xsrc: Source device context x position. | |
323 | :param ysrc: Source device context y position. | |
324 | :param rop: Logical function to use: see `SetLogicalFunction`. | |
325 | :param useMask: If true, Blit does a transparent blit using the mask | |
326 | that is associated with the bitmap selected into the | |
327 | source device context. | |
328 | :param xsrcMask: Source x position on the mask. If both xsrcMask and | |
329 | ysrcMask are -1, xsrc and ysrc will be assumed for | |
330 | the mask source position. | |
331 | :param ysrcMask: Source y position on the mask. | |
332 | "); | |
333 | ||
334 | DocDeclStrName( | |
335 | bool , Blit(const wxPoint& destPt, const wxSize& sz, | |
336 | wxDC *source, const wxPoint& srcPt, | |
a72f4631 | 337 | int rop = wxCOPY, bool useMask = false, |
70794ec5 RD |
338 | const wxPoint& srcPtMask = wxDefaultPosition), |
339 | "Copy from a source DC to this DC. Parameters specify the destination | |
340 | coordinates, size of area to copy, source DC, source coordinates, | |
341 | logical function, whether to use a bitmap mask, and mask source | |
342 | position.", " | |
343 | ||
344 | :param destPt: Destination device context position. | |
345 | :param sz: Size of source area to be copied. | |
346 | :param source: Source device context. | |
347 | :param srcPt: Source device context position. | |
348 | :param rop: Logical function to use: see `SetLogicalFunction`. | |
349 | :param useMask: If true, Blit does a transparent blit using the mask | |
350 | that is associated with the bitmap selected into the | |
351 | source device context. | |
352 | :param srcPtMask: Source position on the mask. | |
353 | ", | |
354 | BlitPointSize); | |
355 | ||
d14a1e28 | 356 | |
70794ec5 RD |
357 | DocStr( |
358 | SetClippingRegion, | |
359 | "Sets the clipping region for this device context to the intersection | |
360 | of the given region described by the parameters of this method and the | |
361 | previously set clipping region. You should call `DestroyClippingRegion` | |
362 | if you want to set the clipping region exactly to the region | |
363 | specified. | |
4942342c | 364 | |
70794ec5 RD |
365 | The clipping region is an area to which drawing is |
366 | restricted. Possible uses for the clipping region are for clipping | |
367 | text or for speeding up window redraws when only a known area of the | |
368 | screen is damaged.", " | |
d14a1e28 | 369 | |
70794ec5 RD |
370 | :see: `DestroyClippingRegion`, `wx.Region`"); |
371 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
1b8c7ba6 RD |
372 | %Rename(SetClippingRegionPointSize, void, SetClippingRegion(const wxPoint& pt, const wxSize& sz)); |
373 | %Rename(SetClippingRegionAsRegion, void, SetClippingRegion(const wxRegion& region)); | |
374 | %Rename(SetClippingRect, void, SetClippingRegion(const wxRect& rect)); | |
d7403ad2 | 375 | |
4942342c | 376 | |
70794ec5 RD |
377 | |
378 | DocDeclAStr( | |
379 | void , DrawLines(int points, wxPoint* points_array, | |
380 | wxCoord xoffset = 0, wxCoord yoffset = 0), | |
381 | "DrawLines(self, List points, int xoffset=0, int yoffset=0)", | |
382 | "Draws lines using a sequence of `wx.Point` objects, adding the | |
383 | optional offset coordinate. The current pen is used for drawing the | |
384 | lines.", ""); | |
385 | ||
d14a1e28 | 386 | |
70794ec5 RD |
387 | DocDeclAStr( |
388 | void , DrawPolygon(int points, wxPoint* points_array, | |
d14a1e28 | 389 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
70794ec5 RD |
390 | int fillStyle = wxODDEVEN_RULE), |
391 | "DrawPolygon(self, List points, int xoffset=0, int yoffset=0, | |
392 | int fillStyle=ODDEVEN_RULE)", | |
393 | "Draws a filled polygon using a sequence of `wx.Point` objects, adding | |
394 | the optional offset coordinate. The last argument specifies the fill | |
395 | rule: ``wx.ODDEVEN_RULE`` (the default) or ``wx.WINDING_RULE``. | |
396 | ||
397 | The current pen is used for drawing the outline, and the current brush | |
398 | for filling the shape. Using a transparent brush suppresses | |
399 | filling. Note that wxWidgets automatically closes the first and last | |
400 | points.", ""); | |
401 | ||
d14a1e28 | 402 | |
86aafce3 RD |
403 | // TODO: Figure out a good typemap for this... |
404 | // Convert the first 3 args from a sequence of sequences? | |
405 | // void DrawPolyPolygon(int n, int count[], wxPoint points[], | |
406 | // wxCoord xoffset = 0, wxCoord yoffset = 0, | |
407 | // int fillStyle = wxODDEVEN_RULE); | |
d14a1e28 | 408 | |
86aafce3 | 409 | |
70794ec5 RD |
410 | DocDeclStr( |
411 | void , DrawLabel(const wxString& text, const wxRect& rect, | |
412 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
413 | int indexAccel = -1), | |
414 | "Draw *text* within the specified rectangle, abiding by the alignment | |
415 | flags. Will additionally emphasize the character at *indexAccel* if | |
416 | it is not -1.", " | |
417 | ||
418 | :see: `DrawImageLabel`"); | |
419 | ||
420 | ||
d14a1e28 | 421 | %extend { |
70794ec5 RD |
422 | DocStr(DrawImageLabel, |
423 | "Draw *text* and an image (which may be ``wx.NullBitmap`` to skip | |
424 | drawing it) within the specified rectangle, abiding by the alignment | |
425 | flags. Will additionally emphasize the character at *indexAccel* if | |
426 | it is not -1. Returns the bounding rectangle.", ""); | |
d14a1e28 RD |
427 | wxRect DrawImageLabel(const wxString& text, |
428 | const wxBitmap& image, | |
429 | const wxRect& rect, | |
430 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
431 | int indexAccel = -1) { | |
432 | wxRect rv; | |
433 | self->DrawLabel(text, image, rect, alignment, indexAccel, &rv); | |
434 | return rv; | |
435 | } | |
436 | } | |
437 | ||
438 | ||
439 | ||
70794ec5 RD |
440 | DocDeclAStr( |
441 | void , DrawSpline(int points, wxPoint* points_array), | |
442 | "DrawSpline(self, List points)", | |
443 | "Draws a spline between all given control points, (a list of `wx.Point` | |
444 | objects) using the current pen. The spline is drawn using a series of | |
445 | lines, using an algorithm taken from the X drawing program 'XFIG'.", ""); | |
446 | ||
d14a1e28 RD |
447 | |
448 | ||
4942342c | 449 | |
d14a1e28 RD |
450 | // global DC operations |
451 | // -------------------- | |
452 | ||
70794ec5 RD |
453 | DocDeclStr( |
454 | virtual void , Clear(), | |
455 | "Clears the device context using the current background brush.", ""); | |
456 | ||
d14a1e28 | 457 | |
70794ec5 RD |
458 | DocDeclStr( |
459 | virtual bool , StartDoc(const wxString& message), | |
460 | "Starts a document (only relevant when outputting to a | |
461 | printer). *Message* is a message to show whilst printing.", ""); | |
462 | ||
463 | DocDeclStr( | |
464 | virtual void , EndDoc(), | |
465 | "Ends a document (only relevant when outputting to a printer).", ""); | |
466 | ||
d14a1e28 | 467 | |
70794ec5 RD |
468 | DocDeclStr( |
469 | virtual void , StartPage(), | |
470 | "Starts a document page (only relevant when outputting to a printer).", ""); | |
471 | ||
472 | DocDeclStr( | |
473 | virtual void , EndPage(), | |
474 | "Ends a document page (only relevant when outputting to a printer).", ""); | |
475 | ||
d14a1e28 | 476 | |
4942342c | 477 | |
d14a1e28 RD |
478 | // set objects to use for drawing |
479 | // ------------------------------ | |
480 | ||
70794ec5 RD |
481 | DocDeclStr( |
482 | virtual void , SetFont(const wxFont& font), | |
483 | "Sets the current font for the DC. It must be a valid font, in | |
484 | particular you should not pass ``wx.NullFont`` to this method."," | |
d14a1e28 | 485 | |
70794ec5 RD |
486 | :see: `wx.Font`"); |
487 | ||
488 | DocDeclStr( | |
489 | virtual void , SetPen(const wxPen& pen), | |
490 | "Sets the current pen for the DC. | |
4942342c | 491 | |
70794ec5 RD |
492 | If the argument is ``wx.NullPen``, the current pen is selected out of the |
493 | device context, and the original pen restored.", " | |
d14a1e28 | 494 | |
70794ec5 RD |
495 | :see: `wx.Pen`"); |
496 | ||
497 | DocDeclStr( | |
498 | virtual void , SetBrush(const wxBrush& brush), | |
499 | "Sets the current brush for the DC. | |
500 | ||
501 | If the argument is ``wx.NullBrush``, the current brush is selected out | |
502 | of the device context, and the original brush restored, allowing the | |
503 | current brush to be destroyed safely."," | |
504 | ||
505 | :see: `wx.Brush`"); | |
506 | ||
507 | DocDeclStr( | |
508 | virtual void , SetBackground(const wxBrush& brush), | |
509 | "Sets the current background brush for the DC.", ""); | |
510 | ||
511 | DocDeclStr( | |
512 | virtual void , SetBackgroundMode(int mode), | |
513 | "*mode* may be one of ``wx.SOLID`` and ``wx.TRANSPARENT``. This setting | |
514 | determines whether text will be drawn with a background colour or | |
515 | not.", ""); | |
516 | ||
517 | DocDeclStr( | |
518 | virtual void , SetPalette(const wxPalette& palette), | |
519 | "If this is a window DC or memory DC, assigns the given palette to the | |
520 | window or bitmap associated with the DC. If the argument is | |
521 | ``wx.NullPalette``, the current palette is selected out of the device | |
522 | context, and the original palette restored.", " | |
523 | ||
524 | :see: `wx.Palette`"); | |
525 | ||
526 | ||
527 | ||
528 | DocDeclStr( | |
529 | virtual void , DestroyClippingRegion(), | |
530 | "Destroys the current clipping region so that none of the DC is | |
531 | clipped.", " | |
532 | ||
533 | :see: `SetClippingRegion`"); | |
534 | ||
535 | ||
536 | DocDeclAStr( | |
322913ce | 537 | void, GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const, |
70794ec5 RD |
538 | "GetClippingBox() -> (x, y, width, height)", |
539 | "Gets the rectangle surrounding the current clipping region.", ""); | |
4942342c | 540 | |
d14a1e28 | 541 | %extend { |
70794ec5 RD |
542 | DocStr( |
543 | GetClippingRect, | |
544 | "Gets the rectangle surrounding the current clipping region.", ""); | |
d14a1e28 RD |
545 | wxRect GetClippingRect() { |
546 | wxRect rect; | |
547 | self->GetClippingBox(rect); | |
548 | return rect; | |
549 | } | |
550 | } | |
d14a1e28 | 551 | |
4942342c RD |
552 | |
553 | ||
d14a1e28 RD |
554 | // text extent |
555 | // ----------- | |
556 | ||
70794ec5 RD |
557 | DocDeclStr( |
558 | virtual wxCoord , GetCharHeight() const, | |
559 | "Gets the character height of the currently set font.", ""); | |
560 | ||
561 | DocDeclStr( | |
562 | virtual wxCoord , GetCharWidth() const, | |
563 | "Gets the average character width of the currently set font.", ""); | |
564 | ||
d14a1e28 | 565 | |
d14a1e28 | 566 | |
322913ce RD |
567 | DocDeclAStr( |
568 | void, GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT), | |
569 | "GetTextExtent(wxString string) -> (width, height)", | |
d07d2bc9 RD |
570 | "Get the width and height of the text using the current font. Only |
571 | works for single line strings.", ""); | |
572 | ||
322913ce RD |
573 | DocDeclAStrName( |
574 | void, GetTextExtent(const wxString& string, | |
4942342c | 575 | wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT, |
322913ce RD |
576 | wxFont* font = NULL), |
577 | "GetFullTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)", | |
d07d2bc9 RD |
578 | "Get the width, height, decent and leading of the text using the |
579 | current or specified font. Only works for single line strings.", "", | |
322913ce RD |
580 | GetFullTextExtent); |
581 | ||
4942342c | 582 | |
322913ce RD |
583 | // works for single as well as multi-line strings |
584 | DocDeclAStr( | |
585 | void, GetMultiLineTextExtent(const wxString& text, | |
586 | wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, | |
587 | wxFont *font = NULL), | |
25e29eb2 | 588 | "GetMultiLineTextExtent(wxString string, Font font=None) ->\n (width, height, lineHeight)", |
67cb8b47 | 589 | "Get the width, height, and line height of the text using the |
d07d2bc9 RD |
590 | current or specified font. Works for single as well as multi-line |
591 | strings.", ""); | |
322913ce | 592 | |
746ee6b8 RD |
593 | |
594 | %extend { | |
70794ec5 RD |
595 | DocAStr(GetPartialTextExtents, |
596 | "GetPartialTextExtents(self, text) -> [widths]", | |
597 | "Returns a list of integers such that each value is the distance in | |
598 | pixels from the begining of text to the coresponding character of | |
599 | *text*. The generic version simply builds a running total of the widths | |
600 | of each character using GetTextExtent, however if the various | |
601 | platforms have a native API function that is faster or more accurate | |
43e8916f | 602 | than the generic implementation then it will be used instead.", ""); |
746ee6b8 RD |
603 | wxArrayInt GetPartialTextExtents(const wxString& text) { |
604 | wxArrayInt widths; | |
605 | self->GetPartialTextExtents(text, widths); | |
606 | return widths; | |
607 | } | |
608 | } | |
609 | ||
d14a1e28 RD |
610 | |
611 | // size and resolution | |
612 | // ------------------- | |
613 | ||
70794ec5 RD |
614 | DocStr( |
615 | GetSize, | |
616 | "This gets the horizontal and vertical resolution in device units. It | |
617 | can be used to scale graphics to fit the page. For example, if *maxX* | |
618 | and *maxY* represent the maximum horizontal and vertical 'pixel' values | |
619 | used in your application, the following code will scale the graphic to | |
620 | fit on the printer page:: | |
621 | ||
622 | w, h = dc.GetSize() | |
623 | scaleX = maxX*1.0 / w | |
624 | scaleY = maxY*1.0 / h | |
625 | dc.SetUserScale(min(scaleX,scaleY),min(scaleX,scaleY)) | |
626 | ", ""); | |
d14a1e28 | 627 | wxSize GetSize(); |
322913ce RD |
628 | DocDeclAName( |
629 | void, GetSize( int *OUTPUT, int *OUTPUT ), | |
630 | "GetSizeTuple() -> (width, height)", | |
631 | GetSizeTuple); | |
4942342c | 632 | |
d14a1e28 | 633 | |
d07d2bc9 | 634 | DocStr(GetSizeMM, "Get the DC size in milimeters.", ""); |
d14a1e28 | 635 | wxSize GetSizeMM() const; |
322913ce RD |
636 | DocDeclAName( |
637 | void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const, | |
638 | "GetSizeMMTuple() -> (width, height)", | |
639 | GetSizeMMTuple); | |
4942342c RD |
640 | |
641 | ||
d14a1e28 RD |
642 | |
643 | // coordinates conversions | |
644 | // ----------------------- | |
645 | ||
70794ec5 RD |
646 | DocDeclStr( |
647 | wxCoord , DeviceToLogicalX(wxCoord x) const, | |
648 | "Convert device X coordinate to logical coordinate, using the current | |
649 | mapping mode.", ""); | |
650 | ||
651 | DocDeclStr( | |
652 | wxCoord , DeviceToLogicalY(wxCoord y) const, | |
653 | "Converts device Y coordinate to logical coordinate, using the current | |
654 | mapping mode.", ""); | |
655 | ||
656 | DocDeclStr( | |
657 | wxCoord , DeviceToLogicalXRel(wxCoord x) const, | |
658 | "Convert device X coordinate to relative logical coordinate, using the | |
659 | current mapping mode but ignoring the x axis orientation. Use this | |
660 | function for converting a width, for example.", ""); | |
661 | ||
662 | DocDeclStr( | |
663 | wxCoord , DeviceToLogicalYRel(wxCoord y) const, | |
664 | "Convert device Y coordinate to relative logical coordinate, using the | |
665 | current mapping mode but ignoring the y axis orientation. Use this | |
666 | function for converting a height, for example.", ""); | |
667 | ||
668 | DocDeclStr( | |
669 | wxCoord , LogicalToDeviceX(wxCoord x) const, | |
670 | "Converts logical X coordinate to device coordinate, using the current | |
671 | mapping mode.", ""); | |
672 | ||
673 | DocDeclStr( | |
674 | wxCoord , LogicalToDeviceY(wxCoord y) const, | |
675 | "Converts logical Y coordinate to device coordinate, using the current | |
676 | mapping mode.", ""); | |
677 | ||
678 | DocDeclStr( | |
679 | wxCoord , LogicalToDeviceXRel(wxCoord x) const, | |
680 | "Converts logical X coordinate to relative device coordinate, using the | |
681 | current mapping mode but ignoring the x axis orientation. Use this for | |
682 | converting a width, for example.", ""); | |
683 | ||
684 | DocDeclStr( | |
685 | wxCoord , LogicalToDeviceYRel(wxCoord y) const, | |
686 | "Converts logical Y coordinate to relative device coordinate, using the | |
687 | current mapping mode but ignoring the y axis orientation. Use this for | |
688 | converting a height, for example.", ""); | |
689 | ||
d14a1e28 | 690 | |
70794ec5 | 691 | |
d14a1e28 RD |
692 | // query DC capabilities |
693 | // --------------------- | |
694 | ||
695 | virtual bool CanDrawBitmap() const; | |
696 | virtual bool CanGetTextExtent() const; | |
697 | ||
d14a1e28 | 698 | |
70794ec5 RD |
699 | DocDeclStr( |
700 | virtual int , GetDepth() const, | |
701 | "Returns the colour depth of the DC.", ""); | |
702 | ||
d14a1e28 | 703 | |
70794ec5 RD |
704 | DocDeclStr( |
705 | virtual wxSize , GetPPI() const, | |
361b8ff7 | 706 | "Resolution in pixels per inch", ""); |
70794ec5 | 707 | |
d14a1e28 | 708 | |
70794ec5 | 709 | DocDeclStr( |
6c2dd16f | 710 | virtual bool , IsOk() const, |
70794ec5 | 711 | "Returns true if the DC is ok to use.", ""); |
6c2dd16f | 712 | %pythoncode { Ok = IsOk } |
70794ec5 | 713 | |
4942342c | 714 | |
d14a1e28 | 715 | |
70794ec5 RD |
716 | DocDeclStr( |
717 | int , GetBackgroundMode() const, | |
718 | "Returns the current background mode, either ``wx.SOLID`` or | |
719 | ``wx.TRANSPARENT``."," | |
d14a1e28 | 720 | |
70794ec5 RD |
721 | :see: `SetBackgroundMode`"); |
722 | ||
723 | DocDeclStr( | |
724 | const wxBrush& , GetBackground() const, | |
725 | "Gets the brush used for painting the background."," | |
d14a1e28 | 726 | |
70794ec5 RD |
727 | :see: `SetBackground`"); |
728 | ||
729 | DocDeclStr( | |
730 | const wxBrush& , GetBrush() const, | |
731 | "Gets the current brush", ""); | |
732 | ||
733 | DocDeclStr( | |
734 | const wxFont& , GetFont() const, | |
735 | "Gets the current font", ""); | |
736 | ||
737 | DocDeclStr( | |
738 | const wxPen& , GetPen() const, | |
739 | "Gets the current pen", ""); | |
740 | ||
741 | DocDeclStr( | |
742 | const wxColour& , GetTextBackground() const, | |
743 | "Gets the current text background colour", ""); | |
744 | ||
745 | DocDeclStr( | |
746 | const wxColour& , GetTextForeground() const, | |
747 | "Gets the current text foreground colour", ""); | |
748 | ||
d14a1e28 | 749 | |
70794ec5 RD |
750 | DocDeclStr( |
751 | virtual void , SetTextForeground(const wxColour& colour), | |
752 | "Sets the current text foreground colour for the DC.", ""); | |
753 | ||
754 | DocDeclStr( | |
755 | virtual void , SetTextBackground(const wxColour& colour), | |
756 | "Sets the current text background colour for the DC.", ""); | |
757 | ||
4942342c | 758 | |
70794ec5 RD |
759 | DocDeclStr( |
760 | int , GetMapMode() const, | |
761 | "Gets the current *mapping mode* for the device context ", ""); | |
762 | ||
763 | DocDeclStr( | |
764 | virtual void , SetMapMode(int mode), | |
765 | "The *mapping mode* of the device context defines the unit of | |
766 | measurement used to convert logical units to device units. The | |
767 | mapping mode can be one of the following: | |
768 | ||
769 | ================ ============================================= | |
770 | wx.MM_TWIPS Each logical unit is 1/20 of a point, or 1/1440 | |
771 | of an inch. | |
772 | wx.MM_POINTS Each logical unit is a point, or 1/72 of an inch. | |
773 | wx.MM_METRIC Each logical unit is 1 mm. | |
774 | wx.MM_LOMETRIC Each logical unit is 1/10 of a mm. | |
775 | wx.MM_TEXT Each logical unit is 1 pixel. | |
776 | ================ ============================================= | |
777 | "," | |
778 | Note that in X, text drawing isn't handled consistently with the | |
779 | mapping mode; a font is always specified in point size. However, | |
780 | setting the user scale (see `SetUserScale`) scales the text | |
781 | appropriately. In Windows, scalable TrueType fonts are always used; in | |
782 | X, results depend on availability of fonts, but usually a reasonable | |
783 | match is found. | |
784 | ||
785 | The coordinate origin is always at the top left of the screen/printer. | |
786 | ||
787 | Drawing to a Windows printer device context uses the current mapping | |
788 | mode, but mapping mode is currently ignored for PostScript output. | |
789 | "); | |
790 | ||
791 | ||
792 | ||
793 | DocDeclAStr( | |
322913ce | 794 | virtual void, GetUserScale(double *OUTPUT, double *OUTPUT) const, |
70794ec5 RD |
795 | "GetUserScale(self) -> (xScale, yScale)", |
796 | "Gets the current user scale factor (set by `SetUserScale`).", ""); | |
4942342c | 797 | |
70794ec5 RD |
798 | DocDeclStr( |
799 | virtual void , SetUserScale(double x, double y), | |
800 | "Sets the user scaling factor, useful for applications which require | |
801 | 'zooming'.", ""); | |
802 | ||
d14a1e28 | 803 | |
4942342c | 804 | |
322913ce RD |
805 | DocDeclA( |
806 | virtual void, GetLogicalScale(double *OUTPUT, double *OUTPUT), | |
807 | "GetLogicalScale() -> (xScale, yScale)"); | |
808 | ||
d14a1e28 RD |
809 | virtual void SetLogicalScale(double x, double y); |
810 | ||
322913ce | 811 | |
d14a1e28 | 812 | wxPoint GetLogicalOrigin() const; |
322913ce RD |
813 | DocDeclAName( |
814 | void, GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const, | |
815 | "GetLogicalOriginTuple() -> (x,y)", | |
816 | GetLogicalOriginTuple); | |
4942342c | 817 | |
d14a1e28 | 818 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); |
d7403ad2 RD |
819 | %extend { |
820 | void SetLogicalOriginPoint(const wxPoint& point) { | |
821 | self->SetLogicalOrigin(point.x, point.y); | |
822 | } | |
823 | } | |
d14a1e28 | 824 | |
d7403ad2 | 825 | |
d14a1e28 | 826 | wxPoint GetDeviceOrigin() const; |
322913ce RD |
827 | DocDeclAName( |
828 | void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const, | |
829 | "GetDeviceOriginTuple() -> (x,y)", | |
830 | GetDeviceOriginTuple); | |
4942342c | 831 | |
d14a1e28 | 832 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); |
d7403ad2 RD |
833 | %extend { |
834 | void SetDeviceOriginPoint(const wxPoint& point) { | |
835 | self->SetDeviceOrigin(point.x, point.y); | |
836 | } | |
837 | } | |
d14a1e28 | 838 | |
70794ec5 RD |
839 | DocDeclStr( |
840 | virtual void , SetAxisOrientation(bool xLeftRight, bool yBottomUp), | |
841 | "Sets the x and y axis orientation (i.e., the direction from lowest to | |
842 | highest values on the axis). The default orientation is the natural | |
843 | orientation, e.g. x axis from left to right and y axis from bottom up.", ""); | |
3350d652 | 844 | |
d14a1e28 | 845 | |
70794ec5 RD |
846 | DocDeclStr( |
847 | int , GetLogicalFunction() const, | |
848 | "Gets the current logical function (set by `SetLogicalFunction`).", ""); | |
849 | ||
850 | DocDeclStr( | |
851 | virtual void , SetLogicalFunction(int function), | |
852 | "Sets the current logical function for the device context. This | |
853 | determines how a source pixel (from a pen or brush colour, or source | |
854 | device context if using `Blit`) combines with a destination pixel in | |
855 | the current device context. | |
856 | ||
857 | The possible values and their meaning in terms of source and | |
858 | destination pixel values are as follows: | |
859 | ||
860 | ================ ========================== | |
861 | wx.AND src AND dst | |
862 | wx.AND_INVERT (NOT src) AND dst | |
863 | wx.AND_REVERSE src AND (NOT dst) | |
864 | wx.CLEAR 0 | |
865 | wx.COPY src | |
866 | wx.EQUIV (NOT src) XOR dst | |
867 | wx.INVERT NOT dst | |
868 | wx.NAND (NOT src) OR (NOT dst) | |
869 | wx.NOR (NOT src) AND (NOT dst) | |
870 | wx.NO_OP dst | |
871 | wx.OR src OR dst | |
872 | wx.OR_INVERT (NOT src) OR dst | |
873 | wx.OR_REVERSE src OR (NOT dst) | |
874 | wx.SET 1 | |
875 | wx.SRC_INVERT NOT src | |
876 | wx.XOR src XOR dst | |
877 | ================ ========================== | |
878 | ||
879 | The default is wx.COPY, which simply draws with the current | |
880 | colour. The others combine the current colour and the background using | |
881 | a logical operation. wx.INVERT is commonly used for drawing rubber | |
882 | bands or moving outlines, since drawing twice reverts to the original | |
883 | colour. | |
884 | ", ""); | |
885 | ||
d14a1e28 | 886 | |
25e29eb2 RD |
887 | DocDeclStr( |
888 | void , ComputeScaleAndOrigin(), | |
889 | "Performs all necessary computations for given platform and context | |
890 | type after each change of scale and origin parameters. Usually called | |
891 | automatically internally after such changes. | |
892 | ", ""); | |
3350d652 RD |
893 | |
894 | ||
895 | ||
49e6b3c3 RD |
896 | // DocDeclStr( |
897 | // virtual void , SetOptimization(bool optimize), | |
898 | // "If *optimize* is true this function sets optimization mode on. This | |
899 | // currently means that under X, the device context will not try to set a | |
900 | // pen or brush property if it is known to be set already. This approach | |
901 | // can fall down if non-wxWidgets code is using the same device context | |
902 | // or window, for example when the window is a panel on which the | |
903 | // windowing system draws panel items. The wxWidgets device context | |
904 | // 'memory' will now be out of step with reality. | |
905 | ||
906 | // Setting optimization off, drawing, then setting it back on again, is a | |
907 | // trick that must occasionally be employed.", ""); | |
908 | ||
909 | // DocDeclStr( | |
910 | // virtual bool , GetOptimization(), | |
911 | // "Returns true if device context optimization is on. See | |
912 | // `SetOptimization` for details.", ""); | |
913 | ||
914 | %pythoncode { | |
915 | def SetOptimization(self, optimize): | |
916 | pass | |
917 | def GetOptimization(self): | |
918 | return False | |
919 | ||
920 | SetOptimization = wx._deprecated(SetOptimization) | |
921 | GetOptimization = wx._deprecated(GetOptimization) | |
922 | } | |
70794ec5 | 923 | |
70794ec5 | 924 | |
d14a1e28 RD |
925 | // bounding box |
926 | // ------------ | |
927 | ||
70794ec5 RD |
928 | DocDeclStr( |
929 | virtual void , CalcBoundingBox(wxCoord x, wxCoord y), | |
930 | "Adds the specified point to the bounding box which can be retrieved | |
931 | with `MinX`, `MaxX` and `MinY`, `MaxY` or `GetBoundingBox` functions.", ""); | |
932 | ||
d7403ad2 | 933 | %extend { |
70794ec5 RD |
934 | DocStr(CalcBoundingBoxPoint, |
935 | "Adds the specified point to the bounding box which can be retrieved | |
936 | with `MinX`, `MaxX` and `MinY`, `MaxY` or `GetBoundingBox` functions.",""); | |
d7403ad2 RD |
937 | void CalcBoundingBoxPoint(const wxPoint& point) { |
938 | self->CalcBoundingBox(point.x, point.y); | |
939 | } | |
940 | } | |
941 | ||
70794ec5 RD |
942 | DocDeclStr( |
943 | void , ResetBoundingBox(), | |
944 | "Resets the bounding box: after a call to this function, the bounding | |
945 | box doesn't contain anything.", ""); | |
946 | ||
d14a1e28 RD |
947 | |
948 | // Get the final bounding box of the PostScript or Metafile picture. | |
70794ec5 RD |
949 | DocDeclStr( |
950 | wxCoord , MinX() const, | |
951 | "Gets the minimum horizontal extent used in drawing commands so far.", ""); | |
952 | ||
953 | DocDeclStr( | |
954 | wxCoord , MaxX() const, | |
955 | "Gets the maximum horizontal extent used in drawing commands so far.", ""); | |
956 | ||
957 | DocDeclStr( | |
958 | wxCoord , MinY() const, | |
959 | "Gets the minimum vertical extent used in drawing commands so far.", ""); | |
960 | ||
961 | DocDeclStr( | |
962 | wxCoord , MaxY() const, | |
963 | "Gets the maximum vertical extent used in drawing commands so far.", ""); | |
964 | ||
d14a1e28 RD |
965 | |
966 | ||
70794ec5 RD |
967 | DocAStr(GetBoundingBox, |
968 | "GetBoundingBox() -> (x1,y1, x2,y2)", | |
969 | "Returns the min and max points used in drawing commands so far.", ""); | |
d14a1e28 RD |
970 | %extend { |
971 | void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT); | |
972 | // See below for implementation | |
4942342c | 973 | } |
70794ec5 | 974 | |
6c2dd16f | 975 | %pythoncode { def __nonzero__(self): return self.IsOk() }; |
d14a1e28 RD |
976 | |
977 | ||
8adc9d9d RD |
978 | // RTL related functions |
979 | // --------------------- | |
980 | ||
981 | DocDeclStr( | |
982 | virtual wxLayoutDirection , GetLayoutDirection() const, | |
983 | "Get the layout direction (LTR or RTL)_ for this dc. On platforms | |
984 | where RTL layout is supported, the return value will either be | |
985 | ``wx.Layout_LeftToRight`` or ``wx.Layout_RightToLeft``. | |
986 | ``wx.Layout_Default`` is returned if layout direction is not | |
987 | supported.", ""); | |
988 | ||
989 | DocDeclStr( | |
990 | virtual void , SetLayoutDirection(wxLayoutDirection dir), | |
991 | "Change the layout direction for this dc.", ""); | |
992 | ||
993 | ||
994 | ||
995 | ||
96fc3ef4 RD |
996 | #ifdef __WXMSW__ |
997 | long GetHDC(); | |
998 | #endif | |
999 | ||
d14a1e28 RD |
1000 | |
1001 | %extend { // See drawlist.cpp for impplementaion of these... | |
1002 | PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
1003 | { | |
1004 | return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes); | |
1005 | } | |
1006 | ||
1007 | PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
1008 | { | |
1009 | return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes); | |
1010 | } | |
1011 | ||
1012 | PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
1013 | { | |
1014 | return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes); | |
1015 | } | |
1016 | ||
1017 | PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
1018 | { | |
1019 | return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes); | |
1020 | } | |
1021 | ||
1022 | PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
1023 | { | |
1024 | return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes); | |
1025 | } | |
1026 | ||
1027 | PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints, | |
1028 | PyObject* foregroundList, PyObject* backgroundList) { | |
1029 | return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList); | |
1030 | } | |
1031 | } | |
1032 | ||
1033 | %pythoncode { | |
1034 | def DrawPointList(self, points, pens=None): | |
70794ec5 RD |
1035 | """ |
1036 | Draw a list of points as quickly as possible. | |
1037 | ||
1038 | :param points: A sequence of 2-element sequences representing | |
1039 | each point to draw, (x,y). | |
1040 | :param pens: If None, then the current pen is used. If a | |
1041 | single pen then it will be used for all points. If | |
1042 | a list of pens then there should be one for each point | |
1043 | in points. | |
1044 | """ | |
d14a1e28 RD |
1045 | if pens is None: |
1046 | pens = [] | |
1047 | elif isinstance(pens, wx.Pen): | |
1048 | pens = [pens] | |
1049 | elif len(pens) != len(points): | |
1050 | raise ValueError('points and pens must have same length') | |
1051 | return self._DrawPointList(points, pens, []) | |
1052 | ||
1053 | ||
1054 | def DrawLineList(self, lines, pens=None): | |
70794ec5 RD |
1055 | """ |
1056 | Draw a list of lines as quickly as possible. | |
1057 | ||
1058 | :param lines: A sequence of 4-element sequences representing | |
1059 | each line to draw, (x1,y1, x2,y2). | |
1060 | :param pens: If None, then the current pen is used. If a | |
1061 | single pen then it will be used for all lines. If | |
1062 | a list of pens then there should be one for each line | |
1063 | in lines. | |
1064 | """ | |
d14a1e28 RD |
1065 | if pens is None: |
1066 | pens = [] | |
1067 | elif isinstance(pens, wx.Pen): | |
1068 | pens = [pens] | |
1069 | elif len(pens) != len(lines): | |
1070 | raise ValueError('lines and pens must have same length') | |
1071 | return self._DrawLineList(lines, pens, []) | |
1072 | ||
1073 | ||
1074 | def DrawRectangleList(self, rectangles, pens=None, brushes=None): | |
70794ec5 RD |
1075 | """ |
1076 | Draw a list of rectangles as quickly as possible. | |
1077 | ||
1078 | :param rectangles: A sequence of 4-element sequences representing | |
1079 | each rectangle to draw, (x,y, w,h). | |
1080 | :param pens: If None, then the current pen is used. If a | |
1081 | single pen then it will be used for all rectangles. | |
1082 | If a list of pens then there should be one for each | |
1083 | rectangle in rectangles. | |
1084 | :param brushes: A brush or brushes to be used to fill the rectagles, | |
1085 | with similar semantics as the pens parameter. | |
1086 | """ | |
d14a1e28 RD |
1087 | if pens is None: |
1088 | pens = [] | |
1089 | elif isinstance(pens, wx.Pen): | |
1090 | pens = [pens] | |
1091 | elif len(pens) != len(rectangles): | |
1092 | raise ValueError('rectangles and pens must have same length') | |
1093 | if brushes is None: | |
1094 | brushes = [] | |
1095 | elif isinstance(brushes, wx.Brush): | |
1096 | brushes = [brushes] | |
1097 | elif len(brushes) != len(rectangles): | |
1098 | raise ValueError('rectangles and brushes must have same length') | |
1099 | return self._DrawRectangleList(rectangles, pens, brushes) | |
1100 | ||
1101 | ||
1102 | def DrawEllipseList(self, ellipses, pens=None, brushes=None): | |
70794ec5 RD |
1103 | """ |
1104 | Draw a list of ellipses as quickly as possible. | |
1105 | ||
1106 | :param ellipses: A sequence of 4-element sequences representing | |
1107 | each ellipse to draw, (x,y, w,h). | |
1108 | :param pens: If None, then the current pen is used. If a | |
1109 | single pen then it will be used for all ellipses. | |
1110 | If a list of pens then there should be one for each | |
1111 | ellipse in ellipses. | |
1112 | :param brushes: A brush or brushes to be used to fill the ellipses, | |
1113 | with similar semantics as the pens parameter. | |
1114 | """ | |
d14a1e28 RD |
1115 | if pens is None: |
1116 | pens = [] | |
1117 | elif isinstance(pens, wx.Pen): | |
1118 | pens = [pens] | |
1119 | elif len(pens) != len(ellipses): | |
1120 | raise ValueError('ellipses and pens must have same length') | |
1121 | if brushes is None: | |
1122 | brushes = [] | |
1123 | elif isinstance(brushes, wx.Brush): | |
1124 | brushes = [brushes] | |
1125 | elif len(brushes) != len(ellipses): | |
1126 | raise ValueError('ellipses and brushes must have same length') | |
1127 | return self._DrawEllipseList(ellipses, pens, brushes) | |
1128 | ||
1129 | ||
1130 | def DrawPolygonList(self, polygons, pens=None, brushes=None): | |
70794ec5 RD |
1131 | """ |
1132 | Draw a list of polygons, each of which is a list of points. | |
1133 | ||
1134 | :param polygons: A sequence of sequences of sequences. | |
1135 | [[(x1,y1),(x2,y2),(x3,y3)...], | |
1136 | [(x1,y1),(x2,y2),(x3,y3)...]] | |
1137 | ||
1138 | :param pens: If None, then the current pen is used. If a | |
1139 | single pen then it will be used for all polygons. | |
1140 | If a list of pens then there should be one for each | |
1141 | polygon. | |
1142 | :param brushes: A brush or brushes to be used to fill the polygons, | |
1143 | with similar semantics as the pens parameter. | |
1144 | """ | |
d14a1e28 RD |
1145 | if pens is None: |
1146 | pens = [] | |
1147 | elif isinstance(pens, wx.Pen): | |
1148 | pens = [pens] | |
1149 | elif len(pens) != len(polygons): | |
1150 | raise ValueError('polygons and pens must have same length') | |
1151 | if brushes is None: | |
1152 | brushes = [] | |
1153 | elif isinstance(brushes, wx.Brush): | |
1154 | brushes = [brushes] | |
1155 | elif len(brushes) != len(polygons): | |
1156 | raise ValueError('polygons and brushes must have same length') | |
1157 | return self._DrawPolygonList(polygons, pens, brushes) | |
1158 | ||
1159 | ||
70794ec5 RD |
1160 | def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None): |
1161 | """ | |
1162 | Draw a list of strings using a list of coordinants for positioning each string. | |
1163 | ||
1164 | :param textList: A list of strings | |
1165 | :param coords: A list of (x,y) positions | |
1166 | :param foregrounds: A list of `wx.Colour` objects to use for the | |
1167 | foregrounds of the strings. | |
1168 | :param backgrounds: A list of `wx.Colour` objects to use for the | |
1169 | backgrounds of the strings. | |
1170 | ||
1171 | NOTE: Make sure you set Background mode to wx.Solid (DC.SetBackgroundMode) | |
1172 | If you want backgrounds to do anything. | |
1173 | """ | |
d14a1e28 RD |
1174 | if type(textList) == type(''): |
1175 | textList = [textList] | |
1176 | elif len(textList) != len(coords): | |
1177 | raise ValueError('textlist and coords must have same length') | |
1178 | if foregrounds is None: | |
1179 | foregrounds = [] | |
fd3f2efe | 1180 | elif isinstance(foregrounds, wx.Colour): |
d14a1e28 RD |
1181 | foregrounds = [foregrounds] |
1182 | elif len(foregrounds) != len(coords): | |
1183 | raise ValueError('foregrounds and coords must have same length') | |
1184 | if backgrounds is None: | |
1185 | backgrounds = [] | |
fd3f2efe | 1186 | elif isinstance(backgrounds, wx.Colour): |
d14a1e28 RD |
1187 | backgrounds = [backgrounds] |
1188 | elif len(backgrounds) != len(coords): | |
1189 | raise ValueError('backgrounds and coords must have same length') | |
1190 | return self._DrawTextList(textList, coords, foregrounds, backgrounds) | |
1191 | } | |
1192 | ||
0eae5d09 RD |
1193 | %property(Background, GetBackground, SetBackground, doc="See `GetBackground` and `SetBackground`"); |
1194 | %property(BackgroundMode, GetBackgroundMode, SetBackgroundMode, doc="See `GetBackgroundMode` and `SetBackgroundMode`"); | |
1195 | %property(BoundingBox, GetBoundingBox, doc="See `GetBoundingBox`"); | |
1196 | %property(Brush, GetBrush, SetBrush, doc="See `GetBrush` and `SetBrush`"); | |
1197 | %property(CharHeight, GetCharHeight, doc="See `GetCharHeight`"); | |
1198 | %property(CharWidth, GetCharWidth, doc="See `GetCharWidth`"); | |
1199 | %property(ClippingBox, GetClippingBox, doc="See `GetClippingBox`"); | |
1200 | %property(ClippingRect, GetClippingRect, SetClippingRect, doc="See `GetClippingRect` and `SetClippingRect`"); | |
1201 | %property(Depth, GetDepth, doc="See `GetDepth`"); | |
1202 | %property(DeviceOrigin, GetDeviceOrigin, SetDeviceOrigin, doc="See `GetDeviceOrigin` and `SetDeviceOrigin`"); | |
1203 | %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`"); | |
1204 | %property(FullTextExtent, GetFullTextExtent, doc="See `GetFullTextExtent`"); | |
1205 | %property(LogicalFunction, GetLogicalFunction, SetLogicalFunction, doc="See `GetLogicalFunction` and `SetLogicalFunction`"); | |
1206 | %property(LogicalOrigin, GetLogicalOrigin, SetLogicalOrigin, doc="See `GetLogicalOrigin` and `SetLogicalOrigin`"); | |
1207 | %property(LogicalScale, GetLogicalScale, SetLogicalScale, doc="See `GetLogicalScale` and `SetLogicalScale`"); | |
1208 | %property(MapMode, GetMapMode, SetMapMode, doc="See `GetMapMode` and `SetMapMode`"); | |
1209 | %property(MultiLineTextExtent, GetMultiLineTextExtent, doc="See `GetMultiLineTextExtent`"); | |
1210 | %property(Optimization, GetOptimization, SetOptimization, doc="See `GetOptimization` and `SetOptimization`"); | |
1211 | %property(PPI, GetPPI, doc="See `GetPPI`"); | |
1212 | %property(PartialTextExtents, GetPartialTextExtents, doc="See `GetPartialTextExtents`"); | |
1213 | %property(Pen, GetPen, SetPen, doc="See `GetPen` and `SetPen`"); | |
1214 | %property(Pixel, GetPixel, doc="See `GetPixel`"); | |
1215 | %property(PixelPoint, GetPixelPoint, doc="See `GetPixelPoint`"); | |
1216 | %property(Size, GetSize, doc="See `GetSize`"); | |
1217 | %property(SizeMM, GetSizeMM, doc="See `GetSizeMM`"); | |
1218 | %property(TextBackground, GetTextBackground, SetTextBackground, doc="See `GetTextBackground` and `SetTextBackground`"); | |
1219 | %property(TextExtent, GetTextExtent, doc="See `GetTextExtent`"); | |
1220 | %property(TextForeground, GetTextForeground, SetTextForeground, doc="See `GetTextForeground` and `SetTextForeground`"); | |
1221 | %property(UserScale, GetUserScale, SetUserScale, doc="See `GetUserScale` and `SetUserScale`"); | |
8adc9d9d RD |
1222 | |
1223 | %property(LayoutDirection, GetLayoutDirection, SetLayoutDirection); | |
d14a1e28 RD |
1224 | }; |
1225 | ||
1226 | ||
1227 | ||
1228 | %{ | |
1229 | static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { | |
1230 | *x1 = dc->MinX(); | |
1231 | *y1 = dc->MinY(); | |
1232 | *x2 = dc->MaxX(); | |
1233 | *y2 = dc->MaxY(); | |
1234 | } | |
1235 | %} | |
1236 | ||
1237 | ||
1238 | //--------------------------------------------------------------------------- | |
1239 | %newgroup | |
1240 | ||
ab1f7d2a RD |
1241 | MustHaveApp(wxMemoryDC); |
1242 | ||
70794ec5 RD |
1243 | DocStr(wxMemoryDC, |
1244 | "A memory device context provides a means to draw graphics onto a | |
1245 | bitmap. A bitmap must be selected into the new memory DC before it may | |
1246 | be used for anything. Typical usage is as follows:: | |
1247 | ||
1248 | dc = wx.MemoryDC() | |
1249 | dc.SelectObject(bitmap) | |
1250 | # draw on the dc usign any of the Draw methods | |
1251 | dc.SelectObject(wx.NullBitmap) | |
1252 | # the bitmap now contains wahtever was drawn upon it | |
1253 | ||
1254 | Note that the memory DC *must* be deleted (or the bitmap selected out | |
1255 | of it) before a bitmap can be reselected into another memory DC. | |
1256 | ", ""); | |
1257 | ||
d14a1e28 RD |
1258 | class wxMemoryDC : public wxDC { |
1259 | public: | |
70794ec5 RD |
1260 | DocCtorStr( |
1261 | wxMemoryDC(), | |
1262 | "Constructs a new memory device context. | |
1263 | ||
1264 | Use the Ok member to test whether the constructor was successful in | |
1265 | creating a usable device context. Don't forget to select a bitmap into | |
1266 | the DC before drawing on it.", " | |
4942342c | 1267 | |
70794ec5 RD |
1268 | :see: `MemoryDCFromDC`"); |
1269 | ||
1270 | DocCtorStrName( | |
1271 | wxMemoryDC(wxDC* oldDC), | |
1272 | "Creates a DC that is compatible with the oldDC.", "", | |
1273 | MemoryDCFromDC); | |
1274 | ||
1275 | ||
1276 | DocDeclStr( | |
1277 | void , SelectObject(const wxBitmap& bitmap), | |
1278 | "Selects the bitmap into the device context, to use as the memory | |
1279 | bitmap. Selecting the bitmap into a memory DC allows you to draw into | |
1280 | the DC, and therefore the bitmap, and also to use Blit to copy the | |
1281 | bitmap to a window. | |
1282 | ||
1283 | If the argument is wx.NullBitmap (or some other uninitialised | |
1284 | `wx.Bitmap`) the current bitmap is selected out of the device context, | |
1285 | and the original bitmap restored, allowing the current bitmap to be | |
1286 | destroyed safely.", ""); | |
1287 | ||
d14a1e28 RD |
1288 | }; |
1289 | ||
1290 | //--------------------------------------------------------------------------- | |
1291 | %newgroup | |
1292 | ||
b159c5c4 | 1293 | |
ef22e3d3 | 1294 | %{ |
ef22e3d3 | 1295 | #include <wx/dcbuffer.h> |
ef22e3d3 RD |
1296 | %} |
1297 | ||
67a5217c RD |
1298 | enum { |
1299 | wxBUFFER_VIRTUAL_AREA, | |
1300 | wxBUFFER_CLIENT_AREA | |
1301 | }; | |
ef22e3d3 | 1302 | |
ab1f7d2a RD |
1303 | MustHaveApp(wxBufferedDC); |
1304 | ||
70794ec5 RD |
1305 | DocStr(wxBufferedDC, |
1306 | "This simple class provides a simple way to avoid flicker: when drawing | |
1307 | on it, everything is in fact first drawn on an in-memory buffer (a | |
1308 | `wx.Bitmap`) and then copied to the screen only once, when this object | |
1309 | is destroyed. | |
1310 | ||
6a223074 RD |
1311 | It can be used in the same way as any other device context. |
1312 | wx.BufferedDC itself typically replaces `wx.ClientDC`, if you want to | |
1313 | use it in your EVT_PAINT handler, you should look at | |
70794ec5 | 1314 | `wx.BufferedPaintDC`. |
6a223074 RD |
1315 | |
1316 | Please note that GTK+ 2.0 and OS X provide double buffering themselves | |
8de3594c RD |
1317 | natively. wxBufferedDC is aware of this however, and will bypass the buffering |
1318 | unless an explicit buffer bitmap is given. | |
70794ec5 RD |
1319 | ", ""); |
1320 | ||
8adc9d9d | 1321 | class wxBufferedDC : public wxDC |
d14a1e28 RD |
1322 | { |
1323 | public: | |
e608d228 | 1324 | %pythonAppend wxBufferedDC |
70794ec5 | 1325 | "self.__dc = args[0] # save a ref so the other dc will not be deleted before self"; |
1b8c7ba6 | 1326 | |
b159c5c4 | 1327 | %nokwargs wxBufferedDC; |
d14a1e28 | 1328 | |
70794ec5 RD |
1329 | DocStr( |
1330 | wxBufferedDC, | |
1331 | "Constructs a buffered DC.", " | |
1332 | ||
1333 | :param dc: The underlying DC: everything drawn to this object will | |
1334 | be flushed to this DC when this object is destroyed. You may | |
1335 | pass ``None`` in order to just initialize the buffer, and not | |
1336 | flush it. | |
1337 | ||
1338 | :param buffer: If a `wx.Size` object is passed as the 2nd arg then | |
1339 | it is the size of the bitmap that will be created internally | |
1340 | and used for an implicit buffer. If the 2nd arg is a | |
1341 | `wx.Bitmap` then it is the explicit buffer that will be | |
1342 | used. Using an explicit buffer is the most efficient solution | |
1343 | as the bitmap doesn't have to be recreated each time but it | |
1344 | also requires more memory as the bitmap is never freed. The | |
1345 | bitmap should have appropriate size, anything drawn outside of | |
4a065572 RD |
1346 | its bounds is clipped. If wx.NullBitmap is used then a new |
1347 | buffer will be allocated that is the same size as the dc. | |
b159c5c4 | 1348 | |
67a5217c RD |
1349 | :param style: The style parameter indicates whether the supplied buffer is |
1350 | intended to cover the entire virtual size of a `wx.ScrolledWindow` or | |
1351 | if it only covers the client area. Acceptable values are | |
1352 | ``wx.BUFFER_VIRTUAL_AREA`` and ``wx.BUFFER_CLIENT_AREA``. | |
1353 | ||
1354 | "); | |
4a065572 RD |
1355 | wxBufferedDC( wxDC* dc, |
1356 | const wxBitmap& buffer=wxNullBitmap, | |
1357 | int style = wxBUFFER_CLIENT_AREA ); | |
1358 | wxBufferedDC( wxDC* dc, | |
1359 | const wxSize& area, | |
1360 | int style = wxBUFFER_CLIENT_AREA ); | |
9a3dccf6 RD |
1361 | wxBufferedDC(wxWindow* win, |
1362 | wxDC *dc, | |
1363 | const wxSize &area, | |
1364 | int style = wxBUFFER_CLIENT_AREA); | |
1365 | ||
7a0b15e9 | 1366 | |
70794ec5 RD |
1367 | DocCtorStr( |
1368 | ~wxBufferedDC(), | |
1369 | "Copies everything drawn on the DC so far to the underlying DC | |
1370 | associated with this object, if any.", ""); | |
1371 | ||
4a065572 | 1372 | |
70794ec5 RD |
1373 | DocDeclStr( |
1374 | void , UnMask(), | |
1375 | "Blits the buffer to the dc, and detaches the dc from the buffer (so it | |
1376 | can be effectively used once only). This is usually only called in | |
1377 | the destructor.", ""); | |
e608d228 | 1378 | |
d14a1e28 RD |
1379 | }; |
1380 | ||
1381 | ||
7a0b15e9 | 1382 | |
70794ec5 | 1383 | |
ab1f7d2a | 1384 | MustHaveApp(wxBufferedPaintDC); |
7a0b15e9 | 1385 | |
70794ec5 RD |
1386 | DocStr(wxBufferedPaintDC, |
1387 | "This is a subclass of `wx.BufferedDC` which can be used inside of an | |
1388 | EVT_PAINT event handler. Just create an object of this class instead | |
1389 | of `wx.PaintDC` and that's all you have to do to (mostly) avoid | |
1390 | flicker. The only thing to watch out for is that if you are using this | |
1391 | class together with `wx.ScrolledWindow`, you probably do **not** want | |
1392 | to call `wx.Window.PrepareDC` on it as it already does this internally | |
1393 | for the real underlying `wx.PaintDC`. | |
1394 | ||
1395 | If your window is already fully buffered in a `wx.Bitmap` then your | |
1396 | EVT_PAINT handler can be as simple as just creating a | |
1397 | ``wx.BufferedPaintDC`` as it will `Blit` the buffer to the window | |
1398 | automatically when it is destroyed. For example:: | |
1399 | ||
1400 | def OnPaint(self, event): | |
1401 | dc = wx.BufferedPaintDC(self, self.buffer) | |
1402 | ||
1403 | ||
1404 | ", ""); | |
1405 | ||
d14a1e28 RD |
1406 | class wxBufferedPaintDC : public wxBufferedDC |
1407 | { | |
1408 | public: | |
b159c5c4 | 1409 | |
70794ec5 | 1410 | DocCtorStr( |
67a5217c RD |
1411 | wxBufferedPaintDC( wxWindow *window, |
1412 | const wxBitmap &buffer = wxNullBitmap, | |
1413 | int style = wxBUFFER_CLIENT_AREA), | |
70794ec5 RD |
1414 | "Create a buffered paint DC. As with `wx.BufferedDC`, you may either |
1415 | provide the bitmap to be used for buffering or let this object create | |
1416 | one internally (in the latter case, the size of the client part of the | |
9a3dccf6 | 1417 | window is automatically used).", ""); |
b159c5c4 | 1418 | |
d14a1e28 RD |
1419 | }; |
1420 | ||
d14a1e28 RD |
1421 | //--------------------------------------------------------------------------- |
1422 | %newgroup | |
1423 | ||
ab1f7d2a RD |
1424 | MustHaveApp(wxScreenDC); |
1425 | ||
70794ec5 RD |
1426 | DocStr(wxScreenDC, |
1427 | "A wxScreenDC can be used to paint anywhere on the screen. This should | |
1428 | normally be constructed as a temporary stack object; don't store a | |
1429 | wxScreenDC object. | |
1430 | ", ""); | |
d14a1e28 RD |
1431 | class wxScreenDC : public wxDC { |
1432 | public: | |
1433 | wxScreenDC(); | |
1434 | ||
70794ec5 RD |
1435 | DocDeclStrName( |
1436 | bool , StartDrawingOnTop(wxWindow* window), | |
1437 | "Specify that the area of the screen to be drawn upon coincides with | |
1438 | the given window. | |
1439 | ||
1440 | :see: `EndDrawingOnTop`", "", | |
1441 | StartDrawingOnTopWin); | |
1442 | ||
1443 | ||
1444 | DocDeclStr( | |
1445 | bool , StartDrawingOnTop(wxRect* rect = NULL), | |
1446 | "Specify that the area is the given rectangle, or the whole screen if | |
1447 | ``None`` is passed. | |
1448 | ||
1449 | :see: `EndDrawingOnTop`", ""); | |
1450 | ||
1451 | ||
1452 | DocDeclStr( | |
1453 | bool , EndDrawingOnTop(), | |
1454 | "Use this in conjunction with `StartDrawingOnTop` or | |
1455 | `StartDrawingOnTopWin` to ensure that drawing to the screen occurs on | |
1456 | top of existing windows. Without this, some window systems (such as X) | |
1457 | only allow drawing to take place underneath other windows. | |
1458 | ||
1459 | You might use this pair of functions when implementing a drag feature, | |
1460 | for example as in the `wx.SplitterWindow` implementation. | |
1461 | ||
1462 | These functions are probably obsolete since the X implementations | |
1463 | allow drawing directly on the screen now. However, the fact that this | |
1464 | function allows the screen to be refreshed afterwards may be useful | |
1465 | to some applications.", ""); | |
1466 | ||
d14a1e28 RD |
1467 | }; |
1468 | ||
1469 | //--------------------------------------------------------------------------- | |
1470 | %newgroup | |
1471 | ||
205d49f7 RD |
1472 | MustHaveApp(wxWindowDC); |
1473 | ||
1474 | DocStr(wxWindowDC, | |
1475 | "A wx.WindowDC must be constructed if an application wishes to paint on | |
1476 | the whole area of a window (client and decorations). This should | |
1477 | normally be constructed as a temporary stack object; don't store a | |
1478 | wx.WindowDC object.",""); | |
1479 | class wxWindowDC : public wxDC { | |
1480 | public: | |
1481 | DocCtorStr( | |
1482 | wxWindowDC(wxWindow* win), | |
1483 | "Constructor. Pass the window on which you wish to paint.",""); | |
1484 | }; | |
1485 | ||
1486 | //--------------------------------------------------------------------------- | |
1487 | %newgroup | |
1488 | ||
ab1f7d2a RD |
1489 | MustHaveApp(wxClientDC); |
1490 | ||
70794ec5 RD |
1491 | DocStr(wxClientDC, |
1492 | "A wx.ClientDC must be constructed if an application wishes to paint on | |
1493 | the client area of a window from outside an EVT_PAINT event. This should | |
1494 | normally be constructed as a temporary stack object; don't store a | |
1495 | wx.ClientDC object long term. | |
1496 | ||
1497 | To draw on a window from within an EVT_PAINT handler, construct a | |
1498 | `wx.PaintDC` object. | |
1499 | ||
1500 | To draw on the whole window including decorations, construct a | |
1501 | `wx.WindowDC` object (Windows only). | |
1502 | ", ""); | |
205d49f7 | 1503 | class wxClientDC : public wxWindowDC { |
d14a1e28 | 1504 | public: |
70794ec5 RD |
1505 | DocCtorStr( |
1506 | wxClientDC(wxWindow* win), | |
1507 | "Constructor. Pass the window on which you wish to paint.", ""); | |
d14a1e28 RD |
1508 | }; |
1509 | ||
1510 | //--------------------------------------------------------------------------- | |
1511 | %newgroup | |
1512 | ||
ab1f7d2a RD |
1513 | MustHaveApp(wxPaintDC); |
1514 | ||
70794ec5 RD |
1515 | DocStr(wxPaintDC, |
1516 | "A wx.PaintDC must be constructed if an application wishes to paint on | |
1517 | the client area of a window from within an EVT_PAINT event | |
1518 | handler. This should normally be constructed as a temporary stack | |
1519 | object; don't store a wx.PaintDC object. If you have an EVT_PAINT | |
1520 | handler, you **must** create a wx.PaintDC object within it even if you | |
1521 | don't actually use it. | |
1522 | ||
1523 | Using wx.PaintDC within EVT_PAINT handlers is important because it | |
1524 | automatically sets the clipping area to the damaged area of the | |
1525 | window. Attempts to draw outside this area do not appear. | |
1526 | ||
1527 | To draw on a window from outside EVT_PAINT handlers, construct a | |
1528 | `wx.ClientDC` object. | |
1529 | ",""); | |
205d49f7 | 1530 | class wxPaintDC : public wxClientDC { |
d14a1e28 | 1531 | public: |
70794ec5 RD |
1532 | DocCtorStr( |
1533 | wxPaintDC(wxWindow* win), | |
1534 | "Constructor. Pass the window on which you wish to paint.", ""); | |
d14a1e28 RD |
1535 | }; |
1536 | ||
9a3dccf6 RD |
1537 | |
1538 | ||
1539 | //--------------------------------------------------------------------------- | |
1540 | %newgroup | |
1541 | ||
1542 | %pythoncode { | |
1543 | if 'wxMac' in wx.PlatformInfo or 'gtk2' in wx.PlatformInfo: | |
1544 | _AutoBufferedPaintDCBase = PaintDC | |
1545 | else: | |
1546 | _AutoBufferedPaintDCBase = BufferedPaintDC | |
1547 | ||
1548 | class AutoBufferedPaintDC(_AutoBufferedPaintDCBase): | |
1549 | """ | |
1550 | If the current platform double buffers by default then this DC is the | |
1551 | same as a plain `wx.PaintDC`, otherwise it is a `wx.BufferedPaintDC`. | |
1552 | """ | |
1553 | def __init__(self, window): | |
1554 | _AutoBufferedPaintDCBase.__init__(self, window) | |
1555 | } | |
1556 | ||
d14a1e28 RD |
1557 | //--------------------------------------------------------------------------- |
1558 | %newgroup | |
1559 | ||
ab1f7d2a RD |
1560 | MustHaveApp(wxMirrorDC); |
1561 | ||
70794ec5 RD |
1562 | DocStr(wxMirrorDC, |
1563 | "wx.MirrorDC is a simple wrapper class which is always associated with a | |
1564 | real `wx.DC` object and either forwards all of its operations to it | |
1565 | without changes (no mirroring takes place) or exchanges x and y | |
1566 | coordinates which makes it possible to reuse the same code to draw a | |
1567 | figure and its mirror -- i.e. reflection related to the diagonal line | |
1568 | x == y.", ""); | |
d14a1e28 RD |
1569 | class wxMirrorDC : public wxDC |
1570 | { | |
1571 | public: | |
70794ec5 RD |
1572 | DocCtorStr( |
1573 | wxMirrorDC(wxDC& dc, bool mirror), | |
1574 | "Creates a mirrored DC associated with the real *dc*. Everything drawn | |
1575 | on the wx.MirrorDC will appear on the *dc*, and will be mirrored if | |
1576 | *mirror* is True.",""); | |
d14a1e28 RD |
1577 | }; |
1578 | ||
1579 | //--------------------------------------------------------------------------- | |
1580 | %newgroup | |
1581 | ||
1582 | %{ | |
1583 | #include <wx/dcps.h> | |
1584 | %} | |
1585 | ||
ab1f7d2a RD |
1586 | MustHaveApp(wxPostScriptDC); |
1587 | ||
70794ec5 RD |
1588 | DocStr(wxPostScriptDC, |
1589 | "This is a `wx.DC` that can write to PostScript files on any platform.",""); | |
1590 | ||
d14a1e28 RD |
1591 | class wxPostScriptDC : public wxDC { |
1592 | public: | |
70794ec5 RD |
1593 | DocCtorStr( |
1594 | wxPostScriptDC(const wxPrintData& printData), | |
1595 | "Constructs a PostScript printer device context from a `wx.PrintData` | |
1596 | object.", ""); | |
d14a1e28 RD |
1597 | |
1598 | wxPrintData& GetPrintData(); | |
1599 | void SetPrintData(const wxPrintData& data); | |
1600 | ||
70794ec5 RD |
1601 | DocDeclStr( |
1602 | static void , SetResolution(int ppi), | |
1603 | "Set resolution (in pixels per inch) that will be used in PostScript | |
1604 | output. Default is 720ppi.", ""); | |
1605 | ||
1606 | DocDeclStr( | |
1607 | static int , GetResolution(), | |
1608 | "Return resolution used in PostScript output.", ""); | |
7012bb9f RD |
1609 | |
1610 | %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`"); | |
d14a1e28 RD |
1611 | }; |
1612 | ||
1613 | //--------------------------------------------------------------------------- | |
1614 | %newgroup | |
1615 | ||
1616 | ||
ab1f7d2a RD |
1617 | MustHaveApp(wxMetaFile); |
1618 | MustHaveApp(wxMetaFileDC); | |
1619 | ||
1620 | ||
da457c1b | 1621 | #if defined(__WXMSW__) || defined(__WXMAC__) |
d14a1e28 RD |
1622 | |
1623 | %{ | |
1624 | #include <wx/metafile.h> | |
1625 | %} | |
1626 | ||
1627 | class wxMetaFile : public wxObject { | |
1628 | public: | |
1629 | wxMetaFile(const wxString& filename = wxPyEmptyString); | |
1630 | ~wxMetaFile(); | |
1631 | ||
6c2dd16f RD |
1632 | bool IsOk(); |
1633 | %pythoncode { Ok = IsOk } | |
d14a1e28 RD |
1634 | bool SetClipboard(int width = 0, int height = 0); |
1635 | ||
1636 | wxSize GetSize(); | |
1637 | int GetWidth(); | |
1638 | int GetHeight(); | |
1639 | ||
da457c1b | 1640 | #ifdef __WXMSW__ |
d14a1e28 | 1641 | const wxString& GetFileName() const; |
da457c1b RD |
1642 | #endif |
1643 | ||
6c2dd16f | 1644 | %pythoncode { def __nonzero__(self): return self.IsOk() } |
d14a1e28 RD |
1645 | }; |
1646 | ||
1647 | // bool wxMakeMetaFilePlaceable(const wxString& filename, | |
1648 | // int minX, int minY, int maxX, int maxY, float scale=1.0); | |
1649 | ||
1650 | ||
1651 | class wxMetaFileDC : public wxDC { | |
1652 | public: | |
1653 | wxMetaFileDC(const wxString& filename = wxPyEmptyString, | |
1654 | int width = 0, int height = 0, | |
1655 | const wxString& description = wxPyEmptyString); | |
1656 | wxMetaFile* Close(); | |
1657 | }; | |
1658 | ||
1659 | ||
1660 | ||
1661 | #else // Make some dummies for the other platforms | |
1662 | ||
1663 | %{ | |
1664 | class wxMetaFile : public wxObject { | |
1665 | public: | |
1666 | wxMetaFile(const wxString&) | |
81cfe5e1 | 1667 | { wxPyRaiseNotImplemented(); } |
d14a1e28 RD |
1668 | }; |
1669 | ||
1670 | class wxMetaFileDC : public wxClientDC { | |
1671 | public: | |
1672 | wxMetaFileDC(const wxString&, int, int, const wxString&) | |
81cfe5e1 | 1673 | { wxPyRaiseNotImplemented(); } |
d14a1e28 RD |
1674 | }; |
1675 | ||
1676 | %} | |
1677 | ||
1678 | class wxMetaFile : public wxObject { | |
1679 | public: | |
1680 | wxMetaFile(const wxString& filename = wxPyEmptyString); | |
1681 | }; | |
1682 | ||
1683 | class wxMetaFileDC : public wxDC { | |
1684 | public: | |
1685 | wxMetaFileDC(const wxString& filename = wxPyEmptyString, | |
1686 | int width = 0, int height = 0, | |
1687 | const wxString& description = wxPyEmptyString); | |
1688 | }; | |
1689 | ||
1690 | ||
1691 | #endif | |
1692 | ||
1693 | ||
1694 | //--------------------------------------------------------------------------- | |
1695 | ||
ab1f7d2a RD |
1696 | MustHaveApp(wxPrinterDC); |
1697 | ||
d14a1e28 RD |
1698 | #if defined(__WXMSW__) || defined(__WXMAC__) |
1699 | ||
1700 | class wxPrinterDC : public wxDC { | |
1701 | public: | |
1702 | wxPrinterDC(const wxPrintData& printData); | |
d14a1e28 RD |
1703 | }; |
1704 | ||
1705 | #else | |
1706 | %{ | |
1707 | class wxPrinterDC : public wxClientDC { | |
1708 | public: | |
1709 | wxPrinterDC(const wxPrintData&) | |
81cfe5e1 | 1710 | { wxPyRaiseNotImplemented(); } |
4942342c | 1711 | |
d14a1e28 RD |
1712 | }; |
1713 | %} | |
4942342c | 1714 | |
d14a1e28 RD |
1715 | class wxPrinterDC : public wxDC { |
1716 | public: | |
1717 | wxPrinterDC(const wxPrintData& printData); | |
d14a1e28 RD |
1718 | }; |
1719 | #endif | |
1720 | ||
4942342c RD |
1721 | //--------------------------------------------------------------------------- |
1722 | //--------------------------------------------------------------------------- |