]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _control.i | |
3 | // Purpose: SWIG interface defs for wxControl and other base classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 10-June-1998 | |
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 | ||
b2dc1044 | 18 | MAKE_CONST_WXSTRING(ControlNameStr); |
d14a1e28 RD |
19 | |
20 | //--------------------------------------------------------------------------- | |
21 | %newgroup; | |
22 | ||
23 | ||
861d4832 RD |
24 | DocStr(wxControl, |
25 | "This is the base class for a control or 'widget'. | |
26 | ||
27 | A control is generally a small window which processes user input and/or | |
28 | displays one or more item of data."); | |
29 | ||
d14a1e28 RD |
30 | class wxControl : public wxWindow |
31 | { | |
32 | public: | |
2b9048c5 RD |
33 | %pythonAppend wxControl "self._setOORInfo(self)" |
34 | %pythonAppend wxControl() "" | |
d14a1e28 | 35 | |
861d4832 RD |
36 | DocCtorStr( |
37 | wxControl(wxWindow *parent, | |
d14a1e28 RD |
38 | wxWindowID id, |
39 | const wxPoint& pos=wxDefaultPosition, | |
40 | const wxSize& size=wxDefaultSize, | |
41 | long style=0, | |
42 | const wxValidator& validator=wxDefaultValidator, | |
861d4832 RD |
43 | const wxString& name=wxPyControlNameStr), |
44 | "Create a Control. Normally you should only call this from a\n" | |
45 | "subclass' __init__ as a plain old wx.Control is not very useful."); | |
46 | ||
47 | DocCtorStrName( | |
48 | wxControl(), | |
49 | "Precreate a Control control for 2-phase creation", | |
50 | PreControl); | |
51 | ||
52 | DocDeclStr( | |
53 | bool , Create(wxWindow *parent, | |
54 | wxWindowID id, | |
55 | const wxPoint& pos=wxDefaultPosition, | |
56 | const wxSize& size=wxDefaultSize, | |
57 | long style=0, | |
58 | const wxValidator& validator=wxDefaultValidator, | |
59 | const wxString& name=wxPyControlNameStr), | |
60 | "Do the 2nd phase and create the GUI control."); | |
61 | ||
d14a1e28 | 62 | |
861d4832 RD |
63 | DocDeclStr( |
64 | void , Command(wxCommandEvent& event), | |
65 | "Simulates the effect of the user issuing a command to the\n" | |
66 | "item. See wxCommandEvent."); | |
67 | ||
68 | DocDeclStr( | |
69 | wxString , GetLabel(), | |
70 | "Return a control's text."); | |
71 | ||
72 | DocDeclStr( | |
73 | void , SetLabel(const wxString& label), | |
74 | "Sets the item's text."); | |
d14a1e28 RD |
75 | }; |
76 | ||
77 | ||
78 | //--------------------------------------------------------------------------- | |
79 | %newgroup; | |
80 | ||
81 | ||
861d4832 RD |
82 | DocStr(wxItemContainer, |
83 | "wx.ItemContainer defines an interface which is implemented by all | |
84 | controls which have string subitems, each of which may be | |
85 | selected, such as wx.ListBox, wx.CheckListBox, wx.Choice and | |
86 | wx.ComboBox (which implements an extended interface deriving from | |
87 | this one) | |
88 | ||
89 | It defines the methods for accessing the control's items and | |
90 | although each of the derived classes implements them differently, | |
91 | they still all conform to the same interface. | |
92 | ||
93 | The items in a wx.ItemContainer have (non empty) string labels | |
94 | and, optionally, client data associated with them. | |
95 | "); | |
96 | ||
d14a1e28 RD |
97 | class wxItemContainer |
98 | { | |
99 | public: | |
100 | // wxItemContainer() { m_clientDataItemsType = wxClientData_None; } ** It's an ABC | |
861d4832 | 101 | |
d14a1e28 | 102 | |
d14a1e28 | 103 | %extend { |
861d4832 RD |
104 | DocStr(Append, |
105 | "Adds the item to the control, associating the given data with the\n" | |
106 | "item if not None. The return value is the index of the newly\n" | |
107 | "added item which may be different from the last one if the\n" | |
108 | "control is sorted (e.g. has wx.LB_SORT or wx.CB_SORT style)."); | |
d14a1e28 RD |
109 | int Append(const wxString& item, PyObject* clientData=NULL) { |
110 | if (clientData) { | |
111 | wxPyClientData* data = new wxPyClientData(clientData); | |
112 | return self->Append(item, data); | |
113 | } else | |
114 | return self->Append(item); | |
115 | } | |
116 | } | |
117 | ||
861d4832 RD |
118 | DocDeclStrName( |
119 | void , Append(const wxArrayString& strings), | |
120 | "Apend several items at once to the control. Notice that calling\n" | |
121 | "this method may be much faster than appending the items one by\n" | |
122 | "one if you need to add a lot of items.", | |
123 | AppendItems); | |
d14a1e28 | 124 | |
861d4832 | 125 | |
d14a1e28 | 126 | %extend { |
861d4832 RD |
127 | DocStr(Insert, |
128 | "Insert an item into the control before the item at the pos index,\n" | |
129 | "optionally associating some data object with the item."); | |
d14a1e28 RD |
130 | int Insert(const wxString& item, int pos, PyObject* clientData=NULL) { |
131 | if (clientData) { | |
132 | wxPyClientData* data = new wxPyClientData(clientData); | |
133 | return self->Insert(item, pos, data); | |
134 | } else | |
135 | return self->Insert(item, pos); | |
136 | } | |
137 | } | |
138 | ||
139 | ||
861d4832 RD |
140 | DocDeclStr( |
141 | virtual void , Clear(), | |
142 | "Removes all items from the control."); | |
143 | ||
144 | DocDeclStr( | |
145 | virtual void , Delete(int n), | |
146 | "Deletes the item at the zero-based index 'n' from the control.\n" | |
147 | "Note that it is an error (signalled by a PyAssertionError\n" | |
148 | "exception if enabled) to remove an item with the index negative\n" | |
149 | "or greater or equal than the number of items in the control."); | |
150 | ||
d14a1e28 RD |
151 | |
152 | ||
861d4832 RD |
153 | DocDeclStr( |
154 | virtual int , GetCount() const, | |
155 | "Returns the number of items in the control."); | |
156 | ||
157 | DocDeclStr( | |
158 | bool , IsEmpty() const, | |
159 | "Returns True if the control is empty or False if it has some items."); | |
160 | ||
161 | DocDeclStr( | |
162 | virtual wxString , GetString(int n) const, | |
163 | "Returns the label of the item with the given index."); | |
164 | ||
165 | DocDeclStr( | |
166 | wxArrayString , GetStrings() const, | |
167 | ""); | |
168 | ||
169 | DocDeclStr( | |
170 | virtual void , SetString(int n, const wxString& s), | |
171 | "Sets the label for the given item."); | |
172 | ||
173 | DocDeclStr( | |
174 | virtual int , FindString(const wxString& s) const, | |
175 | "Finds an item whose label matches the given string. Returns the\n" | |
176 | "zero-based position of the item, or wx.NOT_FOUND if the string\n" | |
177 | "was not found."); | |
178 | ||
d14a1e28 RD |
179 | |
180 | ||
861d4832 RD |
181 | DocDeclStr( |
182 | virtual void , Select(int n), | |
183 | "Sets the item at index 'n' to be the selected item."); | |
d14a1e28 | 184 | |
861d4832 RD |
185 | %pythoncode { SetSelection = Select } |
186 | ||
187 | DocDeclStr( | |
188 | virtual int , GetSelection() const, | |
189 | "Returns the index of the selected item or wx.NOT_FOUND if no item is selected."); | |
190 | ||
191 | ||
192 | DocDeclStr( | |
193 | wxString , GetStringSelection() const, | |
194 | "Returns the label of the selected item or an empty string if no item is selected."); | |
195 | ||
d14a1e28 RD |
196 | |
197 | ||
d14a1e28 | 198 | %extend { |
861d4832 RD |
199 | DocStr(GetClientData, |
200 | "Returns the client data associated with the given item, (if any.)"); | |
d14a1e28 RD |
201 | PyObject* GetClientData(int n) { |
202 | wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n); | |
203 | if (data) { | |
204 | Py_INCREF(data->m_obj); | |
205 | return data->m_obj; | |
206 | } else { | |
207 | Py_INCREF(Py_None); | |
208 | return Py_None; | |
209 | } | |
210 | } | |
211 | ||
861d4832 RD |
212 | DocStr(SetClientData, |
213 | "Associate the given client data with the item at position n."); | |
d14a1e28 RD |
214 | void SetClientData(int n, PyObject* clientData) { |
215 | wxPyClientData* data = new wxPyClientData(clientData); | |
216 | self->SetClientObject(n, data); | |
217 | } | |
218 | } | |
219 | ||
220 | }; | |
221 | ||
222 | ||
223 | //--------------------------------------------------------------------------- | |
224 | %newgroup; | |
225 | ||
861d4832 RD |
226 | DocStr(wxControlWithItems, |
227 | "wx.ControlWithItems combines the wx.ItemContainer class with the | |
228 | wx.Control class, and is used for the base class of various | |
229 | controls that have items."); | |
230 | ||
d14a1e28 RD |
231 | class wxControlWithItems : public wxControl, public wxItemContainer |
232 | { | |
233 | public: | |
234 | }; | |
235 | ||
236 | //--------------------------------------------------------------------------- | |
237 |