]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/_dc.i
wxScreenDC also needs a pango context and layout so it can do GetTextExtent
[wxWidgets.git] / wxPython / src / _dc.i
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: _dc.i
3// Purpose: SWIG interface defs for wxDC and releated classes
4//
5// Author: Robin Dunn
6//
7// Created: 7-July-1997
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16
17//---------------------------------------------------------------------------
18
19%{
20#include "wx/wxPython/pydrawxxx.h"
21%}
22
23// TODO: 1. wrappers for wxDrawObject and wxDC::DrawObject
24
25
26//---------------------------------------------------------------------------
27
28%typemap(in) (int points, wxPoint* points_array ) {
29 $2 = wxPoint_LIST_helper($input, &$1);
30 if ($2 == NULL) SWIG_fail;
31}
32%typemap(freearg) (int points, wxPoint* points_array ) {
33 if ($2) delete [] $2;
34}
35
36
37//---------------------------------------------------------------------------
38%newgroup;
39
40
41// 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
56#if defined(wxUSE_DC_OLD_METHODS)
57
58 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
59 %name(FloodFillPoint) bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE);
60
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 }
68 wxColour GetPixelPoint(const wxPoint& pt) {
69 wxColour col;
70 self->GetPixel(pt, &col);
71 return col;
72 }
73 }
74
75 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
76 %name(DrawLinePoint) void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
77
78 void CrossHair(wxCoord x, wxCoord y);
79 %name(CrossHairPoint) void CrossHair(const wxPoint& pt);
80
81 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
82 %name(DrawArcPoint) void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre);
83
84 void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
85 %name(DrawCheckMarkRect) void DrawCheckMark(const wxRect& rect);
86
87 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea);
88 %name(DrawEllipticArcPtSz) void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double sa, double ea);
89
90 void DrawPoint(wxCoord x, wxCoord y);
91 %name(DrawPointPoint) void DrawPoint(const wxPoint& pt);
92
93 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
94 %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect);
95 %name(DrawRectanglePtSz) void DrawRectangle(const wxPoint& pt, const wxSize& sz);
96
97 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius);
98 %name(DrawRoundedRectangleRect) void DrawRoundedRectangle(const wxRect& r, double radius);
99 %name(DrawRoundedRectanglePtSz) void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius);
100
101 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
102 %name(DrawCirclePoint) void DrawCircle(const wxPoint& pt, wxCoord radius);
103
104 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
105 %name(DrawEllipseRect) void DrawEllipse(const wxRect& rect);
106 %name(DrawEllipsePtSz) void DrawEllipse(const wxPoint& pt, const wxSize& sz);
107
108 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
109 %name(DrawIconPoint) void DrawIcon(const wxIcon& icon, const wxPoint& pt);
110
111 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = False);
112 %name(DrawBitmapPoint) void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = False);
113
114 void DrawText(const wxString& text, wxCoord x, wxCoord y);
115 %name(DrawTextPoint) void DrawText(const wxString& text, const wxPoint& pt);
116
117 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
118 %name(DrawRotatedTextPoint) void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle);
119
120 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
121 wxDC *source, wxCoord xsrc, wxCoord ysrc,
122 int rop = wxCOPY, bool useMask = False,
123 wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
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);
128
129
130
131#else // The new way
132
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 }
150
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
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);
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
196
197 %name(BlitXY) bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
198 wxDC *source, wxCoord xsrc, wxCoord ysrc,
199 int rop = wxCOPY, bool useMask = False,
200 wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
201 bool Blit(const wxPoint& destPt, const wxSize& sz,
202 wxDC *source, const wxPoint& srcPt,
203 int rop = wxCOPY, bool useMask = False,
204 const wxPoint& srcPtMask = wxDefaultPosition);
205
206#endif
207
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
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);
219
220
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
245
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
257
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
268
269 // clipping region
270 // ---------------
271
272 %name(SetClippingRegionXY)void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
273 void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
274 %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
275 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
276
277 virtual void DestroyClippingRegion();
278
279 DocDeclA(
280 void, GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const,
281 "GetClippingBox() -> (x, y, width, height)");
282
283 %extend {
284 wxRect GetClippingRect() {
285 wxRect rect;
286 self->GetClippingBox(rect);
287 return rect;
288 }
289 }
290
291
292
293 // text extent
294 // -----------
295
296 virtual wxCoord GetCharHeight() const;
297 virtual wxCoord GetCharWidth() const;
298
299
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,
307 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
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
314
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
324
325 %extend {
326 wxArrayInt GetPartialTextExtents(const wxString& text) {
327 wxArrayInt widths;
328 self->GetPartialTextExtents(text, widths);
329 return widths;
330 }
331 }
332
333
334 // size and resolution
335 // -------------------
336
337 DocStr(GetSize, "Get the DC size in device units.");
338 wxSize GetSize();
339 DocDeclAName(
340 void, GetSize( int *OUTPUT, int *OUTPUT ),
341 "GetSizeTuple() -> (width, height)",
342 GetSizeTuple);
343
344
345 DocStr(GetSizeMM, "Get the DC size in milimeters.");
346 wxSize GetSizeMM() const;
347 DocDeclAName(
348 void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const,
349 "GetSizeMMTuple() -> (width, height)",
350 GetSizeMMTuple);
351
352
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
382
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
398
399 DocDeclA(
400 virtual void, GetUserScale(double *OUTPUT, double *OUTPUT) const,
401 "GetUserScale() -> (xScale, yScale)");
402
403 virtual void SetUserScale(double x, double y);
404
405
406 DocDeclA(
407 virtual void, GetLogicalScale(double *OUTPUT, double *OUTPUT),
408 "GetLogicalScale() -> (xScale, yScale)");
409
410 virtual void SetLogicalScale(double x, double y);
411
412
413 wxPoint GetLogicalOrigin() const;
414 DocDeclAName(
415 void, GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
416 "GetLogicalOriginTuple() -> (x,y)",
417 GetLogicalOriginTuple);
418
419 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
420
421
422 wxPoint GetDeviceOrigin() const;
423 DocDeclAName(
424 void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
425 "GetDeviceOriginTuple() -> (x,y)",
426 GetDeviceOriginTuple);
427
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();
437
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
452 DocA(GetBoundingBox,
453 "GetBoundingBox() -> (x1,y1, x2,y2)");
454 %extend {
455 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
456 // See below for implementation
457 }
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):
548 %## Note: This does not currently support fill style or offset
549 %## you can always use the non-List version if need be.
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):
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.
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 = []
575 elif isinstance(foregrounds, wx.Colour):
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 = []
581 elif isinstance(backgrounds, wx.Colour):
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);
609
610 void SelectObject(const wxBitmap& bitmap);
611};
612
613//---------------------------------------------------------------------------
614%newgroup
615
616
617%{
618#include <wx/dcbuffer.h>
619%}
620
621
622class wxBufferedDC : public wxMemoryDC
623{
624public:
625 %pythonAppend wxBufferedDC
626 "self._dc = args[0] # save a ref so the other dc will not be deleted before self";
627
628 %nokwargs wxBufferedDC;
629
630 // Construct a wxBufferedDC using a user supplied buffer.
631 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
632
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)
636 wxBufferedDC( wxDC *dc, const wxSize &area );
637
638
639 // TODO: Keep this one too?
640 %pythonAppend wxBufferedDC( wxDC *dc, const wxSize &area )
641 "val._dc = args[0] # save a ref so the other dc will not be deleted before self";
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();
647
648
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.
654 void UnMask();
655};
656
657
658
659
660// Creates a double buffered wxPaintDC, optionally allowing the
661// user to specify their own buffer to use.
662class wxBufferedPaintDC : public wxBufferedDC
663{
664public:
665
666 // If no bitmap is supplied by the user, a temporary one will be created.
667 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
668
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 //
716 // if mirror parameter is True, all vertical and horizontal coordinates are
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,
734// bool interactive = True,
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
748#if defined(__WXMSW__) || defined(__WXMAC__)
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
766#ifdef __WXMSW__
767 const wxString& GetFileName() const;
768#endif
769
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&)
793 { wxPyRaiseNotImplemented(); }
794};
795
796class wxMetaFileDC : public wxClientDC {
797public:
798 wxMetaFileDC(const wxString&, int, int, const wxString&)
799 { wxPyRaiseNotImplemented(); }
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,
830// bool interactive = True,
831// int orientation = wxPORTRAIT);
832};
833
834#else
835%{
836class wxPrinterDC : public wxClientDC {
837public:
838 wxPrinterDC(const wxPrintData&)
839 { wxPyRaiseNotImplemented(); }
840
841// wxPrinterDC(const wxString&, const wxString&, const wxString&, bool, int)
842// { wxPyRaiseNotImplemented(); }
843};
844%}
845
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,
852// bool interactive = True,
853// int orientation = wxPORTRAIT);
854};
855#endif
856
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
902//---------------------------------------------------------------------------