]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_dc.i
Updates for STCStyleEditor
[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
573 %{
574 //-=-=-=-=-=-=-=-=-=-=-
575
576 #if 1
577 // Use the standard wxBufferedDC
578 #include <wx/dcbuffer.h>
579
580 #else
581
582 // Or, temporarily put a set of classes here similar to the old buffered DC
583 // classes until the real ones can be fixed to work "correctly" again.
584
585 class wxBufferedDC : public wxMemoryDC
586 {
587 private:
588 wxDC *m_dc;
589 wxBitmap m_buffer;
590
591 public:
592
593 wxBufferedDC() : m_dc( 0 ) {}
594
595 wxBufferedDC( wxDC *dc, const wxBitmap &buffer )
596 : m_dc( dc ), m_buffer( buffer )
597 {
598 SelectObject( m_buffer );
599 }
600
601 wxBufferedDC( wxDC *dc, const wxSize &area )
602 : m_dc( dc ), m_buffer( area.GetWidth(), area.GetHeight() )
603 {
604 SelectObject( m_buffer );
605 }
606
607 ~wxBufferedDC() {
608 if( m_dc != 0 )
609 UnMask();
610 }
611
612
613 void Init( wxDC *dc, const wxBitmap &buffer ) {
614 wxASSERT_MSG( m_dc == 0 && m_buffer == wxNullBitmap,
615 _T("wxBufferedDC already initialised") );
616 m_dc = dc;
617 m_buffer = buffer;
618 SelectObject( m_buffer );
619 }
620
621 void Init( wxDC *dc, const wxSize &area ) {
622 wxASSERT_MSG( m_dc == 0 && m_buffer == wxNullBitmap,
623 _T("wxBufferedDC already initialised") );
624 m_dc = dc;
625 m_buffer = wxBitmap( area.GetWidth(), area.GetHeight() );
626 SelectObject( m_buffer );
627 }
628
629 void UnMask() {
630 wxASSERT_MSG( m_dc != 0, _T("No low level DC associated with buffer (anymore)") );
631 m_dc->Blit( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight(), this, 0, 0 );
632 m_dc = 0;
633 }
634 };
635
636
637 class wxBufferedPaintDC : public wxBufferedDC
638 {
639 private:
640 wxPaintDC m_paintdc;
641
642 public:
643 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap )
644 : m_paintdc( window )
645 {
646 window->PrepareDC( m_paintdc );
647
648 if( buffer != wxNullBitmap )
649 Init( &m_paintdc, buffer );
650 else
651 Init( &m_paintdc, window->GetClientSize() );
652 }
653
654 ~wxBufferedPaintDC() {
655 UnMask();
656 }
657 };
658
659 #endif
660 //-=-=-=-=-=-=-=-=-=-=-
661 %}
662
663
664
665
666 class wxBufferedDC : public wxMemoryDC
667 {
668 public:
669 %pythonAppend wxBufferedDC
670 "self._dc = args[0] # save a ref so the other dc will not be deleted before self";
671
672 %nokwargs wxBufferedDC;
673
674 // Construct a wxBufferedDC using a user supplied buffer.
675 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
676
677 // Construct a wxBufferedDC with an internal buffer of 'area'
678 // (where area is usually something like the size of the window
679 // being buffered)
680 wxBufferedDC( wxDC *dc, const wxSize &area );
681
682
683 // TODO: Keep this one too?
684 %pythonAppend wxBufferedDC( wxDC *dc, const wxSize &area )
685 "val._dc = args[0] # save a ref so the other dc will not be deleted before self";
686 %name(BufferedDCInternalBuffer) wxBufferedDC( wxDC *dc, const wxSize &area );
687
688
689 // The buffer is blit to the real DC when the BufferedDC is destroyed.
690 ~wxBufferedDC();
691
692
693 // Blits the buffer to the dc, and detaches the dc from
694 // the buffer. Usually called in the dtor or by the dtor
695 // of derived classes if the BufferedDC must blit before
696 // the derived class (which may own the dc it's blitting
697 // to) is destroyed.
698 void UnMask();
699 };
700
701
702
703
704 // Creates a double buffered wxPaintDC, optionally allowing the
705 // user to specify their own buffer to use.
706 class wxBufferedPaintDC : public wxBufferedDC
707 {
708 public:
709
710 // If no bitmap is supplied by the user, a temporary one will be created.
711 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
712
713 };
714
715
716 //---------------------------------------------------------------------------
717 %newgroup
718
719 class wxScreenDC : public wxDC {
720 public:
721 wxScreenDC();
722
723 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
724 bool StartDrawingOnTop(wxRect* rect = NULL);
725 bool EndDrawingOnTop();
726 };
727
728 //---------------------------------------------------------------------------
729 %newgroup
730
731 class wxClientDC : public wxDC {
732 public:
733 wxClientDC(wxWindow* win);
734 };
735
736 //---------------------------------------------------------------------------
737 %newgroup
738
739 class wxPaintDC : public wxDC {
740 public:
741 wxPaintDC(wxWindow* win);
742 };
743
744 //---------------------------------------------------------------------------
745 %newgroup
746
747 class wxWindowDC : public wxDC {
748 public:
749 wxWindowDC(wxWindow* win);
750 };
751
752 //---------------------------------------------------------------------------
753 %newgroup
754
755 class wxMirrorDC : public wxDC
756 {
757 public:
758 // constructs a mirror DC associated with the given real DC
759 //
760 // if mirror parameter is True, all vertical and horizontal coordinates are
761 // exchanged, otherwise this class behaves in exactly the same way as a
762 // plain DC
763 //
764 wxMirrorDC(wxDC& dc, bool mirror);
765 };
766
767 //---------------------------------------------------------------------------
768 %newgroup
769
770 %{
771 #include <wx/dcps.h>
772 %}
773
774 class wxPostScriptDC : public wxDC {
775 public:
776 wxPostScriptDC(const wxPrintData& printData);
777 // %name(PostScriptDC2)wxPostScriptDC(const wxString& output,
778 // bool interactive = True,
779 // wxWindow* parent = NULL);
780
781 wxPrintData& GetPrintData();
782 void SetPrintData(const wxPrintData& data);
783
784 static void SetResolution(int ppi);
785 static int GetResolution();
786 };
787
788 //---------------------------------------------------------------------------
789 %newgroup
790
791
792 #ifdef __WXMSW__
793
794 %{
795 #include <wx/metafile.h>
796 %}
797
798 class wxMetaFile : public wxObject {
799 public:
800 wxMetaFile(const wxString& filename = wxPyEmptyString);
801 ~wxMetaFile();
802
803 bool Ok();
804 bool SetClipboard(int width = 0, int height = 0);
805
806 wxSize GetSize();
807 int GetWidth();
808 int GetHeight();
809
810 const wxString& GetFileName() const;
811
812 %pythoncode { def __nonzero__(self): return self.Ok() }
813 };
814
815 // bool wxMakeMetaFilePlaceable(const wxString& filename,
816 // int minX, int minY, int maxX, int maxY, float scale=1.0);
817
818
819 class wxMetaFileDC : public wxDC {
820 public:
821 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
822 int width = 0, int height = 0,
823 const wxString& description = wxPyEmptyString);
824 wxMetaFile* Close();
825 };
826
827
828
829 #else // Make some dummies for the other platforms
830
831 %{
832 class wxMetaFile : public wxObject {
833 public:
834 wxMetaFile(const wxString&)
835 { wxPyRaiseNotImplemented(); }
836 };
837
838 class wxMetaFileDC : public wxClientDC {
839 public:
840 wxMetaFileDC(const wxString&, int, int, const wxString&)
841 { wxPyRaiseNotImplemented(); }
842 };
843
844 %}
845
846 class wxMetaFile : public wxObject {
847 public:
848 wxMetaFile(const wxString& filename = wxPyEmptyString);
849 };
850
851 class wxMetaFileDC : public wxDC {
852 public:
853 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
854 int width = 0, int height = 0,
855 const wxString& description = wxPyEmptyString);
856 };
857
858
859 #endif
860
861
862 //---------------------------------------------------------------------------
863
864 #if defined(__WXMSW__) || defined(__WXMAC__)
865
866 class wxPrinterDC : public wxDC {
867 public:
868 wxPrinterDC(const wxPrintData& printData);
869 // %name(PrinterDC2) wxPrinterDC(const wxString& driver,
870 // const wxString& device,
871 // const wxString& output,
872 // bool interactive = True,
873 // int orientation = wxPORTRAIT);
874 };
875
876 #else
877 %{
878 class wxPrinterDC : public wxClientDC {
879 public:
880 wxPrinterDC(const wxPrintData&)
881 { wxPyRaiseNotImplemented(); }
882
883 // wxPrinterDC(const wxString&, const wxString&, const wxString&, bool, int)
884 // { wxPyRaiseNotImplemented(); }
885 };
886 %}
887
888 class wxPrinterDC : public wxDC {
889 public:
890 wxPrinterDC(const wxPrintData& printData);
891 // %name(PrinterDC2) wxPrinterDC(const wxString& driver,
892 // const wxString& device,
893 // const wxString& output,
894 // bool interactive = True,
895 // int orientation = wxPORTRAIT);
896 };
897 #endif
898
899 //---------------------------------------------------------------------------
900 //---------------------------------------------------------------------------
901
902 // Now define some Python classes that rename the Draw methods to be
903 // compatible with the DC Draw methods in 2.4. See also wxPython/_wx.py.
904
905
906 %define MAKE_OLD_DC_CLASS(classname)
907 %pythoncode {
908 class classname##_old(classname):
909 """DC class that has methods with 2.4 compatible parameters."""
910 FloodFill = classname.FloodFillXY
911 GetPixel = classname.GetPixelXY
912 DrawLine = classname.DrawLineXY
913 CrossHair = classname.CrossHairXY
914 DrawArc = classname.DrawArcXY
915 DrawCheckMark = classname.DrawCheckMarkXY
916 DrawEllipticArc = classname.DrawEllipticArcXY
917 DrawPoint = classname.DrawPointXY
918 DrawRectangle = classname.DrawRectangleXY
919 DrawRoundedRectangle = classname.DrawRoundedRectangleXY
920 DrawCircle = classname.DrawCircleXY
921 DrawEllipse = classname.DrawEllipseXY
922 DrawIcon = classname.DrawIconXY
923 DrawBitmap = classname.DrawBitmapXY
924 DrawText = classname.DrawTextXY
925 DrawRotatedText = classname.DrawRotatedTextXY
926 Blit = classname.BlitXY
927 }
928 %enddef
929
930 MAKE_OLD_DC_CLASS(DC);
931 MAKE_OLD_DC_CLASS(MemoryDC);
932 MAKE_OLD_DC_CLASS(BufferedDC);
933 MAKE_OLD_DC_CLASS(BufferedPaintDC);
934 MAKE_OLD_DC_CLASS(ScreenDC);
935 MAKE_OLD_DC_CLASS(ClientDC);
936 MAKE_OLD_DC_CLASS(PaintDC);
937 MAKE_OLD_DC_CLASS(WindowDC);
938 MAKE_OLD_DC_CLASS(MirrorDC);
939 MAKE_OLD_DC_CLASS(PostScriptDC);
940 MAKE_OLD_DC_CLASS(MetaFileDC);
941 MAKE_OLD_DC_CLASS(PrinterDC);
942
943
944 //---------------------------------------------------------------------------