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