1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxOwnerDrawnComboBox
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 enum wxOwnerDrawnComboBoxPaintingFlags
13 Combo control is being painted, instead of a list item.
14 Argument item may be @c wxNOT_FOUND in this case.
16 wxODCB_PAINTING_CONTROL
= 0x0001,
19 An item with selection background is being painted.
20 DC text colour should already be correct.
22 wxODCB_PAINTING_SELECTED
= 0x0002
27 New window styles for wxOwnerDrawnComboBox
32 Double-clicking cycles item if wxCB_READONLY is also used.
34 wxODCB_DCLICK_CYCLES
= wxCC_SPECIAL_DCLICK
,
37 If used, control itself is not custom paint using callback.
38 Even if this is not used, writable combo is never custom paint
39 until SetCustomPaintWidth is called
41 wxODCB_STD_CONTROL_PAINT
= 0x1000
47 @class wxOwnerDrawnComboBox
49 wxOwnerDrawnComboBox is a combobox with owner-drawn list items.
50 In essence, it is a wxComboCtrl with wxVListBox popup and wxControlWithItems
53 Implementing item drawing and measuring is similar to wxVListBox.
54 Application needs to subclass wxOwnerDrawnComboBox and implement
55 OnDrawItem(), OnMeasureItem() and OnMeasureItemWidth().
58 @style{wxODCB_DCLICK_CYCLES}
59 Double-clicking cycles item if wxCB_READONLY is also used.
60 Synonymous with wxCC_SPECIAL_DCLICK.
61 @style{wxODCB_STD_CONTROL_PAINT}
62 Control itself is not custom painted using OnDrawItem. Even if this
63 style is not used, writable wxOwnerDrawnComboBox is never custom
64 painted unless SetCustomPaintWidth() is called.
67 @see wxComboCtrl window styles and @ref overview_windowstyles.
69 @beginEventEmissionTable{wxCommandEvent}
70 @event{EVT_COMBOBOX(id, func)}
71 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
72 the list is selected. Note that calling GetValue() returns the new
76 @see Events emitted by wxComboCtrl.
80 @appearance{ownerdrawncombobox}
82 @see wxComboCtrl, wxComboBox, wxVListBox, wxCommandEvent
84 class wxOwnerDrawnComboBox
: public wxComboCtrl
, public wxItemContainer
90 wxOwnerDrawnComboBox();
93 Constructor, creating and showing a owner-drawn combobox.
96 Parent window. Must not be @NULL.
98 Window identifier. The value @c wxID_ANY indicates a default value.
100 Initial selection string. An empty string indicates no selection.
105 If ::wxDefaultSize is specified then the window is sized appropriately.
107 Number of strings with which to initialise the control.
109 An array of strings with which to initialise the control.
111 Window style. See wxOwnerDrawnComboBox.
117 @see Create(), wxValidator
119 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
120 const wxString
& value
= wxEmptyString
,
121 const wxPoint
& pos
= wxDefaultPosition
,
122 const wxSize
& size
= wxDefaultSize
,
124 const wxString choices
[] = NULL
,
126 const wxValidator
& validator
= wxDefaultValidator
,
127 const wxString
& name
= "comboBox");
129 Constructor, creating and showing a owner-drawn combobox.
132 Parent window. Must not be @NULL.
134 Window identifier. The value @c wxID_ANY indicates a default value.
136 Initial selection string. An empty string indicates no selection.
141 If ::wxDefaultSize is specified then the window is sized appropriately.
143 An array of strings with which to initialise the control.
145 Window style. See wxOwnerDrawnComboBox.
151 @see Create(), wxValidator
153 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
154 const wxString
& value
,
157 const wxArrayString
& choices
,
159 const wxValidator
& validator
= wxDefaultValidator
,
160 const wxString
& name
= "comboBox");
163 Destructor, destroying the owner-drawn combobox.
165 virtual ~wxOwnerDrawnComboBox();
169 Creates the combobox for two-step construction.
170 See wxOwnerDrawnComboBox() for further details.
172 @remarks Derived classes should call or replace this function.
174 bool Create(wxWindow
*parent
,
176 const wxString
& value
= wxEmptyString
,
177 const wxPoint
& pos
= wxDefaultPosition
,
178 const wxSize
& size
= wxDefaultSize
,
180 const wxValidator
& validator
= wxDefaultValidator
,
181 const wxString
& name
= wxComboBoxNameStr
);
182 bool Create(wxWindow
*parent
,
184 const wxString
& value
,
188 const wxString choices
[],
190 const wxValidator
& validator
= wxDefaultValidator
,
191 const wxString
& name
= wxComboBoxNameStr
);
192 bool Create(wxWindow
*parent
,
194 const wxString
& value
,
197 const wxArrayString
& choices
,
199 const wxValidator
& validator
= wxDefaultValidator
,
200 const wxString
& name
= wxComboBoxNameStr
);
204 Returns index to the widest item in the list.
206 virtual int GetWidestItem();
209 Returns width of the widest item in the list.
211 virtual int GetWidestItemWidth();
216 This method is used to draw the items background and, maybe, a border around it.
218 The base class version implements a reasonable default behaviour which consists
219 in drawing the selected item with the standard background colour and drawing a
220 border around the item if it is either selected or current.
222 @remarks flags has the same meaning as with OnDrawItem().
224 virtual void OnDrawBackground(wxDC
& dc
, const wxRect
& rect
, int item
,
228 The derived class may implement this function to actually draw the item
229 with the given index on the provided DC.
231 If function is not implemented, the item text is simply drawn, as if the control
232 was a normal combobox.
235 The device context to use for drawing
237 The bounding rectangle for the item being drawn (DC clipping
238 region is set to this rectangle before calling this function)
240 The index of the item to be drawn
242 A combination of the ::wxOwnerDrawnComboBoxPaintingFlags enumeration values.
244 virtual void OnDrawItem(wxDC
& dc
, const wxRect
& rect
, int item
,
248 The derived class may implement this method to return the height of the
249 specified item (in pixels).
251 The default implementation returns text height, as if this control was
254 virtual wxCoord
OnMeasureItem(size_t item
) const;
257 The derived class may implement this method to return the width of the
258 specified item (in pixels). If -1 is returned, then the item text width
261 The default implementation returns -1.
263 virtual wxCoord
OnMeasureItemWidth(size_t item
) const;