1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface defs for wxControl and other base classes
7 // Created: 10-June-1998
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
18 MAKE_CONST_WXSTRING(ControlNameStr);
20 //---------------------------------------------------------------------------
25 "This is the base class for a control or 'widget'.
27 A control is generally a small window which processes user input and/or
28 displays one or more item of data.");
30 class wxControl : public wxWindow
33 %pythonAppend wxControl "self._setOORInfo(self)"
34 %pythonAppend wxControl() ""
37 wxControl(wxWindow *parent,
39 const wxPoint& pos=wxDefaultPosition,
40 const wxSize& size=wxDefaultSize,
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.");
49 "Precreate a Control control for 2-phase creation",
53 bool , Create(wxWindow *parent,
55 const wxPoint& pos=wxDefaultPosition,
56 const wxSize& size=wxDefaultSize,
58 const wxValidator& validator=wxDefaultValidator,
59 const wxString& name=wxPyControlNameStr),
60 "Do the 2nd phase and create the GUI control.");
64 void , Command(wxCommandEvent& event),
65 "Simulates the effect of the user issuing a command to the\n"
66 "item. See wx.CommandEvent.");
69 wxString , GetLabel(),
70 "Return a control's text.");
73 void , SetLabel(const wxString& label),
74 "Sets the item's text.");
77 static wxVisualAttributes
78 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
82 //---------------------------------------------------------------------------
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
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.
97 The items in a wx.ItemContainer have (non empty) string labels
98 and, optionally, client data associated with them.
101 class wxItemContainer
104 // wxItemContainer() { m_clientDataItemsType = wxClientData_None; } ** It's an ABC
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) {
115 wxPyClientData* data = new wxPyClientData(clientData);
116 return self->Append(item, data);
118 return self->Append(item);
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.",
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) {
136 wxPyClientData* data = new wxPyClientData(clientData);
137 return self->Insert(item, pos, data);
139 return self->Insert(item, pos);
145 virtual void , Clear(),
146 "Removes all items from the control.");
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.");
158 virtual int , GetCount() const,
159 "Returns the number of items in the control.");
162 bool , IsEmpty() const,
163 "Returns True if the control is empty or False if it has some items.");
166 virtual wxString , GetString(int n) const,
167 "Returns the label of the item with the given index.");
170 wxArrayString , GetStrings() const,
174 virtual void , SetString(int n, const wxString& s),
175 "Sets the label for the given item.");
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"
186 virtual void , Select(int n),
187 "Sets the item at index 'n' to be the selected item.");
189 %pythoncode { SetSelection = Select }
192 virtual int , GetSelection() const,
193 "Returns the index of the selected item or wx.NOT_FOUND if no item is selected.");
197 wxString , GetStringSelection() const,
198 "Returns the label of the selected item or an empty string if no item is selected.");
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);
208 Py_INCREF(data->m_obj);
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);
227 //---------------------------------------------------------------------------
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.");
235 class wxControlWithItems : public wxControl, public wxItemContainer
240 //---------------------------------------------------------------------------