]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/gdi.i
Fix broken binaries...
[wxWidgets.git] / wxPython / src / gdi.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gdi.i
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, etc.
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7/7/97
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13
14 %module gdi
15
16 %{
17 #include "helpers.h"
18 #include <wx/imaglist.h>
19 #include <wx/fontmap.h>
20 #include <wx/fontenc.h>
21 #include <wx/fontmap.h>
22 #include <wx/fontutil.h>
23 #include <wx/dcbuffer.h>
24 #include <wx/iconbndl.h>
25 %}
26
27 //----------------------------------------------------------------------
28
29 %include typemaps.i
30 %include my_typemaps.i
31
32 // Import some definitions of other classes, etc.
33 %import _defs.i
34 %import misc.i
35 %import fonts.i
36
37 %pragma(python) code = "import wx"
38
39 //---------------------------------------------------------------------------
40 %{
41 // Put some wx default wxChar* values into wxStrings.
42 static const wxString wxPyEmptyString(wxT(""));
43 %}
44 //---------------------------------------------------------------------------
45
46 class wxGDIObject : public wxObject {
47 public:
48 wxGDIObject();
49 ~wxGDIObject();
50
51 bool GetVisible();
52 void SetVisible( bool visible );
53
54 bool IsNull();
55
56 };
57
58 //---------------------------------------------------------------------------
59
60 class wxBitmap : public wxGDIObject
61 {
62 public:
63 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
64 ~wxBitmap();
65
66 wxPalette* GetPalette();
67 wxMask* GetMask();
68 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
69 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
70 void SetMask(wxMask* mask);
71 %pragma(python) addtoclass = "
72 def SetMaskColour(self, colour):
73 mask = wxMaskColour(self, colour)
74 self.SetMask(mask)
75 "
76 #ifdef __WXMSW__
77 void SetPalette(wxPalette& palette);
78 #endif
79
80 // wxGDIImage methods
81 #ifdef __WXMSW__
82 long GetHandle();
83 void SetHandle(long handle);
84 #endif
85 bool Ok();
86 int GetWidth();
87 int GetHeight();
88 int GetDepth();
89 void SetWidth(int w);
90 void SetHeight(int h);
91 void SetDepth(int d);
92 #ifdef __WXMSW__
93 void SetSize(const wxSize& size);
94 #endif
95
96 wxBitmap GetSubBitmap( const wxRect& rect );
97 bool CopyFromIcon(const wxIcon& icon);
98 #ifdef __WXMSW__
99 bool CopyFromCursor(const wxCursor& cursor);
100 int GetQuality();
101 void SetQuality(int q);
102 #endif
103
104 };
105
106
107 // Declarations of some alternate "constructors"
108 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
109 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
110 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
111 %new wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 );
112
113 // #ifdef __WXMSW__
114 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
115 // int width, int height, int depth = 1);
116 // #endif
117
118
119
120 %{ // Implementations of some alternate "constructors"
121
122 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
123 return new wxBitmap(width, height, depth);
124 }
125
126 static char** ConvertListOfStrings(PyObject* listOfStrings) {
127 char** cArray = NULL;
128 int count;
129
130 if (!PyList_Check(listOfStrings)) {
131 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
132 return NULL;
133 }
134 count = PyList_Size(listOfStrings);
135 cArray = new char*[count];
136
137 for(int x=0; x<count; x++) {
138 // TODO: Need some validation and error checking here
139 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
140 }
141 return cArray;
142 }
143
144
145 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
146 char** cArray = NULL;
147 wxBitmap* bmp;
148
149 cArray = ConvertListOfStrings(listOfStrings);
150 if (! cArray)
151 return NULL;
152 bmp = new wxBitmap(cArray);
153 delete [] cArray;
154 return bmp;
155 }
156
157
158 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
159 return new wxBitmap(icon);
160 }
161
162
163 wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ) {
164 char* buf;
165 int length;
166 PyString_AsStringAndSize(bits, &buf, &length);
167 return new wxBitmap(buf, width, height, depth);
168 }
169
170
171 // #ifdef __WXMSW__
172 // wxBitmap* wxBitmapFromData(PyObject* data, long type,
173 // int width, int height, int depth = 1) {
174 // if (! PyString_Check(data)) {
175 // PyErr_SetString(PyExc_TypeError, "Expected string object");
176 // return NULL;
177 // }
178 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
179 // }
180 // #endif
181 %}
182
183 //---------------------------------------------------------------------------
184
185 class wxMask : public wxObject {
186 public:
187 wxMask(const wxBitmap& bitmap);
188 //~wxMask();
189
190 %addmethods { void Destroy() { delete self; } }
191 };
192
193 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
194 %{
195 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
196 return new wxMask(bitmap, colour);
197 }
198 %}
199
200
201 //---------------------------------------------------------------------------
202
203
204 class wxIcon : public wxGDIObject
205 {
206 public:
207 wxIcon(const wxString& name, long flags,
208 int desiredWidth = -1, int desiredHeight = -1);
209 ~wxIcon();
210
211 #ifndef __WXMAC__
212 bool LoadFile(const wxString& name, long flags);
213 #endif
214
215 // wxGDIImage methods
216 #ifdef __WXMSW__
217 long GetHandle();
218 void SetHandle(long handle);
219 #endif
220 bool Ok();
221 int GetWidth();
222 int GetHeight();
223 int GetDepth();
224 void SetWidth(int w);
225 void SetHeight(int h);
226 void SetDepth(int d);
227 #ifdef __WXMSW__
228 void SetSize(const wxSize& size);
229 #endif
230 void CopyFromBitmap(const wxBitmap& bmp);
231
232 };
233
234
235 // Declarations of some alternate "constructors"
236 %new wxIcon* wxEmptyIcon();
237 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
238 %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
239
240 %{ // Implementations of some alternate "constructors"
241 wxIcon* wxEmptyIcon() {
242 return new wxIcon();
243 }
244
245 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
246 char** cArray = NULL;
247 wxIcon* icon;
248
249 cArray = ConvertListOfStrings(listOfStrings);
250 if (! cArray)
251 return NULL;
252 icon = new wxIcon(cArray);
253 delete [] cArray;
254 return icon;
255 }
256
257 wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
258 wxIcon* icon = new wxIcon();
259 icon->CopyFromBitmap(bmp);
260 return icon;
261 }
262 %}
263
264 //---------------------------------------------------------------------------
265
266 class wxIconBundle
267 {
268 public:
269 // default constructor
270 wxIconBundle();
271
272 // initializes the bundle with the icon(s) found in the file
273 %name(wxIconBundleFromFile) wxIconBundle( const wxString& file, long type );
274
275 // initializes the bundle with a single icon
276 %name(wxIconBundleFromIcon)wxIconBundle( const wxIcon& icon );
277
278 ~wxIconBundle();
279
280 // adds the icon to the collection, if the collection already
281 // contains an icon with the same width and height, it is
282 // replaced
283 void AddIcon( const wxIcon& icon );
284
285 // adds all the icons contained in the file to the collection,
286 // if the collection already contains icons with the same
287 // width and height, they are replaced
288 %name(AddIconFromFile)void AddIcon( const wxString& file, long type );
289
290 // returns the icon with the given size; if no such icon exists,
291 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
292 // returns the first icon in the bundle
293 const wxIcon& GetIcon( const wxSize& size ) const;
294 };
295
296 //---------------------------------------------------------------------------
297
298 class wxCursor : public wxGDIObject
299 {
300 public:
301 #ifdef __WXMSW__
302 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
303 #endif
304 ~wxCursor();
305
306 // wxGDIImage methods
307 #ifdef __WXMSW__
308 long GetHandle();
309 void SetHandle(long handle);
310 #endif
311 bool Ok();
312 #ifdef __WXMSW__
313 int GetWidth();
314 int GetHeight();
315 int GetDepth();
316 void SetWidth(int w);
317 void SetHeight(int h);
318 void SetDepth(int d);
319 void SetSize(const wxSize& size);
320 #endif
321 };
322
323 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
324 %{ // Alternate 'constructor'
325 wxCursor* wxPyStockCursor(int id) {
326 return new wxCursor(id);
327 }
328 %}
329
330 %new wxCursor* wxCursorFromImage(const wxImage& image);
331 %{
332 wxCursor* wxCursorFromImage(const wxImage& image) {
333 #ifndef __WXMAC__
334 return new wxCursor(image);
335 #else
336 return NULL;
337 #endif
338 }
339 %}
340
341 //----------------------------------------------------------------------
342
343 class wxColour : public wxObject {
344 public:
345 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
346 ~wxColour();
347 unsigned char Red();
348 unsigned char Green();
349 unsigned char Blue();
350 bool Ok();
351 void Set(unsigned char red, unsigned char green, unsigned char blue);
352 %addmethods {
353 PyObject* Get() {
354 PyObject* rv = PyTuple_New(3);
355 int red = -1;
356 int green = -1;
357 int blue = -1;
358 if (self->Ok()) {
359 red = self->Red();
360 green = self->Green();
361 blue = self->Blue();
362 }
363 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
364 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
365 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
366 return rv;
367 }
368 bool __eq__(PyObject* obj) {
369 wxColour tmp;
370 wxColour* ptr = &tmp;
371 if (obj == Py_None) return FALSE;
372 wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
373 if (! success) return FALSE;
374 return *self == *ptr;
375 }
376 bool __ne__(PyObject* obj) {
377 wxColour tmp;
378 wxColour* ptr = &tmp;
379 if (obj == Py_None) return TRUE;
380 wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
381 if (! success) return TRUE;
382 return *self != *ptr;
383 }
384 }
385
386 %pragma(python) addtoclass = "asTuple = Get
387 def __str__(self): return str(self.asTuple())
388 def __repr__(self): return 'wxColour:' + str(self.asTuple())
389 def __nonzero__(self): return self.Ok()
390 def __getinitargs__(self): return ()
391 def __getstate__(self): return self.asTuple()
392 def __setstate__(self, state): self.Set(*state)
393 "
394
395 };
396
397 %new wxColour* wxNamedColour(const wxString& colorName);
398
399 %{ // Alternate 'constructor'
400 wxColour* wxNamedColour(const wxString& colorName) {
401 return new wxColour(colorName);
402 }
403 %}
404
405
406
407 class wxColourDatabase : public wxObject {
408 public:
409
410 wxColour *FindColour(const wxString& colour);
411 wxString FindName(const wxColour& colour) const;
412
413 %addmethods {
414 void Append(const wxString& name, int red, int green, int blue) {
415 // first see if the name is already there
416 wxString cName = name;
417 cName.MakeUpper();
418 wxString cName2 = cName;
419 if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
420 cName2.clear();
421
422 wxNode *node = self->GetFirst();
423 while ( node ) {
424 const wxChar *key = node->GetKeyString();
425 if ( cName == key || cName2 == key ) {
426 wxColour* c = (wxColour *)node->GetData();
427 c->Set(red, green, blue);
428 return;
429 }
430 node = node->GetNext();
431 }
432
433 // otherwise append the new colour
434 self->Append(name.c_str(), new wxColour(red, green, blue));
435 }
436 }
437 };
438
439
440 //----------------------------------------------------------------------
441
442 class wxPen : public wxGDIObject {
443 public:
444 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
445 ~wxPen();
446
447 int GetCap();
448 wxColour GetColour();
449
450 int GetJoin();
451 int GetStyle();
452 int GetWidth();
453 bool Ok();
454 void SetCap(int cap_style);
455 void SetColour(wxColour& colour);
456 void SetJoin(int join_style);
457 void SetStyle(int style);
458 void SetWidth(int width);
459
460
461 void SetDashes(int LCOUNT, wxDash* choices);
462 //int GetDashes(wxDash **dashes);
463 %addmethods {
464 PyObject* GetDashes() {
465 wxDash* dashes;
466 int count = self->GetDashes(&dashes);
467 wxPyBeginBlockThreads();
468 PyObject* retval = PyList_New(0);
469 for (int x=0; x<count; x++)
470 PyList_Append(retval, PyInt_FromLong(dashes[x]));
471 wxPyEndBlockThreads();
472 return retval;
473 }
474 }
475
476 #ifdef __WXMSW__
477 wxBitmap* GetStipple();
478 void SetStipple(wxBitmap& stipple);
479 #endif
480 };
481
482
483
484
485 // The list of ints for the dashes needs to exist for the life of the pen
486 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
487 // in _extras.py
488
489 %{
490 class wxPyPen : public wxPen {
491 public:
492 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
493 : wxPen(colour, width, style)
494 { m_dash = NULL; }
495 ~wxPyPen() {
496 if (m_dash)
497 delete [] m_dash;
498 }
499
500 void SetDashes(int nb_dashes, const wxDash *dash) {
501 if (m_dash)
502 delete [] m_dash;
503 m_dash = new wxDash[nb_dashes];
504 for (int i=0; i<nb_dashes; i++) {
505 m_dash[i] = dash[i];
506 }
507 wxPen::SetDashes(nb_dashes, m_dash);
508 }
509
510 private:
511 wxDash* m_dash;
512 };
513 %}
514
515
516 class wxPyPen : public wxPen {
517 public:
518 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
519 ~wxPyPen();
520
521 void SetDashes(int LCOUNT, wxDash* choices);
522 };
523
524
525
526
527 class wxPenList : public wxObject {
528 public:
529
530 void AddPen(wxPen* pen);
531 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
532 void RemovePen(wxPen* pen);
533
534 int GetCount();
535 };
536
537
538
539 //----------------------------------------------------------------------
540
541 class wxBrush : public wxGDIObject {
542 public:
543 wxBrush(const wxColour& colour, int style=wxSOLID);
544 ~wxBrush();
545
546 wxColour GetColour();
547 wxBitmap * GetStipple();
548 int GetStyle();
549 bool Ok();
550 void SetColour(wxColour &colour);
551 void SetStipple(wxBitmap& bitmap);
552 void SetStyle(int style);
553 };
554
555
556 class wxBrushList : public wxObject {
557 public:
558
559 void AddBrush(wxBrush *brush);
560 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
561 void RemoveBrush(wxBrush *brush);
562
563 int GetCount();
564 };
565
566 //----------------------------------------------------------------------
567
568
569 class wxDC : public wxObject {
570 public:
571 // wxDC(); **** abstract base class, can't instantiate.
572 ~wxDC();
573
574 void BeginDrawing();
575
576 // %name(BlitXY)
577 bool Blit(wxCoord xdest, wxCoord ydest,
578 wxCoord width, wxCoord height,
579 wxDC *source, wxCoord xsrc, wxCoord ysrc,
580 int logicalFunc = wxCOPY, int useMask = FALSE);
581 // bool Blit(const wxPoint& destPt, const wxSize& sz,
582 // wxDC *source, const wxPoint& srcPt,
583 // int logicalFunc = wxCOPY, int useMask = FALSE);
584
585 void Clear();
586 void CrossHair(wxCoord x, wxCoord y);
587 void DestroyClippingRegion();
588 wxCoord DeviceToLogicalX(wxCoord x);
589 wxCoord DeviceToLogicalXRel(wxCoord x);
590 wxCoord DeviceToLogicalY(wxCoord y);
591 wxCoord DeviceToLogicalYRel(wxCoord y);
592 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
593 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
594 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
595 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord start, wxCoord end);
596 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
597
598 void DrawLabel(const wxString& text, const wxRect& rect,
599 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
600 int indexAccel = -1);
601
602 %addmethods {
603 wxRect DrawImageLabel(const wxString& text,
604 const wxBitmap& image,
605 const wxRect& rect,
606 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
607 int indexAccel = -1) {
608 wxRect rv;
609 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
610 return rv;
611 }
612 }
613
614 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
615 void DrawLines(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0);
616 void DrawPolygon(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0,
617 int fill_style=wxODDEVEN_RULE);
618 void DrawPoint(wxCoord x, wxCoord y);
619 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
620 %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect);
621 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
622 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord radius=20);
623 void DrawSpline(int PCOUNT, wxPoint* points);
624 void DrawText(const wxString& text, wxCoord x, wxCoord y);
625 void EndDoc();
626 void EndDrawing();
627 void EndPage();
628 bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, int style=wxFLOOD_SURFACE);
629 wxBrush GetBackground();
630 wxBrush GetBrush();
631 wxCoord GetCharHeight();
632 wxCoord GetCharWidth();
633 void GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT,
634 wxCoord *OUTPUT, wxCoord *OUTPUT);
635 wxFont GetFont();
636 int GetLogicalFunction();
637 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
638 int GetMapMode();
639 bool GetOptimization();
640 wxPen GetPen();
641 %addmethods {
642 %new wxColour* GetPixel(wxCoord x, wxCoord y) {
643 wxColour* wc = new wxColour();
644 self->GetPixel(x, y, wc);
645 return wc;
646 }
647 }
648 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
649 wxSize GetSize();
650 wxSize GetSizeMM();
651 wxColour GetTextBackground();
652 void GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT);
653 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
654 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
655 const wxFont* font = NULL);
656 void GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT,
657 wxFont *font = NULL);
658 wxColour GetTextForeground();
659 void GetUserScale(double *OUTPUT, double *OUTPUT);
660 wxCoord LogicalToDeviceX(wxCoord x);
661 wxCoord LogicalToDeviceXRel(wxCoord x);
662 wxCoord LogicalToDeviceY(wxCoord y);
663 wxCoord LogicalToDeviceYRel(wxCoord y);
664 wxCoord MaxX();
665 wxCoord MaxY();
666 wxCoord MinX();
667 wxCoord MinY();
668 bool Ok();
669 void SetDeviceOrigin(wxCoord x, wxCoord y);
670 void SetBackground(const wxBrush& brush);
671 void SetBackgroundMode(int mode);
672 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
673 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
674 %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
675 void SetPalette(const wxPalette& colourMap);
676 void SetBrush(const wxBrush& brush);
677 void SetFont(const wxFont& font);
678 void SetLogicalFunction(int function);
679 void SetLogicalScale(double x, double y);
680 void SetMapMode(int mode);
681 void SetOptimization(bool optimize);
682 void SetPen(const wxPen& pen);
683 void SetTextBackground(const wxColour& colour);
684 void SetTextForeground(const wxColour& colour);
685 void SetUserScale(double x_scale, double y_scale);
686 bool StartDoc(const wxString& message);
687 void StartPage();
688
689
690
691 void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y,
692 int useMask = FALSE);
693
694 bool CanDrawBitmap();
695 bool CanGetTextExtent();
696 int GetDepth();
697 wxSize GetPPI();
698
699 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
700 void SetLogicalOrigin(int x, int y);
701 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
702 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
703
704 void CalcBoundingBox(int x, int y);
705 void ResetBoundingBox();
706
707 %addmethods {
708 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
709 // See below for implementation
710 }
711
712 #ifdef __WXMSW__
713 long GetHDC();
714 #endif
715
716
717 %addmethods { // See drawlist.cpp for impplementaion of these...
718
719 PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
720 {
721 return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes);
722 }
723
724 PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
725 {
726 return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes);
727 }
728
729 PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
730 {
731 return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes);
732 }
733
734 PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
735 {
736 return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes);
737 }
738
739 PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
740 {
741 return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes);
742 }
743
744 PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints,
745 PyObject* foregroundList, PyObject* backgroundList) {
746 return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList);
747 }
748 }
749
750 %pragma(python) addtoclass = "
751 def DrawPointList(self, points, pens=None):
752 if pens is None:
753 pens = []
754 elif isinstance(pens, wxPenPtr):
755 pens = [pens]
756 elif len(pens) != len(points):
757 raise ValueError('points and pens must have same length')
758 return self._DrawPointList(points, pens, [])
759
760
761 def DrawLineList(self, lines, pens=None):
762 if pens is None:
763 pens = []
764 elif isinstance(pens, wxPenPtr):
765 pens = [pens]
766 elif len(pens) != len(lines):
767 raise ValueError('lines and pens must have same length')
768 return self._DrawLineList(lines, pens, [])
769
770
771 def DrawRectangleList(self, rectangles, pens=None, brushes=None):
772 if pens is None:
773 pens = []
774 elif isinstance(pens, wxPenPtr):
775 pens = [pens]
776 elif len(pens) != len(rectangles):
777 raise ValueError('rectangles and pens must have same length')
778 if brushes is None:
779 brushes = []
780 elif isinstance(brushes, wxBrushPtr):
781 brushes = [brushes]
782 elif len(brushes) != len(rectangles):
783 raise ValueError('rectangles and brushes must have same length')
784 return self._DrawRectangleList(rectangles, pens, brushes)
785
786
787 def DrawEllipseList(self, ellipses, pens=None, brushes=None):
788 if pens is None:
789 pens = []
790 elif isinstance(pens, wxPenPtr):
791 pens = [pens]
792 elif len(pens) != len(ellipses):
793 raise ValueError('ellipses and pens must have same length')
794 if brushes is None:
795 brushes = []
796 elif isinstance(brushes, wxBrushPtr):
797 brushes = [brushes]
798 elif len(brushes) != len(ellipses):
799 raise ValueError('ellipses and brushes must have same length')
800 return self._DrawEllipseList(ellipses, pens, brushes)
801
802
803 def DrawPolygonList(self, polygons, pens=None, brushes=None):
804 ## Note: This does not currently support fill style or offset
805 ## you can always use the non-List version if need be.
806 ## I really would like to support fill-style, however,
807 ## but wxODDEVEN_RULE does not appear to be defined at the Python level
808 ## [It's in wx.py... --Robin]
809 if pens is None:
810 pens = []
811 elif isinstance(pens, wxPenPtr):
812 pens = [pens]
813 elif len(pens) != len(polygons):
814 raise ValueError('polygons and pens must have same length')
815 if brushes is None:
816 brushes = []
817 elif isinstance(brushes, wxBrushPtr):
818 brushes = [brushes]
819 elif len(brushes) != len(polygons):
820 raise ValueError('polygons and brushes must have same length')
821 return self._DrawPolygonList(polygons, pens, brushes)
822
823
824 def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None):
825 ## NOTE: this does not currently support changing the font
826 ## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode)
827 ## If you want backgounds to do anything.
828 if type(textList) == type(''):
829 textList = [textList]
830 elif len(textList) != len(coords):
831 raise ValueError('textlist and coords must have same length')
832 if foregrounds is None:
833 foregrounds = []
834 elif isinstance(foregrounds, wxColourPtr):
835 foregrounds = [foregrounds]
836 elif len(foregrounds) != len(coords):
837 raise ValueError('foregrounds and coords must have same length')
838 if backgrounds is None:
839 backgrounds = []
840 elif isinstance(backgrounds, wxColourPtr):
841 backgrounds = [backgrounds]
842 elif len(backgrounds) != len(coords):
843 raise ValueError('backgrounds and coords must have same length')
844 return self._DrawTextList(textList, coords, foregrounds, backgrounds)
845 "
846
847
848 };
849
850
851
852 %{
853 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
854 *x1 = dc->MinX();
855 *y1 = dc->MinY();
856 *x2 = dc->MaxX();
857 *y2 = dc->MaxY();
858 }
859 %}
860
861 //----------------------------------------------------------------------
862
863 class wxMemoryDC : public wxDC {
864 public:
865 wxMemoryDC();
866
867 void SelectObject(const wxBitmap& bitmap);
868 }
869
870 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
871 %{ // Alternate 'constructor'
872 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
873 return new wxMemoryDC(oldDC);
874 }
875 %}
876
877
878 //---------------------------------------------------------------------------
879
880 class wxBufferedDC : public wxMemoryDC {
881 public:
882 // Construct a wxBufferedDC using a user supplied buffer.
883 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
884
885 // Construct a wxBufferedDC with an internal buffer of 'area'
886 // (where area is usually something like the size of the window
887 // being buffered)
888 %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area );
889
890 // Blits the buffer to the dc, and detaches the dc from
891 // the buffer. Usually called in the dtor or by the dtor
892 // of derived classes if the BufferedDC must blit before
893 // the derived class (which may own the dc it's blitting
894 // to) is destroyed.
895 void UnMask();
896
897
898 %pragma(python) addtomethod =
899 "__init__:self._dc = _args[0] # save a ref so the other dc won't be deleted before self"
900 %pragma(python) addtomethod =
901 "wxBufferedDCInternalBuffer:val._dc = _args[0] # save a ref so the other dc won't be deleted before self"
902 };
903
904
905 class wxBufferedPaintDC : public wxBufferedDC
906 {
907 public:
908 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
909 };
910
911 //---------------------------------------------------------------------------
912
913 class wxScreenDC : public wxDC {
914 public:
915 wxScreenDC();
916
917 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
918 bool StartDrawingOnTop(wxRect* rect = NULL);
919 bool EndDrawingOnTop();
920 };
921
922 //---------------------------------------------------------------------------
923
924 class wxClientDC : public wxDC {
925 public:
926 wxClientDC(wxWindow* win);
927 };
928
929 //---------------------------------------------------------------------------
930
931 class wxPaintDC : public wxDC {
932 public:
933 wxPaintDC(wxWindow* win);
934 };
935
936 //---------------------------------------------------------------------------
937
938 class wxWindowDC : public wxDC {
939 public:
940 wxWindowDC(wxWindow* win);
941 };
942
943 //---------------------------------------------------------------------------
944
945
946 #ifdef __WXMSW__
947
948 %{
949 #include <wx/metafile.h>
950 %}
951
952 class wxMetaFile : public wxObject {
953 public:
954 wxMetaFile(const wxString& filename = wxPyEmptyString);
955 ~wxMetaFile();
956
957 bool Ok();
958 bool SetClipboard(int width = 0, int height = 0);
959
960 wxSize GetSize();
961 int GetWidth();
962 int GetHeight();
963
964 const wxString& GetFileName() const { return m_filename; }
965
966 };
967
968 // bool wxMakeMetaFilePlaceable(const wxString& filename,
969 // int minX, int minY, int maxX, int maxY, float scale=1.0);
970
971
972 class wxMetaFileDC : public wxDC {
973 public:
974 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
975 int width = 0, int height = 0,
976 const wxString& description = wxPyEmptyString);
977 wxMetaFile* Close();
978 };
979
980 #endif
981
982 //---------------------------------------------------------------------------
983
984 class wxPalette : public wxGDIObject {
985 public:
986 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
987 ~wxPalette();
988
989 int GetPixel(byte red, byte green, byte blue);
990 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
991 bool Ok();
992 };
993
994 //---------------------------------------------------------------------------
995
996 enum {
997 wxIMAGELIST_DRAW_NORMAL ,
998 wxIMAGELIST_DRAW_TRANSPARENT,
999 wxIMAGELIST_DRAW_SELECTED,
1000 wxIMAGELIST_DRAW_FOCUSED,
1001 wxIMAGE_LIST_NORMAL,
1002 wxIMAGE_LIST_SMALL,
1003 wxIMAGE_LIST_STATE
1004 };
1005
1006 class wxImageList : public wxObject {
1007 public:
1008 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1009 ~wxImageList();
1010
1011 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1012 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1013 %name(AddIcon)int Add(const wxIcon& icon);
1014 #ifdef __WXMSW__
1015 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1016 #else
1017 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1018 // int Add(const wxBitmap& bitmap);
1019 bool Replace(int index, const wxBitmap& bitmap);
1020 #endif
1021
1022 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1023 const bool solidBackground = FALSE);
1024
1025 int GetImageCount();
1026 bool Remove(int index);
1027 bool RemoveAll();
1028 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1029 };
1030
1031
1032 //---------------------------------------------------------------------------
1033 // Regions, etc.
1034
1035 enum wxRegionContain {
1036 wxOutRegion, wxPartRegion, wxInRegion
1037 };
1038
1039
1040 class wxRegion : public wxGDIObject {
1041 public:
1042 wxRegion(wxCoord x=0, wxCoord y=0, wxCoord width=0, wxCoord height=0);
1043 #ifndef __WXMAC__
1044 %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE);
1045 #endif
1046 ~wxRegion();
1047
1048 void Clear();
1049 #ifndef __WXMAC__
1050 bool Offset(wxCoord x, wxCoord y);
1051 #endif
1052
1053 wxRegionContain Contains(wxCoord x, wxCoord y);
1054 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1055 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1056 %name(ContainsRectDim)wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
1057
1058 wxRect GetBox();
1059
1060 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1061 %name(IntersectRect)bool Intersect(const wxRect& rect);
1062 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1063
1064 bool IsEmpty();
1065
1066 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1067 %name(UnionRect)bool Union(const wxRect& rect);
1068 %name(UnionRegion)bool Union(const wxRegion& region);
1069
1070 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1071 %name(SubtractRect)bool Subtract(const wxRect& rect);
1072 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1073
1074 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1075 %name(XorRect)bool Xor(const wxRect& rect);
1076 %name(XorRegion)bool Xor(const wxRegion& region);
1077 };
1078
1079
1080
1081 class wxRegionIterator : public wxObject {
1082 public:
1083 wxRegionIterator(const wxRegion& region);
1084 ~wxRegionIterator();
1085
1086 wxCoord GetX();
1087 wxCoord GetY();
1088 wxCoord GetW();
1089 wxCoord GetWidth();
1090 wxCoord GetH();
1091 wxCoord GetHeight();
1092 wxRect GetRect();
1093 bool HaveRects();
1094 void Reset();
1095
1096 %addmethods {
1097 void Next() {
1098 (*self) ++;
1099 }
1100 };
1101 };
1102
1103
1104 //---------------------------------------------------------------------------
1105
1106 %readonly
1107 %{
1108 #if 0
1109 %}
1110
1111 extern wxFont *wxNORMAL_FONT;
1112 extern wxFont *wxSMALL_FONT;
1113 extern wxFont *wxITALIC_FONT;
1114 extern wxFont *wxSWISS_FONT;
1115
1116 extern wxPen *wxRED_PEN;
1117 extern wxPen *wxCYAN_PEN;
1118 extern wxPen *wxGREEN_PEN;
1119 extern wxPen *wxBLACK_PEN;
1120 extern wxPen *wxWHITE_PEN;
1121 extern wxPen *wxTRANSPARENT_PEN;
1122 extern wxPen *wxBLACK_DASHED_PEN;
1123 extern wxPen *wxGREY_PEN;
1124 extern wxPen *wxMEDIUM_GREY_PEN;
1125 extern wxPen *wxLIGHT_GREY_PEN;
1126
1127 extern wxBrush *wxBLUE_BRUSH;
1128 extern wxBrush *wxGREEN_BRUSH;
1129 extern wxBrush *wxWHITE_BRUSH;
1130 extern wxBrush *wxBLACK_BRUSH;
1131 extern wxBrush *wxTRANSPARENT_BRUSH;
1132 extern wxBrush *wxCYAN_BRUSH;
1133 extern wxBrush *wxRED_BRUSH;
1134 extern wxBrush *wxGREY_BRUSH;
1135 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1136 extern wxBrush *wxLIGHT_GREY_BRUSH;
1137
1138 extern wxColour *wxBLACK;
1139 extern wxColour *wxWHITE;
1140 extern wxColour *wxRED;
1141 extern wxColour *wxBLUE;
1142 extern wxColour *wxGREEN;
1143 extern wxColour *wxCYAN;
1144 extern wxColour *wxLIGHT_GREY;
1145
1146 extern wxCursor *wxSTANDARD_CURSOR;
1147 extern wxCursor *wxHOURGLASS_CURSOR;
1148 extern wxCursor *wxCROSS_CURSOR;
1149
1150
1151 extern wxBitmap wxNullBitmap;
1152 extern wxIcon wxNullIcon;
1153 extern wxCursor wxNullCursor;
1154 extern wxPen wxNullPen;
1155 extern wxBrush wxNullBrush;
1156 extern wxPalette wxNullPalette;
1157 extern wxFont wxNullFont;
1158 extern wxColour wxNullColour;
1159
1160
1161 extern wxFontList* wxTheFontList;
1162 extern wxPenList* wxThePenList;
1163 extern wxBrushList* wxTheBrushList;
1164 extern wxColourDatabase* wxTheColourDatabase;
1165
1166
1167 %readwrite
1168 %{
1169 #endif
1170 %}
1171
1172 //---------------------------------------------------------------------------
1173 //---------------------------------------------------------------------------
1174