]>
git.saurik.com Git - wxWidgets.git/blob - interface/odcombo.h
e05263140305119c7a1fba3f3246061aa7ae4fb3
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxOwnerDrawnComboBox class
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.
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}
45 wxComboCtrl, wxComboBox, wxVListBox, wxCommandEvent
47 class wxOwnerDrawnComboBox
: public wxComboCtrl
52 Constructor, creating and showing a owner-drawn combobox.
55 Parent window. Must not be @NULL.
57 Window identifier. The value wxID_ANY indicates a default value.
59 Initial selection string. An empty string indicates no selection.
63 Window size. If wxDefaultSize is specified then the window is
67 Number of strings with which to initialise the control.
69 An array of strings with which to initialise the control.
71 Window style. See wxOwnerDrawnComboBox.
77 @see Create(), wxValidator
79 wxOwnerDrawnComboBox();
80 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
81 const wxString
& value
= "",
82 const wxPoint
& pos
= wxDefaultPosition
,
83 const wxSize
& size
= wxDefaultSize
,
85 const wxString choices
[] = NULL
,
87 const wxValidator
& validator
= wxDefaultValidator
,
88 const wxString
& name
= "comboBox");
89 wxOwnerDrawnComboBox(wxWindow
* parent
, wxWindowID id
,
90 const wxString
& value
,
93 const wxArrayString
& choices
,
95 const wxValidator
& validator
= wxDefaultValidator
,
96 const wxString
& name
= "comboBox");
100 Destructor, destroying the owner-drawn combobox.
102 ~wxOwnerDrawnComboBox();
106 Creates the combobox for two-step construction. Derived classes
107 should call or replace this function. See
108 wxOwnerDrawnComboBox()
111 bool Create(wxWindow
* parent
, wxWindowID id
,
112 const wxString
& value
= "",
113 const wxPoint
& pos
= wxDefaultPosition
,
114 const wxSize
& size
= wxDefaultSize
,
115 int n
, const wxString choices
[],
117 const wxValidator
& validator
= wxDefaultValidator
,
118 const wxString
& name
= "comboBox");
119 bool Create(wxWindow
* parent
, wxWindowID id
,
120 const wxString
& value
,
123 const wxArrayString
& choices
,
125 const wxValidator
& validator
= wxDefaultValidator
,
126 const wxString
& name
= "comboBox");
130 Returns index to the widest item in the list.
132 int GetWidestItem() const;
135 Returns width of the widest item in the list.
137 int GetWidestItemWidth() const;
140 This method is used to draw the items background and, maybe, a border around it.
141 The base class version implements a reasonable default behaviour which consists
142 in drawing the selected item with the standard background colour and drawing a
143 border around the item if it is either selected or current.
145 @remarks flags has the same meaning as with OnDrawItem.
147 void OnDrawBackground(wxDC
& dc
, const wxRect
& rect
, int item
,
151 The derived class may implement this function to actually draw the item
152 with the given index on the provided DC. If function is not implemented,
153 the item text is simply drawn, as if the control was a normal combobox.
156 The device context to use for drawing
158 The bounding rectangle for the item being drawn (DC clipping
159 region is set to this rectangle before calling this function)
161 The index of the item to be drawn
163 Combines any of the following flag values:
165 void OnDrawItem(wxDC
& dc
, const wxRect
& rect
, int item
,
169 The derived class may implement this method to return the height of the
170 specified item (in pixels).
171 The default implementation returns text height, as if this control was
174 wxCoord
OnMeasureItem(size_t item
) const;
177 The derived class may implement this method to return the width of the
178 specified item (in pixels). If -1 is returned, then the item text width
180 The default implementation returns -1.
182 wxCoord
OnMeasureItemWidth(size_t item
) const;