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