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