]>
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
15 wxVListBox popup and wxControlWithItems
18 Implementing item drawing and measuring is similar to wxVListBox.
19 Application needs to subclass wxOwnerDrawnComboBox and implement
20 wxOwnerDrawnComboBox::OnDrawItem, wxOwnerDrawnComboBox::OnMeasureItem
21 and wxOwnerDrawnComboBox::OnMeasureItemWidth.
24 @style{wxODCB_DCLICK_CYCLES}:
25 Double-clicking cycles item if wxCB_READONLY is also used.
26 Synonymous with wxCC_SPECIAL_DCLICK.
27 @style{wxODCB_STD_CONTROL_PAINT}:
28 Control itself is not custom painted using OnDrawItem. Even if this
29 style is not used, writable wxOwnerDrawnComboBox is never custom
30 painted unless SetCustomPaintWidth is called.
33 @beginEventTable{wxCommandEvent}
34 @event{EVT_COMBOBOX(id, func)}:
35 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
36 the list is selected. Note that calling GetValue returns the new
42 @appearance{ownerdrawncombobox.png}
44 @see wxComboCtrl, wxComboBox, wxVListBox, wxCommandEvent
46 class wxOwnerDrawnComboBox
: public wxComboCtrl
51 Constructor, creating and showing a owner-drawn combobox.
54 Parent window. Must not be @NULL.
56 Window identifier. The value wxID_ANY indicates a default value.
58 Initial selection string. An empty string indicates no selection.
62 Window size. If wxDefaultSize is specified then the window is
66 Number of strings with which to initialise the control.
68 An array of strings with which to initialise the control.
70 Window style. See wxOwnerDrawnComboBox.
76 @see Create(), wxValidator
78 wxOwnerDrawnComboBox();
79 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
80 const wxString
& value
= "",
81 const wxPoint
& pos
= wxDefaultPosition
,
82 const wxSize
& size
= wxDefaultSize
,
84 const wxString choices
[] = NULL
,
86 const wxValidator
& validator
= wxDefaultValidator
,
87 const wxString
& name
= "comboBox");
88 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
89 const wxString
& value
,
92 const wxArrayString
& choices
,
94 const wxValidator
& validator
= wxDefaultValidator
,
95 const wxString
& name
= "comboBox");
99 Destructor, destroying the owner-drawn combobox.
101 ~wxOwnerDrawnComboBox();
105 Creates the combobox for two-step construction. Derived classes
106 should call or replace this function. See
107 wxOwnerDrawnComboBox()
110 bool Create(wxWindow
* parent
, wxWindowID id
,
111 const wxString
& value
= "",
112 const wxPoint
& pos
= wxDefaultPosition
,
113 const wxSize
& size
= wxDefaultSize
,
114 int n
, const wxString choices
[],
116 const wxValidator
& validator
= wxDefaultValidator
,
117 const wxString
& name
= "comboBox");
118 bool Create(wxWindow
* parent
, wxWindowID id
,
119 const wxString
& value
,
122 const wxArrayString
& choices
,
124 const wxValidator
& validator
= wxDefaultValidator
,
125 const wxString
& name
= "comboBox");
129 Returns index to the widest item in the list.
131 int GetWidestItem() const;
134 Returns width of the widest item in the list.
136 int GetWidestItemWidth() const;
139 This method is used to draw the items background and, maybe, a border around it.
140 The base class version implements a reasonable default behaviour which consists
141 in drawing the selected item with the standard background colour and drawing a
142 border around the item if it is either selected or current.
144 @remarks flags has the same meaning as with OnDrawItem.
146 void OnDrawBackground(wxDC
& dc
, const wxRect
& rect
, int item
,
150 The derived class may implement this function to actually draw the item
151 with the given index on the provided DC. If function is not implemented,
152 the item text is simply drawn, as if the control was a normal combobox.
155 The device context to use for drawing
157 The bounding rectangle for the item being drawn (DC clipping
158 region is set to this rectangle before calling this function)
160 The index of the item to be drawn
162 Combines any of the following flag values:
164 void OnDrawItem(wxDC
& dc
, const wxRect
& rect
, int item
,
168 The derived class may implement this method to return the height of the
169 specified item (in pixels).
170 The default implementation returns text height, as if this control was
173 wxCoord
OnMeasureItem(size_t item
) const;
176 The derived class may implement this method to return the width of the
177 specified item (in pixels). If -1 is returned, then the item text width
179 The default implementation returns -1.
181 wxCoord
OnMeasureItemWidth(size_t item
) const;