]>
git.saurik.com Git - wxWidgets.git/blob - interface/odcombo.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxOwnerDrawnComboBox
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxOwnerDrawnComboBox
13 wxOwnerDrawnComboBox is a combobox with owner-drawn list items.
14 In essence, it is a wxComboCtrl with wxVListBox popup and wxControlWithItems
17 Implementing item drawing and measuring is similar to wxVListBox.
18 Application needs to subclass wxOwnerDrawnComboBox and implement
19 OnDrawItem(), OnMeasureItem() and OnMeasureItemWidth().
22 @style{wxODCB_DCLICK_CYCLES}
23 Double-clicking cycles item if wxCB_READONLY is also used.
24 Synonymous with wxCC_SPECIAL_DCLICK.
25 @style{wxODCB_STD_CONTROL_PAINT}
26 Control itself is not custom painted using OnDrawItem. Even if this
27 style is not used, writable wxOwnerDrawnComboBox is never custom
28 painted unless SetCustomPaintWidth() is called.
31 @beginEventTable{wxCommandEvent}
32 @event{EVT_COMBOBOX(id, func)}
33 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
34 the list is selected. Note that calling GetValue() returns the new
38 @see Events emitted by wxComboCtrl.
42 @appearance{ownerdrawncombobox.png}
44 @see wxComboCtrl, wxComboBox, wxVListBox, wxCommandEvent
46 class wxOwnerDrawnComboBox
: public wxComboCtrl
52 wxOwnerDrawnComboBox();
56 Constructor, creating and showing a owner-drawn combobox.
59 Parent window. Must not be @NULL.
61 Window identifier. The value @c wxID_ANY indicates a default value.
63 Initial selection string. An empty string indicates no selection.
67 Window size. If @c wxDefaultSize is specified then the window is sized
70 Number of strings with which to initialise the control.
72 An array of strings with which to initialise the control.
74 Window style. See wxOwnerDrawnComboBox.
80 @see Create(), wxValidator
82 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
83 const wxString
& value
= "",
84 const wxPoint
& pos
= wxDefaultPosition
,
85 const wxSize
& size
= wxDefaultSize
,
87 const wxString
[] choices
= NULL
,
89 const wxValidator
& validator
= wxDefaultValidator
,
90 const wxString
& name
= "comboBox");
91 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
92 const wxString
& value
,
95 const wxArrayString
& choices
,
97 const wxValidator
& validator
= wxDefaultValidator
,
98 const wxString
& name
= "comboBox");
102 Destructor, destroying the owner-drawn combobox.
104 ~wxOwnerDrawnComboBox();
108 Creates the combobox for two-step construction.
109 See wxOwnerDrawnComboBox() for further details.
111 @remarks Derived classes should call or replace this function.
113 bool Create(wxWindow
* parent
, wxWindowID id
,
114 const wxString
& value
= "",
115 const wxPoint
& pos
= wxDefaultPosition
,
116 const wxSize
& size
= wxDefaultSize
,
117 int n
, const wxString choices
[],
119 const wxValidator
& validator
= wxDefaultValidator
,
120 const wxString
& name
= "comboBox");
121 bool Create(wxWindow
* parent
, wxWindowID id
,
122 const wxString
& value
,
125 const wxArrayString
& choices
,
127 const wxValidator
& validator
= wxDefaultValidator
,
128 const wxString
& name
= "comboBox");
132 Returns index to the widest item in the list.
134 int GetWidestItem() const;
137 Returns width of the widest item in the list.
139 int GetWidestItemWidth() const;
142 This method is used to draw the items background and, maybe, a border around it.
144 The base class version implements a reasonable default behaviour which consists
145 in drawing the selected item with the standard background colour and drawing a
146 border around the item if it is either selected or current.
148 @remarks flags has the same meaning as with OnDrawItem().
150 void OnDrawBackground(wxDC
& dc
, const wxRect
& rect
, int item
,
154 The derived class may implement this function to actually draw the item
155 with the given index on the provided DC.
157 If function is not implemented, the item text is simply drawn, as if the control
158 was a normal combobox.
161 The device context to use for drawing
163 The bounding rectangle for the item being drawn (DC clipping
164 region is set to this rectangle before calling this function)
166 The index of the item to be drawn
168 Combines any of the following flag values:
171 @style{wxODCB_PAINTING_CONTROL}
172 Combo control is being painted, instead of a list item.
173 Argument item may be @c wxNOT_FOUND in this case.
174 @style{wxODCB_PAINTING_SELECTED}
175 An item with selection background is being painted.
176 DC text colour should already be correct.
179 void OnDrawItem(wxDC
& dc
, const wxRect
& rect
, int item
,
183 The derived class may implement this method to return the height of the
184 specified item (in pixels).
186 The default implementation returns text height, as if this control was
189 wxCoord
OnMeasureItem(size_t item
) const;
192 The derived class may implement this method to return the width of the
193 specified item (in pixels). If -1 is returned, then the item text width
196 The default implementation returns -1.
198 wxCoord
OnMeasureItemWidth(size_t item
) const;