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