1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, wxFont, etc.
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/metafile.h>
19 #include <wx/imaglist.h>
25 //----------------------------------------------------------------------
28 %include my_typemaps.i
30 // Import some definitions of other classes, etc.
35 static wxString wxPyEmptyStr("");
38 //---------------------------------------------------------------------------
40 class wxGDIObject : public wxObject {
46 void SetVisible( bool visible );
52 //---------------------------------------------------------------------------
54 class wxBitmap : public wxGDIObject
57 wxBitmap(const wxString& name, wxBitmapType type);
60 wxPalette* GetPalette();
62 bool LoadFile(const wxString& name, long flags);
63 bool SaveFile(const wxString& name, int type, wxPalette* palette = NULL);
64 void SetMask(wxMask* mask);
66 void SetPalette(wxPalette& palette);
72 void SetHandle(long handle);
79 void SetHeight(int h);
82 void SetSize(const wxSize& size);
85 wxBitmap GetSubBitmap( const wxRect& rect );
87 bool CopyFromIcon(const wxIcon& icon);
88 bool CopyFromCursor(const wxCursor& cursor);
90 void SetQuality(int q);
93 %pragma(python) addtoclass = "
94 def __del__(self,gdic=gdic):
96 if self.thisown == 1 :
97 gdic.delete_wxBitmap(self)
104 // Declarations of some alternate "constructors"
105 %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
106 %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
107 %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
110 %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
111 int width, int height, int depth = 1);
116 %{ // Implementations of some alternate "constructors"
118 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
119 return new wxBitmap(width, height, depth);
122 static char** ConvertListOfStrings(PyObject* listOfStrings) {
123 char** cArray = NULL;
126 if (!PyList_Check(listOfStrings)) {
127 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
130 count = PyList_Size(listOfStrings);
131 cArray = new char*[count];
133 for(int x=0; x<count; x++) {
134 // TODO: Need some validation and error checking here
135 cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
140 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
141 char** cArray = NULL;
144 cArray = ConvertListOfStrings(listOfStrings);
147 bmp = new wxBitmap(cArray);
153 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
154 return new wxBitmap(icon);
160 wxBitmap* wxBitmapFromData(PyObject* data, long type,
161 int width, int height, int depth = 1) {
162 if (! PyString_Check(data)) {
163 PyErr_SetString(PyExc_TypeError, "Expected string object");
167 return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
172 //---------------------------------------------------------------------------
174 class wxMask : public wxObject {
176 wxMask(const wxBitmap& bitmap);
179 %addmethods { void Destroy() { delete self; } }
182 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
184 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
185 return new wxMask(bitmap, colour);
190 //---------------------------------------------------------------------------
193 class wxIcon : public wxGDIObject
196 wxIcon(const wxString& name, long flags,
197 int desiredWidth = -1, int desiredHeight = -1);
200 bool LoadFile(const wxString& name, long flags);
202 // wxGDIImage methods
205 void SetHandle(long handle);
211 void SetWidth(int w);
212 void SetHeight(int h);
213 void SetDepth(int d);
215 void SetSize(const wxSize& size);
217 void CopyFromBitmap(const wxBitmap& bmp);
219 %pragma(python) addtoclass = "
220 def __del__(self,gdic=gdic):
222 if self.thisown == 1 :
223 gdic.delete_wxIcon(self)
230 // Declarations of some alternate "constructors"
231 %new wxIcon* wxEmptyIcon();
232 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
234 %{ // Implementations of some alternate "constructors"
235 wxIcon* wxEmptyIcon() {
239 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
240 char** cArray = NULL;
243 cArray = ConvertListOfStrings(listOfStrings);
246 icon = new wxIcon(cArray);
252 //---------------------------------------------------------------------------
254 class wxCursor : public wxGDIObject
258 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
262 // wxGDIImage methods
265 void SetHandle(long handle);
272 void SetWidth(int w);
273 void SetHeight(int h);
274 void SetDepth(int d);
275 void SetSize(const wxSize& size);
279 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
280 %{ // Alternate 'constructor'
281 wxCursor* wxPyStockCursor(int id) {
282 return new wxCursor(id);
286 //----------------------------------------------------------------------
291 wxFONTENCODING_SYSTEM = -1, // system default
292 wxFONTENCODING_DEFAULT, // current default encoding
294 // ISO8859 standard defines a number of single-byte charsets
295 wxFONTENCODING_ISO8859_1, // West European (Latin1)
296 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
297 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
298 wxFONTENCODING_ISO8859_4, // Baltic languages (Estonian) (Latin4)
299 wxFONTENCODING_ISO8859_5, // Cyrillic
300 wxFONTENCODING_ISO8859_6, // Arabic
301 wxFONTENCODING_ISO8859_7, // Greek
302 wxFONTENCODING_ISO8859_8, // Hebrew
303 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
304 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
305 wxFONTENCODING_ISO8859_11, // Thai
306 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
307 // here anyhow to make all ISO8859
308 // consecutive numbers
309 wxFONTENCODING_ISO8859_13, // Latin7
310 wxFONTENCODING_ISO8859_14, // Latin8
311 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
313 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
314 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
315 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
316 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
318 // what would we do without Microsoft? They have their own encodings
320 wxFONTENCODING_CP437, // original MS-DOS codepage
321 wxFONTENCODING_CP850, // CP437 merged with Latin1
322 wxFONTENCODING_CP852, // CP437 merged with Latin2
323 wxFONTENCODING_CP855, // another cyrillic encoding
324 wxFONTENCODING_CP866, // and another one
326 wxFONTENCODING_CP1250, // WinLatin2
327 wxFONTENCODING_CP1251, // WinCyrillic
328 wxFONTENCODING_CP1252, // WinLatin1
334 class wxFont : public wxGDIObject {
336 wxFont( int pointSize, int family, int style, int weight,
337 int underline=FALSE, char* faceName = "",
338 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
342 wxString GetFaceName();
349 bool GetUnderlined();
351 wxFontEncoding GetEncoding();
352 void SetFaceName(const wxString& faceName);
353 void SetFamily(int family);
354 void SetPointSize(int pointSize);
355 void SetStyle(int style);
356 void SetUnderlined(bool underlined);
357 void SetWeight(int weight);
358 void SetEncoding(wxFontEncoding encoding);
359 wxString GetFamilyString();
360 wxString GetStyleString();
361 wxString GetWeightString();
365 wxFontEncoding wxFont_GetDefaultEncoding() {
366 return wxFont::GetDefaultEncoding();
369 void wxFont_SetDefaultEncoding(wxFontEncoding encoding) {
370 wxFont::SetDefaultEncoding(encoding);
375 class wxFontList : public wxObject {
378 void AddFont(wxFont* font);
379 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
380 bool underline = FALSE, const char* facename = NULL,
381 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
382 void RemoveFont(wxFont *font);
386 //----------------------------------------------------------------------
388 class wxColour : public wxObject {
390 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
393 unsigned char Green();
394 unsigned char Blue();
396 void Set(unsigned char red, unsigned char green, unsigned char blue);
399 PyObject* rv = PyTuple_New(3);
400 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
401 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
402 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
406 %pragma(python) addtoclass = "asTuple = Get"
407 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
408 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
412 %new wxColour* wxNamedColour(const wxString& colorName);
414 %{ // Alternate 'constructor'
415 wxColour* wxNamedColour(const wxString& colorName) {
416 return new wxColour(colorName);
422 class wxColourDatabase : public wxObject {
425 wxColour *FindColour(const wxString& colour);
426 wxString FindName(const wxColour& colour) const;
429 void Append(const wxString& name, int red, int green, int blue) {
430 self->Append(name.c_str(), new wxColour(red, green, blue));
436 //----------------------------------------------------------------------
439 class wxPen : public wxGDIObject {
441 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
445 wxColour GetColour();
451 void SetCap(int cap_style);
452 void SetColour(wxColour& colour);
453 void SetJoin(int join_style);
454 void SetStyle(int style);
455 void SetWidth(int width);
457 // **** This one needs to return a list of ints (wxDash)
458 int GetDashes(wxDash **dashes);
459 void SetDashes(int LCOUNT, wxDash* choices);
462 wxBitmap* GetStipple();
463 void SetStipple(wxBitmap& stipple);
468 class wxPenList : public wxObject {
471 void AddPen(wxPen* pen);
472 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
473 void RemovePen(wxPen* pen);
478 //----------------------------------------------------------------------
480 class wxBrush : public wxGDIObject {
482 wxBrush(const wxColour& colour, int style=wxSOLID);
485 wxColour GetColour();
486 wxBitmap * GetStipple();
489 void SetColour(wxColour &colour);
490 void SetStipple(wxBitmap& bitmap);
491 void SetStyle(int style);
498 void AddBrush(wxBrush *brush);
499 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
500 void RemoveBrush(wxBrush *brush);
503 //----------------------------------------------------------------------
507 class wxDC : public wxObject {
509 // wxDC(); **** abstract base class, can't instantiate.
514 bool Blit(long xdest, long ydest,
515 long width, long height,
516 wxDC *source, long xsrc, long ysrc,
517 int logicalFunc = wxCOPY, int useMask = FALSE);
518 // bool Blit(const wxPoint& destPt, const wxSize& sz,
519 // wxDC *source, const wxPoint& srcPt,
520 // int logicalFunc = wxCOPY, int useMask = FALSE);
523 void CrossHair(long x, long y);
524 void DestroyClippingRegion();
525 long DeviceToLogicalX(long x);
526 long DeviceToLogicalXRel(long x);
527 long DeviceToLogicalY(long y);
528 long DeviceToLogicalYRel(long y);
529 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
530 void DrawCircle(long x, long y, long radius);
531 void DrawEllipse(long x, long y, long width, long height);
532 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
533 void DrawIcon(const wxIcon& icon, long x, long y);
534 void DrawLine(long x1, long y1, long x2, long y2);
535 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
536 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
537 int fill_style=wxODDEVEN_RULE);
538 void DrawPoint(long x, long y);
539 void DrawRectangle(long x, long y, long width, long height);
540 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
541 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
542 void DrawSpline(int PCOUNT, wxPoint* points);
543 void DrawText(const wxString& text, long x, long y);
547 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
548 wxBrush& GetBackground();
550 long GetCharHeight();
552 void GetClippingBox(long *OUTPUT, long *OUTPUT,
553 long *OUTPUT, long *OUTPUT);
555 int GetLogicalFunction();
556 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
558 bool GetOptimization();
561 %new wxColour* GetPixel(long x, long y) {
562 wxColour* wc = new wxColour();
563 self->GetPixel(x, y, wc);
567 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
570 wxColour GetTextBackground();
571 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
572 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
573 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
574 const wxFont* font = NULL);
575 wxColour GetTextForeground();
576 void GetUserScale(double *OUTPUT, double *OUTPUT);
577 long LogicalToDeviceX(long x);
578 long LogicalToDeviceXRel(long x);
579 long LogicalToDeviceY(long y);
580 long LogicalToDeviceYRel(long y);
586 void SetDeviceOrigin(long x, long y);
587 void SetBackground(const wxBrush& brush);
588 void SetBackgroundMode(int mode);
589 void SetClippingRegion(long x, long y, long width, long height);
590 void SetPalette(const wxPalette& colourMap);
591 void SetBrush(const wxBrush& brush);
592 void SetFont(const wxFont& font);
593 void SetLogicalFunction(int function);
594 void SetLogicalScale(double x, double y);
595 void SetMapMode(int mode);
596 void SetOptimization(bool optimize);
597 void SetPen(const wxPen& pen);
598 void SetTextBackground(const wxColour& colour);
599 void SetTextForeground(const wxColour& colour);
600 void SetUserScale(double x_scale, double y_scale);
601 bool StartDoc(const wxString& message);
606 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
607 int useMask = FALSE);
609 bool CanDrawBitmap();
610 bool CanGetTextExtent();
614 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
615 void SetLogicalOrigin(int x, int y);
616 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
617 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
619 void CalcBoundingBox(int x, int y);
620 void ResetBoundingBox();
624 //----------------------------------------------------------------------
626 class wxMemoryDC : public wxDC {
630 void SelectObject(const wxBitmap& bitmap);
633 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
634 %{ // Alternate 'constructor'
635 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
636 return new wxMemoryDC(oldDC);
641 //---------------------------------------------------------------------------
643 class wxScreenDC : public wxDC {
647 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
648 bool StartDrawingOnTop(wxRect* rect = NULL);
649 bool EndDrawingOnTop();
652 //---------------------------------------------------------------------------
654 class wxClientDC : public wxDC {
656 wxClientDC(wxWindow* win);
659 //---------------------------------------------------------------------------
661 class wxPaintDC : public wxDC {
663 wxPaintDC(wxWindow* win);
666 //---------------------------------------------------------------------------
668 class wxWindowDC : public wxDC {
670 wxWindowDC(wxWindow* win);
673 //---------------------------------------------------------------------------
676 class wxPostScriptDC : public wxDC {
678 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow* win = NULL);
682 //---------------------------------------------------------------------------
686 class wxMetaFileDC : public wxDC {
688 wxMetaFileDC(const wxString& filename = wxPyEmptyStr);
693 //---------------------------------------------------------------------------
694 //---------------------------------------------------------------------------
701 extern wxFont *wxNORMAL_FONT;
702 extern wxFont *wxSMALL_FONT;
703 extern wxFont *wxITALIC_FONT;
704 extern wxFont *wxSWISS_FONT;
706 extern wxPen *wxRED_PEN;
707 extern wxPen *wxCYAN_PEN;
708 extern wxPen *wxGREEN_PEN;
709 extern wxPen *wxBLACK_PEN;
710 extern wxPen *wxWHITE_PEN;
711 extern wxPen *wxTRANSPARENT_PEN;
712 extern wxPen *wxBLACK_DASHED_PEN;
713 extern wxPen *wxGREY_PEN;
714 extern wxPen *wxMEDIUM_GREY_PEN;
715 extern wxPen *wxLIGHT_GREY_PEN;
717 extern wxBrush *wxBLUE_BRUSH;
718 extern wxBrush *wxGREEN_BRUSH;
719 extern wxBrush *wxWHITE_BRUSH;
720 extern wxBrush *wxBLACK_BRUSH;
721 extern wxBrush *wxTRANSPARENT_BRUSH;
722 extern wxBrush *wxCYAN_BRUSH;
723 extern wxBrush *wxRED_BRUSH;
724 extern wxBrush *wxGREY_BRUSH;
725 extern wxBrush *wxMEDIUM_GREY_BRUSH;
726 extern wxBrush *wxLIGHT_GREY_BRUSH;
728 extern wxColour *wxBLACK;
729 extern wxColour *wxWHITE;
730 extern wxColour *wxRED;
731 extern wxColour *wxBLUE;
732 extern wxColour *wxGREEN;
733 extern wxColour *wxCYAN;
734 extern wxColour *wxLIGHT_GREY;
736 extern wxCursor *wxSTANDARD_CURSOR;
737 extern wxCursor *wxHOURGLASS_CURSOR;
738 extern wxCursor *wxCROSS_CURSOR;
740 extern wxBitmap wxNullBitmap;
741 extern wxIcon wxNullIcon;
742 extern wxCursor wxNullCursor;
743 extern wxPen wxNullPen;
744 extern wxBrush wxNullBrush;
745 extern wxPalette wxNullPalette;
746 extern wxFont wxNullFont;
747 extern wxColour wxNullColour;
750 extern wxFontList* wxTheFontList;
751 extern wxPenList* wxThePenList;
752 extern wxBrushlist* wxTheBrushList;
753 extern wxColourDatabase* wxTheColourDatabase;
761 //---------------------------------------------------------------------------
763 class wxPalette : public wxGDIObject {
765 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
768 int GetPixel(byte red, byte green, byte blue);
769 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
773 //---------------------------------------------------------------------------
776 wxIMAGELIST_DRAW_NORMAL ,
777 wxIMAGELIST_DRAW_TRANSPARENT,
778 wxIMAGELIST_DRAW_SELECTED,
779 wxIMAGELIST_DRAW_FOCUSED,
785 class wxImageList : public wxObject {
787 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
790 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
791 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
792 %name(AddIcon)int Add(const wxIcon& icon);
794 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
796 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
797 // int Add(const wxBitmap& bitmap);
798 bool Replace(int index, const wxBitmap& bitmap);
801 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
802 const bool solidBackground = FALSE);
805 bool Remove(int index);
807 void GetSize(int index, int& OUTPUT, int& OUTPUT);
811 //---------------------------------------------------------------------------
814 enum wxRegionContain {
815 wxOutRegion, wxPartRegion, wxInRegion
819 class wxRegion : public wxGDIObject {
821 wxRegion(long x=0, long y=0, long width=0, long height=0);
825 wxRegionContain Contains(long x, long y);
826 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
827 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
828 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
832 bool Intersect(long x, long y, long width, long height);
833 %name(IntersectRect)bool Intersect(const wxRect& rect);
834 %name(IntersectRegion)bool Intersect(const wxRegion& region);
838 bool Union(long x, long y, long width, long height);
839 %name(UnionRect)bool Union(const wxRect& rect);
840 %name(UnionRegion)bool Union(const wxRegion& region);
842 bool Subtract(long x, long y, long width, long height);
843 %name(SubtractRect)bool Subtract(const wxRect& rect);
844 %name(SubtractRegion)bool Subtract(const wxRegion& region);
846 bool Xor(long x, long y, long width, long height);
847 %name(XorRect)bool Xor(const wxRect& rect);
848 %name(XorRegion)bool Xor(const wxRegion& region);
853 class wxRegionIterator : public wxObject {
855 wxRegionIterator(const wxRegion& region);
876 //---------------------------------------------------------------------------