]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/combobox.h
Apply patch [ 1548750 ] wxVsnprintf() various fixes
[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 WXDLLEXPORT 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 _T("next")
26 #define wxACTION_COMBOBOX_SELECT_PREV _T("prev")
27 #define wxACTION_COMBOBOX_SELECT _T("select")
28
29
30 // ----------------------------------------------------------------------------
31 // wxComboBox: a combination of text control and a listbox
32 // ----------------------------------------------------------------------------
33
34 class WXDLLEXPORT wxComboBox : public wxComboCtrl, public wxComboBoxBase
35 {
36 public:
37 // ctors and such
38 wxComboBox() { Init(); }
39
40 wxComboBox(wxWindow *parent,
41 wxWindowID id,
42 const wxString& value = wxEmptyString,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 int n = 0,
46 const wxString choices[] = (const wxString *) NULL,
47 long style = 0,
48 const wxValidator& validator = wxDefaultValidator,
49 const wxString& name = wxComboBoxNameStr)
50 {
51 Init();
52
53 (void)Create(parent, id, value, pos, size, n, choices,
54 style, validator, name);
55 }
56 wxComboBox(wxWindow *parent,
57 wxWindowID id,
58 const wxString& value,
59 const wxPoint& pos,
60 const wxSize& size,
61 const wxArrayString& choices,
62 long style = 0,
63 const wxValidator& validator = wxDefaultValidator,
64 const wxString& name = wxComboBoxNameStr);
65
66 bool Create(wxWindow *parent,
67 wxWindowID id,
68 const wxString& value = wxEmptyString,
69 const wxPoint& pos = wxDefaultPosition,
70 const wxSize& size = wxDefaultSize,
71 int n = 0,
72 const wxString choices[] = (const wxString *) NULL,
73 long style = 0,
74 const wxValidator& validator = wxDefaultValidator,
75 const wxString& name = wxComboBoxNameStr);
76 bool Create(wxWindow *parent,
77 wxWindowID id,
78 const wxString& value,
79 const wxPoint& pos,
80 const wxSize& size,
81 const wxArrayString& choices,
82 long style = 0,
83 const wxValidator& validator = wxDefaultValidator,
84 const wxString& name = wxComboBoxNameStr);
85
86 virtual ~wxComboBox();
87
88 // the wxUniversal-specific methods
89 // --------------------------------
90
91 // implement the combobox interface
92
93 // wxTextCtrl methods
94 virtual wxString GetValue() const;
95 virtual void SetValue(const wxString& value);
96 virtual void Copy();
97 virtual void Cut();
98 virtual void Paste();
99 virtual void SetInsertionPoint(long pos);
100 virtual void SetInsertionPointEnd();
101 virtual long GetInsertionPoint() const;
102 virtual wxTextPos GetLastPosition() const;
103 virtual void Replace(long from, long to, const wxString& value);
104 virtual void Remove(long from, long to);
105 virtual void SetSelection(long from, long to);
106 virtual void SetEditable(bool editable);
107 virtual bool IsEditable() const;
108
109 virtual void Undo();
110 virtual void Redo();
111 virtual void SelectAll();
112
113 virtual bool CanCopy() const;
114 virtual bool CanCut() const;
115 virtual bool CanPaste() const;
116 virtual bool CanUndo() const;
117 virtual bool CanRedo() const;
118
119 // wxControlWithItems methods
120 virtual void Clear();
121 virtual void Delete(unsigned int n);
122 virtual unsigned int GetCount() const;
123 virtual wxString GetString(unsigned int n) const;
124 virtual void SetString(unsigned int n, const wxString& s);
125 virtual int FindString(const wxString& s, bool bCase = false) const;
126 virtual void SetSelection(int n);
127 virtual int GetSelection() const;
128
129 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
130
131 // we have our own input handler and our own actions
132 // (but wxComboCtrl already handled Popup/Dismiss)
133 /*
134 virtual bool PerformAction(const wxControlAction& action,
135 long numArg = 0l,
136 const wxString& strArg = wxEmptyString);
137 */
138
139 protected:
140 virtual int DoAppend(const wxString& item);
141 virtual int DoInsert(const wxString& item, unsigned int pos);
142 virtual void DoSetItemClientData(unsigned int n, void* clientData);
143 virtual void* DoGetItemClientData(unsigned int n) const;
144 virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
145 virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
146
147 // common part of all ctors
148 void Init();
149
150 // get the associated listbox
151 wxListBox *GetLBox() const { return m_lbox; }
152
153 private:
154 // the popup listbox
155 wxListBox *m_lbox;
156
157 //DECLARE_EVENT_TABLE()
158 DECLARE_DYNAMIC_CLASS(wxComboBox)
159 };
160
161
162 // ----------------------------------------------------------------------------
163 // wxStdComboBoxInputHandler: allows the user to open/close the combo from kbd
164 // ----------------------------------------------------------------------------
165
166 class WXDLLEXPORT wxStdComboBoxInputHandler : public wxStdInputHandler
167 {
168 public:
169 wxStdComboBoxInputHandler(wxInputHandler *inphand);
170
171 virtual bool HandleKey(wxInputConsumer *consumer,
172 const wxKeyEvent& event,
173 bool pressed);
174 };
175
176
177 #endif // _WX_UNIV_COMBOBOX_H_