1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Wraper definitions for the wxPseudoDC Class
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/wxPython/pseudodc.h"
20 "A PseudoDC is an object that can be used as if it were a `wx.DC`. All
21 commands issued to the PseudoDC are stored in a list. You can then
22 play these commands back to a real DC object using the DrawToDC
23 method. Commands in the command list are indexed by ID. You can use
24 this to clear the operations associated with a single ID and then
25 re-draw the object associated with that ID.", "");
27 class wxPseudoDC : public wxObject
32 "Constructs a new Pseudo device context for recording dc operations","");
34 void , BeginDrawing(),
35 "Allows for optimization of drawing code on platforms that need it. On
36 other platforms this is just an empty function and is harmless. To
37 take advantage of this postential optimization simply enclose each
38 group of calls to the drawing primitives within calls to
39 `BeginDrawing` and `EndDrawing`.", "");
43 "Ends the group of drawing primitives started with `BeginDrawing`, and
44 invokes whatever optimization is available for this DC type on the
45 current platform.", "");
48 "Frees memory used by the operation list of the pseudo dc","");
51 "Removes all objects and operations from the recorded list.", "");
54 "Returns the number of operations in the recorded list.", "");
57 "Sets the id to be associated with subsequent operations.", "");
59 void, ClearId(int id),
60 "Removes all operations associated with id so the object can be redrawn.", "");
62 void, RemoveId(int id),
63 "Remove the object node (and all operations) associated with an id.", "");
65 void, TranslateId(int id, wxCoord dx, wxCoord dy),
66 "Translate the operations of id by dx,dy.", "");
68 void, DrawIdToDC(int id, wxDC *dc),
69 "Draw recorded operations of id to dc.", "");
71 void, SetIdBounds(int id, wxRect& rect),
72 "Set the bounding rect of a given object. This will create
73 an object node if one doesn't exist.", "");
77 "Returns the bounding rectangle previouly set with SetIdBounds. If
78 no bounds have been set, it returns wx.Rect(0,0,0,0).", "");
79 wxRect GetIdBounds(int id) {
81 self->GetIdBounds(id, rect);
86 void, DrawToDCClipped(wxDC *dc, const wxRect& rect),
87 "Draws the recorded operations to dc unless the operation is known to
88 be outside rect.", "");
90 void, DrawToDCClippedRgn(wxDC *dc, const wxRegion& region),
91 "Draws the recorded operations to dc unless the operation is known to
92 be outside rect.", "");
94 void, DrawToDC(wxDC *dc),
95 "Draws the recorded operations to dc.", "");
97 //-------------------------------------------------------------------------
98 // Methods Mirrored from wxDC
99 //-------------------------------------------------------------------------
102 // void , SetFont(const wxFont& font),
103 // "Sets the current font for the DC. It must be a valid font, in
104 //particular you should not pass ``wx.NullFont`` to this method.","
109 // void , SetPen(const wxPen& pen),
110 // "Sets the current pen for the DC.
112 //If the argument is ``wx.NullPen``, the current pen is selected out of the
113 //device context, and the original pen restored.", "
118 // void , SetBrush(const wxBrush& brush),
119 // "Sets the current brush for the DC.
121 //If the argument is ``wx.NullBrush``, the current brush is selected out
122 //of the device context, and the original brush restored, allowing the
123 //current brush to be destroyed safely.","
125 //:see: `wx.Brush`");
128 // void , SetBackground(const wxBrush& brush),
129 // "Sets the current background brush for the DC.", "");
132 // void , SetBackgroundMode(int mode),
133 // "*mode* may be one of ``wx.SOLID`` and ``wx.TRANSPARENT``. This setting
134 //determines whether text will be drawn with a background colour or
138 // void , SetTextForeground(const wxColour& colour),
139 // "Sets the current text foreground colour for the DC.", "");
142 // void , SetTextBackground(const wxColour& colour),
143 // "Sets the current text background colour for the DC.", "");
145 // void , DrawLabel(const wxString& text, const wxRect& rect,
146 // int alignment = wxALIGN_LEFT | wxALIGN_TOP,
147 // int indexAccel = -1),
148 // "Draw *text* within the specified rectangle, abiding by the alignment
149 //flags. Will additionally emphasize the character at *indexAccel* if
152 //:see: `DrawImageLabel`");
155 // "Draws a text string at the specified point, using the current text
156 //font, and the current text foreground and background colours.
158 //The coordinates refer to the top-left corner of the rectangle bounding
159 //the string. See `GetTextExtent` for how to get the dimensions of a
160 //text string, which can be used to position the text more precisely.
162 //**NOTE**: under wxGTK the current logical function is used by this
163 //function but it is ignored by wxMSW. Thus, you should avoid using
164 //logical functions with this function in portable programs.", "
166 //:see: `DrawRotatedText`");
167 // void DrawText(const wxString& text, wxCoord x, wxCoord y);
170 // "Draws a line from the first point to the second. The current pen is
171 //used for drawing the line. Note that the second point is *not* part of
172 //the line and is not drawn by this function (this is consistent with
173 //the behaviour of many other toolkits).", "");
174 // void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
176 // void, DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height),
177 // "Draws a rectangle with the given top left corner, and with the given
178 //size. The current pen is used for the outline and the current brush
179 //for filling the shape.", "");
182 // "Clears the device context using the current background brush.", "");
186 "Flood fills the device context starting from the given point, using
187 the current brush colour, and using a style:
189 - **wxFLOOD_SURFACE**: the flooding occurs until a colour other than
190 the given colour is encountered.
192 - **wxFLOOD_BORDER**: the area to be flooded is bounded by the given
195 Returns False if the operation failed.
197 Note: The present implementation for non-Windows platforms may fail to
198 find colour borders if the pixels do not match the colour
199 exactly. However the function will still return true.", "");
200 void FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
201 %Rename(FloodFillPoint, void, FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE));
206 "Draws a line from the first point to the second. The current pen is
207 used for drawing the line. Note that the second point is *not* part of
208 the line and is not drawn by this function (this is consistent with
209 the behaviour of many other toolkits).", "");
210 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
211 %Rename(DrawLinePoint, void, DrawLine(const wxPoint& pt1, const wxPoint& pt2));
216 "Displays a cross hair using the current pen. This is a vertical and
217 horizontal line the height and width of the window, centred on the
219 void CrossHair(wxCoord x, wxCoord y);
220 %Rename(CrossHairPoint, void, CrossHair(const wxPoint& pt));
225 "Draws an arc of a circle, centred on the *center* point (xc, yc), from
226 the first point to the second. The current pen is used for the outline
227 and the current brush for filling the shape.
229 The arc is drawn in an anticlockwise direction from the start point to
230 the end point.", "");
231 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
232 %Rename(DrawArcPoint, void, DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& center));
237 "Draws a check mark inside the given rectangle.", "");
238 void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
239 %Rename(DrawCheckMarkRect, void, DrawCheckMark(const wxRect& rect));
243 "Draws an arc of an ellipse, with the given rectangle defining the
244 bounds of the ellipse. The current pen is used for drawing the arc and
245 the current brush is used for drawing the pie.
247 The *start* and *end* parameters specify the start and end of the arc
248 relative to the three-o'clock position from the center of the
249 rectangle. Angles are specified in degrees (360 is a complete
250 circle). Positive values mean counter-clockwise motion. If start is
251 equal to end, a complete ellipse will be drawn.", "");
252 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double start, double end);
253 %Rename(DrawEllipticArcPointSize, void, DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double start, double end));
258 "Draws a point using the current pen.", "");
259 void DrawPoint(wxCoord x, wxCoord y);
260 %Rename(DrawPointPoint, void, DrawPoint(const wxPoint& pt));
265 "Draws a rectangle with the given top left corner, and with the given
266 size. The current pen is used for the outline and the current brush
267 for filling the shape.", "");
268 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
269 %Rename(DrawRectangleRect,void, DrawRectangle(const wxRect& rect));
270 %Rename(DrawRectanglePointSize, void, DrawRectangle(const wxPoint& pt, const wxSize& sz));
274 DrawRoundedRectangle,
275 "Draws a rectangle with the given top left corner, and with the given
276 size. The corners are quarter-circles using the given radius. The
277 current pen is used for the outline and the current brush for filling
280 If radius is positive, the value is assumed to be the radius of the
281 rounded corner. If radius is negative, the absolute value is assumed
282 to be the proportion of the smallest dimension of the rectangle. This
283 means that the corner can be a sensible size relative to the size of
284 the rectangle, and also avoids the strange effects X produces when the
285 corners are too big for the rectangle.", "");
286 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius);
287 %Rename(DrawRoundedRectangleRect, void, DrawRoundedRectangle(const wxRect& r, double radius));
288 %Rename(DrawRoundedRectanglePointSize, void, DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius));
293 "Draws a circle with the given center point and radius. The current
294 pen is used for the outline and the current brush for filling the
297 :see: `DrawEllipse`");
298 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
299 %Rename(DrawCirclePoint, void, DrawCircle(const wxPoint& pt, wxCoord radius));
304 "Draws an ellipse contained in the specified rectangle. The current pen
305 is used for the outline and the current brush for filling the shape.", "
307 :see: `DrawCircle`");
308 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
309 %Rename(DrawEllipseRect, void, DrawEllipse(const wxRect& rect));
310 %Rename(DrawEllipsePointSize, void, DrawEllipse(const wxPoint& pt, const wxSize& sz));
315 "Draw an icon on the display (does nothing if the device context is
316 PostScript). This can be the simplest way of drawing bitmaps on a
318 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
319 %Rename(DrawIconPoint, void, DrawIcon(const wxIcon& icon, const wxPoint& pt));
324 "Draw a bitmap on the device context at the specified point. If
325 *transparent* is true and the bitmap has a transparency mask, (or
326 alpha channel on the platforms that support it) then the bitmap will
327 be drawn transparently.", "
329 When drawing a mono-bitmap, the current text foreground colour will be
330 used to draw the foreground of the bitmap (all bits set to 1), and the
331 current text background colour to draw the background (all bits set to
334 :see: `SetTextForeground`, `SetTextBackground` and `wx.MemoryDC`");
335 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = false);
336 %Rename(DrawBitmapPoint, void, DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = false));
341 "Draws a text string at the specified point, using the current text
342 font, and the current text foreground and background colours.
344 The coordinates refer to the top-left corner of the rectangle bounding
345 the string. See `GetTextExtent` for how to get the dimensions of a
346 text string, which can be used to position the text more precisely.
348 **NOTE**: under wxGTK the current logical function is used by this
349 function but it is ignored by wxMSW. Thus, you should avoid using
350 logical functions with this function in portable programs.", "
352 :see: `DrawRotatedText`");
353 void DrawText(const wxString& text, wxCoord x, wxCoord y);
354 %Rename(DrawTextPoint, void, DrawText(const wxString& text, const wxPoint& pt));
359 "Draws the text rotated by *angle* degrees, if supported by the platform.
361 **NOTE**: Under Win9x only TrueType fonts can be drawn by this
362 function. In particular, a font different from ``wx.NORMAL_FONT``
363 should be used as the it is not normally a TrueType
364 font. ``wx.SWISS_FONT`` is an example of a font which is.","
367 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
368 %Rename(DrawRotatedTextPoint, void, DrawRotatedText(const wxString& text, const wxPoint& pt, double angle));
372 // bool , Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
373 // wxDC *source, wxCoord xsrc, wxCoord ysrc,
374 // int rop = wxCOPY, bool useMask = false,
375 // wxCoord xsrcMask = -1, wxCoord ysrcMask = -1),
376 // "Copy from a source DC to this DC. Parameters specify the destination
377 //coordinates, size of area to copy, source DC, source coordinates,
378 //logical function, whether to use a bitmap mask, and mask source
381 // :param xdest: Destination device context x position.
382 // :param ydest: Destination device context y position.
383 // :param width: Width of source area to be copied.
384 // :param height: Height of source area to be copied.
385 // :param source: Source device context.
386 // :param xsrc: Source device context x position.
387 // :param ysrc: Source device context y position.
388 // :param rop: Logical function to use: see `SetLogicalFunction`.
389 // :param useMask: If true, Blit does a transparent blit using the mask
390 // that is associated with the bitmap selected into the
391 // source device context.
392 // :param xsrcMask: Source x position on the mask. If both xsrcMask and
393 // ysrcMask are -1, xsrc and ysrc will be assumed for
394 // the mask source position.
395 // :param ysrcMask: Source y position on the mask.
399 // bool , Blit(const wxPoint& destPt, const wxSize& sz,
400 // wxDC *source, const wxPoint& srcPt,
401 // int rop = wxCOPY, bool useMask = false,
402 // const wxPoint& srcPtMask = wxDefaultPosition),
403 // "Copy from a source DC to this DC. Parameters specify the destination
404 //coordinates, size of area to copy, source DC, source coordinates,
405 //logical function, whether to use a bitmap mask, and mask source
408 // :param destPt: Destination device context position.
409 // :param sz: Size of source area to be copied.
410 // :param source: Source device context.
411 // :param srcPt: Source device context position.
412 // :param rop: Logical function to use: see `SetLogicalFunction`.
413 // :param useMask: If true, Blit does a transparent blit using the mask
414 // that is associated with the bitmap selected into the
415 // source device context.
416 // :param srcPtMask: Source position on the mask.
422 void , DrawLines(int points, wxPoint* points_array,
423 wxCoord xoffset = 0, wxCoord yoffset = 0),
424 "DrawLines(self, List points, int xoffset=0, int yoffset=0)",
425 "Draws lines using a sequence of `wx.Point` objects, adding the
426 optional offset coordinate. The current pen is used for drawing the
431 void , DrawPolygon(int points, wxPoint* points_array,
432 wxCoord xoffset = 0, wxCoord yoffset = 0,
433 int fillStyle = wxODDEVEN_RULE),
434 "DrawPolygon(self, List points, int xoffset=0, int yoffset=0,
435 int fillStyle=ODDEVEN_RULE)",
436 "Draws a filled polygon using a sequence of `wx.Point` objects, adding
437 the optional offset coordinate. The last argument specifies the fill
438 rule: ``wx.ODDEVEN_RULE`` (the default) or ``wx.WINDING_RULE``.
440 The current pen is used for drawing the outline, and the current brush
441 for filling the shape. Using a transparent brush suppresses
442 filling. Note that wxWidgets automatically closes the first and last
446 // TODO: Figure out a good typemap for this...
447 // Convert the first 3 args from a sequence of sequences?
448 // void DrawPolyPolygon(int n, int count[], wxPoint points[],
449 // wxCoord xoffset = 0, wxCoord yoffset = 0,
450 // int fillStyle = wxODDEVEN_RULE);
454 void , DrawLabel(const wxString& text, const wxRect& rect,
455 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
456 int indexAccel = -1),
457 "Draw *text* within the specified rectangle, abiding by the alignment
458 flags. Will additionally emphasize the character at *indexAccel* if
461 :see: `DrawImageLabel`");
464 void, DrawLabel(const wxString& text,
465 const wxBitmap& image,
467 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
468 int indexAccel = -1),
469 "Draw *text* and an image (which may be ``wx.NullBitmap`` to skip
470 drawing it) within the specified rectangle, abiding by the alignment
471 flags. Will additionally emphasize the character at *indexAccel* if
472 it is not -1.", "", DrawImageLabel);
476 void , DrawSpline(int points, wxPoint* points_array),
477 "DrawSpline(self, List points)",
478 "Draws a spline between all given control points, (a list of `wx.Point`
479 objects) using the current pen. The spline is drawn using a series of
480 lines, using an algorithm taken from the X drawing program 'XFIG'.", "");
484 virtual void , Clear(),
485 "Clears the device context using the current background brush.", "");
488 // set objects to use for drawing
489 // ------------------------------
492 virtual void , SetFont(const wxFont& font),
493 "Sets the current font for the DC. It must be a valid font, in
494 particular you should not pass ``wx.NullFont`` to this method.","
499 virtual void , SetPen(const wxPen& pen),
500 "Sets the current pen for the DC.
502 If the argument is ``wx.NullPen``, the current pen is selected out of the
503 device context, and the original pen restored.", "
508 virtual void , SetBrush(const wxBrush& brush),
509 "Sets the current brush for the DC.
511 If the argument is ``wx.NullBrush``, the current brush is selected out
512 of the device context, and the original brush restored, allowing the
513 current brush to be destroyed safely.","
518 virtual void , SetBackground(const wxBrush& brush),
519 "Sets the current background brush for the DC.", "");
522 virtual void , SetBackgroundMode(int mode),
523 "*mode* may be one of ``wx.SOLID`` and ``wx.TRANSPARENT``. This setting
524 determines whether text will be drawn with a background colour or
528 virtual void , SetPalette(const wxPalette& palette),
529 "If this is a window DC or memory DC, assigns the given palette to the
530 window or bitmap associated with the DC. If the argument is
531 ``wx.NullPalette``, the current palette is selected out of the device
532 context, and the original palette restored.", "
534 :see: `wx.Palette`");
538 virtual void , SetTextForeground(const wxColour& colour),
539 "Sets the current text foreground colour for the DC.", "");
542 virtual void , SetTextBackground(const wxColour& colour),
543 "Sets the current text background colour for the DC.", "");
546 virtual void , SetLogicalFunction(int function),
547 "Sets the current logical function for the device context. This
548 determines how a source pixel (from a pen or brush colour, or source
549 device context if using `Blit`) combines with a destination pixel in
550 the current device context.
552 The possible values and their meaning in terms of source and
553 destination pixel values are as follows:
555 ================ ==========================
557 wx.AND_INVERT (NOT src) AND dst
558 wx.AND_REVERSE src AND (NOT dst)
561 wx.EQUIV (NOT src) XOR dst
563 wx.NAND (NOT src) OR (NOT dst)
564 wx.NOR (NOT src) AND (NOT dst)
567 wx.OR_INVERT (NOT src) OR dst
568 wx.OR_REVERSE src OR (NOT dst)
570 wx.SRC_INVERT NOT src
572 ================ ==========================
574 The default is wx.COPY, which simply draws with the current
575 colour. The others combine the current colour and the background using
576 a logical operation. wx.INVERT is commonly used for drawing rubber
577 bands or moving outlines, since drawing twice reverts to the original