1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/combobox.h
3 // Purpose: the universal combobox
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_UNIV_COMBOBOX_H_
14 #define _WX_UNIV_COMBOBOX_H_
18 class WXDLLIMPEXP_FWD_CORE wxListBox
;
20 // ----------------------------------------------------------------------------
21 // NB: some actions supported by this control are in wx/generic/combo.h
22 // ----------------------------------------------------------------------------
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")
30 // ----------------------------------------------------------------------------
31 // wxComboBox: a combination of text control and a listbox
32 // ----------------------------------------------------------------------------
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
37 class WXDLLIMPEXP_CORE wxComboBox
:
38 public wxWindowWithItems
<wxComboCtrl
, wxItemContainer
>
42 wxComboBox() { Init(); }
44 wxComboBox(wxWindow
*parent
,
46 const wxString
& value
= wxEmptyString
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
50 const wxString choices
[] = (const wxString
*) NULL
,
52 const wxValidator
& validator
= wxDefaultValidator
,
53 const wxString
& name
= wxComboBoxNameStr
)
57 (void)Create(parent
, id
, value
, pos
, size
, n
, choices
,
58 style
, validator
, name
);
60 wxComboBox(wxWindow
*parent
,
62 const wxString
& value
,
65 const wxArrayString
& choices
,
67 const wxValidator
& validator
= wxDefaultValidator
,
68 const wxString
& name
= wxComboBoxNameStr
);
70 bool Create(wxWindow
*parent
,
72 const wxString
& value
= wxEmptyString
,
73 const wxPoint
& pos
= wxDefaultPosition
,
74 const wxSize
& size
= wxDefaultSize
,
76 const wxString choices
[] = (const wxString
*) NULL
,
78 const wxValidator
& validator
= wxDefaultValidator
,
79 const wxString
& name
= wxComboBoxNameStr
);
80 bool Create(wxWindow
*parent
,
82 const wxString
& value
,
85 const wxArrayString
& choices
,
87 const wxValidator
& validator
= wxDefaultValidator
,
88 const wxString
& name
= wxComboBoxNameStr
);
90 virtual ~wxComboBox();
92 // the wxUniversal-specific methods
93 // --------------------------------
95 // implement the combobox interface
98 virtual wxString
GetValue() const { return DoGetValue(); }
99 virtual void SetValue(const wxString
& value
);
100 virtual void WriteText(const wxString
& value
);
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;
117 virtual void SelectAll();
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;
125 // override these methods to disambiguate between two base classes versions
128 wxComboCtrl::Clear();
129 wxItemContainer::Clear();
132 // See wxComboBoxBase discussion of IsEmpty().
133 bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
134 bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
136 // wxControlWithItems methods
137 virtual void DoClear();
138 virtual void DoDeleteOneItem(unsigned int n
);
139 virtual unsigned int GetCount() const;
140 virtual wxString
GetString(unsigned int n
) const;
141 virtual void SetString(unsigned int n
, const wxString
& s
);
142 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
143 virtual void SetSelection(int n
);
144 virtual int GetSelection() const;
145 virtual wxString
GetStringSelection() const;
147 // we have our own input handler and our own actions
148 // (but wxComboCtrl already handled Popup/Dismiss)
150 virtual bool PerformAction(const wxControlAction& action,
152 const wxString& strArg = wxEmptyString);
155 static wxInputHandler
*GetStdInputHandler(wxInputHandler
*handlerDef
);
156 virtual wxInputHandler
*DoGetStdInputHandler(wxInputHandler
*handlerDef
)
158 return GetStdInputHandler(handlerDef
);
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
163 virtual wxClientDataType
GetClientDataType() const;
164 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
167 virtual wxString
DoGetValue() const;
169 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
171 void **clientData
, wxClientDataType type
);
173 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
174 virtual void* DoGetItemClientData(unsigned int n
) const;
177 // common part of all ctors
180 // get the associated listbox
181 wxListBox
*GetLBox() const { return m_lbox
; }
184 // implement wxTextEntry pure virtual method
185 virtual wxWindow
*GetEditableWindow() { return this; }
190 //DECLARE_EVENT_TABLE()
191 DECLARE_DYNAMIC_CLASS(wxComboBox
)
194 #endif // _WX_UNIV_COMBOBOX_H_