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
26 @class wxOwnerDrawnComboBox
28 wxOwnerDrawnComboBox is a combobox with owner-drawn list items.
29 In essence, it is a wxComboCtrl with wxVListBox popup and wxControlWithItems
32 Implementing item drawing and measuring is similar to wxVListBox.
33 Application needs to subclass wxOwnerDrawnComboBox and implement
34 OnDrawItem(), OnMeasureItem() and OnMeasureItemWidth().
37 @style{wxODCB_DCLICK_CYCLES}
38 Double-clicking cycles item if wxCB_READONLY is also used.
39 Synonymous with wxCC_SPECIAL_DCLICK.
40 @style{wxODCB_STD_CONTROL_PAINT}
41 Control itself is not custom painted using OnDrawItem. Even if this
42 style is not used, writable wxOwnerDrawnComboBox is never custom
43 painted unless SetCustomPaintWidth() is called.
46 @see wxComboCtrl window styles and @ref overview_windowstyles.
48 @beginEventEmissionTable{wxCommandEvent}
49 @event{EVT_COMBOBOX(id, func)}
50 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
51 the list is selected. Note that calling GetValue() returns the new
55 @see Events emitted by wxComboCtrl.
59 @appearance{ownerdrawncombobox.png}
61 @see wxComboCtrl, wxComboBox, wxVListBox, wxCommandEvent
63 class wxOwnerDrawnComboBox
: public wxComboCtrl
69 wxOwnerDrawnComboBox();
72 Constructor, creating and showing a owner-drawn combobox.
75 Parent window. Must not be @NULL.
77 Window identifier. The value @c wxID_ANY indicates a default value.
79 Initial selection string. An empty string indicates no selection.
84 If ::wxDefaultSize is specified then the window is sized appropriately.
86 Number of strings with which to initialise the control.
88 An array of strings with which to initialise the control.
90 Window style. See wxOwnerDrawnComboBox.
96 @see Create(), wxValidator
98 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
99 const wxString
& value
= wxEmptyString
,
100 const wxPoint
& pos
= wxDefaultPosition
,
101 const wxSize
& size
= wxDefaultSize
,
103 const wxString
[] choices
= NULL
,
105 const wxValidator
& validator
= wxDefaultValidator
,
106 const wxString
& name
= "comboBox");
108 Constructor, creating and showing a owner-drawn combobox.
111 Parent window. Must not be @NULL.
113 Window identifier. The value @c wxID_ANY indicates a default value.
115 Initial selection string. An empty string indicates no selection.
120 If ::wxDefaultSize is specified then the window is sized appropriately.
122 An array of strings with which to initialise the control.
124 Window style. See wxOwnerDrawnComboBox.
130 @see Create(), wxValidator
132 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
133 const wxString
& value
,
136 const wxArrayString
& choices
,
138 const wxValidator
& validator
= wxDefaultValidator
,
139 const wxString
& name
= "comboBox");
142 Destructor, destroying the owner-drawn combobox.
144 virtual ~wxOwnerDrawnComboBox();
148 Creates the combobox for two-step construction.
149 See wxOwnerDrawnComboBox() for further details.
151 @remarks Derived classes should call or replace this function.
153 bool Create(wxWindow
*parent
,
155 const wxString
& value
= wxEmptyString
,
156 const wxPoint
& pos
= wxDefaultPosition
,
157 const wxSize
& size
= wxDefaultSize
,
159 const wxValidator
& validator
= wxDefaultValidator
,
160 const wxString
& name
= wxComboBoxNameStr
);
161 bool Create(wxWindow
*parent
,
163 const wxString
& value
,
167 const wxString choices
[],
169 const wxValidator
& validator
= wxDefaultValidator
,
170 const wxString
& name
= wxComboBoxNameStr
);
171 bool Create(wxWindow
*parent
,
173 const wxString
& value
,
176 const wxArrayString
& choices
,
178 const wxValidator
& validator
= wxDefaultValidator
,
179 const wxString
& name
= wxComboBoxNameStr
);
183 Returns index to the widest item in the list.
185 virtual int GetWidestItem();
188 Returns width of the widest item in the list.
190 virtual int GetWidestItemWidth();
195 This method is used to draw the items background and, maybe, a border around it.
197 The base class version implements a reasonable default behaviour which consists
198 in drawing the selected item with the standard background colour and drawing a
199 border around the item if it is either selected or current.
201 @remarks flags has the same meaning as with OnDrawItem().
203 virtual void OnDrawBackground(wxDC
& dc
, const wxRect
& rect
, int item
,
207 The derived class may implement this function to actually draw the item
208 with the given index on the provided DC.
210 If function is not implemented, the item text is simply drawn, as if the control
211 was a normal combobox.
214 The device context to use for drawing
216 The bounding rectangle for the item being drawn (DC clipping
217 region is set to this rectangle before calling this function)
219 The index of the item to be drawn
221 A combination of the ::wxOwnerDrawnComboBoxPaintingFlags enumeration values.
223 virtual void OnDrawItem(wxDC
& dc
, const wxRect
& rect
, int item
,
227 The derived class may implement this method to return the height of the
228 specified item (in pixels).
230 The default implementation returns text height, as if this control was
233 virtual wxCoord
OnMeasureItem(size_t item
) const;
236 The derived class may implement this method to return the width of the
237 specified item (in pixels). If -1 is returned, then the item text width
240 The default implementation returns -1.
242 virtual wxCoord
OnMeasureItemWidth(size_t item
) const;