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 //---------------------------------------------------------------------------
32 class wxPen : public wxGDIObject {
34 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
45 void SetCap(int cap_style);
46 void SetColour(wxColour& colour);
47 void SetJoin(int join_style);
48 void SetStyle(int style);
49 void SetWidth(int width);
51 void SetDashes(int dashes, wxDash* dashes_array);
52 //int GetDashes(wxDash **dashes);
54 PyObject* GetDashes() {
56 int count = self->GetDashes(&dashes);
57 bool blocked = wxPyBeginBlockThreads();
58 PyObject* retval = PyList_New(0);
59 for (int x=0; x<count; x++) {
60 PyObject* pyint = PyInt_FromLong(dashes[x]);
61 PyList_Append(retval, pyint);
64 wxPyEndBlockThreads(blocked);
68 void _SetDashes(PyObject* _self, PyObject* pyDashes) {
69 bool blocked = wxPyBeginBlockThreads();
70 int size = PyList_Size(pyDashes);
71 wxDash* dashes = (wxDash*)byte_LIST_helper(pyDashes);
73 // black magic warning! The array of wxDashes needs to exist as
74 // long as the pen does because wxPen does not copy the array. So
75 // stick a copy in a Python string object and attach it to _self,
76 // and then call SetDashes with a pointer to that array. Then
77 // when the Python pen object is destroyed the array will be
79 PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
80 PyObject_SetAttrString(_self, "_dashes", strDashes);
82 self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
85 wxPyEndBlockThreads(blocked);
89 def SetDashes(self, dashes):
91 Associate a list of dash lengths with the Pen.
93 self._SetDashes(self, dashes)
98 int GetDashCount() const;
102 wxBitmap* GetStipple();
103 void SetStipple(wxBitmap& stipple);
108 bool __eq__(const wxPen* other) { return other ? (*self == *other) : False; }
109 bool __ne__(const wxPen* other) { return other ? (*self != *other) : True; }
111 %pythoncode { def __nonzero__(self): return self.Ok() }
115 //---------------------------------------------------------------------------