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 //---------------------------------------------------------------------------
19 DECLARE_DEF_STRING(ControlNameStr);
22 //---------------------------------------------------------------------------
26 // This is the base class for a control or 'widget'.
28 // A control is generally a small window which processes user input and/or
29 // displays one or more item of data.
30 class wxControl : public wxWindow
33 %addtofunc wxControl "self._setOORInfo(self)"
34 %addtofunc wxControl() ""
36 wxControl(wxWindow *parent,
38 const wxPoint& pos=wxDefaultPosition,
39 const wxSize& size=wxDefaultSize,
41 const wxValidator& validator=wxDefaultValidator,
42 const wxString& name=wxPyControlNameStr);
44 %name(PreControl)wxControl();
46 bool Create(wxWindow *parent,
48 const wxPoint& pos=wxDefaultPosition,
49 const wxSize& size=wxDefaultSize,
51 const wxValidator& validator=wxDefaultValidator,
52 const wxString& name=wxPyControlNameStr);
55 // Simulates the effect of the user issuing a command to the item. See
57 void Command(wxCommandEvent& event);
59 // Return a control's text.
62 // Sets the item's text.
63 void SetLabel(const wxString& label);
68 //---------------------------------------------------------------------------
72 // wxItemContainer defines an interface which is implemented by all controls
73 // which have string subitems each of which may be selected.
75 // Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox (which
76 // implements an extended interface deriving from this one)
80 // wxItemContainer() { m_clientDataItemsType = wxClientData_None; } ** It's an ABC
83 // int Append(const wxString& item)
84 // int Append(const wxString& item, void *clientData)
85 // int Append(const wxString& item, wxClientData *clientData)
87 // Adds the item to the control, associating the given data with the
89 int Append(const wxString& item, PyObject* clientData=NULL) {
91 wxPyClientData* data = new wxPyClientData(clientData);
92 return self->Append(item, data);
94 return self->Append(item);
98 // append several items at once to the control
99 %name(AppendItems) void Append(const wxArrayString& strings);
101 // int Insert(const wxString& item, int pos)
102 // int Insert(const wxString& item, int pos, void *clientData);
103 // int Insert(const wxString& item, int pos, wxClientData *clientData);
105 int Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
107 wxPyClientData* data = new wxPyClientData(clientData);
108 return self->Insert(item, pos, data);
110 return self->Insert(item, pos);
116 virtual void Clear();
117 virtual void Delete(int n);
121 virtual int GetCount() const;
122 bool IsEmpty() const;
123 virtual wxString GetString(int n) const;
124 wxArrayString GetStrings() const;
125 virtual void SetString(int n, const wxString& s);
126 virtual int FindString(const wxString& s) const;
130 virtual void Select(int n);
131 virtual int GetSelection() const;
133 wxString GetStringSelection() const;
138 // Returns the client data associated with the given item, (if any.)
139 PyObject* GetClientData(int n) {
140 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
142 Py_INCREF(data->m_obj);
150 // Associate the given client data with the item at position n.
151 void SetClientData(int n, PyObject* clientData) {
152 wxPyClientData* data = new wxPyClientData(clientData);
153 self->SetClientObject(n, data);
160 //---------------------------------------------------------------------------
163 class wxControlWithItems : public wxControl, public wxItemContainer
168 //---------------------------------------------------------------------------