1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxOwnerDrawnComboBox
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 enum wxOwnerDrawnComboBoxPaintingFlags
12 Combo control is being painted, instead of a list item.
13 Argument item may be @c wxNOT_FOUND in this case.
15 wxODCB_PAINTING_CONTROL
= 0x0001,
18 An item with selection background is being painted.
19 DC text colour should already be correct.
21 wxODCB_PAINTING_SELECTED
= 0x0002
26 New window styles for wxOwnerDrawnComboBox
31 Double-clicking cycles item if wxCB_READONLY is also used.
33 wxODCB_DCLICK_CYCLES
= wxCC_SPECIAL_DCLICK
,
36 If used, control itself is not custom paint using callback.
37 Even if this is not used, writable combo is never custom paint
38 until SetCustomPaintWidth is called
40 wxODCB_STD_CONTROL_PAINT
= 0x1000
46 @class wxOwnerDrawnComboBox
48 wxOwnerDrawnComboBox is a combobox with owner-drawn list items.
49 In essence, it is a wxComboCtrl with wxVListBox popup and wxControlWithItems
52 Implementing item drawing and measuring is similar to wxVListBox.
53 Application needs to subclass wxOwnerDrawnComboBox and implement
54 OnDrawItem(), OnMeasureItem() and OnMeasureItemWidth().
57 @style{wxODCB_DCLICK_CYCLES}
58 Double-clicking cycles item if wxCB_READONLY is also used.
59 Synonymous with wxCC_SPECIAL_DCLICK.
60 @style{wxODCB_STD_CONTROL_PAINT}
61 Control itself is not custom painted using OnDrawItem. Even if this
62 style is not used, writable wxOwnerDrawnComboBox is never custom
63 painted unless SetCustomPaintWidth() is called.
66 @see wxComboCtrl window styles and @ref overview_windowstyles.
68 @beginEventEmissionTable{wxCommandEvent}
69 @event{EVT_COMBOBOX(id, func)}
70 Process a wxEVT_COMBOBOX event, when an item on
71 the list is selected. Note that calling GetValue() returns the new
75 @see Events emitted by wxComboCtrl.
79 @appearance{ownerdrawncombobox}
81 @see wxComboCtrl, wxComboBox, wxVListBox, wxCommandEvent
83 class wxOwnerDrawnComboBox
: public wxComboCtrl
, public wxItemContainer
89 wxOwnerDrawnComboBox();
92 Constructor, creating and showing a owner-drawn combobox.
95 Parent window. Must not be @NULL.
97 Window identifier. The value @c wxID_ANY indicates a default value.
99 Initial selection string. An empty string indicates no selection.
104 If ::wxDefaultSize is specified then the window is sized appropriately.
106 Number of strings with which to initialise the control.
108 An array of strings with which to initialise the control.
110 Window style. See wxOwnerDrawnComboBox.
116 @see Create(), wxValidator
118 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
119 const wxString
& value
= wxEmptyString
,
120 const wxPoint
& pos
= wxDefaultPosition
,
121 const wxSize
& size
= wxDefaultSize
,
123 const wxString choices
[] = NULL
,
125 const wxValidator
& validator
= wxDefaultValidator
,
126 const wxString
& name
= "comboBox");
128 Constructor, creating and showing a owner-drawn combobox.
131 Parent window. Must not be @NULL.
133 Window identifier. The value @c wxID_ANY indicates a default value.
135 Initial selection string. An empty string indicates no selection.
140 If ::wxDefaultSize is specified then the window is sized appropriately.
142 An array of strings with which to initialise the control.
144 Window style. See wxOwnerDrawnComboBox.
150 @see Create(), wxValidator
152 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
153 const wxString
& value
,
156 const wxArrayString
& choices
,
158 const wxValidator
& validator
= wxDefaultValidator
,
159 const wxString
& name
= "comboBox");
162 Destructor, destroying the owner-drawn combobox.
164 virtual ~wxOwnerDrawnComboBox();
168 Creates the combobox for two-step construction.
169 See wxOwnerDrawnComboBox() for further details.
171 @remarks Derived classes should call or replace this function.
173 bool Create(wxWindow
*parent
,
175 const wxString
& value
= wxEmptyString
,
176 const wxPoint
& pos
= wxDefaultPosition
,
177 const wxSize
& size
= wxDefaultSize
,
179 const wxValidator
& validator
= wxDefaultValidator
,
180 const wxString
& name
= wxComboBoxNameStr
);
181 bool Create(wxWindow
*parent
,
183 const wxString
& value
,
187 const wxString choices
[],
189 const wxValidator
& validator
= wxDefaultValidator
,
190 const wxString
& name
= wxComboBoxNameStr
);
191 bool Create(wxWindow
*parent
,
193 const wxString
& value
,
196 const wxArrayString
& choices
,
198 const wxValidator
& validator
= wxDefaultValidator
,
199 const wxString
& name
= wxComboBoxNameStr
);
203 Returns index to the widest item in the list.
205 virtual int GetWidestItem();
208 Returns width of the widest item in the list.
210 virtual int GetWidestItemWidth();
215 This method is used to draw the items background and, maybe, a border around it.
217 The base class version implements a reasonable default behaviour which consists
218 in drawing the selected item with the standard background colour and drawing a
219 border around the item if it is either selected or current.
221 @remarks flags has the same meaning as with OnDrawItem().
223 virtual void OnDrawBackground(wxDC
& dc
, const wxRect
& rect
, int item
,
227 The derived class may implement this function to actually draw the item
228 with the given index on the provided DC.
230 If function is not implemented, the item text is simply drawn, as if the control
231 was a normal combobox.
234 The device context to use for drawing
236 The bounding rectangle for the item being drawn (DC clipping
237 region is set to this rectangle before calling this function)
239 The index of the item to be drawn
241 A combination of the ::wxOwnerDrawnComboBoxPaintingFlags enumeration values.
243 virtual void OnDrawItem(wxDC
& dc
, const wxRect
& rect
, int item
,
247 The derived class may implement this method to return the height of the
248 specified item (in pixels).
250 The default implementation returns text height, as if this control was
253 virtual wxCoord
OnMeasureItem(size_t item
) const;
256 The derived class may implement this method to return the width of the
257 specified item (in pixels). If -1 is returned, then the item text width
260 The default implementation returns -1.
262 virtual wxCoord
OnMeasureItemWidth(size_t item
) const;