1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/combobox.h
3 // Purpose: the universal combobox
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_COMBOBOX_H_
13 #define _WX_UNIV_COMBOBOX_H_
17 class WXDLLIMPEXP_FWD_CORE wxListBox
;
19 // ----------------------------------------------------------------------------
20 // NB: some actions supported by this control are in wx/generic/combo.h
21 // ----------------------------------------------------------------------------
23 // choose the next/prev/specified (by numArg) item
24 #define wxACTION_COMBOBOX_SELECT_NEXT wxT("next")
25 #define wxACTION_COMBOBOX_SELECT_PREV wxT("prev")
26 #define wxACTION_COMBOBOX_SELECT wxT("select")
29 // ----------------------------------------------------------------------------
30 // wxComboBox: a combination of text control and a listbox
31 // ----------------------------------------------------------------------------
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
36 class WXDLLIMPEXP_CORE wxComboBox
:
37 public wxWindowWithItems
<wxComboCtrl
, wxItemContainer
>
41 wxComboBox() { Init(); }
43 wxComboBox(wxWindow
*parent
,
45 const wxString
& value
= wxEmptyString
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
49 const wxString choices
[] = (const wxString
*) NULL
,
51 const wxValidator
& validator
= wxDefaultValidator
,
52 const wxString
& name
= wxComboBoxNameStr
)
56 (void)Create(parent
, id
, value
, pos
, size
, n
, choices
,
57 style
, validator
, name
);
59 wxComboBox(wxWindow
*parent
,
61 const wxString
& value
,
64 const wxArrayString
& choices
,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxComboBoxNameStr
);
69 bool Create(wxWindow
*parent
,
71 const wxString
& value
= wxEmptyString
,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& size
= wxDefaultSize
,
75 const wxString choices
[] = (const wxString
*) NULL
,
77 const wxValidator
& validator
= wxDefaultValidator
,
78 const wxString
& name
= wxComboBoxNameStr
);
79 bool Create(wxWindow
*parent
,
81 const wxString
& value
,
84 const wxArrayString
& choices
,
86 const wxValidator
& validator
= wxDefaultValidator
,
87 const wxString
& name
= wxComboBoxNameStr
);
89 virtual ~wxComboBox();
91 // the wxUniversal-specific methods
92 // --------------------------------
94 // implement the combobox interface
97 virtual wxString
GetValue() const { return DoGetValue(); }
98 virtual void SetValue(const wxString
& value
);
99 virtual void WriteText(const wxString
& value
);
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;
116 virtual void SelectAll();
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;
124 // override these methods to disambiguate between two base classes versions
127 wxComboCtrl::Clear();
128 wxItemContainer::Clear();
131 // See wxComboBoxBase discussion of IsEmpty().
132 bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
133 bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
135 // wxControlWithItems methods
136 virtual void DoClear();
137 virtual void DoDeleteOneItem(unsigned int n
);
138 virtual unsigned int GetCount() const;
139 virtual wxString
GetString(unsigned int n
) const;
140 virtual void SetString(unsigned int n
, const wxString
& s
);
141 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
142 virtual void SetSelection(int n
);
143 virtual int GetSelection() const;
144 virtual wxString
GetStringSelection() const;
146 // we have our own input handler and our own actions
147 // (but wxComboCtrl already handled Popup/Dismiss)
149 virtual bool PerformAction(const wxControlAction& action,
151 const wxString& strArg = wxEmptyString);
154 static wxInputHandler
*GetStdInputHandler(wxInputHandler
*handlerDef
);
155 virtual wxInputHandler
*DoGetStdInputHandler(wxInputHandler
*handlerDef
)
157 return GetStdInputHandler(handlerDef
);
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
);
166 virtual wxString
DoGetValue() const;
168 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
170 void **clientData
, wxClientDataType type
);
172 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
173 virtual void* DoGetItemClientData(unsigned int n
) const;
176 // common part of all ctors
179 // get the associated listbox
180 wxListBox
*GetLBox() const { return m_lbox
; }
183 // implement wxTextEntry pure virtual method
184 virtual wxWindow
*GetEditableWindow() { return this; }
189 //DECLARE_EVENT_TABLE()
190 DECLARE_DYNAMIC_CLASS(wxComboBox
)
193 #endif // _WX_UNIV_COMBOBOX_H_