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
28 and/or displays one or more item of data.", "");
30 MustHaveApp(wxControl);
32 class wxControl : public wxWindow
35 %pythonAppend wxControl "self._setOORInfo(self)"
36 %pythonAppend wxControl() ""
39 wxControl(wxWindow *parent,
41 const wxPoint& pos=wxDefaultPosition,
42 const wxSize& size=wxDefaultSize,
44 const wxValidator& validator=wxDefaultValidator,
45 const wxString& name=wxPyControlNameStr),
46 "Create a Control. Normally you should only call this from a subclass'
47 __init__ as a plain old wx.Control is not very useful.", "");
51 "Precreate a Control control for 2-phase creation", "",
55 bool , Create(wxWindow *parent,
57 const wxPoint& pos=wxDefaultPosition,
58 const wxSize& size=wxDefaultSize,
60 const wxValidator& validator=wxDefaultValidator,
61 const wxString& name=wxPyControlNameStr),
62 "Do the 2nd phase and create the GUI control.", "");
66 void , Command(wxCommandEvent& event),
67 "Simulates the effect of the user issuing a command to the item.
69 :see: `wx.CommandEvent`
73 wxString , GetLabel(),
74 "Return a control's text.", "");
77 void , SetLabel(const wxString& label),
78 "Sets the item's text.", "");
82 // bool , GetAdjustMinSizeFlag(),
83 // "Returns whether the minsize should be adjusted for this control when
84 // `SetLabel` or `SetFont` are called.", "");
87 // void , SetAdjustMinSizeFlag(bool adjust),
88 // "By default controls will readjust their size and minsize when
89 // `SetLabel` or `SetFont` are called. This flag will allow you to
90 // control this behavior.", "
92 // :see: `GetAdjustMinSizeFlag`
95 static wxVisualAttributes
96 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
100 //---------------------------------------------------------------------------
104 DocStr(wxItemContainer,
105 "wx.ItemContainer defines an interface which is implemented by all
106 controls which have string subitems, each of which may be selected,
107 such as `wx.ListBox`, `wx.CheckListBox`, `wx.Choice` as well as
108 `wx.ComboBox` which implements an extended interface deriving from
111 It defines the methods for accessing the control's items and although
112 each of the derived classes implements them differently, they still
113 all conform to the same interface.
115 The items in a wx.ItemContainer have (non empty) string labels and,
116 optionally, client data associated with them.
119 class wxItemContainer
122 // wxItemContainer() { m_clientDataItemsType = wxClientData_None; } ** It's an ABC
127 "Adds the item to the control, associating the given data with the item
128 if not None. The return value is the index of the newly added item
129 which may be different from the last one if the control is sorted (e.g.
130 has wx.LB_SORT or wx.CB_SORT style).", "");
131 int Append(const wxString& item, PyObject* clientData=NULL) {
133 wxPyClientData* data = new wxPyClientData(clientData);
134 return self->Append(item, data);
136 return self->Append(item);
141 void , Append(const wxArrayString& strings),
142 "Apend several items at once to the control. Notice that calling this
143 method may be much faster than appending the items one by one if you
144 need to add a lot of items.", "",
150 "Insert an item into the control before the item at the ``pos`` index,
151 optionally associating some data object with the item.", "");
152 int Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
154 wxPyClientData* data = new wxPyClientData(clientData);
155 return self->Insert(item, pos, data);
157 return self->Insert(item, pos);
163 virtual void , Clear(),
164 "Removes all items from the control.", "");
167 virtual void , Delete(int n),
168 "Deletes the item at the zero-based index 'n' from the control. Note
169 that it is an error (signalled by a `wx.PyAssertionError` exception if
170 enabled) to remove an item with the index negative or greater or equal
171 than the number of items in the control.", "");
176 virtual int , GetCount() const,
177 "Returns the number of items in the control.", "");
180 bool , IsEmpty() const,
181 "Returns True if the control is empty or False if it has some items.", "");
184 virtual wxString , GetString(int n) const,
185 "Returns the label of the item with the given index.", "");
188 wxArrayString , GetStrings() const,
192 virtual void , SetString(int n, const wxString& s),
193 "Sets the label for the given item.", "");
196 virtual int , FindString(const wxString& s) const,
197 "Finds an item whose label matches the given string. Returns the
198 zero-based position of the item, or ``wx.NOT_FOUND`` if the string was not
204 virtual void , Select(int n),
205 "Sets the item at index 'n' to be the selected item.", "");
207 %pythoncode { SetSelection = Select }
210 virtual int , GetSelection() const,
211 "Returns the index of the selected item or ``wx.NOT_FOUND`` if no item
216 wxString , GetStringSelection() const,
217 "Returns the label of the selected item or an empty string if no item
223 DocStr(GetClientData,
224 "Returns the client data associated with the given item, (if any.)", "");
225 PyObject* GetClientData(int n) {
226 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
228 Py_INCREF(data->m_obj);
236 DocStr(SetClientData,
237 "Associate the given client data with the item at position n.", "");
238 void SetClientData(int n, PyObject* clientData) {
239 wxPyClientData* data = new wxPyClientData(clientData);
240 self->SetClientObject(n, data);
247 //---------------------------------------------------------------------------
250 DocStr(wxControlWithItems,
251 "wx.ControlWithItems combines the ``wx.ItemContainer`` class with the
252 wx.Control class, and is used for the base class of various controls
253 that have items.", "");
255 class wxControlWithItems : public wxControl, public wxItemContainer
260 //---------------------------------------------------------------------------