]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/combobox.h
Add some basic tests for wxDataViewCtrl selection handling.
[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 :
38 public wxWindowWithItems<wxComboCtrl, wxItemContainer>
39 {
40 public:
41 // ctors and such
42 wxComboBox() { Init(); }
43
44 wxComboBox(wxWindow *parent,
45 wxWindowID id,
46 const wxString& value = wxEmptyString,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 int n = 0,
50 const wxString choices[] = (const wxString *) NULL,
51 long style = 0,
52 const wxValidator& validator = wxDefaultValidator,
53 const wxString& name = wxComboBoxNameStr)
54 {
55 Init();
56
57 (void)Create(parent, id, value, pos, size, n, choices,
58 style, validator, name);
59 }
60 wxComboBox(wxWindow *parent,
61 wxWindowID id,
62 const wxString& value,
63 const wxPoint& pos,
64 const wxSize& size,
65 const wxArrayString& choices,
66 long style = 0,
67 const wxValidator& validator = wxDefaultValidator,
68 const wxString& name = wxComboBoxNameStr);
69
70 bool Create(wxWindow *parent,
71 wxWindowID id,
72 const wxString& value = wxEmptyString,
73 const wxPoint& pos = wxDefaultPosition,
74 const wxSize& size = wxDefaultSize,
75 int n = 0,
76 const wxString choices[] = (const wxString *) NULL,
77 long style = 0,
78 const wxValidator& validator = wxDefaultValidator,
79 const wxString& name = wxComboBoxNameStr);
80 bool Create(wxWindow *parent,
81 wxWindowID id,
82 const wxString& value,
83 const wxPoint& pos,
84 const wxSize& size,
85 const wxArrayString& choices,
86 long style = 0,
87 const wxValidator& validator = wxDefaultValidator,
88 const wxString& name = wxComboBoxNameStr);
89
90 virtual ~wxComboBox();
91
92 // the wxUniversal-specific methods
93 // --------------------------------
94
95 // implement the combobox interface
96
97 // wxTextCtrl methods
98 virtual wxString GetValue() const { return DoGetValue(); }
99 virtual void SetValue(const wxString& value);
100 virtual void WriteText(const wxString& value);
101 virtual void Copy();
102 virtual void Cut();
103 virtual void Paste();
104 virtual void SetInsertionPoint(long pos);
105 virtual void SetInsertionPointEnd();
106 virtual long GetInsertionPoint() const;
107 virtual wxTextPos GetLastPosition() const;
108 virtual void Replace(long from, long to, const wxString& value);
109 virtual void Remove(long from, long to);
110 virtual void SetSelection(long from, long to);
111 virtual void GetSelection(long *from, long *to) const;
112 virtual void SetEditable(bool editable);
113 virtual bool IsEditable() const;
114
115 virtual void Undo();
116 virtual void Redo();
117 virtual void SelectAll();
118
119 virtual bool CanCopy() const;
120 virtual bool CanCut() const;
121 virtual bool CanPaste() const;
122 virtual bool CanUndo() const;
123 virtual bool CanRedo() const;
124
125 // override these methods to disambiguate between two base classes versions
126 virtual void Clear()
127 {
128 wxComboCtrl::Clear();
129 wxItemContainer::Clear();
130 }
131
132 bool IsEmpty() const { return wxItemContainer::IsEmpty(); }
133
134 // wxControlWithItems methods
135 virtual void DoClear();
136 virtual void DoDeleteOneItem(unsigned int n);
137 virtual unsigned int GetCount() const;
138 virtual wxString GetString(unsigned int n) const;
139 virtual void SetString(unsigned int n, const wxString& s);
140 virtual int FindString(const wxString& s, bool bCase = false) const;
141 virtual void SetSelection(int n);
142 virtual int GetSelection() const;
143 virtual wxString GetStringSelection() const;
144
145 // we have our own input handler and our own actions
146 // (but wxComboCtrl already handled Popup/Dismiss)
147 /*
148 virtual bool PerformAction(const wxControlAction& action,
149 long numArg = 0l,
150 const wxString& strArg = wxEmptyString);
151 */
152
153 static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
154 virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
155 {
156 return GetStdInputHandler(handlerDef);
157 }
158
159 // we delegate our client data handling to wxListBox which we use for the
160 // items, so override this and other methods dealing with the client data
161 virtual wxClientDataType GetClientDataType() const;
162 virtual void SetClientDataType(wxClientDataType clientDataItemsType);
163
164 protected:
165 virtual wxString DoGetValue() const;
166
167 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
168 unsigned int pos,
169 void **clientData, wxClientDataType type);
170
171 virtual void DoSetItemClientData(unsigned int n, void* clientData);
172 virtual void* DoGetItemClientData(unsigned int n) const;
173
174
175 // common part of all ctors
176 void Init();
177
178 // get the associated listbox
179 wxListBox *GetLBox() const { return m_lbox; }
180
181 private:
182 // implement wxTextEntry pure virtual method
183 virtual wxWindow *GetEditableWindow() { return this; }
184
185 // the popup listbox
186 wxListBox *m_lbox;
187
188 //DECLARE_EVENT_TABLE()
189 DECLARE_DYNAMIC_CLASS(wxComboBox)
190 };
191
192 #endif // _WX_UNIV_COMBOBOX_H_