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