1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wxPen
7 // Created: 7-July-1997
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
18 // wxDash is a signed char, byte is unsigned char...
19 %typemap(in) (int dashes, wxDash* dashes_array ) {
20 $1 = PyList_Size($input);
21 $2 = (wxDash*)byte_LIST_helper($input);
22 if ($2 == NULL) SWIG_fail;
24 %typemap(freearg) (int dashes, wxDash* dashes_array ) {
28 //---------------------------------------------------------------------------
34 class wxPen : public wxGDIObject {
36 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
47 void SetCap(int cap_style);
48 void SetColour(wxColour& colour);
49 void SetJoin(int join_style);
50 void SetStyle(int style);
51 void SetWidth(int width);
53 void SetDashes(int dashes, wxDash* dashes_array);
54 //int GetDashes(wxDash **dashes);
56 PyObject* GetDashes() {
58 int count = self->GetDashes(&dashes);
59 wxPyBlock_t blocked = wxPyBeginBlockThreads();
60 PyObject* retval = PyList_New(0);
61 for (int x=0; x<count; x++) {
62 PyObject* pyint = PyInt_FromLong(dashes[x]);
63 PyList_Append(retval, pyint);
66 wxPyEndBlockThreads(blocked);
70 void _SetDashes(PyObject* _self, PyObject* pyDashes) {
71 wxPyBlock_t blocked = wxPyBeginBlockThreads();
72 int size = PyList_Size(pyDashes);
73 wxDash* dashes = (wxDash*)byte_LIST_helper(pyDashes);
75 // black magic warning! The array of wxDashes needs to exist as
76 // long as the pen does because wxPen does not copy the array. So
77 // stick a copy in a Python string object and attach it to _self,
78 // and then call SetDashes with a pointer to that array. Then
79 // when the Python pen object is destroyed the array will be
81 PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
82 PyObject_SetAttrString(_self, "_dashes", strDashes);
84 self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
87 wxPyEndBlockThreads(blocked);
91 def SetDashes(self, dashes):
93 Associate a list of dash lengths with the Pen.
95 self._SetDashes(self, dashes)
100 int GetDashCount() const;
104 wxBitmap* GetStipple();
105 void SetStipple(wxBitmap& stipple);
110 bool __eq__(const wxPen* other) { return other ? (*self == *other) : false; }
111 bool __ne__(const wxPen* other) { return other ? (*self != *other) : true; }
113 %pythoncode { def __nonzero__(self): return self.Ok() }
117 //---------------------------------------------------------------------------