]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_pen.i
cleanup - heavy reformatting
[wxWidgets.git] / wxPython / src / _pen.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _pen.i
3 // Purpose: SWIG interface for wxPen
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7-July-1997
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
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;
23 }
24 %typemap(freearg) (int dashes, wxDash* dashes_array ) {
25 if ($2) delete [] $2;
26 }
27
28 //---------------------------------------------------------------------------
29 %newgroup
30
31
32 MustHaveApp(wxPen);
33
34 class wxPen : public wxGDIObject {
35 public:
36 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
37 ~wxPen();
38
39 int GetCap();
40 wxColour GetColour();
41 int GetJoin();
42 int GetStyle();
43 int GetWidth();
44
45 bool Ok();
46
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);
52
53 void SetDashes(int dashes, wxDash* dashes_array);
54 //int GetDashes(wxDash **dashes);
55 %extend {
56 PyObject* GetDashes() {
57 wxDash* dashes;
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);
64 Py_DECREF(pyint);
65 }
66 wxPyEndBlockThreads(blocked);
67 return retval;
68 }
69
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);
74
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
80 // cleaned up too.
81 PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
82 PyObject_SetAttrString(_self, "_dashes", strDashes);
83
84 self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
85 delete [] dashes;
86 Py_DECREF(strDashes);
87 wxPyEndBlockThreads(blocked);
88 }
89 }
90 %pythoncode {
91 def SetDashes(self, dashes):
92 """
93 Associate a list of dash lengths with the Pen.
94 """
95 self._SetDashes(self, dashes)
96 }
97
98
99 #ifndef __WXMAC__
100 int GetDashCount() const;
101 #endif
102
103 #ifdef __WXMSW__
104 wxBitmap* GetStipple();
105 void SetStipple(wxBitmap& stipple);
106 #endif
107
108
109 %extend {
110 bool __eq__(const wxPen* other) { return other ? (*self == *other) : false; }
111 bool __ne__(const wxPen* other) { return other ? (*self != *other) : true; }
112 }
113 %pythoncode { def __nonzero__(self): return self.Ok() }
114 };
115
116
117 //---------------------------------------------------------------------------