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