X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e4a197e4c60e461b8068b0619692ea083e30b8b..877d6bae5ea06c6d45b74307e7ce61f65af514d9:/wxPython/src/gdi.i diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index 7d521625ed..d3fe92e1ae 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -21,6 +21,7 @@ #include #include #include +#include #include %} @@ -57,6 +58,10 @@ public: //--------------------------------------------------------------------------- + +// TODO: When the API stabalizes and is available on other platforms, add +// wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff... + class wxBitmap : public wxGDIObject { public: @@ -101,6 +106,7 @@ public: void SetQuality(int q); #endif + %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" }; @@ -229,6 +235,7 @@ public: #endif void CopyFromBitmap(const wxBitmap& bmp); + %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" }; @@ -236,6 +243,7 @@ public: %new wxIcon* wxEmptyIcon(); %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings); %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp); +%new wxIcon* wxIconFromLocation(const wxIconLocation& loc); %{ // Implementations of some alternate "constructors" wxIcon* wxEmptyIcon() { @@ -259,8 +267,61 @@ public: icon->CopyFromBitmap(bmp); return icon; } + + wxIcon* wxIconFromLocation(const wxIconLocation& loc) { + wxIcon* icon = new wxIcon(loc); + return icon; + } %} + +//--------------------------------------------------------------------------- + +class wxIconLocation +{ +public: + // ctor takes the name of the file where the icon is + %addmethods { + wxIconLocation(const wxString* filename = &wxPyEmptyString, int num = 0) { +#ifdef __WXMSW__ + return new wxIconLocation(*filename, num); +#else + return new wxIconLocation(*filename); +#endif + } + } + + ~wxIconLocation(); + + + // returns true if this object is valid/initialized + bool IsOk() const; + + // set/get the icon file name + void SetFileName(const wxString& filename); + const wxString& GetFileName() const; + + %addmethods { + void SetIndex(int num) { +#ifdef __WXMSW__ + self->SetIndex(num); +#else + // do nothing +#endif + } + + int GetIndex() { +#ifdef __WXMSW__ + return self->GetIndex(); +#else + return -1; +#endif + } + } +}; + + + //--------------------------------------------------------------------------- class wxIconBundle @@ -298,9 +359,17 @@ public: class wxCursor : public wxGDIObject { public: -#ifdef __WXMSW__ - wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0); + %addmethods { + wxCursor(const wxString* cursorName, long flags, int hotSpotX=0, int hotSpotY=0) { +#ifdef __WXGTK__ + wxCHECK_MSG(FALSE, NULL, + wxT("wxCursor constructor not implemented for wxGTK, use wxStockCursor, wxCursorFromImage, or wxCursorFromBits instead.")); +#else + return new wxCursor(*cursorName, flags, hotSpotX, hotSpotY); #endif + } + } + ~wxCursor(); // wxGDIImage methods @@ -318,23 +387,34 @@ public: void SetDepth(int d); void SetSize(const wxSize& size); #endif + %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" }; %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id); -%{ // Alternate 'constructor' +%new wxCursor* wxCursorFromImage(const wxImage& image); +%new wxCursor* wxCursorFromBits(PyObject* bits, int width, int height, + int hotSpotX=-1, int hotSpotY=-1, + PyObject* maskBits=0); + +%{ wxCursor* wxPyStockCursor(int id) { return new wxCursor(id); } -%} -%new wxCursor* wxCursorFromImage(const wxImage& image); -%{ wxCursor* wxCursorFromImage(const wxImage& image) { - #ifndef __WXMAC__ return new wxCursor(image); - #else - return NULL; - #endif + } + + wxCursor* wxCursorFromBits(PyObject* bits, int width, int height, + int hotSpotX=-1, int hotSpotY=-1, + PyObject* maskBits=0) { + char* bitsbuf; + char* maskbuf = NULL; + int length; + PyString_AsStringAndSize(bits, &bitsbuf, &length); + if (maskBits) + PyString_AsStringAndSize(maskBits, &maskbuf, &length); + return new wxCursor(bitsbuf, width, height, hotSpotX, hotSpotY, maskbuf); } %} @@ -407,31 +487,20 @@ public: class wxColourDatabase : public wxObject { public: - wxColour *FindColour(const wxString& colour); + wxColour *FindColour(const wxString& colour) ; + wxColour *FindColourNoAdd(const wxString& colour) const; wxString FindName(const wxColour& colour) const; %addmethods { - void Append(const wxString& name, int red, int green, int blue) { - // first see if the name is already there - wxString cName = name; - cName.MakeUpper(); - wxString cName2 = cName; - if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) ) - cName2.clear(); - - wxNode *node = self->GetFirst(); - while ( node ) { - const wxChar *key = node->GetKeyString(); - if ( cName == key || cName2 == key ) { - wxColour* c = (wxColour *)node->GetData(); - c->Set(red, green, blue); - return; - } - node = node->GetNext(); - } + void AddColour(const wxString& name, wxColour* colour) { + // make a copy since the python one will be GC'd + wxColour* c = new wxColour(*colour); + self->AddColour(name, c); + } - // otherwise append the new colour - self->Append(name.c_str(), new wxColour(red, green, blue)); + void Append(const wxString& name, int red, int green, int blue) { + wxColour* c = new wxColour(red, green, blue); + self->AddColour(name, c); } } }; @@ -477,6 +546,8 @@ public: wxBitmap* GetStipple(); void SetStipple(wxBitmap& stipple); #endif + + %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" }; @@ -550,6 +621,13 @@ public: void SetColour(wxColour &colour); void SetStipple(wxBitmap& bitmap); void SetStyle(int style); + +#ifdef __WXMAC__ + short GetMacTheme(); + void SetMacTheme(short macThemeBrush); +#endif + + %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" }; @@ -709,6 +787,8 @@ public: // See below for implementation } + %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" + #ifdef __WXMSW__ long GetHDC(); #endif @@ -942,6 +1022,20 @@ public: //--------------------------------------------------------------------------- +class wxMirrorDC : public wxDC +{ +public: + // constructs a mirror DC associated with the given real DC + // + // if mirror parameter is true, all vertical and horizontal coordinates are + // exchanged, otherwise this class behaves in exactly the same way as a + // plain DC + // + wxMirrorDC(wxDC& dc, bool mirror); +}; + +//--------------------------------------------------------------------------- + #ifdef __WXMSW__ @@ -963,6 +1057,7 @@ public: const wxString& GetFileName() const { return m_filename; } + %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" }; // bool wxMakeMetaFilePlaceable(const wxString& filename, @@ -989,6 +1084,8 @@ public: int GetPixel(byte red, byte green, byte blue); bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT); bool Ok(); + + %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" }; //--------------------------------------------------------------------------- @@ -1043,8 +1140,12 @@ public: #ifndef __WXMAC__ %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE); #endif + %name(wxRegionFromBitmap)wxRegion(const wxBitmap& bmp, + const wxColour& transColour = wxNullColour, + int tolerance = 0); ~wxRegion(); + void Clear(); #ifndef __WXMAC__ bool Offset(wxCoord x, wxCoord y); @@ -1074,6 +1175,18 @@ public: bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height); %name(XorRect)bool Xor(const wxRect& rect); %name(XorRegion)bool Xor(const wxRegion& region); + + // Convert the region to a B&W bitmap with the white pixels being inside + // the region. + wxBitmap ConvertToBitmap(); + + // Use the non-transparent pixels of a wxBitmap for the region to combine + // with this region. If the bitmap has a mask then it will be used, + // otherwise the colour to be treated as transparent may be specified, + // along with an optional tolerance value. + %name(UnionBitmap)bool Union(const wxBitmap& bmp, + const wxColour& transColour = wxNullColour, + int tolerance = 0); }; @@ -1103,11 +1216,14 @@ public: //--------------------------------------------------------------------------- + %readonly %{ #if 0 %} +// See also wxPy_ReinitStockObjects in helpers.cpp + extern wxFont *wxNORMAL_FONT; extern wxFont *wxSMALL_FONT; extern wxFont *wxITALIC_FONT;