]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_dc.i
fixed memory leaks when reading invalid GIFs
[wxWidgets.git] / wxPython / src / _dc.i
CommitLineData
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
41DocStr(wxDC,
42"A wx.DC is a device context onto which graphics and text can be
43drawn. It is intended to represent a number of output devices in a
44generic way, so a window can have a device context associated with it,
45and a printer also has a device context. In this way, the same piece
46of code may write to a number of different devices, if the device
47context is used as a parameter.
48
49Derived types of wxDC have documentation for specific features only,
50so refer to this section for most device context information.
51
52The wx.DC class is abstract and can not be instantiated, you must use
53one of the derived classes instead. Which one will depend on the
54situation in which it is used.", "");
55
d14a1e28
RD
56class wxDC : public wxObject {
57public:
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
77the 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 85Returns False if the operation failed.
d14a1e28 86
70794ec5
RD
87Note: The present implementation for non-Windows platforms may fail to
88find colour borders if the pixels do not match the colour
89exactly. 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
102initialColour in the center of the circle and fading to destColour on
103the outside of the circle. The circleCenter argument is the relative
104coordinants of the center of the circle in the specified rect.
105
106Note: Currently this function is very slow, don't use it for real-time
107drawing.", "");
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
116initialColour and eventually fading to destColour. The nDirection
117parameter specifies the direction of the colour change, default is to
118use initialColour on the left part of the rectangle and destColour on
119the 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
143used for drawing the line. Note that the second point is *not* part of
144the line and is not drawn by this function (this is consistent with
145the 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
153horizontal line the height and width of the window, centred on the
154given 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
162the first point to the second. The current pen is used for the outline
163and the current brush for filling the shape.
164
165The arc is drawn in an anticlockwise direction from the start point to
166the 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
180bounds of the ellipse. The current pen is used for drawing the arc and
181the current brush is used for drawing the pie.
182
183The *start* and *end* parameters specify the start and end of the arc
184relative to the three-o'clock position from the center of the
185rectangle. Angles are specified in degrees (360 is a complete
186circle). Positive values mean counter-clockwise motion. If start is
187equal 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
202size. The current pen is used for the outline and the current brush
203for 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
212size. The corners are quarter-circles using the given radius. The
213current pen is used for the outline and the current brush for filling
214the shape.
215
216If radius is positive, the value is assumed to be the radius of the
217rounded corner. If radius is negative, the absolute value is assumed
218to be the proportion of the smallest dimension of the rectangle. This
219means that the corner can be a sensible size relative to the size of
220the rectangle, and also avoids the strange effects X produces when the
221corners 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
230pen is used for the outline and the current brush for filling the
231shape.", "
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
241is 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
252PostScript). This can be the simplest way of drawing bitmaps on a
253window.", "");
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
262alpha channel on the platforms that support it) then the bitmap will
263be drawn transparently.", "
4942342c 264
70794ec5
RD
265When drawing a mono-bitmap, the current text foreground colour will be
266used to draw the foreground of the bitmap (all bits set to 1), and the
267current text background colour to draw the background (all bits set to
2680).
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
278font, and the current text foreground and background colours.
d14a1e28 279
70794ec5
RD
280The coordinates refer to the top-left corner of the rectangle bounding
281the string. See `GetTextExtent` for how to get the dimensions of a
282text 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
285function but it is ignored by wxMSW. Thus, you should avoid using
286logical 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
298function. In particular, a font different from ``wx.NORMAL_FONT``
299should be used as the it is not normally a TrueType
300font. ``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
313coordinates, size of area to copy, source DC, source coordinates,
314logical function, whether to use a bitmap mask, and mask source
315position.", "
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
340coordinates, size of area to copy, source DC, source coordinates,
341logical function, whether to use a bitmap mask, and mask source
342position.", "
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);
8f514ab4
RD
355
356
cbfc9df6
RD
357 DocDeclStr(
358 bool , StretchBlit(wxCoord dstX, wxCoord dstY,
359 wxCoord dstWidth, wxCoord dstHeight,
360 wxDC *source,
361 wxCoord srcX, wxCoord srcY,
362 wxCoord srcWidth, wxCoord srcHeight,
363 int rop = wxCOPY, bool useMask = false,
364 wxCoord srcMaskX = wxDefaultCoord,
365 wxCoord srcMaskY = wxDefaultCoord),
366 "Copy from a source DC to this DC, specifying the destination
367coordinates, destination size, source DC, source coordinates, size of
368source area to copy, logical function, whether to use a bitmap mask,
369and mask source position.", "
370
371 :param xdest: Destination device context x position.
372 :param ydest: Destination device context y position.
373 :param dstWidth: Width of destination area.
374 :param dstHeight: Height of destination area.
375 :param source: Source device context.
376 :param xsrc: Source device context x position.
377 :param ysrc: Source device context y position.
378 :param srcWidth: Width of source area to be copied.
379 :param srcHeight: Height of source area to be copied.
380 :param logicalFunc: Logical function to use: see `SetLogicalFunction`.
381 :param useMask: If true, StretchBlit does a transparent blit using
382 the mask that is associated with the bitmap selected
383 into the source device context.
384 :param xsrcMask: Source x position on the mask. If both xsrcMask and
385 ysrcMask are -1, xsrc and ysrc will be assumed for
386 the mask source position. Currently only implemented
387 on Windows.
388 :param ysrcMask: Source y position on the mask.
389");
390
391
392
393 DocDeclStrName(
394 bool , StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
395 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
396 int rop = wxCOPY, bool useMask = false,
397 const wxPoint& srcMaskPt = wxDefaultPosition),
398 "Copy from a source DC to this DC, specifying the destination
399coordinates, destination size, source DC, source coordinates, size of
400source area to copy, logical function, whether to use a bitmap mask,
401and mask source position. This version is the same as `StretchBlit`
402except `wx.Point` and `wx.Size` objects are used instead of individual
403position and size components.", "",
404 StretchBlitPointSize);
405
406
407
8f514ab4
RD
408 DocDeclStr(
409 wxBitmap , GetAsBitmap(const wxRect *subrect = NULL) const,
410 "", "");
411
70794ec5 412
d14a1e28 413
70794ec5
RD
414 DocStr(
415 SetClippingRegion,
416 "Sets the clipping region for this device context to the intersection
417of the given region described by the parameters of this method and the
418previously set clipping region. You should call `DestroyClippingRegion`
419if you want to set the clipping region exactly to the region
420specified.
4942342c 421
70794ec5
RD
422The clipping region is an area to which drawing is
423restricted. Possible uses for the clipping region are for clipping
424text or for speeding up window redraws when only a known area of the
425screen is damaged.", "
d14a1e28 426
70794ec5
RD
427:see: `DestroyClippingRegion`, `wx.Region`");
428 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1b8c7ba6
RD
429 %Rename(SetClippingRegionPointSize, void, SetClippingRegion(const wxPoint& pt, const wxSize& sz));
430 %Rename(SetClippingRegionAsRegion, void, SetClippingRegion(const wxRegion& region));
431 %Rename(SetClippingRect, void, SetClippingRegion(const wxRect& rect));
d7403ad2 432
4942342c 433
70794ec5
RD
434
435 DocDeclAStr(
436 void , DrawLines(int points, wxPoint* points_array,
437 wxCoord xoffset = 0, wxCoord yoffset = 0),
438 "DrawLines(self, List points, int xoffset=0, int yoffset=0)",
439 "Draws lines using a sequence of `wx.Point` objects, adding the
440optional offset coordinate. The current pen is used for drawing the
441lines.", "");
442
d14a1e28 443
70794ec5
RD
444 DocDeclAStr(
445 void , DrawPolygon(int points, wxPoint* points_array,
d14a1e28 446 wxCoord xoffset = 0, wxCoord yoffset = 0,
70794ec5
RD
447 int fillStyle = wxODDEVEN_RULE),
448 "DrawPolygon(self, List points, int xoffset=0, int yoffset=0,
449 int fillStyle=ODDEVEN_RULE)",
450 "Draws a filled polygon using a sequence of `wx.Point` objects, adding
451the optional offset coordinate. The last argument specifies the fill
452rule: ``wx.ODDEVEN_RULE`` (the default) or ``wx.WINDING_RULE``.
453
454The current pen is used for drawing the outline, and the current brush
455for filling the shape. Using a transparent brush suppresses
456filling. Note that wxWidgets automatically closes the first and last
457points.", "");
458
d14a1e28 459
86aafce3
RD
460 // TODO: Figure out a good typemap for this...
461 // Convert the first 3 args from a sequence of sequences?
462// void DrawPolyPolygon(int n, int count[], wxPoint points[],
463// wxCoord xoffset = 0, wxCoord yoffset = 0,
464// int fillStyle = wxODDEVEN_RULE);
d14a1e28 465
86aafce3 466
70794ec5
RD
467 DocDeclStr(
468 void , DrawLabel(const wxString& text, const wxRect& rect,
469 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
470 int indexAccel = -1),
471 "Draw *text* within the specified rectangle, abiding by the alignment
472flags. Will additionally emphasize the character at *indexAccel* if
473it is not -1.", "
474
475:see: `DrawImageLabel`");
476
477
d14a1e28 478 %extend {
70794ec5
RD
479 DocStr(DrawImageLabel,
480 "Draw *text* and an image (which may be ``wx.NullBitmap`` to skip
481drawing it) within the specified rectangle, abiding by the alignment
482flags. Will additionally emphasize the character at *indexAccel* if
483it is not -1. Returns the bounding rectangle.", "");
d14a1e28
RD
484 wxRect DrawImageLabel(const wxString& text,
485 const wxBitmap& image,
486 const wxRect& rect,
487 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
488 int indexAccel = -1) {
489 wxRect rv;
490 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
491 return rv;
492 }
493 }
494
495
496
70794ec5
RD
497 DocDeclAStr(
498 void , DrawSpline(int points, wxPoint* points_array),
499 "DrawSpline(self, List points)",
500 "Draws a spline between all given control points, (a list of `wx.Point`
501objects) using the current pen. The spline is drawn using a series of
502lines, using an algorithm taken from the X drawing program 'XFIG'.", "");
503
d14a1e28
RD
504
505
4942342c 506
d14a1e28
RD
507 // global DC operations
508 // --------------------
509
70794ec5
RD
510 DocDeclStr(
511 virtual void , Clear(),
512 "Clears the device context using the current background brush.", "");
513
d14a1e28 514
70794ec5
RD
515 DocDeclStr(
516 virtual bool , StartDoc(const wxString& message),
517 "Starts a document (only relevant when outputting to a
518printer). *Message* is a message to show whilst printing.", "");
519
520 DocDeclStr(
521 virtual void , EndDoc(),
522 "Ends a document (only relevant when outputting to a printer).", "");
523
d14a1e28 524
70794ec5
RD
525 DocDeclStr(
526 virtual void , StartPage(),
527 "Starts a document page (only relevant when outputting to a printer).", "");
528
529 DocDeclStr(
530 virtual void , EndPage(),
531 "Ends a document page (only relevant when outputting to a printer).", "");
532
d14a1e28 533
4942342c 534
d14a1e28
RD
535 // set objects to use for drawing
536 // ------------------------------
537
70794ec5
RD
538 DocDeclStr(
539 virtual void , SetFont(const wxFont& font),
540 "Sets the current font for the DC. It must be a valid font, in
541particular you should not pass ``wx.NullFont`` to this method.","
d14a1e28 542
70794ec5
RD
543:see: `wx.Font`");
544
545 DocDeclStr(
546 virtual void , SetPen(const wxPen& pen),
547 "Sets the current pen for the DC.
4942342c 548
70794ec5
RD
549If the argument is ``wx.NullPen``, the current pen is selected out of the
550device context, and the original pen restored.", "
d14a1e28 551
70794ec5
RD
552:see: `wx.Pen`");
553
554 DocDeclStr(
555 virtual void , SetBrush(const wxBrush& brush),
556 "Sets the current brush for the DC.
557
558If the argument is ``wx.NullBrush``, the current brush is selected out
559of the device context, and the original brush restored, allowing the
560current brush to be destroyed safely.","
561
562:see: `wx.Brush`");
563
564 DocDeclStr(
565 virtual void , SetBackground(const wxBrush& brush),
566 "Sets the current background brush for the DC.", "");
567
568 DocDeclStr(
569 virtual void , SetBackgroundMode(int mode),
570 "*mode* may be one of ``wx.SOLID`` and ``wx.TRANSPARENT``. This setting
571determines whether text will be drawn with a background colour or
572not.", "");
573
574 DocDeclStr(
575 virtual void , SetPalette(const wxPalette& palette),
576 "If this is a window DC or memory DC, assigns the given palette to the
577window or bitmap associated with the DC. If the argument is
578``wx.NullPalette``, the current palette is selected out of the device
579context, and the original palette restored.", "
580
581:see: `wx.Palette`");
582
583
584
585 DocDeclStr(
586 virtual void , DestroyClippingRegion(),
587 "Destroys the current clipping region so that none of the DC is
588clipped.", "
589
590:see: `SetClippingRegion`");
591
592
593 DocDeclAStr(
322913ce 594 void, GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const,
70794ec5
RD
595 "GetClippingBox() -> (x, y, width, height)",
596 "Gets the rectangle surrounding the current clipping region.", "");
4942342c 597
d14a1e28 598 %extend {
70794ec5
RD
599 DocStr(
600 GetClippingRect,
601 "Gets the rectangle surrounding the current clipping region.", "");
d14a1e28
RD
602 wxRect GetClippingRect() {
603 wxRect rect;
604 self->GetClippingBox(rect);
605 return rect;
606 }
607 }
d14a1e28 608
4942342c
RD
609
610
d14a1e28
RD
611 // text extent
612 // -----------
613
70794ec5
RD
614 DocDeclStr(
615 virtual wxCoord , GetCharHeight() const,
616 "Gets the character height of the currently set font.", "");
617
618 DocDeclStr(
619 virtual wxCoord , GetCharWidth() const,
620 "Gets the average character width of the currently set font.", "");
621
d14a1e28 622
d14a1e28 623
322913ce
RD
624 DocDeclAStr(
625 void, GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT),
626 "GetTextExtent(wxString string) -> (width, height)",
d07d2bc9
RD
627 "Get the width and height of the text using the current font. Only
628works for single line strings.", "");
629
322913ce
RD
630 DocDeclAStrName(
631 void, GetTextExtent(const wxString& string,
4942342c 632 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
322913ce
RD
633 wxFont* font = NULL),
634 "GetFullTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)",
d07d2bc9
RD
635 "Get the width, height, decent and leading of the text using the
636current or specified font. Only works for single line strings.", "",
322913ce
RD
637 GetFullTextExtent);
638
4942342c 639
322913ce
RD
640 // works for single as well as multi-line strings
641 DocDeclAStr(
642 void, GetMultiLineTextExtent(const wxString& text,
643 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT,
644 wxFont *font = NULL),
25e29eb2 645 "GetMultiLineTextExtent(wxString string, Font font=None) ->\n (width, height, lineHeight)",
67cb8b47 646 "Get the width, height, and line height of the text using the
d07d2bc9
RD
647current or specified font. Works for single as well as multi-line
648strings.", "");
322913ce 649
746ee6b8
RD
650
651 %extend {
70794ec5
RD
652 DocAStr(GetPartialTextExtents,
653 "GetPartialTextExtents(self, text) -> [widths]",
654 "Returns a list of integers such that each value is the distance in
655pixels from the begining of text to the coresponding character of
656*text*. The generic version simply builds a running total of the widths
657of each character using GetTextExtent, however if the various
658platforms have a native API function that is faster or more accurate
43e8916f 659than the generic implementation then it will be used instead.", "");
746ee6b8
RD
660 wxArrayInt GetPartialTextExtents(const wxString& text) {
661 wxArrayInt widths;
662 self->GetPartialTextExtents(text, widths);
663 return widths;
664 }
665 }
666
d14a1e28
RD
667
668 // size and resolution
669 // -------------------
670
70794ec5
RD
671 DocStr(
672 GetSize,
673 "This gets the horizontal and vertical resolution in device units. It
674can be used to scale graphics to fit the page. For example, if *maxX*
675and *maxY* represent the maximum horizontal and vertical 'pixel' values
676used in your application, the following code will scale the graphic to
677fit on the printer page::
678
679 w, h = dc.GetSize()
680 scaleX = maxX*1.0 / w
681 scaleY = maxY*1.0 / h
682 dc.SetUserScale(min(scaleX,scaleY),min(scaleX,scaleY))
683", "");
d14a1e28 684 wxSize GetSize();
322913ce
RD
685 DocDeclAName(
686 void, GetSize( int *OUTPUT, int *OUTPUT ),
687 "GetSizeTuple() -> (width, height)",
688 GetSizeTuple);
4942342c 689
d14a1e28 690
d07d2bc9 691 DocStr(GetSizeMM, "Get the DC size in milimeters.", "");
d14a1e28 692 wxSize GetSizeMM() const;
322913ce
RD
693 DocDeclAName(
694 void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const,
695 "GetSizeMMTuple() -> (width, height)",
696 GetSizeMMTuple);
4942342c
RD
697
698
d14a1e28
RD
699
700 // coordinates conversions
701 // -----------------------
702
70794ec5
RD
703 DocDeclStr(
704 wxCoord , DeviceToLogicalX(wxCoord x) const,
705 "Convert device X coordinate to logical coordinate, using the current
706mapping mode.", "");
707
708 DocDeclStr(
709 wxCoord , DeviceToLogicalY(wxCoord y) const,
710 "Converts device Y coordinate to logical coordinate, using the current
711mapping mode.", "");
712
713 DocDeclStr(
714 wxCoord , DeviceToLogicalXRel(wxCoord x) const,
715 "Convert device X coordinate to relative logical coordinate, using the
716current mapping mode but ignoring the x axis orientation. Use this
717function for converting a width, for example.", "");
718
719 DocDeclStr(
720 wxCoord , DeviceToLogicalYRel(wxCoord y) const,
721 "Convert device Y coordinate to relative logical coordinate, using the
722current mapping mode but ignoring the y axis orientation. Use this
723function for converting a height, for example.", "");
724
725 DocDeclStr(
726 wxCoord , LogicalToDeviceX(wxCoord x) const,
727 "Converts logical X coordinate to device coordinate, using the current
728mapping mode.", "");
729
730 DocDeclStr(
731 wxCoord , LogicalToDeviceY(wxCoord y) const,
732 "Converts logical Y coordinate to device coordinate, using the current
733mapping mode.", "");
734
735 DocDeclStr(
736 wxCoord , LogicalToDeviceXRel(wxCoord x) const,
737 "Converts logical X coordinate to relative device coordinate, using the
738current mapping mode but ignoring the x axis orientation. Use this for
739converting a width, for example.", "");
740
741 DocDeclStr(
742 wxCoord , LogicalToDeviceYRel(wxCoord y) const,
743 "Converts logical Y coordinate to relative device coordinate, using the
744current mapping mode but ignoring the y axis orientation. Use this for
745converting a height, for example.", "");
746
d14a1e28 747
70794ec5 748
d14a1e28
RD
749 // query DC capabilities
750 // ---------------------
751
752 virtual bool CanDrawBitmap() const;
753 virtual bool CanGetTextExtent() const;
754
d14a1e28 755
70794ec5
RD
756 DocDeclStr(
757 virtual int , GetDepth() const,
758 "Returns the colour depth of the DC.", "");
759
d14a1e28 760
70794ec5
RD
761 DocDeclStr(
762 virtual wxSize , GetPPI() const,
361b8ff7 763 "Resolution in pixels per inch", "");
70794ec5 764
d14a1e28 765
70794ec5 766 DocDeclStr(
6c2dd16f 767 virtual bool , IsOk() const,
70794ec5 768 "Returns true if the DC is ok to use.", "");
6c2dd16f 769 %pythoncode { Ok = IsOk }
70794ec5 770
4942342c 771
d14a1e28 772
70794ec5
RD
773 DocDeclStr(
774 int , GetBackgroundMode() const,
775 "Returns the current background mode, either ``wx.SOLID`` or
776``wx.TRANSPARENT``.","
d14a1e28 777
70794ec5
RD
778:see: `SetBackgroundMode`");
779
780 DocDeclStr(
781 const wxBrush& , GetBackground() const,
782 "Gets the brush used for painting the background.","
d14a1e28 783
70794ec5
RD
784:see: `SetBackground`");
785
786 DocDeclStr(
787 const wxBrush& , GetBrush() const,
788 "Gets the current brush", "");
789
790 DocDeclStr(
791 const wxFont& , GetFont() const,
792 "Gets the current font", "");
793
794 DocDeclStr(
795 const wxPen& , GetPen() const,
796 "Gets the current pen", "");
797
798 DocDeclStr(
799 const wxColour& , GetTextBackground() const,
800 "Gets the current text background colour", "");
801
802 DocDeclStr(
803 const wxColour& , GetTextForeground() const,
804 "Gets the current text foreground colour", "");
805
d14a1e28 806
70794ec5
RD
807 DocDeclStr(
808 virtual void , SetTextForeground(const wxColour& colour),
809 "Sets the current text foreground colour for the DC.", "");
810
811 DocDeclStr(
812 virtual void , SetTextBackground(const wxColour& colour),
813 "Sets the current text background colour for the DC.", "");
814
4942342c 815
70794ec5
RD
816 DocDeclStr(
817 int , GetMapMode() const,
818 "Gets the current *mapping mode* for the device context ", "");
819
820 DocDeclStr(
821 virtual void , SetMapMode(int mode),
822 "The *mapping mode* of the device context defines the unit of
823measurement used to convert logical units to device units. The
824mapping mode can be one of the following:
825
826 ================ =============================================
827 wx.MM_TWIPS Each logical unit is 1/20 of a point, or 1/1440
828 of an inch.
829 wx.MM_POINTS Each logical unit is a point, or 1/72 of an inch.
830 wx.MM_METRIC Each logical unit is 1 mm.
831 wx.MM_LOMETRIC Each logical unit is 1/10 of a mm.
832 wx.MM_TEXT Each logical unit is 1 pixel.
833 ================ =============================================
834","
835Note that in X, text drawing isn't handled consistently with the
836mapping mode; a font is always specified in point size. However,
837setting the user scale (see `SetUserScale`) scales the text
838appropriately. In Windows, scalable TrueType fonts are always used; in
839X, results depend on availability of fonts, but usually a reasonable
840match is found.
841
842The coordinate origin is always at the top left of the screen/printer.
843
844Drawing to a Windows printer device context uses the current mapping
845mode, but mapping mode is currently ignored for PostScript output.
846");
847
848
849
850 DocDeclAStr(
322913ce 851 virtual void, GetUserScale(double *OUTPUT, double *OUTPUT) const,
70794ec5
RD
852 "GetUserScale(self) -> (xScale, yScale)",
853 "Gets the current user scale factor (set by `SetUserScale`).", "");
4942342c 854
70794ec5
RD
855 DocDeclStr(
856 virtual void , SetUserScale(double x, double y),
857 "Sets the user scaling factor, useful for applications which require
858'zooming'.", "");
859
d14a1e28 860
4942342c 861
322913ce
RD
862 DocDeclA(
863 virtual void, GetLogicalScale(double *OUTPUT, double *OUTPUT),
864 "GetLogicalScale() -> (xScale, yScale)");
865
d14a1e28
RD
866 virtual void SetLogicalScale(double x, double y);
867
322913ce 868
d14a1e28 869 wxPoint GetLogicalOrigin() const;
322913ce
RD
870 DocDeclAName(
871 void, GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
872 "GetLogicalOriginTuple() -> (x,y)",
873 GetLogicalOriginTuple);
4942342c 874
d14a1e28 875 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
d7403ad2
RD
876 %extend {
877 void SetLogicalOriginPoint(const wxPoint& point) {
878 self->SetLogicalOrigin(point.x, point.y);
879 }
880 }
d14a1e28 881
d7403ad2 882
d14a1e28 883 wxPoint GetDeviceOrigin() const;
322913ce
RD
884 DocDeclAName(
885 void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
886 "GetDeviceOriginTuple() -> (x,y)",
887 GetDeviceOriginTuple);
4942342c 888
d14a1e28 889 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
d7403ad2
RD
890 %extend {
891 void SetDeviceOriginPoint(const wxPoint& point) {
892 self->SetDeviceOrigin(point.x, point.y);
893 }
894 }
d14a1e28 895
70794ec5
RD
896 DocDeclStr(
897 virtual void , SetAxisOrientation(bool xLeftRight, bool yBottomUp),
898 "Sets the x and y axis orientation (i.e., the direction from lowest to
899highest values on the axis). The default orientation is the natural
900orientation, e.g. x axis from left to right and y axis from bottom up.", "");
3350d652 901
d14a1e28 902
70794ec5
RD
903 DocDeclStr(
904 int , GetLogicalFunction() const,
905 "Gets the current logical function (set by `SetLogicalFunction`).", "");
906
907 DocDeclStr(
908 virtual void , SetLogicalFunction(int function),
909 "Sets the current logical function for the device context. This
910determines how a source pixel (from a pen or brush colour, or source
911device context if using `Blit`) combines with a destination pixel in
912the current device context.
913
914The possible values and their meaning in terms of source and
915destination pixel values are as follows:
916
917 ================ ==========================
918 wx.AND src AND dst
919 wx.AND_INVERT (NOT src) AND dst
920 wx.AND_REVERSE src AND (NOT dst)
921 wx.CLEAR 0
922 wx.COPY src
923 wx.EQUIV (NOT src) XOR dst
924 wx.INVERT NOT dst
925 wx.NAND (NOT src) OR (NOT dst)
926 wx.NOR (NOT src) AND (NOT dst)
927 wx.NO_OP dst
928 wx.OR src OR dst
929 wx.OR_INVERT (NOT src) OR dst
930 wx.OR_REVERSE src OR (NOT dst)
931 wx.SET 1
932 wx.SRC_INVERT NOT src
933 wx.XOR src XOR dst
934 ================ ==========================
935
936The default is wx.COPY, which simply draws with the current
937colour. The others combine the current colour and the background using
938a logical operation. wx.INVERT is commonly used for drawing rubber
939bands or moving outlines, since drawing twice reverts to the original
940colour.
941", "");
942
d14a1e28 943
25e29eb2
RD
944 DocDeclStr(
945 void , ComputeScaleAndOrigin(),
946 "Performs all necessary computations for given platform and context
947type after each change of scale and origin parameters. Usually called
948automatically internally after such changes.
949", "");
3350d652
RD
950
951
952
49e6b3c3
RD
953// DocDeclStr(
954// virtual void , SetOptimization(bool optimize),
955// "If *optimize* is true this function sets optimization mode on. This
956// currently means that under X, the device context will not try to set a
957// pen or brush property if it is known to be set already. This approach
958// can fall down if non-wxWidgets code is using the same device context
959// or window, for example when the window is a panel on which the
960// windowing system draws panel items. The wxWidgets device context
961// 'memory' will now be out of step with reality.
962
963// Setting optimization off, drawing, then setting it back on again, is a
964// trick that must occasionally be employed.", "");
965
966// DocDeclStr(
967// virtual bool , GetOptimization(),
968// "Returns true if device context optimization is on. See
969// `SetOptimization` for details.", "");
970
971 %pythoncode {
972 def SetOptimization(self, optimize):
973 pass
974 def GetOptimization(self):
975 return False
976
977 SetOptimization = wx._deprecated(SetOptimization)
978 GetOptimization = wx._deprecated(GetOptimization)
979 }
70794ec5 980
70794ec5 981
d14a1e28
RD
982 // bounding box
983 // ------------
984
70794ec5
RD
985 DocDeclStr(
986 virtual void , CalcBoundingBox(wxCoord x, wxCoord y),
987 "Adds the specified point to the bounding box which can be retrieved
988with `MinX`, `MaxX` and `MinY`, `MaxY` or `GetBoundingBox` functions.", "");
989
d7403ad2 990 %extend {
70794ec5
RD
991 DocStr(CalcBoundingBoxPoint,
992 "Adds the specified point to the bounding box which can be retrieved
993with `MinX`, `MaxX` and `MinY`, `MaxY` or `GetBoundingBox` functions.","");
d7403ad2
RD
994 void CalcBoundingBoxPoint(const wxPoint& point) {
995 self->CalcBoundingBox(point.x, point.y);
996 }
997 }
998
70794ec5
RD
999 DocDeclStr(
1000 void , ResetBoundingBox(),
1001 "Resets the bounding box: after a call to this function, the bounding
1002box doesn't contain anything.", "");
1003
d14a1e28
RD
1004
1005 // Get the final bounding box of the PostScript or Metafile picture.
70794ec5
RD
1006 DocDeclStr(
1007 wxCoord , MinX() const,
1008 "Gets the minimum horizontal extent used in drawing commands so far.", "");
1009
1010 DocDeclStr(
1011 wxCoord , MaxX() const,
1012 "Gets the maximum horizontal extent used in drawing commands so far.", "");
1013
1014 DocDeclStr(
1015 wxCoord , MinY() const,
1016 "Gets the minimum vertical extent used in drawing commands so far.", "");
1017
1018 DocDeclStr(
1019 wxCoord , MaxY() const,
1020 "Gets the maximum vertical extent used in drawing commands so far.", "");
1021
d14a1e28
RD
1022
1023
70794ec5
RD
1024 DocAStr(GetBoundingBox,
1025 "GetBoundingBox() -> (x1,y1, x2,y2)",
1026 "Returns the min and max points used in drawing commands so far.", "");
d14a1e28
RD
1027 %extend {
1028 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
1029 // See below for implementation
4942342c 1030 }
70794ec5 1031
6c2dd16f 1032 %pythoncode { def __nonzero__(self): return self.IsOk() };
d14a1e28
RD
1033
1034
8adc9d9d
RD
1035 // RTL related functions
1036 // ---------------------
1037
1038 DocDeclStr(
1039 virtual wxLayoutDirection , GetLayoutDirection() const,
1040 "Get the layout direction (LTR or RTL)_ for this dc. On platforms
1041where RTL layout is supported, the return value will either be
1042``wx.Layout_LeftToRight`` or ``wx.Layout_RightToLeft``.
1043``wx.Layout_Default`` is returned if layout direction is not
1044supported.", "");
1045
1046 DocDeclStr(
1047 virtual void , SetLayoutDirection(wxLayoutDirection dir),
1048 "Change the layout direction for this dc.", "");
1049
1050
1051
1052
96fc3ef4
RD
1053#ifdef __WXMSW__
1054 long GetHDC();
1055#endif
1056
d14a1e28
RD
1057
1058 %extend { // See drawlist.cpp for impplementaion of these...
1059 PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
1060 {
1061 return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes);
1062 }
1063
1064 PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
1065 {
1066 return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes);
1067 }
1068
1069 PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
1070 {
1071 return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes);
1072 }
1073
1074 PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
1075 {
1076 return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes);
1077 }
1078
1079 PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
1080 {
1081 return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes);
1082 }
1083
1084 PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints,
1085 PyObject* foregroundList, PyObject* backgroundList) {
1086 return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList);
1087 }
1088 }
1089
1090 %pythoncode {
1091 def DrawPointList(self, points, pens=None):
70794ec5
RD
1092 """
1093 Draw a list of points as quickly as possible.
1094
1095 :param points: A sequence of 2-element sequences representing
1096 each point to draw, (x,y).
1097 :param pens: If None, then the current pen is used. If a
1098 single pen then it will be used for all points. If
1099 a list of pens then there should be one for each point
1100 in points.
1101 """
d14a1e28
RD
1102 if pens is None:
1103 pens = []
1104 elif isinstance(pens, wx.Pen):
1105 pens = [pens]
1106 elif len(pens) != len(points):
1107 raise ValueError('points and pens must have same length')
1108 return self._DrawPointList(points, pens, [])
1109
1110
1111 def DrawLineList(self, lines, pens=None):
70794ec5
RD
1112 """
1113 Draw a list of lines as quickly as possible.
1114
1115 :param lines: A sequence of 4-element sequences representing
1116 each line to draw, (x1,y1, x2,y2).
1117 :param pens: If None, then the current pen is used. If a
1118 single pen then it will be used for all lines. If
1119 a list of pens then there should be one for each line
1120 in lines.
1121 """
d14a1e28
RD
1122 if pens is None:
1123 pens = []
1124 elif isinstance(pens, wx.Pen):
1125 pens = [pens]
1126 elif len(pens) != len(lines):
1127 raise ValueError('lines and pens must have same length')
1128 return self._DrawLineList(lines, pens, [])
1129
1130
1131 def DrawRectangleList(self, rectangles, pens=None, brushes=None):
70794ec5
RD
1132 """
1133 Draw a list of rectangles as quickly as possible.
1134
1135 :param rectangles: A sequence of 4-element sequences representing
1136 each rectangle to draw, (x,y, w,h).
1137 :param pens: If None, then the current pen is used. If a
1138 single pen then it will be used for all rectangles.
1139 If a list of pens then there should be one for each
1140 rectangle in rectangles.
1141 :param brushes: A brush or brushes to be used to fill the rectagles,
1142 with similar semantics as the pens parameter.
1143 """
d14a1e28
RD
1144 if pens is None:
1145 pens = []
1146 elif isinstance(pens, wx.Pen):
1147 pens = [pens]
1148 elif len(pens) != len(rectangles):
1149 raise ValueError('rectangles and pens must have same length')
1150 if brushes is None:
1151 brushes = []
1152 elif isinstance(brushes, wx.Brush):
1153 brushes = [brushes]
1154 elif len(brushes) != len(rectangles):
1155 raise ValueError('rectangles and brushes must have same length')
1156 return self._DrawRectangleList(rectangles, pens, brushes)
1157
1158
1159 def DrawEllipseList(self, ellipses, pens=None, brushes=None):
70794ec5
RD
1160 """
1161 Draw a list of ellipses as quickly as possible.
1162
1163 :param ellipses: A sequence of 4-element sequences representing
1164 each ellipse to draw, (x,y, w,h).
1165 :param pens: If None, then the current pen is used. If a
1166 single pen then it will be used for all ellipses.
1167 If a list of pens then there should be one for each
1168 ellipse in ellipses.
1169 :param brushes: A brush or brushes to be used to fill the ellipses,
1170 with similar semantics as the pens parameter.
1171 """
d14a1e28
RD
1172 if pens is None:
1173 pens = []
1174 elif isinstance(pens, wx.Pen):
1175 pens = [pens]
1176 elif len(pens) != len(ellipses):
1177 raise ValueError('ellipses and pens must have same length')
1178 if brushes is None:
1179 brushes = []
1180 elif isinstance(brushes, wx.Brush):
1181 brushes = [brushes]
1182 elif len(brushes) != len(ellipses):
1183 raise ValueError('ellipses and brushes must have same length')
1184 return self._DrawEllipseList(ellipses, pens, brushes)
1185
1186
1187 def DrawPolygonList(self, polygons, pens=None, brushes=None):
70794ec5
RD
1188 """
1189 Draw a list of polygons, each of which is a list of points.
1190
1191 :param polygons: A sequence of sequences of sequences.
1192 [[(x1,y1),(x2,y2),(x3,y3)...],
1193 [(x1,y1),(x2,y2),(x3,y3)...]]
1194
1195 :param pens: If None, then the current pen is used. If a
1196 single pen then it will be used for all polygons.
1197 If a list of pens then there should be one for each
1198 polygon.
1199 :param brushes: A brush or brushes to be used to fill the polygons,
1200 with similar semantics as the pens parameter.
1201 """
d14a1e28
RD
1202 if pens is None:
1203 pens = []
1204 elif isinstance(pens, wx.Pen):
1205 pens = [pens]
1206 elif len(pens) != len(polygons):
1207 raise ValueError('polygons and pens must have same length')
1208 if brushes is None:
1209 brushes = []
1210 elif isinstance(brushes, wx.Brush):
1211 brushes = [brushes]
1212 elif len(brushes) != len(polygons):
1213 raise ValueError('polygons and brushes must have same length')
1214 return self._DrawPolygonList(polygons, pens, brushes)
1215
1216
70794ec5
RD
1217 def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None):
1218 """
1219 Draw a list of strings using a list of coordinants for positioning each string.
1220
1221 :param textList: A list of strings
1222 :param coords: A list of (x,y) positions
1223 :param foregrounds: A list of `wx.Colour` objects to use for the
1224 foregrounds of the strings.
1225 :param backgrounds: A list of `wx.Colour` objects to use for the
1226 backgrounds of the strings.
1227
1228 NOTE: Make sure you set Background mode to wx.Solid (DC.SetBackgroundMode)
1229 If you want backgrounds to do anything.
1230 """
d14a1e28
RD
1231 if type(textList) == type(''):
1232 textList = [textList]
1233 elif len(textList) != len(coords):
1234 raise ValueError('textlist and coords must have same length')
1235 if foregrounds is None:
1236 foregrounds = []
fd3f2efe 1237 elif isinstance(foregrounds, wx.Colour):
d14a1e28
RD
1238 foregrounds = [foregrounds]
1239 elif len(foregrounds) != len(coords):
1240 raise ValueError('foregrounds and coords must have same length')
1241 if backgrounds is None:
1242 backgrounds = []
fd3f2efe 1243 elif isinstance(backgrounds, wx.Colour):
d14a1e28
RD
1244 backgrounds = [backgrounds]
1245 elif len(backgrounds) != len(coords):
1246 raise ValueError('backgrounds and coords must have same length')
1247 return self._DrawTextList(textList, coords, foregrounds, backgrounds)
1248 }
1249
0eae5d09
RD
1250 %property(Background, GetBackground, SetBackground, doc="See `GetBackground` and `SetBackground`");
1251 %property(BackgroundMode, GetBackgroundMode, SetBackgroundMode, doc="See `GetBackgroundMode` and `SetBackgroundMode`");
1252 %property(BoundingBox, GetBoundingBox, doc="See `GetBoundingBox`");
1253 %property(Brush, GetBrush, SetBrush, doc="See `GetBrush` and `SetBrush`");
1254 %property(CharHeight, GetCharHeight, doc="See `GetCharHeight`");
1255 %property(CharWidth, GetCharWidth, doc="See `GetCharWidth`");
1256 %property(ClippingBox, GetClippingBox, doc="See `GetClippingBox`");
1257 %property(ClippingRect, GetClippingRect, SetClippingRect, doc="See `GetClippingRect` and `SetClippingRect`");
1258 %property(Depth, GetDepth, doc="See `GetDepth`");
1259 %property(DeviceOrigin, GetDeviceOrigin, SetDeviceOrigin, doc="See `GetDeviceOrigin` and `SetDeviceOrigin`");
1260 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
1261 %property(FullTextExtent, GetFullTextExtent, doc="See `GetFullTextExtent`");
1262 %property(LogicalFunction, GetLogicalFunction, SetLogicalFunction, doc="See `GetLogicalFunction` and `SetLogicalFunction`");
1263 %property(LogicalOrigin, GetLogicalOrigin, SetLogicalOrigin, doc="See `GetLogicalOrigin` and `SetLogicalOrigin`");
1264 %property(LogicalScale, GetLogicalScale, SetLogicalScale, doc="See `GetLogicalScale` and `SetLogicalScale`");
1265 %property(MapMode, GetMapMode, SetMapMode, doc="See `GetMapMode` and `SetMapMode`");
1266 %property(MultiLineTextExtent, GetMultiLineTextExtent, doc="See `GetMultiLineTextExtent`");
1267 %property(Optimization, GetOptimization, SetOptimization, doc="See `GetOptimization` and `SetOptimization`");
1268 %property(PPI, GetPPI, doc="See `GetPPI`");
1269 %property(PartialTextExtents, GetPartialTextExtents, doc="See `GetPartialTextExtents`");
1270 %property(Pen, GetPen, SetPen, doc="See `GetPen` and `SetPen`");
1271 %property(Pixel, GetPixel, doc="See `GetPixel`");
1272 %property(PixelPoint, GetPixelPoint, doc="See `GetPixelPoint`");
1273 %property(Size, GetSize, doc="See `GetSize`");
1274 %property(SizeMM, GetSizeMM, doc="See `GetSizeMM`");
1275 %property(TextBackground, GetTextBackground, SetTextBackground, doc="See `GetTextBackground` and `SetTextBackground`");
1276 %property(TextExtent, GetTextExtent, doc="See `GetTextExtent`");
1277 %property(TextForeground, GetTextForeground, SetTextForeground, doc="See `GetTextForeground` and `SetTextForeground`");
1278 %property(UserScale, GetUserScale, SetUserScale, doc="See `GetUserScale` and `SetUserScale`");
8adc9d9d
RD
1279
1280 %property(LayoutDirection, GetLayoutDirection, SetLayoutDirection);
d14a1e28
RD
1281};
1282
1283
1284
1285%{
1286static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1287 *x1 = dc->MinX();
1288 *y1 = dc->MinY();
1289 *x2 = dc->MaxX();
1290 *y2 = dc->MaxY();
1291}
1292%}
1293
1294
ad55c49e
RD
1295//---------------------------------------------------------------------------
1296%newgroup
1297
1298DocStr(wxDCTextColourChanger,
1299"wx.DCTextColourChanger can be used to temporarily change the DC text
1300colour and restore it automatically when the object goes out of scope", "");
1301
1302class wxDCTextColourChanger
1303{
1304public:
1305 wxDCTextColourChanger(wxDC& dc, const wxColour& col);
1306 ~wxDCTextColourChanger();
1307};
1308
1309
1310DocStr(wxDCPenChanger,
1311"wx.DCPenChanger can be used to temporarily change the DC pen and
1312restore it automatically when the object goes out of scope", "");
1313
1314class wxDCPenChanger
1315{
1316public:
1317 wxDCPenChanger(wxDC& dc, const wxPen& pen);
1318 ~wxDCPenChanger();
1319};
1320
1321
1322
1323DocStr(wxDCBrushChanger,
1324"wx.DCBrushChanger can be used to temporarily change the DC brush and
1325restore it automatically when the object goes out of scope", "");
1326
1327class wxDCBrushChanger
1328{
1329public:
1330 wxDCBrushChanger(wxDC& dc, const wxBrush& brush);
1331 ~wxDCBrushChanger();
1332};
1333
1334
1335DocStr(wxDCClipper,
1336"wx.wxDCClipper sets the DC's clipping region when it is constructed,
1337and then automatically destroys the clipping region when the clipper
1338goes out of scope.", "");
1339
1340class wxDCClipper
1341{
1342public:
1343 %nokwargs wxDCClipper;
1344 wxDCClipper(wxDC& dc, const wxRegion& r);
1345 wxDCClipper(wxDC& dc, const wxRect& r);
1346 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h);
1347 ~wxDCClipper();
1348};
1349
1350
1351
1352
72156afe
RD
1353//---------------------------------------------------------------------------
1354%newgroup
1355
1356MustHaveApp(wxScreenDC);
1357
1358DocStr(wxScreenDC,
1359"A wxScreenDC can be used to paint anywhere on the screen. This should
1360normally be constructed as a temporary stack object; don't store a
1361wxScreenDC object.
1362", "");
1363class wxScreenDC : public wxDC {
1364public:
1365 wxScreenDC();
1366
1367 DocDeclStrName(
1368 bool , StartDrawingOnTop(wxWindow* window),
1369 "Specify that the area of the screen to be drawn upon coincides with
1370the given window.
1371
1372:see: `EndDrawingOnTop`", "",
1373 StartDrawingOnTopWin);
1374
1375
1376 DocDeclStr(
1377 bool , StartDrawingOnTop(wxRect* rect = NULL),
1378 "Specify that the area is the given rectangle, or the whole screen if
1379``None`` is passed.
1380
1381:see: `EndDrawingOnTop`", "");
1382
1383
1384 DocDeclStr(
1385 bool , EndDrawingOnTop(),
1386 "Use this in conjunction with `StartDrawingOnTop` or
1387`StartDrawingOnTopWin` to ensure that drawing to the screen occurs on
1388top of existing windows. Without this, some window systems (such as X)
1389only allow drawing to take place underneath other windows.
1390
1391You might use this pair of functions when implementing a drag feature,
1392for example as in the `wx.SplitterWindow` implementation.
1393
1394These functions are probably obsolete since the X implementations
1395allow drawing directly on the screen now. However, the fact that this
1396function allows the screen to be refreshed afterwards may be useful
1397to some applications.", "");
1398
1399};
1400
1401//---------------------------------------------------------------------------
1402%newgroup
1403
1404MustHaveApp(wxWindowDC);
1405
1406DocStr(wxWindowDC,
1407 "A wx.WindowDC must be constructed if an application wishes to paint on
1408the whole area of a window (client and decorations). This should
1409normally be constructed as a temporary stack object; don't store a
1410wx.WindowDC object.","");
1411class wxWindowDC : public wxDC {
1412public:
1413 DocCtorStr(
1414 wxWindowDC(wxWindow* win),
1415 "Constructor. Pass the window on which you wish to paint.","");
1416};
1417
1418//---------------------------------------------------------------------------
1419%newgroup
1420
1421MustHaveApp(wxClientDC);
1422
1423DocStr(wxClientDC,
1424"A wx.ClientDC must be constructed if an application wishes to paint on
1425the client area of a window from outside an EVT_PAINT event. This should
1426normally be constructed as a temporary stack object; don't store a
1427wx.ClientDC object long term.
1428
1429To draw on a window from within an EVT_PAINT handler, construct a
1430`wx.PaintDC` object.
1431
1432To draw on the whole window including decorations, construct a
1433`wx.WindowDC` object (Windows only).
1434", "");
1435class wxClientDC : public wxWindowDC {
1436public:
1437 DocCtorStr(
1438 wxClientDC(wxWindow* win),
1439 "Constructor. Pass the window on which you wish to paint.", "");
1440};
1441
1442//---------------------------------------------------------------------------
1443%newgroup
1444
1445MustHaveApp(wxPaintDC);
1446
1447DocStr(wxPaintDC,
1448"A wx.PaintDC must be constructed if an application wishes to paint on
1449the client area of a window from within an EVT_PAINT event
1450handler. This should normally be constructed as a temporary stack
1451object; don't store a wx.PaintDC object. If you have an EVT_PAINT
1452handler, you **must** create a wx.PaintDC object within it even if you
1453don't actually use it.
1454
1455Using wx.PaintDC within EVT_PAINT handlers is important because it
1456automatically sets the clipping area to the damaged area of the
1457window. Attempts to draw outside this area do not appear.
1458
1459To draw on a window from outside EVT_PAINT handlers, construct a
1460`wx.ClientDC` object.
1461","");
1462class wxPaintDC : public wxClientDC {
1463public:
1464 DocCtorStr(
1465 wxPaintDC(wxWindow* win),
1466 "Constructor. Pass the window on which you wish to paint.", "");
1467};
1468
1469
1470
e676f137
RD
1471//---------------------------------------------------------------------------
1472%newgroup
1473
1474MustHaveApp(wxMemoryDC);
1475
1476DocStr(wxMemoryDC,
1477"A memory device context provides a means to draw graphics onto a
1478bitmap. A bitmap must be selected into the new memory DC before it may
1479be used for anything. Typical usage is as follows::
1480
1481 dc = wx.MemoryDC()
1482 dc.SelectObject(bitmap)
1483 # draw on the dc using any of the Draw methods
1484 dc.SelectObject(wx.NullBitmap)
1485 # the bitmap now contains wahtever was drawn upon it
1486
1487Note that the memory DC *must* be deleted (or the bitmap selected out
1488of it) before a bitmap can be reselected into another memory DC.
1489", "");
1490
1491class wxMemoryDC : public wxWindowDC {
1492public:
1493 DocCtorStr(
1494 wxMemoryDC(wxBitmap& bitmap = wxNullBitmap),
1495 "Constructs a new memory device context.
1496
1497Use the Ok member to test whether the constructor was successful in
1498creating a usable device context. If a bitmap is not given to this
1499constructor then don't forget to select a bitmap into the DC before
1500drawing on it.", "
1501
1502:see: `MemoryDCFromDC`");
1503
1504 DocCtorStrName(
1505 wxMemoryDC(wxDC* oldDC),
1506 "Creates a DC that is compatible with the oldDC.", "",
1507 MemoryDCFromDC);
1508
1509
1510 DocDeclStr(
1511 void , SelectObject(wxBitmap& bitmap),
1512 "Selects the bitmap into the device context, to use as the memory
1513bitmap. Selecting the bitmap into a memory DC allows you to draw into
1514the DC, and therefore the bitmap, and also to use Blit to copy the
1515bitmap to a window.
1516
1517If the argument is wx.NullBitmap (or some other uninitialised
1518`wx.Bitmap`) the current bitmap is selected out of the device context,
1519and the original bitmap restored, allowing the current bitmap to be
1520destroyed safely.", "");
1521
1522
1523 DocDeclStr(
1524 void , SelectObjectAsSource(const wxBitmap& bmp),
1525 "", "");
1526
1527
1528};
1529
1530
d14a1e28
RD
1531//---------------------------------------------------------------------------
1532%newgroup
1533
b159c5c4 1534
ef22e3d3 1535%{
ef22e3d3 1536#include <wx/dcbuffer.h>
ef22e3d3
RD
1537%}
1538
67a5217c
RD
1539enum {
1540 wxBUFFER_VIRTUAL_AREA,
cbfc9df6
RD
1541 wxBUFFER_CLIENT_AREA,
1542 wxBUFFER_USES_SHARED_BUFFER
67a5217c 1543};
ef22e3d3 1544
ab1f7d2a
RD
1545MustHaveApp(wxBufferedDC);
1546
70794ec5
RD
1547DocStr(wxBufferedDC,
1548"This simple class provides a simple way to avoid flicker: when drawing
1549on it, everything is in fact first drawn on an in-memory buffer (a
1550`wx.Bitmap`) and then copied to the screen only once, when this object
0a012f77
RD
1551is destroyed. You can either provide a buffer bitmap yourself, and
1552reuse it the next time something needs painted, or you can let the
1553buffered DC create and provide a buffer bitmap itself.
70794ec5 1554
0a012f77 1555Buffered DCs can be used in the same way as any other device context.
6a223074
RD
1556wx.BufferedDC itself typically replaces `wx.ClientDC`, if you want to
1557use it in your EVT_PAINT handler, you should look at
0a012f77
RD
1558`wx.BufferedPaintDC`. You can also use a wx.BufferedDC without
1559providing a target DC. In this case the operations done on the dc
1560will only be written to the buffer bitmap and *not* to any window, so
1561you will want to have provided the buffer bitmap and then reuse it
1562when it needs painted to the window.
6a223074
RD
1563
1564Please note that GTK+ 2.0 and OS X provide double buffering themselves
0a012f77
RD
1565natively. You may want to use `wx.Window.IsDoubleBuffered` to
1566determine whether you need to use buffering or not, or use
1567`wx.AutoBufferedPaintDC` to avoid needless double buffering on systems
1568that already do it automatically.
1569
1570
70794ec5
RD
1571", "");
1572
96285a18 1573class wxBufferedDC : public wxMemoryDC
d14a1e28
RD
1574{
1575public:
d14a1e28 1576
70794ec5
RD
1577 DocStr(
1578 wxBufferedDC,
1579 "Constructs a buffered DC.", "
1580
1581 :param dc: The underlying DC: everything drawn to this object will
1582 be flushed to this DC when this object is destroyed. You may
1583 pass ``None`` in order to just initialize the buffer, and not
1584 flush it.
1585
1586 :param buffer: If a `wx.Size` object is passed as the 2nd arg then
1587 it is the size of the bitmap that will be created internally
1588 and used for an implicit buffer. If the 2nd arg is a
1589 `wx.Bitmap` then it is the explicit buffer that will be
1590 used. Using an explicit buffer is the most efficient solution
1591 as the bitmap doesn't have to be recreated each time but it
1592 also requires more memory as the bitmap is never freed. The
1593 bitmap should have appropriate size, anything drawn outside of
4a065572
RD
1594 its bounds is clipped. If wx.NullBitmap is used then a new
1595 buffer will be allocated that is the same size as the dc.
b159c5c4 1596
67a5217c
RD
1597 :param style: The style parameter indicates whether the supplied buffer is
1598 intended to cover the entire virtual size of a `wx.ScrolledWindow` or
1599 if it only covers the client area. Acceptable values are
1600 ``wx.BUFFER_VIRTUAL_AREA`` and ``wx.BUFFER_CLIENT_AREA``.
67a5217c 1601");
43acd3c1
RD
1602
1603 %nokwargs wxBufferedDC;
1604 %pythonAppend wxBufferedDC
1605"# save a ref so the other dc will not be deleted before self
1606 self.__dc = args[0]
1607 # also save a ref to the bitmap
1608 if len(args) > 1: self.__bmp = args[1]
1609";
1610
4a065572 1611 wxBufferedDC( wxDC* dc,
d9b33d70 1612 wxBitmap& buffer=wxNullBitmap,
4a065572
RD
1613 int style = wxBUFFER_CLIENT_AREA );
1614 wxBufferedDC( wxDC* dc,
1615 const wxSize& area,
1616 int style = wxBUFFER_CLIENT_AREA );
96285a18
RD
1617// wxBufferedDC(wxWindow* win,
1618// wxDC *dc,
1619// const wxSize &area,
1620// int style = wxBUFFER_CLIENT_AREA);
9a3dccf6 1621
7a0b15e9 1622
70794ec5
RD
1623 DocCtorStr(
1624 ~wxBufferedDC(),
1625 "Copies everything drawn on the DC so far to the underlying DC
1626associated with this object, if any.", "");
1627
4a065572 1628
70794ec5
RD
1629 DocDeclStr(
1630 void , UnMask(),
1631 "Blits the buffer to the dc, and detaches the dc from the buffer (so it
1632can be effectively used once only). This is usually only called in
1633the destructor.", "");
d9b33d70
RD
1634
1635 // Set and get the style
1636 void SetStyle(int style);
1637 int GetStyle() const;
d14a1e28
RD
1638};
1639
1640
7a0b15e9 1641
70794ec5 1642
ab1f7d2a 1643MustHaveApp(wxBufferedPaintDC);
7a0b15e9 1644
70794ec5
RD
1645DocStr(wxBufferedPaintDC,
1646"This is a subclass of `wx.BufferedDC` which can be used inside of an
1647EVT_PAINT event handler. Just create an object of this class instead
1648of `wx.PaintDC` and that's all you have to do to (mostly) avoid
1649flicker. The only thing to watch out for is that if you are using this
1650class together with `wx.ScrolledWindow`, you probably do **not** want
1651to call `wx.Window.PrepareDC` on it as it already does this internally
1652for the real underlying `wx.PaintDC`.
1653
1654If your window is already fully buffered in a `wx.Bitmap` then your
1655EVT_PAINT handler can be as simple as just creating a
1656``wx.BufferedPaintDC`` as it will `Blit` the buffer to the window
1657automatically when it is destroyed. For example::
1658
1659 def OnPaint(self, event):
1660 dc = wx.BufferedPaintDC(self, self.buffer)
1661
1662
1663", "");
1664
d14a1e28
RD
1665class wxBufferedPaintDC : public wxBufferedDC
1666{
1667public:
b159c5c4 1668
43acd3c1
RD
1669 %pythonAppend wxBufferedPaintDC "if len(args) > 1: self.__bmp = args[1]";
1670
70794ec5 1671 DocCtorStr(
67a5217c 1672 wxBufferedPaintDC( wxWindow *window,
d9b33d70 1673 wxBitmap &buffer = wxNullBitmap,
67a5217c 1674 int style = wxBUFFER_CLIENT_AREA),
70794ec5
RD
1675 "Create a buffered paint DC. As with `wx.BufferedDC`, you may either
1676provide the bitmap to be used for buffering or let this object create
1677one internally (in the latter case, the size of the client part of the
9a3dccf6 1678window is automatically used).", "");
b159c5c4 1679
d14a1e28
RD
1680};
1681
d14a1e28
RD
1682//---------------------------------------------------------------------------
1683%newgroup
1684
72156afe
RD
1685// Epydoc doesn't like this for some strange reason...
1686// %pythoncode {
1687// if 'wxMac' in wx.PlatformInfo or 'gtk2' in wx.PlatformInfo:
1688// _AutoBufferedPaintDCBase = PaintDC
1689// else:
1690// _AutoBufferedPaintDCBase = BufferedPaintDC
1691
1692// class AutoBufferedPaintDC(_AutoBufferedPaintDCBase):
1693// """
1694// If the current platform double buffers by default then this DC is the
1695// same as a plain `wx.PaintDC`, otherwise it is a `wx.BufferedPaintDC`.
205d49f7 1696
72156afe
RD
1697// :see: `wx.AutoBufferedPaintDCFactory`
1698// """
1699// def __init__(self, window):
1700// _AutoBufferedPaintDCBase.__init__(self, window)
1701// }
205d49f7 1702
ab1f7d2a 1703
72156afe
RD
1704DocStr(wxAutoBufferedPaintDC,
1705"If the current platform double buffers by default then this DC is the
1706same as a plain `wx.PaintDC`, otherwise it is a `wx.BufferedPaintDC`.
70794ec5 1707
72156afe 1708:see: `wx.AutoBufferedPaintDCFactory`
70794ec5 1709", "");
70794ec5 1710
72156afe
RD
1711class wxAutoBufferedPaintDC: public wxDC
1712{
d14a1e28 1713public:
72156afe 1714 wxAutoBufferedPaintDC(wxWindow* win);
d14a1e28
RD
1715};
1716
9a3dccf6 1717
96285a18
RD
1718%newobject wxAutoBufferedPaintDCFactory;
1719DocDeclStr(
1720 wxDC* , wxAutoBufferedPaintDCFactory(wxWindow* window),
1721 "Checks if the window is natively double buffered and will return a
72156afe
RD
1722`wx.PaintDC` if it is, a `wx.BufferedPaintDC` otherwise. The advantage of
1723this function over `wx.AutoBufferedPaintDC` is that this function will check
1724if the the specified window has double-buffering enabled rather than just
1725going by platform defaults.", "");
96285a18
RD
1726
1727
1728
d14a1e28
RD
1729//---------------------------------------------------------------------------
1730%newgroup
1731
ab1f7d2a
RD
1732MustHaveApp(wxMirrorDC);
1733
70794ec5
RD
1734DocStr(wxMirrorDC,
1735"wx.MirrorDC is a simple wrapper class which is always associated with a
1736real `wx.DC` object and either forwards all of its operations to it
1737without changes (no mirroring takes place) or exchanges x and y
1738coordinates which makes it possible to reuse the same code to draw a
1739figure and its mirror -- i.e. reflection related to the diagonal line
1740x == y.", "");
d14a1e28
RD
1741class wxMirrorDC : public wxDC
1742{
1743public:
70794ec5
RD
1744 DocCtorStr(
1745 wxMirrorDC(wxDC& dc, bool mirror),
1746 "Creates a mirrored DC associated with the real *dc*. Everything drawn
1747on the wx.MirrorDC will appear on the *dc*, and will be mirrored if
1748*mirror* is True.","");
d14a1e28
RD
1749};
1750
1751//---------------------------------------------------------------------------
1752%newgroup
1753
1754%{
1755#include <wx/dcps.h>
1756%}
1757
ab1f7d2a
RD
1758MustHaveApp(wxPostScriptDC);
1759
70794ec5
RD
1760DocStr(wxPostScriptDC,
1761"This is a `wx.DC` that can write to PostScript files on any platform.","");
1762
d14a1e28
RD
1763class wxPostScriptDC : public wxDC {
1764public:
70794ec5
RD
1765 DocCtorStr(
1766 wxPostScriptDC(const wxPrintData& printData),
1767 "Constructs a PostScript printer device context from a `wx.PrintData`
1768object.", "");
d14a1e28
RD
1769
1770 wxPrintData& GetPrintData();
1771 void SetPrintData(const wxPrintData& data);
1772
70794ec5
RD
1773 DocDeclStr(
1774 static void , SetResolution(int ppi),
1775 "Set resolution (in pixels per inch) that will be used in PostScript
1776output. Default is 720ppi.", "");
1777
1778 DocDeclStr(
1779 static int , GetResolution(),
1780 "Return resolution used in PostScript output.", "");
7012bb9f
RD
1781
1782 %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
d14a1e28
RD
1783};
1784
1785//---------------------------------------------------------------------------
1786%newgroup
1787
1788
ab1f7d2a
RD
1789MustHaveApp(wxMetaFile);
1790MustHaveApp(wxMetaFileDC);
1791
1792
da457c1b 1793#if defined(__WXMSW__) || defined(__WXMAC__)
d14a1e28
RD
1794
1795%{
1796#include <wx/metafile.h>
1797%}
1798
1799class wxMetaFile : public wxObject {
1800public:
1801 wxMetaFile(const wxString& filename = wxPyEmptyString);
1802 ~wxMetaFile();
1803
6c2dd16f
RD
1804 bool IsOk();
1805 %pythoncode { Ok = IsOk }
d14a1e28
RD
1806 bool SetClipboard(int width = 0, int height = 0);
1807
1808 wxSize GetSize();
1809 int GetWidth();
1810 int GetHeight();
1811
da457c1b 1812#ifdef __WXMSW__
d14a1e28 1813 const wxString& GetFileName() const;
da457c1b
RD
1814#endif
1815
6c2dd16f 1816 %pythoncode { def __nonzero__(self): return self.IsOk() }
d14a1e28
RD
1817};
1818
1819// bool wxMakeMetaFilePlaceable(const wxString& filename,
1820// int minX, int minY, int maxX, int maxY, float scale=1.0);
1821
1822
1823class wxMetaFileDC : public wxDC {
1824public:
1825 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
1826 int width = 0, int height = 0,
1827 const wxString& description = wxPyEmptyString);
1828 wxMetaFile* Close();
1829};
1830
1831
1832
1833#else // Make some dummies for the other platforms
1834
1835%{
1836class wxMetaFile : public wxObject {
1837public:
1838 wxMetaFile(const wxString&)
81cfe5e1 1839 { wxPyRaiseNotImplemented(); }
d14a1e28
RD
1840};
1841
1842class wxMetaFileDC : public wxClientDC {
1843public:
1844 wxMetaFileDC(const wxString&, int, int, const wxString&)
81cfe5e1 1845 { wxPyRaiseNotImplemented(); }
d14a1e28
RD
1846};
1847
1848%}
1849
1850class wxMetaFile : public wxObject {
1851public:
1852 wxMetaFile(const wxString& filename = wxPyEmptyString);
1853};
1854
1855class wxMetaFileDC : public wxDC {
1856public:
1857 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
1858 int width = 0, int height = 0,
1859 const wxString& description = wxPyEmptyString);
1860};
1861
1862
1863#endif
1864
1865
1866//---------------------------------------------------------------------------
1867
ab1f7d2a
RD
1868MustHaveApp(wxPrinterDC);
1869
d14a1e28
RD
1870#if defined(__WXMSW__) || defined(__WXMAC__)
1871
1872class wxPrinterDC : public wxDC {
1873public:
1874 wxPrinterDC(const wxPrintData& printData);
d14a1e28
RD
1875};
1876
1877#else
1878%{
1879class wxPrinterDC : public wxClientDC {
1880public:
1881 wxPrinterDC(const wxPrintData&)
81cfe5e1 1882 { wxPyRaiseNotImplemented(); }
4942342c 1883
d14a1e28
RD
1884};
1885%}
4942342c 1886
d14a1e28
RD
1887class wxPrinterDC : public wxDC {
1888public:
1889 wxPrinterDC(const wxPrintData& printData);
d14a1e28
RD
1890};
1891#endif
1892
4942342c
RD
1893//---------------------------------------------------------------------------
1894//---------------------------------------------------------------------------