]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_dc.i
This workaround is no longer needed because of fix in
[wxWidgets.git] / wxPython / src / _dc.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _dc.i
3// Purpose: SWIG interface defs for wxDC and releated classes
4//
5// Author: Robin Dunn
6//
7// Created: 7-July-1997
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
4942342c 16
d14a1e28
RD
17//---------------------------------------------------------------------------
18
19%{
20#include "wx/wxPython/pydrawxxx.h"
21%}
22
23// TODO: 1. wrappers for wxDrawObject and wxDC::DrawObject
24
25
26//---------------------------------------------------------------------------
27
28%typemap(in) (int points, wxPoint* points_array ) {
29 $2 = wxPoint_LIST_helper($input, &$1);
30 if ($2 == NULL) SWIG_fail;
31}
32%typemap(freearg) (int points, wxPoint* points_array ) {
33 if ($2) delete [] $2;
34}
35
36
37//---------------------------------------------------------------------------
38%newgroup;
39
40
41// wxDC is the device context - object on which any drawing is done
42class wxDC : public wxObject {
43public:
44// wxDC(); **** abstract base class, can't instantiate.
45 ~wxDC();
46
47
48 virtual void BeginDrawing();
49 virtual void EndDrawing();
50
51
52// virtual void DrawObject(wxDrawObject* drawobject);
53
54
55
d7403ad2 56#if 1 // The < 2.4 and > 2.5.1.5 way
d14a1e28
RD
57
58 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
dce2bd22
RD
59 %name(FloodFillPoint) bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE);
60
d14a1e28
RD
61 //bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const;
62 %extend {
63 wxColour GetPixel(wxCoord x, wxCoord y) {
64 wxColour col;
65 self->GetPixel(x, y, &col);
66 return col;
67 }
dce2bd22
RD
68 wxColour GetPixelPoint(const wxPoint& pt) {
69 wxColour col;
70 self->GetPixel(pt, &col);
71 return col;
72 }
d14a1e28 73 }
dce2bd22 74
d14a1e28 75 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
dce2bd22
RD
76 %name(DrawLinePoint) void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
77
d14a1e28 78 void CrossHair(wxCoord x, wxCoord y);
dce2bd22
RD
79 %name(CrossHairPoint) void CrossHair(const wxPoint& pt);
80
d14a1e28 81 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
dce2bd22
RD
82 %name(DrawArcPoint) void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre);
83
d14a1e28 84 void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
dce2bd22
RD
85 %name(DrawCheckMarkRect) void DrawCheckMark(const wxRect& rect);
86
d14a1e28 87 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea);
d7403ad2 88 %name(DrawEllipticArcPointSize) void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double sa, double ea);
dce2bd22 89
d14a1e28 90 void DrawPoint(wxCoord x, wxCoord y);
dce2bd22
RD
91 %name(DrawPointPoint) void DrawPoint(const wxPoint& pt);
92
d14a1e28
RD
93 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
94 %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect);
d7403ad2 95 %name(DrawRectanglePointSize) void DrawRectangle(const wxPoint& pt, const wxSize& sz);
dce2bd22 96
d14a1e28 97 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius);
dce2bd22 98 %name(DrawRoundedRectangleRect) void DrawRoundedRectangle(const wxRect& r, double radius);
d7403ad2 99 %name(DrawRoundedRectanglePointSize) void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius);
dce2bd22 100
d14a1e28 101 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
dce2bd22
RD
102 %name(DrawCirclePoint) void DrawCircle(const wxPoint& pt, wxCoord radius);
103
d14a1e28 104 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
dce2bd22 105 %name(DrawEllipseRect) void DrawEllipse(const wxRect& rect);
d7403ad2 106 %name(DrawEllipsePointSize) void DrawEllipse(const wxPoint& pt, const wxSize& sz);
dce2bd22 107
d14a1e28 108 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
dce2bd22
RD
109 %name(DrawIconPoint) void DrawIcon(const wxIcon& icon, const wxPoint& pt);
110
dd9f7fea 111 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = False);
dce2bd22
RD
112 %name(DrawBitmapPoint) void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = False);
113
d14a1e28 114 void DrawText(const wxString& text, wxCoord x, wxCoord y);
dce2bd22
RD
115 %name(DrawTextPoint) void DrawText(const wxString& text, const wxPoint& pt);
116
d14a1e28 117 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
dce2bd22
RD
118 %name(DrawRotatedTextPoint) void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle);
119
d14a1e28
RD
120 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
121 wxDC *source, wxCoord xsrc, wxCoord ysrc,
dd9f7fea 122 int rop = wxCOPY, bool useMask = False,
d14a1e28 123 wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
d7403ad2
RD
124 %name(BlitPointSize) bool Blit(const wxPoint& destPt, const wxSize& sz,
125 wxDC *source, const wxPoint& srcPt,
126 int rop = wxCOPY, bool useMask = False,
127 const wxPoint& srcPtMask = wxDefaultPosition);
d14a1e28
RD
128
129
d7403ad2
RD
130 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
131 %name(SetClippingRegionPointSize) void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
132 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
133 %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
d14a1e28 134
d7403ad2 135#else // The doomed 2.5.1.5
4942342c 136
d14a1e28
RD
137 %name(FloodFillXY) bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
138 bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE);
139
140 //%name(GetPixelXY) bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const;
141 //bool GetPixel(const wxPoint& pt, wxColour *col) const;
142 %extend {
143 wxColour GetPixelXY(wxCoord x, wxCoord y) {
144 wxColour col;
145 self->GetPixel(x, y, &col);
146 return col;
147 }
148 wxColour GetPixel(const wxPoint& pt) {
149 wxColour col;
150 self->GetPixel(pt, &col);
151 return col;
152 }
153 }
dce2bd22 154
d14a1e28
RD
155 %name(DrawLineXY) void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
156 void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
157
158 %name(CrossHairXY) void CrossHair(wxCoord x, wxCoord y);
159 void CrossHair(const wxPoint& pt);
160
161 %name(DrawArcXY) void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
162 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre);
163
164 %name(DrawCheckMarkXY) void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
165 void DrawCheckMark(const wxRect& rect);
166
167 %name(DrawEllipticArcXY) void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea);
168 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double sa, double ea);
169
170 %name(DrawPointXY) void DrawPoint(wxCoord x, wxCoord y);
171 void DrawPoint(const wxPoint& pt);
172
173 %name(DrawRectangleXY) void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
174 void DrawRectangle(const wxPoint& pt, const wxSize& sz);
175 %name(DrawRectangleRect) void DrawRectangle(const wxRect& rect);
176
177 %name(DrawRoundedRectangleXY) void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius);
178 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius);
179 %name(DrawRoundedRectangleRect) void DrawRoundedRectangle(const wxRect& r, double radius);
180
181 %name(DrawCircleXY) void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
182 void DrawCircle(const wxPoint& pt, wxCoord radius);
183
184 %name(DrawEllipseXY) void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
185 void DrawEllipse(const wxPoint& pt, const wxSize& sz);
186 %name(DrawEllipseRect) void DrawEllipse(const wxRect& rect);
187
188 %name(DrawIconXY) void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
189 void DrawIcon(const wxIcon& icon, const wxPoint& pt);
190
dd9f7fea
RD
191 %name(DrawBitmapXY) void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = False);
192 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = False);
d14a1e28
RD
193
194 %name(DrawTextXY) void DrawText(const wxString& text, wxCoord x, wxCoord y);
195 void DrawText(const wxString& text, const wxPoint& pt);
196
197 %name(DrawRotatedTextXY) void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
198 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle);
199
4942342c 200
d14a1e28
RD
201 %name(BlitXY) bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
202 wxDC *source, wxCoord xsrc, wxCoord ysrc,
dd9f7fea 203 int rop = wxCOPY, bool useMask = False,
d14a1e28 204 wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
4942342c 205 bool Blit(const wxPoint& destPt, const wxSize& sz,
d14a1e28 206 wxDC *source, const wxPoint& srcPt,
dd9f7fea 207 int rop = wxCOPY, bool useMask = False,
d14a1e28
RD
208 const wxPoint& srcPtMask = wxDefaultPosition);
209
d7403ad2
RD
210
211 %name(SetClippingRegionXY)void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
212 void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
213 %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
214 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
215
d14a1e28 216#endif
4942342c 217
d14a1e28
RD
218 void DrawLines(int points, wxPoint* points_array, wxCoord xoffset = 0, wxCoord yoffset = 0);
219
220 void DrawPolygon(int points, wxPoint* points_array,
221 wxCoord xoffset = 0, wxCoord yoffset = 0,
222 int fillStyle = wxODDEVEN_RULE);
223
86aafce3
RD
224 // TODO: Figure out a good typemap for this...
225 // Convert the first 3 args from a sequence of sequences?
226// void DrawPolyPolygon(int n, int count[], wxPoint points[],
227// wxCoord xoffset = 0, wxCoord yoffset = 0,
228// int fillStyle = wxODDEVEN_RULE);
d14a1e28 229
86aafce3 230
d14a1e28
RD
231 // this version puts both optional bitmap and the text into the given
232 // rectangle and aligns is as specified by alignment parameter; it also
233 // will emphasize the character with the given index if it is != -1 and
234 // return the bounding rectangle if required
235 void DrawLabel(const wxString& text, const wxRect& rect,
236 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
237 int indexAccel = -1);
238 %extend {
239 wxRect DrawImageLabel(const wxString& text,
240 const wxBitmap& image,
241 const wxRect& rect,
242 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
243 int indexAccel = -1) {
244 wxRect rv;
245 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
246 return rv;
247 }
248 }
249
250
251
252 void DrawSpline(int points, wxPoint* points_array);
253
254
4942342c 255
d14a1e28
RD
256 // global DC operations
257 // --------------------
258
259 virtual void Clear();
260
261 virtual bool StartDoc(const wxString& message);
262 virtual void EndDoc();
263
264 virtual void StartPage();
265 virtual void EndPage();
266
4942342c 267
d14a1e28
RD
268 // set objects to use for drawing
269 // ------------------------------
270
271 virtual void SetFont(const wxFont& font);
272 virtual void SetPen(const wxPen& pen);
273 virtual void SetBrush(const wxBrush& brush);
274 virtual void SetBackground(const wxBrush& brush);
275 virtual void SetBackgroundMode(int mode);
276 virtual void SetPalette(const wxPalette& palette);
277
4942342c 278
d14a1e28
RD
279 virtual void DestroyClippingRegion();
280
322913ce
RD
281 DocDeclA(
282 void, GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const,
283 "GetClippingBox() -> (x, y, width, height)");
4942342c 284
d14a1e28
RD
285 %extend {
286 wxRect GetClippingRect() {
287 wxRect rect;
288 self->GetClippingBox(rect);
289 return rect;
290 }
291 }
d14a1e28 292
4942342c
RD
293
294
d14a1e28
RD
295 // text extent
296 // -----------
297
298 virtual wxCoord GetCharHeight() const;
299 virtual wxCoord GetCharWidth() const;
300
d14a1e28 301
322913ce
RD
302 DocDeclAStr(
303 void, GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT),
304 "GetTextExtent(wxString string) -> (width, height)",
d07d2bc9
RD
305 "Get the width and height of the text using the current font. Only
306works for single line strings.", "");
307
322913ce
RD
308 DocDeclAStrName(
309 void, GetTextExtent(const wxString& string,
4942342c 310 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
322913ce
RD
311 wxFont* font = NULL),
312 "GetFullTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)",
d07d2bc9
RD
313 "Get the width, height, decent and leading of the text using the
314current or specified font. Only works for single line strings.", "",
322913ce
RD
315 GetFullTextExtent);
316
4942342c 317
322913ce
RD
318 // works for single as well as multi-line strings
319 DocDeclAStr(
320 void, GetMultiLineTextExtent(const wxString& text,
321 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT,
322 wxFont *font = NULL),
323 "GetMultiLineTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)",
d07d2bc9
RD
324 "Get the width, height, decent and leading of the text using the
325current or specified font. Works for single as well as multi-line
326strings.", "");
322913ce 327
746ee6b8
RD
328
329 %extend {
330 wxArrayInt GetPartialTextExtents(const wxString& text) {
331 wxArrayInt widths;
332 self->GetPartialTextExtents(text, widths);
333 return widths;
334 }
335 }
336
d14a1e28
RD
337
338 // size and resolution
339 // -------------------
340
d07d2bc9 341 DocStr(GetSize, "Get the DC size in device units.", "");
d14a1e28 342 wxSize GetSize();
322913ce
RD
343 DocDeclAName(
344 void, GetSize( int *OUTPUT, int *OUTPUT ),
345 "GetSizeTuple() -> (width, height)",
346 GetSizeTuple);
4942342c 347
d14a1e28 348
d07d2bc9 349 DocStr(GetSizeMM, "Get the DC size in milimeters.", "");
d14a1e28 350 wxSize GetSizeMM() const;
322913ce
RD
351 DocDeclAName(
352 void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const,
353 "GetSizeMMTuple() -> (width, height)",
354 GetSizeMMTuple);
4942342c
RD
355
356
d14a1e28
RD
357
358 // coordinates conversions
359 // -----------------------
360
361 // This group of functions does actual conversion of the input, as you'd
362 // expect.
363 wxCoord DeviceToLogicalX(wxCoord x) const;
364 wxCoord DeviceToLogicalY(wxCoord y) const;
365 wxCoord DeviceToLogicalXRel(wxCoord x) const;
366 wxCoord DeviceToLogicalYRel(wxCoord y) const;
367 wxCoord LogicalToDeviceX(wxCoord x) const;
368 wxCoord LogicalToDeviceY(wxCoord y) const;
369 wxCoord LogicalToDeviceXRel(wxCoord x) const;
370 wxCoord LogicalToDeviceYRel(wxCoord y) const;
371
372 // query DC capabilities
373 // ---------------------
374
375 virtual bool CanDrawBitmap() const;
376 virtual bool CanGetTextExtent() const;
377
378 // colour depth
379 virtual int GetDepth() const;
380
381 // Resolution in Pixels per inch
382 virtual wxSize GetPPI() const;
383
384 virtual bool Ok() const;
385
4942342c 386
d14a1e28
RD
387
388 int GetBackgroundMode() const;
389 const wxBrush& GetBackground() const;
390 const wxBrush& GetBrush() const;
391 const wxFont& GetFont() const;
392 const wxPen& GetPen() const;
393 const wxColour& GetTextBackground() const;
394 const wxColour& GetTextForeground() const;
395
396 virtual void SetTextForeground(const wxColour& colour);
397 virtual void SetTextBackground(const wxColour& colour);
398
399 int GetMapMode() const;
400 virtual void SetMapMode(int mode);
401
4942342c 402
322913ce
RD
403 DocDeclA(
404 virtual void, GetUserScale(double *OUTPUT, double *OUTPUT) const,
405 "GetUserScale() -> (xScale, yScale)");
4942342c 406
d14a1e28
RD
407 virtual void SetUserScale(double x, double y);
408
4942342c 409
322913ce
RD
410 DocDeclA(
411 virtual void, GetLogicalScale(double *OUTPUT, double *OUTPUT),
412 "GetLogicalScale() -> (xScale, yScale)");
413
d14a1e28
RD
414 virtual void SetLogicalScale(double x, double y);
415
322913ce 416
d14a1e28 417 wxPoint GetLogicalOrigin() const;
322913ce
RD
418 DocDeclAName(
419 void, GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
420 "GetLogicalOriginTuple() -> (x,y)",
421 GetLogicalOriginTuple);
4942342c 422
d14a1e28 423 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
d7403ad2
RD
424 %extend {
425 void SetLogicalOriginPoint(const wxPoint& point) {
426 self->SetLogicalOrigin(point.x, point.y);
427 }
428 }
d14a1e28 429
d7403ad2 430
d14a1e28 431 wxPoint GetDeviceOrigin() const;
322913ce
RD
432 DocDeclAName(
433 void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
434 "GetDeviceOriginTuple() -> (x,y)",
435 GetDeviceOriginTuple);
4942342c 436
d14a1e28 437 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
d7403ad2
RD
438 %extend {
439 void SetDeviceOriginPoint(const wxPoint& point) {
440 self->SetDeviceOrigin(point.x, point.y);
441 }
442 }
d14a1e28
RD
443
444 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
445
446 int GetLogicalFunction() const;
447 virtual void SetLogicalFunction(int function);
448
449 virtual void SetOptimization(bool opt);
450 virtual bool GetOptimization();
4942342c 451
d14a1e28
RD
452
453 // bounding box
454 // ------------
455
456 virtual void CalcBoundingBox(wxCoord x, wxCoord y);
d7403ad2
RD
457 %extend {
458 void CalcBoundingBoxPoint(const wxPoint& point) {
459 self->CalcBoundingBox(point.x, point.y);
460 }
461 }
462
d14a1e28
RD
463 void ResetBoundingBox();
464
465 // Get the final bounding box of the PostScript or Metafile picture.
466 wxCoord MinX() const;
467 wxCoord MaxX() const;
468 wxCoord MinY() const;
469 wxCoord MaxY() const;
470
471
322913ce
RD
472 DocA(GetBoundingBox,
473 "GetBoundingBox() -> (x1,y1, x2,y2)");
d14a1e28
RD
474 %extend {
475 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
476 // See below for implementation
4942342c 477 }
d14a1e28
RD
478 %pythoncode { def __nonzero__(self): return self.Ok() };
479
480
96fc3ef4
RD
481#ifdef __WXMSW__
482 long GetHDC();
483#endif
484
d14a1e28
RD
485
486 %extend { // See drawlist.cpp for impplementaion of these...
487 PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
488 {
489 return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes);
490 }
491
492 PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
493 {
494 return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes);
495 }
496
497 PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
498 {
499 return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes);
500 }
501
502 PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
503 {
504 return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes);
505 }
506
507 PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
508 {
509 return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes);
510 }
511
512 PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints,
513 PyObject* foregroundList, PyObject* backgroundList) {
514 return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList);
515 }
516 }
517
518 %pythoncode {
519 def DrawPointList(self, points, pens=None):
520 if pens is None:
521 pens = []
522 elif isinstance(pens, wx.Pen):
523 pens = [pens]
524 elif len(pens) != len(points):
525 raise ValueError('points and pens must have same length')
526 return self._DrawPointList(points, pens, [])
527
528
529 def DrawLineList(self, lines, pens=None):
530 if pens is None:
531 pens = []
532 elif isinstance(pens, wx.Pen):
533 pens = [pens]
534 elif len(pens) != len(lines):
535 raise ValueError('lines and pens must have same length')
536 return self._DrawLineList(lines, pens, [])
537
538
539 def DrawRectangleList(self, rectangles, pens=None, brushes=None):
540 if pens is None:
541 pens = []
542 elif isinstance(pens, wx.Pen):
543 pens = [pens]
544 elif len(pens) != len(rectangles):
545 raise ValueError('rectangles and pens must have same length')
546 if brushes is None:
547 brushes = []
548 elif isinstance(brushes, wx.Brush):
549 brushes = [brushes]
550 elif len(brushes) != len(rectangles):
551 raise ValueError('rectangles and brushes must have same length')
552 return self._DrawRectangleList(rectangles, pens, brushes)
553
554
555 def DrawEllipseList(self, ellipses, pens=None, brushes=None):
556 if pens is None:
557 pens = []
558 elif isinstance(pens, wx.Pen):
559 pens = [pens]
560 elif len(pens) != len(ellipses):
561 raise ValueError('ellipses and pens must have same length')
562 if brushes is None:
563 brushes = []
564 elif isinstance(brushes, wx.Brush):
565 brushes = [brushes]
566 elif len(brushes) != len(ellipses):
567 raise ValueError('ellipses and brushes must have same length')
568 return self._DrawEllipseList(ellipses, pens, brushes)
569
570
571 def DrawPolygonList(self, polygons, pens=None, brushes=None):
4942342c
RD
572 %## Note: This does not currently support fill style or offset
573 %## you can always use the non-List version if need be.
d14a1e28
RD
574 if pens is None:
575 pens = []
576 elif isinstance(pens, wx.Pen):
577 pens = [pens]
578 elif len(pens) != len(polygons):
579 raise ValueError('polygons and pens must have same length')
580 if brushes is None:
581 brushes = []
582 elif isinstance(brushes, wx.Brush):
583 brushes = [brushes]
584 elif len(brushes) != len(polygons):
585 raise ValueError('polygons and brushes must have same length')
586 return self._DrawPolygonList(polygons, pens, brushes)
587
588
589 def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None):
4942342c
RD
590 %## NOTE: this does not currently support changing the font
591 %## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode)
592 %## If you want backgounds to do anything.
d14a1e28
RD
593 if type(textList) == type(''):
594 textList = [textList]
595 elif len(textList) != len(coords):
596 raise ValueError('textlist and coords must have same length')
597 if foregrounds is None:
598 foregrounds = []
fd3f2efe 599 elif isinstance(foregrounds, wx.Colour):
d14a1e28
RD
600 foregrounds = [foregrounds]
601 elif len(foregrounds) != len(coords):
602 raise ValueError('foregrounds and coords must have same length')
603 if backgrounds is None:
604 backgrounds = []
fd3f2efe 605 elif isinstance(backgrounds, wx.Colour):
d14a1e28
RD
606 backgrounds = [backgrounds]
607 elif len(backgrounds) != len(coords):
608 raise ValueError('backgrounds and coords must have same length')
609 return self._DrawTextList(textList, coords, foregrounds, backgrounds)
610 }
611
612};
613
614
615
616%{
617static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
618 *x1 = dc->MinX();
619 *y1 = dc->MinY();
620 *x2 = dc->MaxX();
621 *y2 = dc->MaxY();
622}
623%}
624
625
626//---------------------------------------------------------------------------
627%newgroup
628
ab1f7d2a
RD
629MustHaveApp(wxMemoryDC);
630
d14a1e28
RD
631class wxMemoryDC : public wxDC {
632public:
633 wxMemoryDC();
634 %name(MemoryDCFromDC) wxMemoryDC(wxDC* oldDC);
4942342c 635
d14a1e28
RD
636 void SelectObject(const wxBitmap& bitmap);
637};
638
639//---------------------------------------------------------------------------
640%newgroup
641
b159c5c4 642
ef22e3d3 643%{
ef22e3d3 644#include <wx/dcbuffer.h>
ef22e3d3
RD
645%}
646
647
ab1f7d2a
RD
648MustHaveApp(wxBufferedDC);
649
d14a1e28
RD
650class wxBufferedDC : public wxMemoryDC
651{
652public:
e608d228 653 %pythonAppend wxBufferedDC
d14a1e28 654 "self._dc = args[0] # save a ref so the other dc will not be deleted before self";
d14a1e28 655
b159c5c4
RD
656 %nokwargs wxBufferedDC;
657
d14a1e28
RD
658 // Construct a wxBufferedDC using a user supplied buffer.
659 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
660
b159c5c4
RD
661 // Construct a wxBufferedDC with an internal buffer of 'area'
662 // (where area is usually something like the size of the window
663 // being buffered)
7a0b15e9 664 wxBufferedDC( wxDC *dc, const wxSize &area );
b159c5c4 665
e608d228 666
b159c5c4 667 // TODO: Keep this one too?
7a0b15e9 668 %pythonAppend wxBufferedDC( wxDC *dc, const wxSize &area )
e608d228 669 "val._dc = args[0] # save a ref so the other dc will not be deleted before self";
7a0b15e9
RD
670 %name(BufferedDCInternalBuffer) wxBufferedDC( wxDC *dc, const wxSize &area );
671
672
673 // The buffer is blit to the real DC when the BufferedDC is destroyed.
674 ~wxBufferedDC();
d14a1e28 675
e608d228 676
b159c5c4
RD
677 // Blits the buffer to the dc, and detaches the dc from
678 // the buffer. Usually called in the dtor or by the dtor
679 // of derived classes if the BufferedDC must blit before
680 // the derived class (which may own the dc it's blitting
681 // to) is destroyed.
d14a1e28
RD
682 void UnMask();
683};
684
685
7a0b15e9 686
ab1f7d2a 687MustHaveApp(wxBufferedPaintDC);
7a0b15e9
RD
688
689// Creates a double buffered wxPaintDC, optionally allowing the
690// user to specify their own buffer to use.
d14a1e28
RD
691class wxBufferedPaintDC : public wxBufferedDC
692{
693public:
b159c5c4 694
ef22e3d3 695 // If no bitmap is supplied by the user, a temporary one will be created.
7a0b15e9 696 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
b159c5c4 697
d14a1e28
RD
698};
699
700
701//---------------------------------------------------------------------------
702%newgroup
703
ab1f7d2a
RD
704MustHaveApp(wxScreenDC);
705
d14a1e28
RD
706class wxScreenDC : public wxDC {
707public:
708 wxScreenDC();
709
710 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
711 bool StartDrawingOnTop(wxRect* rect = NULL);
712 bool EndDrawingOnTop();
713};
714
715//---------------------------------------------------------------------------
716%newgroup
717
ab1f7d2a
RD
718MustHaveApp(wxClientDC);
719
d14a1e28
RD
720class wxClientDC : public wxDC {
721public:
722 wxClientDC(wxWindow* win);
723};
724
725//---------------------------------------------------------------------------
726%newgroup
727
ab1f7d2a
RD
728MustHaveApp(wxPaintDC);
729
d14a1e28
RD
730class wxPaintDC : public wxDC {
731public:
732 wxPaintDC(wxWindow* win);
733};
734
735//---------------------------------------------------------------------------
736%newgroup
737
ab1f7d2a
RD
738MustHaveApp(wxWindowDC);
739
d14a1e28
RD
740class wxWindowDC : public wxDC {
741public:
742 wxWindowDC(wxWindow* win);
743};
744
745//---------------------------------------------------------------------------
746%newgroup
747
ab1f7d2a
RD
748MustHaveApp(wxMirrorDC);
749
d14a1e28
RD
750class wxMirrorDC : public wxDC
751{
752public:
753 // constructs a mirror DC associated with the given real DC
754 //
dd9f7fea 755 // if mirror parameter is True, all vertical and horizontal coordinates are
d14a1e28
RD
756 // exchanged, otherwise this class behaves in exactly the same way as a
757 // plain DC
758 //
759 wxMirrorDC(wxDC& dc, bool mirror);
760};
761
762//---------------------------------------------------------------------------
763%newgroup
764
765%{
766#include <wx/dcps.h>
767%}
768
ab1f7d2a
RD
769MustHaveApp(wxPostScriptDC);
770
d14a1e28
RD
771class wxPostScriptDC : public wxDC {
772public:
773 wxPostScriptDC(const wxPrintData& printData);
774// %name(PostScriptDC2)wxPostScriptDC(const wxString& output,
dd9f7fea 775// bool interactive = True,
d14a1e28
RD
776// wxWindow* parent = NULL);
777
778 wxPrintData& GetPrintData();
779 void SetPrintData(const wxPrintData& data);
780
781 static void SetResolution(int ppi);
782 static int GetResolution();
783};
784
785//---------------------------------------------------------------------------
786%newgroup
787
788
ab1f7d2a
RD
789MustHaveApp(wxMetaFile);
790MustHaveApp(wxMetaFileDC);
791
792
da457c1b 793#if defined(__WXMSW__) || defined(__WXMAC__)
d14a1e28
RD
794
795%{
796#include <wx/metafile.h>
797%}
798
799class wxMetaFile : public wxObject {
800public:
801 wxMetaFile(const wxString& filename = wxPyEmptyString);
802 ~wxMetaFile();
803
804 bool Ok();
805 bool SetClipboard(int width = 0, int height = 0);
806
807 wxSize GetSize();
808 int GetWidth();
809 int GetHeight();
810
da457c1b 811#ifdef __WXMSW__
d14a1e28 812 const wxString& GetFileName() const;
da457c1b
RD
813#endif
814
d14a1e28
RD
815 %pythoncode { def __nonzero__(self): return self.Ok() }
816};
817
818// bool wxMakeMetaFilePlaceable(const wxString& filename,
819// int minX, int minY, int maxX, int maxY, float scale=1.0);
820
821
822class wxMetaFileDC : public wxDC {
823public:
824 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
825 int width = 0, int height = 0,
826 const wxString& description = wxPyEmptyString);
827 wxMetaFile* Close();
828};
829
830
831
832#else // Make some dummies for the other platforms
833
834%{
835class wxMetaFile : public wxObject {
836public:
837 wxMetaFile(const wxString&)
81cfe5e1 838 { wxPyRaiseNotImplemented(); }
d14a1e28
RD
839};
840
841class wxMetaFileDC : public wxClientDC {
842public:
843 wxMetaFileDC(const wxString&, int, int, const wxString&)
81cfe5e1 844 { wxPyRaiseNotImplemented(); }
d14a1e28
RD
845};
846
847%}
848
849class wxMetaFile : public wxObject {
850public:
851 wxMetaFile(const wxString& filename = wxPyEmptyString);
852};
853
854class wxMetaFileDC : public wxDC {
855public:
856 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
857 int width = 0, int height = 0,
858 const wxString& description = wxPyEmptyString);
859};
860
861
862#endif
863
864
865//---------------------------------------------------------------------------
866
ab1f7d2a
RD
867MustHaveApp(wxPrinterDC);
868
d14a1e28
RD
869#if defined(__WXMSW__) || defined(__WXMAC__)
870
871class wxPrinterDC : public wxDC {
872public:
873 wxPrinterDC(const wxPrintData& printData);
874// %name(PrinterDC2) wxPrinterDC(const wxString& driver,
875// const wxString& device,
876// const wxString& output,
dd9f7fea 877// bool interactive = True,
d14a1e28
RD
878// int orientation = wxPORTRAIT);
879};
880
881#else
882%{
883class wxPrinterDC : public wxClientDC {
884public:
885 wxPrinterDC(const wxPrintData&)
81cfe5e1 886 { wxPyRaiseNotImplemented(); }
4942342c 887
d14a1e28 888// wxPrinterDC(const wxString&, const wxString&, const wxString&, bool, int)
81cfe5e1 889// { wxPyRaiseNotImplemented(); }
d14a1e28
RD
890};
891%}
4942342c 892
d14a1e28
RD
893class wxPrinterDC : public wxDC {
894public:
895 wxPrinterDC(const wxPrintData& printData);
896// %name(PrinterDC2) wxPrinterDC(const wxString& driver,
897// const wxString& device,
898// const wxString& output,
dd9f7fea 899// bool interactive = True,
d14a1e28
RD
900// int orientation = wxPORTRAIT);
901};
902#endif
903
4942342c
RD
904//---------------------------------------------------------------------------
905//---------------------------------------------------------------------------
906
907// Now define some Python classes that rename the Draw methods to be
908// compatible with the DC Draw methods in 2.4. See also wxPython/_wx.py.
909
910
d7403ad2
RD
911#if 0
912
4942342c
RD
913%define MAKE_OLD_DC_CLASS(classname)
914 %pythoncode {
915 class classname##_old(classname):
916 """DC class that has methods with 2.4 compatible parameters."""
917 FloodFill = classname.FloodFillXY
918 GetPixel = classname.GetPixelXY
919 DrawLine = classname.DrawLineXY
920 CrossHair = classname.CrossHairXY
921 DrawArc = classname.DrawArcXY
922 DrawCheckMark = classname.DrawCheckMarkXY
923 DrawEllipticArc = classname.DrawEllipticArcXY
924 DrawPoint = classname.DrawPointXY
925 DrawRectangle = classname.DrawRectangleXY
926 DrawRoundedRectangle = classname.DrawRoundedRectangleXY
927 DrawCircle = classname.DrawCircleXY
928 DrawEllipse = classname.DrawEllipseXY
929 DrawIcon = classname.DrawIconXY
930 DrawBitmap = classname.DrawBitmapXY
931 DrawText = classname.DrawTextXY
932 DrawRotatedText = classname.DrawRotatedTextXY
933 Blit = classname.BlitXY
934 }
935%enddef
936
937MAKE_OLD_DC_CLASS(DC);
938MAKE_OLD_DC_CLASS(MemoryDC);
939MAKE_OLD_DC_CLASS(BufferedDC);
940MAKE_OLD_DC_CLASS(BufferedPaintDC);
941MAKE_OLD_DC_CLASS(ScreenDC);
942MAKE_OLD_DC_CLASS(ClientDC);
943MAKE_OLD_DC_CLASS(PaintDC);
944MAKE_OLD_DC_CLASS(WindowDC);
945MAKE_OLD_DC_CLASS(MirrorDC);
946MAKE_OLD_DC_CLASS(PostScriptDC);
947MAKE_OLD_DC_CLASS(MetaFileDC);
948MAKE_OLD_DC_CLASS(PrinterDC);
949
d7403ad2 950#endif
4942342c 951
d14a1e28 952//---------------------------------------------------------------------------