]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/combobox.h
Define wx[U]IntPtr as long, not [s]size_t, in 32 bit builds.
[wxWidgets.git] / include / wx / univ / combobox.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/combobox.h
3 // Purpose: the universal combobox
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 30.08.00
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12
13 #ifndef _WX_UNIV_COMBOBOX_H_
14 #define _WX_UNIV_COMBOBOX_H_
15
16 #include "wx/combo.h"
17
18 class WXDLLIMPEXP_FWD_CORE wxListBox;
19
20 // ----------------------------------------------------------------------------
21 // NB: some actions supported by this control are in wx/generic/combo.h
22 // ----------------------------------------------------------------------------
23
24 // choose the next/prev/specified (by numArg) item
25 #define wxACTION_COMBOBOX_SELECT_NEXT wxT("next")
26 #define wxACTION_COMBOBOX_SELECT_PREV wxT("prev")
27 #define wxACTION_COMBOBOX_SELECT wxT("select")
28
29
30 // ----------------------------------------------------------------------------
31 // wxComboBox: a combination of text control and a listbox
32 // ----------------------------------------------------------------------------
33
34 // NB: Normally we'd like wxComboBox to inherit from wxComboBoxBase, but here
35 // we can't really do that since both wxComboBoxBase and wxComboCtrl inherit
36 // from wxTextCtrl.
37 class WXDLLIMPEXP_CORE wxComboBox : public wxComboCtrl, public wxItemContainer
38 {
39 public:
40 // ctors and such
41 wxComboBox() { Init(); }
42
43 wxComboBox(wxWindow *parent,
44 wxWindowID id,
45 const wxString& value = wxEmptyString,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 int n = 0,
49 const wxString choices[] = (const wxString *) NULL,
50 long style = 0,
51 const wxValidator& validator = wxDefaultValidator,
52 const wxString& name = wxComboBoxNameStr)
53 {
54 Init();
55
56 (void)Create(parent, id, value, pos, size, n, choices,
57 style, validator, name);
58 }
59 wxComboBox(wxWindow *parent,
60 wxWindowID id,
61 const wxString& value,
62 const wxPoint& pos,
63 const wxSize& size,
64 const wxArrayString& choices,
65 long style = 0,
66 const wxValidator& validator = wxDefaultValidator,
67 const wxString& name = wxComboBoxNameStr);
68
69 bool Create(wxWindow *parent,
70 wxWindowID id,
71 const wxString& value = wxEmptyString,
72 const wxPoint& pos = wxDefaultPosition,
73 const wxSize& size = wxDefaultSize,
74 int n = 0,
75 const wxString choices[] = (const wxString *) NULL,
76 long style = 0,
77 const wxValidator& validator = wxDefaultValidator,
78 const wxString& name = wxComboBoxNameStr);
79 bool Create(wxWindow *parent,
80 wxWindowID id,
81 const wxString& value,
82 const wxPoint& pos,
83 const wxSize& size,
84 const wxArrayString& choices,
85 long style = 0,
86 const wxValidator& validator = wxDefaultValidator,
87 const wxString& name = wxComboBoxNameStr);
88
89 virtual ~wxComboBox();
90
91 // the wxUniversal-specific methods
92 // --------------------------------
93
94 // implement the combobox interface
95
96 // wxTextCtrl methods
97 virtual wxString GetValue() const { return DoGetValue(); }
98 virtual void SetValue(const wxString& value);
99 virtual void WriteText(const wxString& value);
100 virtual void Copy();
101 virtual void Cut();
102 virtual void Paste();
103 virtual void SetInsertionPoint(long pos);
104 virtual void SetInsertionPointEnd();
105 virtual long GetInsertionPoint() const;
106 virtual wxTextPos GetLastPosition() const;
107 virtual void Replace(long from, long to, const wxString& value);
108 virtual void Remove(long from, long to);
109 virtual void SetSelection(long from, long to);
110 virtual void GetSelection(long *from, long *to) const;
111 virtual void SetEditable(bool editable);
112 virtual bool IsEditable() const;
113
114 virtual void Undo();
115 virtual void Redo();
116 virtual void SelectAll();
117
118 virtual bool CanCopy() const;
119 virtual bool CanCut() const;
120 virtual bool CanPaste() const;
121 virtual bool CanUndo() const;
122 virtual bool CanRedo() const;
123
124 // override these methods to disambiguate between two base classes versions
125 virtual void Clear()
126 {
127 wxComboCtrl::Clear();
128 wxItemContainer::Clear();
129 }
130
131 bool IsEmpty() const { return wxItemContainer::IsEmpty(); }
132
133 // wxControlWithItems methods
134 virtual void DoClear();
135 virtual void DoDeleteOneItem(unsigned int n);
136 virtual unsigned int GetCount() const;
137 virtual wxString GetString(unsigned int n) const;
138 virtual void SetString(unsigned int n, const wxString& s);
139 virtual int FindString(const wxString& s, bool bCase = false) const;
140 virtual void SetSelection(int n);
141 virtual int GetSelection() const;
142 virtual wxString GetStringSelection() const;
143
144 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
145
146 // we have our own input handler and our own actions
147 // (but wxComboCtrl already handled Popup/Dismiss)
148 /*
149 virtual bool PerformAction(const wxControlAction& action,
150 long numArg = 0l,
151 const wxString& strArg = wxEmptyString);
152 */
153
154 static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
155 virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
156 {
157 return GetStdInputHandler(handlerDef);
158 }
159
160 // we delegate our client data handling to wxListBox which we use for the
161 // items, so override this and other methods dealing with the client data
162 virtual wxClientDataType GetClientDataType() const;
163 virtual void SetClientDataType(wxClientDataType clientDataItemsType);
164
165 protected:
166 virtual wxString DoGetValue() const;
167
168 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
169 unsigned int pos,
170 void **clientData, wxClientDataType type);
171
172 virtual void DoSetItemClientData(unsigned int n, void* clientData);
173 virtual void* DoGetItemClientData(unsigned int n) const;
174
175
176 // common part of all ctors
177 void Init();
178
179 // get the associated listbox
180 wxListBox *GetLBox() const { return m_lbox; }
181
182 private:
183 // implement wxTextEntry pure virtual method
184 virtual wxWindow *GetEditableWindow() { return this; }
185
186 // the popup listbox
187 wxListBox *m_lbox;
188
189 //DECLARE_EVENT_TABLE()
190 DECLARE_DYNAMIC_CLASS(wxComboBox)
191 };
192
193 #endif // _WX_UNIV_COMBOBOX_H_