]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/odcombo.h
Added wxPGProperty::Enable() for conveniency. Refactored related code and improved...
[wxWidgets.git] / interface / wx / odcombo.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: odcombo.h
e54c96f1 3// Purpose: interface of wxOwnerDrawnComboBox
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
3fedffdc
FM
9
10enum wxOwnerDrawnComboBoxPaintingFlags
11{
12 /**
13 Combo control is being painted, instead of a list item.
14 Argument item may be @c wxNOT_FOUND in this case.
15 */
16 wxODCB_PAINTING_CONTROL = 0x0001,
17
18 /**
19 An item with selection background is being painted.
20 DC text colour should already be correct.
21 */
22 wxODCB_PAINTING_SELECTED = 0x0002
23};
24
23324ae1
FM
25/**
26 @class wxOwnerDrawnComboBox
7c913512 27
23324ae1 28 wxOwnerDrawnComboBox is a combobox with owner-drawn list items.
74bf4e64 29 In essence, it is a wxComboCtrl with wxVListBox popup and wxControlWithItems
23324ae1 30 interface.
7c913512 31
23324ae1
FM
32 Implementing item drawing and measuring is similar to wxVListBox.
33 Application needs to subclass wxOwnerDrawnComboBox and implement
74bf4e64 34 OnDrawItem(), OnMeasureItem() and OnMeasureItemWidth().
7c913512 35
23324ae1 36 @beginStyleTable
8c6791e4 37 @style{wxODCB_DCLICK_CYCLES}
23324ae1
FM
38 Double-clicking cycles item if wxCB_READONLY is also used.
39 Synonymous with wxCC_SPECIAL_DCLICK.
8c6791e4 40 @style{wxODCB_STD_CONTROL_PAINT}
23324ae1
FM
41 Control itself is not custom painted using OnDrawItem. Even if this
42 style is not used, writable wxOwnerDrawnComboBox is never custom
74bf4e64 43 painted unless SetCustomPaintWidth() is called.
23324ae1 44 @endStyleTable
7c913512 45
3fedffdc
FM
46 @see wxComboCtrl window styles and @ref overview_windowstyles.
47
3051a44a 48 @beginEventEmissionTable{wxCommandEvent}
8c6791e4 49 @event{EVT_COMBOBOX(id, func)}
23324ae1 50 Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on
74bf4e64 51 the list is selected. Note that calling GetValue() returns the new
23324ae1
FM
52 value of selection.
53 @endEventTable
7c913512 54
74bf4e64
FM
55 @see Events emitted by wxComboCtrl.
56
23324ae1
FM
57 @library{wxadv}
58 @category{ctrl}
7e59b885 59 @appearance{ownerdrawncombobox.png}
7c913512 60
e54c96f1 61 @see wxComboCtrl, wxComboBox, wxVListBox, wxCommandEvent
23324ae1
FM
62*/
63class wxOwnerDrawnComboBox : public wxComboCtrl
64{
65public:
74bf4e64
FM
66 /**
67 Default constructor.
68 */
69 wxOwnerDrawnComboBox();
8c6791e4 70
23324ae1
FM
71 /**
72 Constructor, creating and showing a owner-drawn combobox.
3c4f71cc 73
7c913512 74 @param parent
4cc4bfaf 75 Parent window. Must not be @NULL.
7c913512 76 @param id
74bf4e64 77 Window identifier. The value @c wxID_ANY indicates a default value.
7c913512 78 @param value
4cc4bfaf 79 Initial selection string. An empty string indicates no selection.
7c913512 80 @param pos
4cc4bfaf 81 Window position.
7c913512 82 @param size
3fedffdc
FM
83 Window size.
84 If ::wxDefaultSize is specified then the window is sized appropriately.
7c913512 85 @param n
4cc4bfaf 86 Number of strings with which to initialise the control.
7c913512 87 @param choices
4cc4bfaf 88 An array of strings with which to initialise the control.
7c913512 89 @param style
4cc4bfaf 90 Window style. See wxOwnerDrawnComboBox.
7c913512 91 @param validator
4cc4bfaf 92 Window validator.
7c913512 93 @param name
4cc4bfaf 94 Window name.
3c4f71cc 95
4cc4bfaf 96 @see Create(), wxValidator
23324ae1 97 */
7c913512 98 wxOwnerDrawnComboBox(wxWindow* parent, wxWindowID id,
e9c3992c 99 const wxString& value = wxEmptyString,
7c913512
FM
100 const wxPoint& pos = wxDefaultPosition,
101 const wxSize& size = wxDefaultSize,
102 int n = 0,
74bf4e64 103 const wxString[] choices = NULL,
7c913512
FM
104 long style = 0,
105 const wxValidator& validator = wxDefaultValidator,
106 const wxString& name = "comboBox");
792255cc
VZ
107 /**
108 Constructor, creating and showing a owner-drawn combobox.
109
110 @param parent
111 Parent window. Must not be @NULL.
112 @param id
113 Window identifier. The value @c wxID_ANY indicates a default value.
114 @param value
115 Initial selection string. An empty string indicates no selection.
116 @param pos
117 Window position.
118 @param size
119 Window size.
120 If ::wxDefaultSize is specified then the window is sized appropriately.
121 @param choices
122 An array of strings with which to initialise the control.
123 @param style
124 Window style. See wxOwnerDrawnComboBox.
125 @param validator
126 Window validator.
127 @param name
128 Window name.
129
130 @see Create(), wxValidator
131 */
7c913512
FM
132 wxOwnerDrawnComboBox(wxWindow* parent, wxWindowID id,
133 const wxString& value,
134 const wxPoint& pos,
135 const wxSize& size,
136 const wxArrayString& choices,
137 long style = 0,
138 const wxValidator& validator = wxDefaultValidator,
139 const wxString& name = "comboBox");
23324ae1
FM
140
141 /**
142 Destructor, destroying the owner-drawn combobox.
143 */
adaaa686 144 virtual ~wxOwnerDrawnComboBox();
23324ae1
FM
145
146 //@{
147 /**
74bf4e64
FM
148 Creates the combobox for two-step construction.
149 See wxOwnerDrawnComboBox() for further details.
150
151 @remarks Derived classes should call or replace this function.
23324ae1 152 */
57bf907d
FM
153 bool Create(wxWindow *parent,
154 wxWindowID id,
e9c3992c 155 const wxString& value = wxEmptyString,
23324ae1
FM
156 const wxPoint& pos = wxDefaultPosition,
157 const wxSize& size = wxDefaultSize,
23324ae1
FM
158 long style = 0,
159 const wxValidator& validator = wxDefaultValidator,
57bf907d
FM
160 const wxString& name = wxComboBoxNameStr);
161 bool Create(wxWindow *parent,
162 wxWindowID id,
163 const wxString& value,
164 const wxPoint& pos,
165 const wxSize& size,
166 int n,
167 const wxString choices[],
168 long style = 0,
169 const wxValidator& validator = wxDefaultValidator,
170 const wxString& name = wxComboBoxNameStr);
171 bool Create(wxWindow *parent,
172 wxWindowID id,
7c913512
FM
173 const wxString& value,
174 const wxPoint& pos,
175 const wxSize& size,
176 const wxArrayString& choices,
177 long style = 0,
178 const wxValidator& validator = wxDefaultValidator,
57bf907d 179 const wxString& name = wxComboBoxNameStr);
23324ae1
FM
180 //@}
181
182 /**
183 Returns index to the widest item in the list.
184 */
adaaa686 185 virtual int GetWidestItem();
23324ae1
FM
186
187 /**
188 Returns width of the widest item in the list.
189 */
adaaa686 190 virtual int GetWidestItemWidth();
23324ae1 191
5e6e278d
FM
192protected:
193
23324ae1
FM
194 /**
195 This method is used to draw the items background and, maybe, a border around it.
74bf4e64 196
23324ae1
FM
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.
3c4f71cc 200
74bf4e64 201 @remarks flags has the same meaning as with OnDrawItem().
23324ae1 202 */
fadc2df6
FM
203 virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, int item,
204 int flags) const;
23324ae1
FM
205
206 /**
207 The derived class may implement this function to actually draw the item
74bf4e64
FM
208 with the given index on the provided DC.
209
210 If function is not implemented, the item text is simply drawn, as if the control
211 was a normal combobox.
3c4f71cc 212
7c913512 213 @param dc
4cc4bfaf 214 The device context to use for drawing
7c913512 215 @param rect
4cc4bfaf
FM
216 The bounding rectangle for the item being drawn (DC clipping
217 region is set to this rectangle before calling this function)
7c913512 218 @param item
4cc4bfaf 219 The index of the item to be drawn
7c913512 220 @param flags
3fedffdc 221 A combination of the ::wxOwnerDrawnComboBoxPaintingFlags enumeration values.
23324ae1 222 */
fadc2df6
FM
223 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item,
224 int flags) const;
23324ae1
FM
225
226 /**
227 The derived class may implement this method to return the height of the
228 specified item (in pixels).
74bf4e64 229
23324ae1
FM
230 The default implementation returns text height, as if this control was
231 a normal combobox.
232 */
0004982c 233 virtual wxCoord OnMeasureItem(size_t item) const;
23324ae1
FM
234
235 /**
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
238 is used.
74bf4e64 239
23324ae1
FM
240 The default implementation returns -1.
241 */
0004982c 242 virtual wxCoord OnMeasureItemWidth(size_t item) const;
23324ae1 243};
e54c96f1 244