Remove the need for the PyPen class
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26987 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -76,22 +76,6 @@ public:
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
class wxPyPen : public wxPen {
|
|
||||||
public:
|
|
||||||
wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
|
|
||||||
: wxPen(colour, width, style)
|
|
||||||
{ m_dash = NULL; }
|
|
||||||
~wxPyPen();
|
|
||||||
|
|
||||||
void SetDashes(int nb_dashes, const wxDash *dash);
|
|
||||||
|
|
||||||
private:
|
|
||||||
wxDash* m_dash;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxPyTimer : public wxTimer
|
class wxPyTimer : public wxTimer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
%rename(Colour) wxColour;
|
%rename(Colour) wxColour;
|
||||||
%rename(Palette) wxPalette;
|
%rename(Palette) wxPalette;
|
||||||
%rename(Pen) wxPen;
|
%rename(Pen) wxPen;
|
||||||
%rename(PyPen) wxPyPen;
|
|
||||||
%rename(Brush) wxBrush;
|
%rename(Brush) wxBrush;
|
||||||
%rename(Bitmap) wxBitmap;
|
%rename(Bitmap) wxBitmap;
|
||||||
%rename(Mask) wxMask;
|
%rename(Mask) wxMask;
|
||||||
|
@@ -61,15 +61,37 @@ public:
|
|||||||
wxPyEndBlockThreads(blocked);
|
wxPyEndBlockThreads(blocked);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _SetDashes(PyObject* _self, PyObject* pyDashes) {
|
||||||
|
bool blocked = wxPyBeginBlockThreads();
|
||||||
|
int size = PyList_Size(pyDashes);
|
||||||
|
wxDash* dashes = (wxDash*)byte_LIST_helper(pyDashes);
|
||||||
|
|
||||||
|
// black magic warning! The array of wxDashes needs to exist as
|
||||||
|
// long as the pen does because wxPen does not copy the array. So
|
||||||
|
// stick a copy in a Python string object and attach it to _self,
|
||||||
|
// and then call SetDashes with a pointer to that array. Then
|
||||||
|
// when the Python pen object is destroyed the array will be
|
||||||
|
// cleaned up too.
|
||||||
|
PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
|
||||||
|
PyObject_SetAttrString(_self, "_dashes", strDashes);
|
||||||
|
|
||||||
|
self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
|
||||||
|
delete [] dashes;
|
||||||
|
Py_DECREF(strDashes);
|
||||||
|
wxPyEndBlockThreads(blocked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%pythoncode {
|
||||||
|
def SetDashes(self, dashes):
|
||||||
|
"""
|
||||||
|
Associate a list of dash lengths with the Pen.
|
||||||
|
"""
|
||||||
|
self._SetDashes(self, dashes)
|
||||||
}
|
}
|
||||||
|
|
||||||
%extend {
|
|
||||||
bool __eq__(const wxPen* other) { return other ? (*self == *other) : False; }
|
|
||||||
bool __ne__(const wxPen* other) { return other ? (*self != *other) : True; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef __WXMAC__
|
#ifndef __WXMAC__
|
||||||
// wxDash* GetDash() const;
|
|
||||||
int GetDashCount() const;
|
int GetDashCount() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -78,42 +100,13 @@ public:
|
|||||||
void SetStipple(wxBitmap& stipple);
|
void SetStipple(wxBitmap& stipple);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
%extend {
|
||||||
|
bool __eq__(const wxPen* other) { return other ? (*self == *other) : False; }
|
||||||
|
bool __ne__(const wxPen* other) { return other ? (*self != *other) : True; }
|
||||||
|
}
|
||||||
%pythoncode { def __nonzero__(self): return self.Ok() }
|
%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<nb_dashes; i++) {
|
|
||||||
m_dash[i] = dash[i];
|
|
||||||
}
|
|
||||||
wxPen::SetDashes(nb_dashes, m_dash);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
class wxPyPen : public wxPen {
|
|
||||||
public:
|
|
||||||
wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
|
|
||||||
~wxPyPen();
|
|
||||||
|
|
||||||
void SetDashes(int dashes, wxDash* dashes_array);
|
|
||||||
};
|
|
||||||
|
|
||||||
// wxPyPen is aliased to wxPen
|
|
||||||
%pythoncode { Pen = PyPen };
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@@ -29,8 +29,6 @@ wxPalette = wx._gdi.Palette
|
|||||||
wxPalettePtr = wx._gdi.PalettePtr
|
wxPalettePtr = wx._gdi.PalettePtr
|
||||||
wxPen = wx._gdi.Pen
|
wxPen = wx._gdi.Pen
|
||||||
wxPenPtr = wx._gdi.PenPtr
|
wxPenPtr = wx._gdi.PenPtr
|
||||||
wxPyPen = wx._gdi.PyPen
|
|
||||||
wxPyPenPtr = wx._gdi.PyPenPtr
|
|
||||||
wxBrush = wx._gdi.Brush
|
wxBrush = wx._gdi.Brush
|
||||||
wxBrushPtr = wx._gdi.BrushPtr
|
wxBrushPtr = wx._gdi.BrushPtr
|
||||||
wxBitmap = wx._gdi.Bitmap
|
wxBitmap = wx._gdi.Bitmap
|
||||||
|
Reference in New Issue
Block a user