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