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