1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, etc.
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
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/dcmirror.h>
25 #include <wx/iconbndl.h>
28 //----------------------------------------------------------------------
31 %include my_typemaps.i
33 // Import some definitions of other classes, etc.
38 %pragma(python) code = "import wx"
40 //---------------------------------------------------------------------------
42 // Put some wx default wxChar* values into wxStrings.
43 static const wxString wxPyEmptyString(wxT(""));
45 //---------------------------------------------------------------------------
47 class wxGDIObject : public wxObject {
53 void SetVisible( bool visible );
59 //---------------------------------------------------------------------------
62 // TODO: When the API stabalizes and is available on other platforms, add
63 // wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff...
65 class wxBitmap : public wxGDIObject
68 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
71 wxPalette* GetPalette();
73 bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
74 bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
75 void SetMask(wxMask* mask);
76 %pragma(python) addtoclass = "
77 def SetMaskColour(self, colour):
78 mask = wxMaskColour(self, colour)
82 void SetPalette(wxPalette& palette);
88 void SetHandle(long handle);
95 void SetHeight(int h);
98 void SetSize(const wxSize& size);
101 wxBitmap GetSubBitmap( const wxRect& rect );
102 bool CopyFromIcon(const wxIcon& icon);
104 bool CopyFromCursor(const wxCursor& cursor);
106 void SetQuality(int q);
109 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
113 // Declarations of some alternate "constructors"
114 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
115 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
116 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
117 %new wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 );
120 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
121 // int width, int height, int depth = 1);
126 %{ // Implementations of some alternate "constructors"
128 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
129 return new wxBitmap(width, height, depth);
132 static char** ConvertListOfStrings(PyObject* listOfStrings) {
133 char** cArray = NULL;
136 if (!PyList_Check(listOfStrings)) {
137 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
140 count = PyList_Size(listOfStrings);
141 cArray = new char*[count];
143 for(int x=0; x<count; x++) {
144 // TODO: Need some validation and error checking here
145 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
151 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
152 char** cArray = NULL;
155 cArray = ConvertListOfStrings(listOfStrings);
158 bmp = new wxBitmap(cArray);
164 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
165 return new wxBitmap(icon);
169 wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ) {
172 PyString_AsStringAndSize(bits, &buf, &length);
173 return new wxBitmap(buf, width, height, depth);
178 // wxBitmap* wxBitmapFromData(PyObject* data, long type,
179 // int width, int height, int depth = 1) {
180 // if (! PyString_Check(data)) {
181 // PyErr_SetString(PyExc_TypeError, "Expected string object");
184 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
189 //---------------------------------------------------------------------------
191 class wxMask : public wxObject {
193 wxMask(const wxBitmap& bitmap);
196 %addmethods { void Destroy() { delete self; } }
199 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
201 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
202 return new wxMask(bitmap, colour);
207 //---------------------------------------------------------------------------
210 class wxIcon : public wxGDIObject
213 wxIcon(const wxString& name, long flags,
214 int desiredWidth = -1, int desiredHeight = -1);
218 bool LoadFile(const wxString& name, long flags);
221 // wxGDIImage methods
224 void SetHandle(long handle);
230 void SetWidth(int w);
231 void SetHeight(int h);
232 void SetDepth(int d);
234 void SetSize(const wxSize& size);
236 void CopyFromBitmap(const wxBitmap& bmp);
238 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
242 // Declarations of some alternate "constructors"
243 %new wxIcon* wxEmptyIcon();
244 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
245 %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
246 %new wxIcon* wxIconFromLocation(const wxIconLocation& loc);
248 %{ // Implementations of some alternate "constructors"
249 wxIcon* wxEmptyIcon() {
253 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
254 char** cArray = NULL;
257 cArray = ConvertListOfStrings(listOfStrings);
260 icon = new wxIcon(cArray);
265 wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
266 wxIcon* icon = new wxIcon();
267 icon->CopyFromBitmap(bmp);
271 wxIcon* wxIconFromLocation(const wxIconLocation& loc) {
272 wxIcon* icon = new wxIcon(loc);
278 //---------------------------------------------------------------------------
283 // ctor takes the name of the file where the icon is
285 wxIconLocation(const wxString* filename = &wxPyEmptyString, int num = 0) {
287 return new wxIconLocation(*filename, num);
289 return new wxIconLocation(*filename);
297 // returns true if this object is valid/initialized
300 // set/get the icon file name
301 void SetFileName(const wxString& filename);
302 const wxString& GetFileName() const;
305 void SetIndex(int num) {
315 return self->GetIndex();
325 //---------------------------------------------------------------------------
330 // default constructor
333 // initializes the bundle with the icon(s) found in the file
334 %name(wxIconBundleFromFile) wxIconBundle( const wxString& file, long type );
336 // initializes the bundle with a single icon
337 %name(wxIconBundleFromIcon)wxIconBundle( const wxIcon& icon );
341 // adds the icon to the collection, if the collection already
342 // contains an icon with the same width and height, it is
344 void AddIcon( const wxIcon& icon );
346 // adds all the icons contained in the file to the collection,
347 // if the collection already contains icons with the same
348 // width and height, they are replaced
349 %name(AddIconFromFile)void AddIcon( const wxString& file, long type );
351 // returns the icon with the given size; if no such icon exists,
352 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
353 // returns the first icon in the bundle
354 const wxIcon& GetIcon( const wxSize& size ) const;
357 //---------------------------------------------------------------------------
359 class wxCursor : public wxGDIObject
363 wxCursor(const wxString* cursorName, long flags, int hotSpotX=0, int hotSpotY=0) {
365 wxCHECK_MSG(FALSE, NULL,
366 wxT("wxCursor constructor not implemented for wxGTK, use wxStockCursor, wxCursorFromImage, or wxCursorFromBits instead."));
368 return new wxCursor(*cursorName, flags, hotSpotX, hotSpotY);
375 // wxGDIImage methods
378 void SetHandle(long handle);
385 void SetWidth(int w);
386 void SetHeight(int h);
387 void SetDepth(int d);
388 void SetSize(const wxSize& size);
390 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
393 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
394 %new wxCursor* wxCursorFromImage(const wxImage& image);
395 %new wxCursor* wxCursorFromBits(PyObject* bits, int width, int height,
396 int hotSpotX=-1, int hotSpotY=-1,
397 PyObject* maskBits=0);
400 wxCursor* wxPyStockCursor(int id) {
401 return new wxCursor(id);
404 wxCursor* wxCursorFromImage(const wxImage& image) {
405 return new wxCursor(image);
408 wxCursor* wxCursorFromBits(PyObject* bits, int width, int height,
409 int hotSpotX=-1, int hotSpotY=-1,
410 PyObject* maskBits=0) {
412 char* maskbuf = NULL;
414 PyString_AsStringAndSize(bits, &bitsbuf, &length);
416 PyString_AsStringAndSize(maskBits, &maskbuf, &length);
417 return new wxCursor(bitsbuf, width, height, hotSpotX, hotSpotY, maskbuf);
421 //----------------------------------------------------------------------
423 class wxColour : public wxObject {
425 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
428 unsigned char Green();
429 unsigned char Blue();
431 void Set(unsigned char red, unsigned char green, unsigned char blue);
434 PyObject* rv = PyTuple_New(3);
440 green = self->Green();
443 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
444 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
445 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
448 bool __eq__(PyObject* obj) {
450 wxColour* ptr = &tmp;
451 if (obj == Py_None) return FALSE;
452 wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
453 if (! success) return FALSE;
454 return *self == *ptr;
456 bool __ne__(PyObject* obj) {
458 wxColour* ptr = &tmp;
459 if (obj == Py_None) return TRUE;
460 wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
461 if (! success) return TRUE;
462 return *self != *ptr;
466 %pragma(python) addtoclass = "asTuple = Get
467 def __str__(self): return str(self.asTuple())
468 def __repr__(self): return 'wxColour:' + str(self.asTuple())
469 def __nonzero__(self): return self.Ok()
470 def __getinitargs__(self): return ()
471 def __getstate__(self): return self.asTuple()
472 def __setstate__(self, state): self.Set(*state)
477 %new wxColour* wxNamedColour(const wxString& colorName);
479 %{ // Alternate 'constructor'
480 wxColour* wxNamedColour(const wxString& colorName) {
481 return new wxColour(colorName);
487 class wxColourDatabase : public wxObject {
490 wxColour *FindColour(const wxString& colour) ;
491 wxColour *FindColourNoAdd(const wxString& colour) const;
492 wxString FindName(const wxColour& colour) const;
495 void AddColour(const wxString& name, wxColour* colour) {
496 // make a copy since the python one will be GC'd
497 wxColour* c = new wxColour(*colour);
498 self->AddColour(name, c);
501 void Append(const wxString& name, int red, int green, int blue) {
502 wxColour* c = new wxColour(red, green, blue);
503 self->AddColour(name, c);
509 //----------------------------------------------------------------------
511 class wxPen : public wxGDIObject {
513 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
517 wxColour GetColour();
523 void SetCap(int cap_style);
524 void SetColour(wxColour& colour);
525 void SetJoin(int join_style);
526 void SetStyle(int style);
527 void SetWidth(int width);
530 void SetDashes(int LCOUNT, wxDash* choices);
531 //int GetDashes(wxDash **dashes);
533 PyObject* GetDashes() {
535 int count = self->GetDashes(&dashes);
536 wxPyBeginBlockThreads();
537 PyObject* retval = PyList_New(0);
538 for (int x=0; x<count; x++)
539 PyList_Append(retval, PyInt_FromLong(dashes[x]));
540 wxPyEndBlockThreads();
546 wxBitmap* GetStipple();
547 void SetStipple(wxBitmap& stipple);
550 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
556 // The list of ints for the dashes needs to exist for the life of the pen
557 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
561 class wxPyPen : public wxPen {
563 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
564 : wxPen(colour, width, style)
571 void SetDashes(int nb_dashes, const wxDash *dash) {
574 m_dash = new wxDash[nb_dashes];
575 for (int i=0; i<nb_dashes; i++) {
578 wxPen::SetDashes(nb_dashes, m_dash);
587 class wxPyPen : public wxPen {
589 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
592 void SetDashes(int LCOUNT, wxDash* choices);
598 class wxPenList : public wxObject {
601 void AddPen(wxPen* pen);
602 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
603 void RemovePen(wxPen* pen);
610 //----------------------------------------------------------------------
612 class wxBrush : public wxGDIObject {
614 wxBrush(const wxColour& colour, int style=wxSOLID);
617 wxColour GetColour();
618 wxBitmap * GetStipple();
621 void SetColour(wxColour &colour);
622 void SetStipple(wxBitmap& bitmap);
623 void SetStyle(int style);
627 void SetMacTheme(short macThemeBrush);
630 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
634 class wxBrushList : public wxObject {
637 void AddBrush(wxBrush *brush);
638 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
639 void RemoveBrush(wxBrush *brush);
644 //----------------------------------------------------------------------
647 class wxDC : public wxObject {
649 // wxDC(); **** abstract base class, can't instantiate.
655 bool Blit(wxCoord xdest, wxCoord ydest,
656 wxCoord width, wxCoord height,
657 wxDC *source, wxCoord xsrc, wxCoord ysrc,
658 int logicalFunc = wxCOPY, int useMask = FALSE);
659 // bool Blit(const wxPoint& destPt, const wxSize& sz,
660 // wxDC *source, const wxPoint& srcPt,
661 // int logicalFunc = wxCOPY, int useMask = FALSE);
664 void CrossHair(wxCoord x, wxCoord y);
665 void DestroyClippingRegion();
666 wxCoord DeviceToLogicalX(wxCoord x);
667 wxCoord DeviceToLogicalXRel(wxCoord x);
668 wxCoord DeviceToLogicalY(wxCoord y);
669 wxCoord DeviceToLogicalYRel(wxCoord y);
670 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
671 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
672 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
673 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord start, wxCoord end);
674 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
676 void DrawLabel(const wxString& text, const wxRect& rect,
677 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
678 int indexAccel = -1);
681 wxRect DrawImageLabel(const wxString& text,
682 const wxBitmap& image,
684 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
685 int indexAccel = -1) {
687 self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
692 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
693 void DrawLines(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0);
694 void DrawPolygon(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0,
695 int fill_style=wxODDEVEN_RULE);
696 void DrawPoint(wxCoord x, wxCoord y);
697 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
698 %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect);
699 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
700 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord radius=20);
701 void DrawSpline(int PCOUNT, wxPoint* points);
702 void DrawText(const wxString& text, wxCoord x, wxCoord y);
706 bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, int style=wxFLOOD_SURFACE);
707 wxBrush GetBackground();
709 wxCoord GetCharHeight();
710 wxCoord GetCharWidth();
711 void GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT,
712 wxCoord *OUTPUT, wxCoord *OUTPUT);
714 int GetLogicalFunction();
715 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
717 bool GetOptimization();
720 %new wxColour* GetPixel(wxCoord x, wxCoord y) {
721 wxColour* wc = new wxColour();
722 self->GetPixel(x, y, wc);
726 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
729 wxColour GetTextBackground();
730 void GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT);
731 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
732 wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT,
733 const wxFont* font = NULL);
734 void GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT,
735 wxFont *font = NULL);
736 wxColour GetTextForeground();
737 void GetUserScale(double *OUTPUT, double *OUTPUT);
738 wxCoord LogicalToDeviceX(wxCoord x);
739 wxCoord LogicalToDeviceXRel(wxCoord x);
740 wxCoord LogicalToDeviceY(wxCoord y);
741 wxCoord LogicalToDeviceYRel(wxCoord y);
747 void SetDeviceOrigin(wxCoord x, wxCoord y);
748 void SetBackground(const wxBrush& brush);
749 void SetBackgroundMode(int mode);
750 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
751 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
752 %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
753 void SetPalette(const wxPalette& colourMap);
754 void SetBrush(const wxBrush& brush);
755 void SetFont(const wxFont& font);
756 void SetLogicalFunction(int function);
757 void SetLogicalScale(double x, double y);
758 void SetMapMode(int mode);
759 void SetOptimization(bool optimize);
760 void SetPen(const wxPen& pen);
761 void SetTextBackground(const wxColour& colour);
762 void SetTextForeground(const wxColour& colour);
763 void SetUserScale(double x_scale, double y_scale);
764 bool StartDoc(const wxString& message);
769 void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y,
770 int useMask = FALSE);
772 bool CanDrawBitmap();
773 bool CanGetTextExtent();
777 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
778 void SetLogicalOrigin(int x, int y);
779 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
780 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
782 void CalcBoundingBox(int x, int y);
783 void ResetBoundingBox();
786 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
787 // See below for implementation
790 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
797 %addmethods { // See drawlist.cpp for impplementaion of these...
799 PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
801 return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes);
804 PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
806 return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes);
809 PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
811 return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes);
814 PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
816 return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes);
819 PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes)
821 return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes);
824 PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints,
825 PyObject* foregroundList, PyObject* backgroundList) {
826 return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList);
830 %pragma(python) addtoclass = "
831 def DrawPointList(self, points, pens=None):
834 elif isinstance(pens, wxPenPtr):
836 elif len(pens) != len(points):
837 raise ValueError('points and pens must have same length')
838 return self._DrawPointList(points, pens, [])
841 def DrawLineList(self, lines, pens=None):
844 elif isinstance(pens, wxPenPtr):
846 elif len(pens) != len(lines):
847 raise ValueError('lines and pens must have same length')
848 return self._DrawLineList(lines, pens, [])
851 def DrawRectangleList(self, rectangles, pens=None, brushes=None):
854 elif isinstance(pens, wxPenPtr):
856 elif len(pens) != len(rectangles):
857 raise ValueError('rectangles and pens must have same length')
860 elif isinstance(brushes, wxBrushPtr):
862 elif len(brushes) != len(rectangles):
863 raise ValueError('rectangles and brushes must have same length')
864 return self._DrawRectangleList(rectangles, pens, brushes)
867 def DrawEllipseList(self, ellipses, pens=None, brushes=None):
870 elif isinstance(pens, wxPenPtr):
872 elif len(pens) != len(ellipses):
873 raise ValueError('ellipses and pens must have same length')
876 elif isinstance(brushes, wxBrushPtr):
878 elif len(brushes) != len(ellipses):
879 raise ValueError('ellipses and brushes must have same length')
880 return self._DrawEllipseList(ellipses, pens, brushes)
883 def DrawPolygonList(self, polygons, pens=None, brushes=None):
884 ## Note: This does not currently support fill style or offset
885 ## you can always use the non-List version if need be.
886 ## I really would like to support fill-style, however,
887 ## but wxODDEVEN_RULE does not appear to be defined at the Python level
888 ## [It's in wx.py... --Robin]
891 elif isinstance(pens, wxPenPtr):
893 elif len(pens) != len(polygons):
894 raise ValueError('polygons and pens must have same length')
897 elif isinstance(brushes, wxBrushPtr):
899 elif len(brushes) != len(polygons):
900 raise ValueError('polygons and brushes must have same length')
901 return self._DrawPolygonList(polygons, pens, brushes)
904 def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None):
905 ## NOTE: this does not currently support changing the font
906 ## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode)
907 ## If you want backgounds to do anything.
908 if type(textList) == type(''):
909 textList = [textList]
910 elif len(textList) != len(coords):
911 raise ValueError('textlist and coords must have same length')
912 if foregrounds is None:
914 elif isinstance(foregrounds, wxColourPtr):
915 foregrounds = [foregrounds]
916 elif len(foregrounds) != len(coords):
917 raise ValueError('foregrounds and coords must have same length')
918 if backgrounds is None:
920 elif isinstance(backgrounds, wxColourPtr):
921 backgrounds = [backgrounds]
922 elif len(backgrounds) != len(coords):
923 raise ValueError('backgrounds and coords must have same length')
924 return self._DrawTextList(textList, coords, foregrounds, backgrounds)
933 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
941 //----------------------------------------------------------------------
943 class wxMemoryDC : public wxDC {
947 void SelectObject(const wxBitmap& bitmap);
950 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
951 %{ // Alternate 'constructor'
952 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
953 return new wxMemoryDC(oldDC);
958 //---------------------------------------------------------------------------
960 class wxBufferedDC : public wxMemoryDC {
962 // Construct a wxBufferedDC using a user supplied buffer.
963 wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
965 // Construct a wxBufferedDC with an internal buffer of 'area'
966 // (where area is usually something like the size of the window
968 %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area );
970 // Blits the buffer to the dc, and detaches the dc from
971 // the buffer. Usually called in the dtor or by the dtor
972 // of derived classes if the BufferedDC must blit before
973 // the derived class (which may own the dc it's blitting
978 %pragma(python) addtomethod =
979 "__init__:self._dc = _args[0] # save a ref so the other dc won't be deleted before self"
980 %pragma(python) addtomethod =
981 "wxBufferedDCInternalBuffer:val._dc = _args[0] # save a ref so the other dc won't be deleted before self"
985 class wxBufferedPaintDC : public wxBufferedDC
988 wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
991 //---------------------------------------------------------------------------
993 class wxScreenDC : public wxDC {
997 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
998 bool StartDrawingOnTop(wxRect* rect = NULL);
999 bool EndDrawingOnTop();
1002 //---------------------------------------------------------------------------
1004 class wxClientDC : public wxDC {
1006 wxClientDC(wxWindow* win);
1009 //---------------------------------------------------------------------------
1011 class wxPaintDC : public wxDC {
1013 wxPaintDC(wxWindow* win);
1016 //---------------------------------------------------------------------------
1018 class wxWindowDC : public wxDC {
1020 wxWindowDC(wxWindow* win);
1023 //---------------------------------------------------------------------------
1025 class wxMirrorDC : public wxDC
1028 // constructs a mirror DC associated with the given real DC
1030 // if mirror parameter is true, all vertical and horizontal coordinates are
1031 // exchanged, otherwise this class behaves in exactly the same way as a
1034 wxMirrorDC(wxDC& dc, bool mirror);
1037 //---------------------------------------------------------------------------
1043 #include <wx/metafile.h>
1046 class wxMetaFile : public wxObject {
1048 wxMetaFile(const wxString& filename = wxPyEmptyString);
1052 bool SetClipboard(int width = 0, int height = 0);
1058 const wxString& GetFileName() const { return m_filename; }
1060 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
1063 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1064 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1067 class wxMetaFileDC : public wxDC {
1069 wxMetaFileDC(const wxString& filename = wxPyEmptyString,
1070 int width = 0, int height = 0,
1071 const wxString& description = wxPyEmptyString);
1072 wxMetaFile* Close();
1077 //---------------------------------------------------------------------------
1079 class wxPalette : public wxGDIObject {
1081 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1084 int GetPixel(byte red, byte green, byte blue);
1085 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1088 %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
1091 //---------------------------------------------------------------------------
1094 wxIMAGELIST_DRAW_NORMAL ,
1095 wxIMAGELIST_DRAW_TRANSPARENT,
1096 wxIMAGELIST_DRAW_SELECTED,
1097 wxIMAGELIST_DRAW_FOCUSED,
1098 wxIMAGE_LIST_NORMAL,
1103 class wxImageList : public wxObject {
1105 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1108 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1109 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1110 %name(AddIcon)int Add(const wxIcon& icon);
1112 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1114 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1115 // int Add(const wxBitmap& bitmap);
1116 bool Replace(int index, const wxBitmap& bitmap);
1119 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1120 const bool solidBackground = FALSE);
1122 int GetImageCount();
1123 bool Remove(int index);
1125 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1129 //---------------------------------------------------------------------------
1132 enum wxRegionContain {
1133 wxOutRegion, wxPartRegion, wxInRegion
1137 class wxRegion : public wxGDIObject {
1139 wxRegion(wxCoord x=0, wxCoord y=0, wxCoord width=0, wxCoord height=0);
1141 %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE);
1143 %name(wxRegionFromBitmap)wxRegion(const wxBitmap& bmp,
1144 const wxColour& transColour = wxNullColour,
1151 bool Offset(wxCoord x, wxCoord y);
1154 wxRegionContain Contains(wxCoord x, wxCoord y);
1155 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1156 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1157 %name(ContainsRectDim)wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
1161 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1162 %name(IntersectRect)bool Intersect(const wxRect& rect);
1163 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1167 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1168 %name(UnionRect)bool Union(const wxRect& rect);
1169 %name(UnionRegion)bool Union(const wxRegion& region);
1171 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1172 %name(SubtractRect)bool Subtract(const wxRect& rect);
1173 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1175 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
1176 %name(XorRect)bool Xor(const wxRect& rect);
1177 %name(XorRegion)bool Xor(const wxRegion& region);
1179 // Convert the region to a B&W bitmap with the white pixels being inside
1181 wxBitmap ConvertToBitmap();
1183 // Use the non-transparent pixels of a wxBitmap for the region to combine
1184 // with this region. If the bitmap has a mask then it will be used,
1185 // otherwise the colour to be treated as transparent may be specified,
1186 // along with an optional tolerance value.
1187 %name(UnionBitmap)bool Union(const wxBitmap& bmp,
1188 const wxColour& transColour = wxNullColour,
1194 class wxRegionIterator : public wxObject {
1196 wxRegionIterator(const wxRegion& region);
1197 ~wxRegionIterator();
1204 wxCoord GetHeight();
1217 //---------------------------------------------------------------------------
1225 // See also wxPy_ReinitStockObjects in helpers.cpp
1227 extern wxFont *wxNORMAL_FONT;
1228 extern wxFont *wxSMALL_FONT;
1229 extern wxFont *wxITALIC_FONT;
1230 extern wxFont *wxSWISS_FONT;
1232 extern wxPen *wxRED_PEN;
1233 extern wxPen *wxCYAN_PEN;
1234 extern wxPen *wxGREEN_PEN;
1235 extern wxPen *wxBLACK_PEN;
1236 extern wxPen *wxWHITE_PEN;
1237 extern wxPen *wxTRANSPARENT_PEN;
1238 extern wxPen *wxBLACK_DASHED_PEN;
1239 extern wxPen *wxGREY_PEN;
1240 extern wxPen *wxMEDIUM_GREY_PEN;
1241 extern wxPen *wxLIGHT_GREY_PEN;
1243 extern wxBrush *wxBLUE_BRUSH;
1244 extern wxBrush *wxGREEN_BRUSH;
1245 extern wxBrush *wxWHITE_BRUSH;
1246 extern wxBrush *wxBLACK_BRUSH;
1247 extern wxBrush *wxTRANSPARENT_BRUSH;
1248 extern wxBrush *wxCYAN_BRUSH;
1249 extern wxBrush *wxRED_BRUSH;
1250 extern wxBrush *wxGREY_BRUSH;
1251 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1252 extern wxBrush *wxLIGHT_GREY_BRUSH;
1254 extern wxColour *wxBLACK;
1255 extern wxColour *wxWHITE;
1256 extern wxColour *wxRED;
1257 extern wxColour *wxBLUE;
1258 extern wxColour *wxGREEN;
1259 extern wxColour *wxCYAN;
1260 extern wxColour *wxLIGHT_GREY;
1262 extern wxCursor *wxSTANDARD_CURSOR;
1263 extern wxCursor *wxHOURGLASS_CURSOR;
1264 extern wxCursor *wxCROSS_CURSOR;
1267 extern wxBitmap wxNullBitmap;
1268 extern wxIcon wxNullIcon;
1269 extern wxCursor wxNullCursor;
1270 extern wxPen wxNullPen;
1271 extern wxBrush wxNullBrush;
1272 extern wxPalette wxNullPalette;
1273 extern wxFont wxNullFont;
1274 extern wxColour wxNullColour;
1277 extern wxFontList* wxTheFontList;
1278 extern wxPenList* wxThePenList;
1279 extern wxBrushList* wxTheBrushList;
1280 extern wxColourDatabase* wxTheColourDatabase;
1288 //---------------------------------------------------------------------------
1289 //---------------------------------------------------------------------------