From e702e598782800c354af1f88047aa907795435ce Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 13 Jun 2003 01:01:49 +0000 Subject: [PATCH] Added wxCursorFromBits. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@21087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/CHANGES.txt | 2 ++ wxPython/src/gdi.i | 34 +++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/wxPython/CHANGES.txt b/wxPython/CHANGES.txt index cf42f94dfe..f4f6f15b3a 100644 --- a/wxPython/CHANGES.txt +++ b/wxPython/CHANGES.txt @@ -69,6 +69,8 @@ still accepted for compatibility, but this will go away in a future release,) SetItemMinSize can now take a wxSize (or 2-tuple) parameter, and Spacers can be specified with a wxSize (or 2-tuple) parameter +Added wxCursorFromBits. + diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index c885dc89f1..78b4310f0a 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -303,7 +303,17 @@ public: class wxCursor : public wxGDIObject { public: - 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 @@ -325,17 +335,31 @@ public: }; %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) { return new wxCursor(image); } + + 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); + } %} //----------------------------------------------------------------------