]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/univ/combobox.h | |
3 | // Purpose: the universal combobox | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 30.08.00 | |
442b35b5 | 7 | // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 8 | // Licence: wxWindows licence |
1e6feb95 VZ |
9 | /////////////////////////////////////////////////////////////////////////////// |
10 | ||
1e6feb95 VZ |
11 | |
12 | #ifndef _WX_UNIV_COMBOBOX_H_ | |
13 | #define _WX_UNIV_COMBOBOX_H_ | |
14 | ||
6d0ce565 VZ |
15 | #include "wx/combo.h" |
16 | ||
b5dbe15d | 17 | class WXDLLIMPEXP_FWD_CORE wxListBox; |
1e6feb95 VZ |
18 | |
19 | // ---------------------------------------------------------------------------- | |
6d0ce565 | 20 | // NB: some actions supported by this control are in wx/generic/combo.h |
1e6feb95 VZ |
21 | // ---------------------------------------------------------------------------- |
22 | ||
1e6feb95 | 23 | // choose the next/prev/specified (by numArg) item |
9a83f860 VZ |
24 | #define wxACTION_COMBOBOX_SELECT_NEXT wxT("next") |
25 | #define wxACTION_COMBOBOX_SELECT_PREV wxT("prev") | |
26 | #define wxACTION_COMBOBOX_SELECT wxT("select") | |
1e6feb95 | 27 | |
1e6feb95 VZ |
28 | |
29 | // ---------------------------------------------------------------------------- | |
30 | // wxComboBox: a combination of text control and a listbox | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
a7f62f39 JS |
33 | // NB: Normally we'd like wxComboBox to inherit from wxComboBoxBase, but here |
34 | // we can't really do that since both wxComboBoxBase and wxComboCtrl inherit | |
35 | // from wxTextCtrl. | |
bf8f1022 VZ |
36 | class WXDLLIMPEXP_CORE wxComboBox : |
37 | public wxWindowWithItems<wxComboCtrl, wxItemContainer> | |
1e6feb95 VZ |
38 | { |
39 | public: | |
40 | // ctors and such | |
6463b9f5 | 41 | wxComboBox() { Init(); } |
1e6feb95 VZ |
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, | |
ba1e9d6c | 49 | const wxString choices[] = (const wxString *) NULL, |
1e6feb95 VZ |
50 | long style = 0, |
51 | const wxValidator& validator = wxDefaultValidator, | |
6463b9f5 JS |
52 | const wxString& name = wxComboBoxNameStr) |
53 | { | |
54 | Init(); | |
55 | ||
56 | (void)Create(parent, id, value, pos, size, n, choices, | |
57 | style, validator, name); | |
58 | } | |
584ad2a3 MB |
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); | |
1e6feb95 VZ |
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); | |
584ad2a3 MB |
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); | |
1e6feb95 VZ |
88 | |
89 | virtual ~wxComboBox(); | |
90 | ||
91 | // the wxUniversal-specific methods | |
92 | // -------------------------------- | |
93 | ||
94 | // implement the combobox interface | |
95 | ||
96 | // wxTextCtrl methods | |
3373e900 | 97 | virtual wxString GetValue() const { return DoGetValue(); } |
1e6feb95 | 98 | virtual void SetValue(const wxString& value); |
0ec1179b | 99 | virtual void WriteText(const wxString& value); |
1e6feb95 VZ |
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; | |
7d8268a1 | 106 | virtual wxTextPos GetLastPosition() const; |
1e6feb95 VZ |
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); | |
0ec1179b | 110 | virtual void GetSelection(long *from, long *to) const; |
1e6feb95 | 111 | virtual void SetEditable(bool editable); |
150e31d2 JS |
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; | |
1e6feb95 | 123 | |
a7f62f39 JS |
124 | // override these methods to disambiguate between two base classes versions |
125 | virtual void Clear() | |
126 | { | |
127 | wxComboCtrl::Clear(); | |
128 | wxItemContainer::Clear(); | |
129 | } | |
130 | ||
36a96421 VZ |
131 | // See wxComboBoxBase discussion of IsEmpty(). |
132 | bool IsListEmpty() const { return wxItemContainer::IsEmpty(); } | |
133 | bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); } | |
a7f62f39 | 134 | |
1e6feb95 | 135 | // wxControlWithItems methods |
a236aa20 VZ |
136 | virtual void DoClear(); |
137 | virtual void DoDeleteOneItem(unsigned int n); | |
aa61d352 VZ |
138 | virtual unsigned int GetCount() const; |
139 | virtual wxString GetString(unsigned int n) const; | |
140 | virtual void SetString(unsigned int n, const wxString& s); | |
853dcc57 | 141 | virtual int FindString(const wxString& s, bool bCase = false) const; |
c6179a84 | 142 | virtual void SetSelection(int n); |
1e6feb95 | 143 | virtual int GetSelection() const; |
0ec1179b | 144 | virtual wxString GetStringSelection() const; |
dcfb179b | 145 | |
6d0ce565 | 146 | // we have our own input handler and our own actions |
a57d600f | 147 | // (but wxComboCtrl already handled Popup/Dismiss) |
6d0ce565 VZ |
148 | /* |
149 | virtual bool PerformAction(const wxControlAction& action, | |
150 | long numArg = 0l, | |
151 | const wxString& strArg = wxEmptyString); | |
152 | */ | |
153 | ||
9467bdb7 VZ |
154 | static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef); |
155 | virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef) | |
156 | { | |
157 | return GetStdInputHandler(handlerDef); | |
158 | } | |
159 | ||
131b1fba VZ |
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 | |
b152d8c5 | 162 | virtual wxClientDataType GetClientDataType() const; |
131b1fba VZ |
163 | virtual void SetClientDataType(wxClientDataType clientDataItemsType); |
164 | ||
1e6feb95 | 165 | protected: |
3373e900 VZ |
166 | virtual wxString DoGetValue() const; |
167 | ||
a236aa20 VZ |
168 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, |
169 | unsigned int pos, | |
170 | void **clientData, wxClientDataType type); | |
171 | ||
aa61d352 VZ |
172 | virtual void DoSetItemClientData(unsigned int n, void* clientData); |
173 | virtual void* DoGetItemClientData(unsigned int n) const; | |
1e6feb95 | 174 | |
131b1fba | 175 | |
1e6feb95 VZ |
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: | |
63f7d502 VZ |
183 | // implement wxTextEntry pure virtual method |
184 | virtual wxWindow *GetEditableWindow() { return this; } | |
185 | ||
1e6feb95 VZ |
186 | // the popup listbox |
187 | wxListBox *m_lbox; | |
188 | ||
189 | //DECLARE_EVENT_TABLE() | |
190 | DECLARE_DYNAMIC_CLASS(wxComboBox) | |
191 | }; | |
192 | ||
1e6feb95 | 193 | #endif // _WX_UNIV_COMBOBOX_H_ |