X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/da32eb53cbe7947f3f4599d7b6b5caa21a68d27f..4ed51f4d1c02f01489df35b25a96a1d5b25c1478:/wxPython/src/_pen.i?ds=sidebyside diff --git a/wxPython/src/_pen.i b/wxPython/src/_pen.i index 911f63d1d0..577c0a936e 100644 --- a/wxPython/src/_pen.i +++ b/wxPython/src/_pen.i @@ -29,6 +29,8 @@ %newgroup +MustHaveApp(wxPen); + class wxPen : public wxGDIObject { public: wxPen(wxColour& colour, int width=1, int style=wxSOLID); @@ -40,7 +42,8 @@ public: int GetStyle(); int GetWidth(); - bool Ok(); + bool IsOk(); + %pythoncode { Ok = IsOk } void SetCap(int cap_style); void SetColour(wxColour& colour); @@ -54,66 +57,71 @@ public: PyObject* GetDashes() { wxDash* dashes; int count = self->GetDashes(&dashes); - bool blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); PyObject* retval = PyList_New(0); - for (int x=0; xSetDashes(size, (wxDash*)PyString_AS_STRING(strDashes)); + delete [] dashes; + Py_DECREF(strDashes); + wxPyEndBlockThreads(blocked); + } } - - %extend { - bool __eq__(const wxPen* other) { return other ? (*self == *other) : False; } - bool __ne__(const wxPen* other) { return other ? (*self != *other) : True; } + %pythoncode { + def SetDashes(self, dashes): + """ + Associate a list of dash lengths with the Pen. + """ + self._SetDashes(self, dashes) } + #ifndef __WXMAC__ -// wxDash* GetDash() const; int GetDashCount() const; + %property(DashCount, GetDashCount, doc="See `GetDashCount`"); #endif #ifdef __WXMSW__ wxBitmap* GetStipple(); void SetStipple(wxBitmap& stipple); + %property(Stipple, GetStipple, SetStipple, doc="See `GetStipple` and `SetStipple`"); #endif - %pythoncode { def __nonzero__(self): return self.Ok() } -}; - - -// The list of ints for the dashes needs to exist for the life of the pen -// so we make it part of the class to save it. See pyclasses.h - -%{ -wxPyPen::~wxPyPen() -{ - if (m_dash) - delete [] m_dash; -} - -void wxPyPen::SetDashes(int nb_dashes, const wxDash *dash) -{ - if (m_dash) - delete [] m_dash; - m_dash = new wxDash[nb_dashes]; - for (int i=0; i