]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_pseudodc.i
Get/SetManagedWindow
[wxWidgets.git] / wxPython / src / _pseudodc.i
CommitLineData
7e664d85
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name:
3// Purpose: Wraper definitions for the wxPseudoDC Class
4// Author: Paul Lanier
5// Modified by:
6// Created: 05/25/06
7// RCS-ID: $Id$
8// Copyright: (c) wxWidgets team
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12
13%{
14#include "wx/wxPython/pseudodc.h"
15%}
16
17%newgroup;
18
19DocStr(wxPseudoDC,
20"A PseudoDC is an object that can be used as if it were a `wx.DC`. All
21commands issued to the PseudoDC are stored in a list. You can then
22play these commands back to a real DC object using the DrawToDC
23method. Commands in the command list are indexed by ID. You can use
24this to clear the operations associated with a single ID and then
25re-draw the object associated with that ID.", "");
26
27class wxPseudoDC : public wxObject
28{
29public:
30 DocCtorStr(
31 wxPseudoDC(),
32 "Constructs a new Pseudo device context for recording dc operations","");
33 DocDeclStr(
34 void , BeginDrawing(),
35 "Allows for optimization of drawing code on platforms that need it. On
36other platforms this is just an empty function and is harmless. To
37take advantage of this postential optimization simply enclose each
38group of calls to the drawing primitives within calls to
39`BeginDrawing` and `EndDrawing`.", "");
40
41 DocDeclStr(
42 void , EndDrawing(),
43 "Ends the group of drawing primitives started with `BeginDrawing`, and
44invokes whatever optimization is available for this DC type on the
45current platform.", "");
46 DocCtorStr(
47 ~wxPseudoDC(),
48 "Frees memory used by the operation list of the pseudo dc","");
49 DocDeclStr(
50 void, RemoveAll(),
51 "Removes all objects and operations from the recorded list.", "");
52 DocDeclStr(
53 int, GetLen(),
54 "Returns the number of operations in the recorded list.", "");
55 DocDeclStr(
56 void, SetId(int id),
57 "Sets the id to be associated with subsequent operations.", "");
58 DocDeclStr(
59 void, ClearId(int id),
60 "Removes all operations associated with id so the object can be redrawn.", "");
61 DocDeclStr(
62 void, RemoveId(int id),
63 "Remove the object node (and all operations) associated with an id.", "");
64 DocDeclStr(
65 void, TranslateId(int id, wxCoord dx, wxCoord dy),
66 "Translate the operations of id by dx,dy.", "");
67 DocDeclStr(
68 void, DrawIdToDC(int id, wxDC *dc),
69 "Draw recorded operations of id to dc.", "");
70 DocDeclStr(
71 void, SetIdBounds(int id, wxRect& rect),
72 "Set the bounding rect of a given object. This will create
73an object node if one doesn't exist.", "");
74 %extend {
75 DocStr(
76 GetIdBounds,
77 "Returns the bounding rectangle previouly set with SetIdBounds. If
78no bounds have been set, it returns wx.Rect(0,0,0,0).", "");
79 wxRect GetIdBounds(int id) {
80 wxRect rect;
81 self->GetIdBounds(id, rect);
82 return rect;
83 }
84 }
85 DocDeclStr(
86 void, DrawToDCClipped(wxDC *dc, const wxRect& rect),
87 "Draws the recorded operations to dc unless the operation is known to
88be outside rect.", "");
89 DocDeclStr(
90 void, DrawToDCClippedRgn(wxDC *dc, const wxRegion& region),
91 "Draws the recorded operations to dc unless the operation is known to
92be outside rect.", "");
93 DocDeclStr(
94 void, DrawToDC(wxDC *dc),
95 "Draws the recorded operations to dc.", "");
96
97 //-------------------------------------------------------------------------
98 // Methods Mirrored from wxDC
99 //-------------------------------------------------------------------------
100//
101// DocDeclStr(
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.","
105//
106//:see: `wx.Font`");
107//
108// DocDeclStr(
109// void , SetPen(const wxPen& pen),
110// "Sets the current pen for the DC.
111//
112//If the argument is ``wx.NullPen``, the current pen is selected out of the
113//device context, and the original pen restored.", "
114//
115//:see: `wx.Pen`");
116//
117// DocDeclStr(
118// void , SetBrush(const wxBrush& brush),
119// "Sets the current brush for the DC.
120//
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.","
124//
125//:see: `wx.Brush`");
126//
127// DocDeclStr(
128// void , SetBackground(const wxBrush& brush),
129// "Sets the current background brush for the DC.", "");
130//
131// DocDeclStr(
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
135//not.", "");
136//
137// DocDeclStr(
138// void , SetTextForeground(const wxColour& colour),
139// "Sets the current text foreground colour for the DC.", "");
140//
141// DocDeclStr(
142// void , SetTextBackground(const wxColour& colour),
143// "Sets the current text background colour for the DC.", "");
144// DocDeclStr(
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
150//it is not -1.", "
151//
152//:see: `DrawImageLabel`");
153// DocStr(
154// DrawText,
155// "Draws a text string at the specified point, using the current text
156//font, and the current text foreground and background colours.
157//
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.
161//
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.", "
165//
166//:see: `DrawRotatedText`");
167// void DrawText(const wxString& text, wxCoord x, wxCoord y);
168// DocStr(
169// DrawLine,
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);
175// DocDeclStr(
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.", "");
180// DocDeclStr(
181// void , Clear(),
182// "Clears the device context using the current background brush.", "");
183
184 DocStr(
185 FloodFill,
186 "Flood fills the device context starting from the given point, using
187the current brush colour, and using a style:
188
189 - **wxFLOOD_SURFACE**: the flooding occurs until a colour other than
190 the given colour is encountered.
191
192 - **wxFLOOD_BORDER**: the area to be flooded is bounded by the given
193 colour.
194
195Returns False if the operation failed.
196
197Note: The present implementation for non-Windows platforms may fail to
198find colour borders if the pixels do not match the colour
199exactly. 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));
202
203
204 DocStr(
205 DrawLine,
206 "Draws a line from the first point to the second. The current pen is
207used for drawing the line. Note that the second point is *not* part of
208the line and is not drawn by this function (this is consistent with
209the 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));
212
213
214 DocStr(
215 CrossHair,
216 "Displays a cross hair using the current pen. This is a vertical and
217horizontal line the height and width of the window, centred on the
218given point.", "");
219 void CrossHair(wxCoord x, wxCoord y);
220 %Rename(CrossHairPoint, void, CrossHair(const wxPoint& pt));
221
222
223 DocStr(
224 DrawArc,
225 "Draws an arc of a circle, centred on the *center* point (xc, yc), from
226the first point to the second. The current pen is used for the outline
227and the current brush for filling the shape.
228
229The arc is drawn in an anticlockwise direction from the start point to
230the 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));
233
234
235 DocStr(
236 DrawCheckMark,
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));
240
241 DocStr(
242 DrawEllipticArc,
243 "Draws an arc of an ellipse, with the given rectangle defining the
244bounds of the ellipse. The current pen is used for drawing the arc and
245the current brush is used for drawing the pie.
246
247The *start* and *end* parameters specify the start and end of the arc
248relative to the three-o'clock position from the center of the
249rectangle. Angles are specified in degrees (360 is a complete
250circle). Positive values mean counter-clockwise motion. If start is
251equal 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));
254
255
256 DocStr(
257 DrawPoint,
258 "Draws a point using the current pen.", "");
259 void DrawPoint(wxCoord x, wxCoord y);
260 %Rename(DrawPointPoint, void, DrawPoint(const wxPoint& pt));
261
262
263 DocStr(
264 DrawRectangle,
265 "Draws a rectangle with the given top left corner, and with the given
266size. The current pen is used for the outline and the current brush
267for 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));
271
272
273 DocStr(
274 DrawRoundedRectangle,
275 "Draws a rectangle with the given top left corner, and with the given
276size. The corners are quarter-circles using the given radius. The
277current pen is used for the outline and the current brush for filling
278the shape.
279
280If radius is positive, the value is assumed to be the radius of the
281rounded corner. If radius is negative, the absolute value is assumed
282to be the proportion of the smallest dimension of the rectangle. This
283means that the corner can be a sensible size relative to the size of
284the rectangle, and also avoids the strange effects X produces when the
285corners 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));
289
290
291 DocStr(
292 DrawCircle,
293 "Draws a circle with the given center point and radius. The current
294pen is used for the outline and the current brush for filling the
295shape.", "
296
297:see: `DrawEllipse`");
298 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
299 %Rename(DrawCirclePoint, void, DrawCircle(const wxPoint& pt, wxCoord radius));
300
301
302 DocStr(
303 DrawEllipse,
304 "Draws an ellipse contained in the specified rectangle. The current pen
305is used for the outline and the current brush for filling the shape.", "
306
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));
311
312
313 DocStr(
314 DrawIcon,
315 "Draw an icon on the display (does nothing if the device context is
316PostScript). This can be the simplest way of drawing bitmaps on a
317window.", "");
318 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
319 %Rename(DrawIconPoint, void, DrawIcon(const wxIcon& icon, const wxPoint& pt));
320
321
322 DocStr(
323 DrawBitmap,
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
326alpha channel on the platforms that support it) then the bitmap will
327be drawn transparently.", "
328
329When drawing a mono-bitmap, the current text foreground colour will be
330used to draw the foreground of the bitmap (all bits set to 1), and the
331current text background colour to draw the background (all bits set to
3320).
333
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));
337
338
339 DocStr(
340 DrawText,
341 "Draws a text string at the specified point, using the current text
342font, and the current text foreground and background colours.
343
344The coordinates refer to the top-left corner of the rectangle bounding
a2cccbc3
RD
345the string. See `wx.DC.GetTextExtent` for how to get the dimensions of
346a text string, which can be used to position the text more precisely,
347(you will need to use a real DC with GetTextExtent as wx.PseudoDC does
348not implement it.)
7e664d85
RD
349
350**NOTE**: under wxGTK the current logical function is used by this
351function but it is ignored by wxMSW. Thus, you should avoid using
352logical functions with this function in portable programs.", "
353
354:see: `DrawRotatedText`");
355 void DrawText(const wxString& text, wxCoord x, wxCoord y);
356 %Rename(DrawTextPoint, void, DrawText(const wxString& text, const wxPoint& pt));
357
358
359 DocStr(
360 DrawRotatedText,
361 "Draws the text rotated by *angle* degrees, if supported by the platform.
362
363**NOTE**: Under Win9x only TrueType fonts can be drawn by this
364function. In particular, a font different from ``wx.NORMAL_FONT``
365should be used as the it is not normally a TrueType
366font. ``wx.SWISS_FONT`` is an example of a font which is.","
367
368:see: `DrawText`");
369 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
370 %Rename(DrawRotatedTextPoint, void, DrawRotatedText(const wxString& text, const wxPoint& pt, double angle));
371
372
373// DocDeclStr(
374// bool , Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
375// wxDC *source, wxCoord xsrc, wxCoord ysrc,
376// int rop = wxCOPY, bool useMask = false,
377// wxCoord xsrcMask = -1, wxCoord ysrcMask = -1),
378// "Copy from a source DC to this DC. Parameters specify the destination
379//coordinates, size of area to copy, source DC, source coordinates,
380//logical function, whether to use a bitmap mask, and mask source
381//position.", "
382//
383// :param xdest: Destination device context x position.
384// :param ydest: Destination device context y position.
385// :param width: Width of source area to be copied.
386// :param height: Height of source area to be copied.
387// :param source: Source device context.
388// :param xsrc: Source device context x position.
389// :param ysrc: Source device context y position.
390// :param rop: Logical function to use: see `SetLogicalFunction`.
391// :param useMask: If true, Blit does a transparent blit using the mask
392// that is associated with the bitmap selected into the
393// source device context.
394// :param xsrcMask: Source x position on the mask. If both xsrcMask and
395// ysrcMask are -1, xsrc and ysrc will be assumed for
396// the mask source position.
397// :param ysrcMask: Source y position on the mask.
398//");
399
400// DocDeclStrName(
401// bool , Blit(const wxPoint& destPt, const wxSize& sz,
402// wxDC *source, const wxPoint& srcPt,
403// int rop = wxCOPY, bool useMask = false,
404// const wxPoint& srcPtMask = wxDefaultPosition),
405// "Copy from a source DC to this DC. Parameters specify the destination
406//coordinates, size of area to copy, source DC, source coordinates,
407//logical function, whether to use a bitmap mask, and mask source
408//position.", "
409//
410// :param destPt: Destination device context position.
411// :param sz: Size of source area to be copied.
412// :param source: Source device context.
413// :param srcPt: Source device context position.
414// :param rop: Logical function to use: see `SetLogicalFunction`.
415// :param useMask: If true, Blit does a transparent blit using the mask
416// that is associated with the bitmap selected into the
417// source device context.
418// :param srcPtMask: Source position on the mask.
419//",
420// BlitPointSize);
421
422
423 DocDeclAStr(
424 void , DrawLines(int points, wxPoint* points_array,
425 wxCoord xoffset = 0, wxCoord yoffset = 0),
426 "DrawLines(self, List points, int xoffset=0, int yoffset=0)",
427 "Draws lines using a sequence of `wx.Point` objects, adding the
428optional offset coordinate. The current pen is used for drawing the
429lines.", "");
430
431
432 DocDeclAStr(
433 void , DrawPolygon(int points, wxPoint* points_array,
434 wxCoord xoffset = 0, wxCoord yoffset = 0,
435 int fillStyle = wxODDEVEN_RULE),
436 "DrawPolygon(self, List points, int xoffset=0, int yoffset=0,
437 int fillStyle=ODDEVEN_RULE)",
438 "Draws a filled polygon using a sequence of `wx.Point` objects, adding
439the optional offset coordinate. The last argument specifies the fill
440rule: ``wx.ODDEVEN_RULE`` (the default) or ``wx.WINDING_RULE``.
441
442The current pen is used for drawing the outline, and the current brush
443for filling the shape. Using a transparent brush suppresses
444filling. Note that wxWidgets automatically closes the first and last
445points.", "");
446
447
448 // TODO: Figure out a good typemap for this...
449 // Convert the first 3 args from a sequence of sequences?
450// void DrawPolyPolygon(int n, int count[], wxPoint points[],
451// wxCoord xoffset = 0, wxCoord yoffset = 0,
452// int fillStyle = wxODDEVEN_RULE);
453
454
455 DocDeclStr(
456 void , DrawLabel(const wxString& text, const wxRect& rect,
457 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
458 int indexAccel = -1),
459 "Draw *text* within the specified rectangle, abiding by the alignment
460flags. Will additionally emphasize the character at *indexAccel* if
461it is not -1.", "
462
463:see: `DrawImageLabel`");
464
465 DocDeclStrName(
466 void, DrawLabel(const wxString& text,
467 const wxBitmap& image,
468 const wxRect& rect,
469 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
470 int indexAccel = -1),
471 "Draw *text* and an image (which may be ``wx.NullBitmap`` to skip
472drawing it) within the specified rectangle, abiding by the alignment
473flags. Will additionally emphasize the character at *indexAccel* if
474it is not -1.", "", DrawImageLabel);
475
476
477 DocDeclAStr(
478 void , DrawSpline(int points, wxPoint* points_array),
479 "DrawSpline(self, List points)",
480 "Draws a spline between all given control points, (a list of `wx.Point`
481objects) using the current pen. The spline is drawn using a series of
482lines, using an algorithm taken from the X drawing program 'XFIG'.", "");
483
484
485 DocDeclStr(
486 virtual void , Clear(),
487 "Clears the device context using the current background brush.", "");
488
489
490 // set objects to use for drawing
491 // ------------------------------
492
493 DocDeclStr(
494 virtual void , SetFont(const wxFont& font),
495 "Sets the current font for the DC. It must be a valid font, in
496particular you should not pass ``wx.NullFont`` to this method.","
497
498:see: `wx.Font`");
499
500 DocDeclStr(
501 virtual void , SetPen(const wxPen& pen),
502 "Sets the current pen for the DC.
503
504If the argument is ``wx.NullPen``, the current pen is selected out of the
505device context, and the original pen restored.", "
506
507:see: `wx.Pen`");
508
509 DocDeclStr(
510 virtual void , SetBrush(const wxBrush& brush),
511 "Sets the current brush for the DC.
512
513If the argument is ``wx.NullBrush``, the current brush is selected out
514of the device context, and the original brush restored, allowing the
515current brush to be destroyed safely.","
516
517:see: `wx.Brush`");
518
519 DocDeclStr(
520 virtual void , SetBackground(const wxBrush& brush),
521 "Sets the current background brush for the DC.", "");
522
523 DocDeclStr(
524 virtual void , SetBackgroundMode(int mode),
525 "*mode* may be one of ``wx.SOLID`` and ``wx.TRANSPARENT``. This setting
526determines whether text will be drawn with a background colour or
527not.", "");
528
529 DocDeclStr(
530 virtual void , SetPalette(const wxPalette& palette),
531 "If this is a window DC or memory DC, assigns the given palette to the
532window or bitmap associated with the DC. If the argument is
533``wx.NullPalette``, the current palette is selected out of the device
534context, and the original palette restored.", "
535
536:see: `wx.Palette`");
537
538
539 DocDeclStr(
540 virtual void , SetTextForeground(const wxColour& colour),
541 "Sets the current text foreground colour for the DC.", "");
542
543 DocDeclStr(
544 virtual void , SetTextBackground(const wxColour& colour),
545 "Sets the current text background colour for the DC.", "");
546
547 DocDeclStr(
548 virtual void , SetLogicalFunction(int function),
549 "Sets the current logical function for the device context. This
a2cccbc3
RD
550determines how a source pixel (from a pen or brush colour, combines
551with a destination pixel in the current device context.
7e664d85
RD
552
553The possible values and their meaning in terms of source and
554destination pixel values are as follows:
555
556 ================ ==========================
557 wx.AND src AND dst
558 wx.AND_INVERT (NOT src) AND dst
559 wx.AND_REVERSE src AND (NOT dst)
560 wx.CLEAR 0
561 wx.COPY src
562 wx.EQUIV (NOT src) XOR dst
563 wx.INVERT NOT dst
564 wx.NAND (NOT src) OR (NOT dst)
565 wx.NOR (NOT src) AND (NOT dst)
566 wx.NO_OP dst
567 wx.OR src OR dst
568 wx.OR_INVERT (NOT src) OR dst
569 wx.OR_REVERSE src OR (NOT dst)
570 wx.SET 1
571 wx.SRC_INVERT NOT src
572 wx.XOR src XOR dst
573 ================ ==========================
574
575The default is wx.COPY, which simply draws with the current
576colour. The others combine the current colour and the background using
577a logical operation. wx.INVERT is commonly used for drawing rubber
578bands or moving outlines, since drawing twice reverts to the original
579colour.
580", "");
581};