]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_pen.i
Don't steal VK_RETURN for wxEVT_COMMAND_LIST_ITEM_ACTIVATED if any of
[wxWidgets.git] / wxPython / src / _pen.i
CommitLineData
d14a1e28
RD
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
ab1f7d2a
RD
32MustHaveApp(wxPen);
33
d14a1e28
RD
34class wxPen : public wxGDIObject {
35public:
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
6c2dd16f
RD
45 bool IsOk();
46 %pythoncode { Ok = IsOk }
d14a1e28
RD
47
48 void SetCap(int cap_style);
49 void SetColour(wxColour& colour);
50 void SetJoin(int join_style);
51 void SetStyle(int style);
52 void SetWidth(int width);
53
54 void SetDashes(int dashes, wxDash* dashes_array);
55 //int GetDashes(wxDash **dashes);
56 %extend {
57 PyObject* GetDashes() {
58 wxDash* dashes;
59 int count = self->GetDashes(&dashes);
6e6b3557 60 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28 61 PyObject* retval = PyList_New(0);
ad411ab2
RD
62 for (int x=0; x<count; x++) {
63 PyObject* pyint = PyInt_FromLong(dashes[x]);
64 PyList_Append(retval, pyint);
65 Py_DECREF(pyint);
66 }
da32eb53 67 wxPyEndBlockThreads(blocked);
d14a1e28
RD
68 return retval;
69 }
9e4e25d5
RD
70
71 void _SetDashes(PyObject* _self, PyObject* pyDashes) {
6e6b3557 72 wxPyBlock_t blocked = wxPyBeginBlockThreads();
9e4e25d5
RD
73 int size = PyList_Size(pyDashes);
74 wxDash* dashes = (wxDash*)byte_LIST_helper(pyDashes);
75
76 // black magic warning! The array of wxDashes needs to exist as
77 // long as the pen does because wxPen does not copy the array. So
78 // stick a copy in a Python string object and attach it to _self,
79 // and then call SetDashes with a pointer to that array. Then
80 // when the Python pen object is destroyed the array will be
81 // cleaned up too.
82 PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
83 PyObject_SetAttrString(_self, "_dashes", strDashes);
84
85 self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
86 delete [] dashes;
87 Py_DECREF(strDashes);
88 wxPyEndBlockThreads(blocked);
89 }
d14a1e28 90 }
9e4e25d5
RD
91 %pythoncode {
92 def SetDashes(self, dashes):
93 """
94 Associate a list of dash lengths with the Pen.
95 """
96 self._SetDashes(self, dashes)
22faec7d 97 }
d14a1e28 98
9e4e25d5 99
9fd4be55 100#ifndef __WXMAC__
3f0ff538 101 int GetDashCount() const;
9c21b187 102 %property(DashCount, GetDashCount, doc="See `GetDashCount`");
9fd4be55
RD
103#endif
104
d14a1e28
RD
105#ifdef __WXMSW__
106 wxBitmap* GetStipple();
107 void SetStipple(wxBitmap& stipple);
9c21b187 108 %property(Stipple, GetStipple, SetStipple, doc="See `GetStipple` and `SetStipple`");
d14a1e28
RD
109#endif
110
9e4e25d5
RD
111
112 %extend {
a72f4631
RD
113 bool __eq__(const wxPen* other) { return other ? (*self == *other) : false; }
114 bool __ne__(const wxPen* other) { return other ? (*self != *other) : true; }
d14a1e28 115 }
6c2dd16f 116 %pythoncode { def __nonzero__(self): return self.IsOk() }
7012bb9f
RD
117
118 %property(Cap, GetCap, SetCap, doc="See `GetCap` and `SetCap`");
119 %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
7012bb9f
RD
120 %property(Dashes, GetDashes, SetDashes, doc="See `GetDashes` and `SetDashes`");
121 %property(Join, GetJoin, SetJoin, doc="See `GetJoin` and `SetJoin`");
122 %property(Style, GetStyle, SetStyle, doc="See `GetStyle` and `SetStyle`");
123 %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
d14a1e28
RD
124};
125
d14a1e28
RD
126
127//---------------------------------------------------------------------------