]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/odcombo.h
Corrected problem of wrong paragraph receiving style in formatting dialog.
[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$
6// Licence: wxWindows license
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
1f1d2182 48 @beginEventTable{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}
0c7fe6f2 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 /**
73 Constructor, creating and showing a owner-drawn combobox.
3c4f71cc 74
7c913512 75 @param parent
4cc4bfaf 76 Parent window. Must not be @NULL.
7c913512 77 @param id
74bf4e64 78 Window identifier. The value @c wxID_ANY indicates a default value.
7c913512 79 @param value
4cc4bfaf 80 Initial selection string. An empty string indicates no selection.
7c913512 81 @param pos
4cc4bfaf 82 Window position.
7c913512 83 @param size
3fedffdc
FM
84 Window size.
85 If ::wxDefaultSize is specified then the window is sized appropriately.
7c913512 86 @param n
4cc4bfaf 87 Number of strings with which to initialise the control.
7c913512 88 @param choices
4cc4bfaf 89 An array of strings with which to initialise the control.
7c913512 90 @param style
4cc4bfaf 91 Window style. See wxOwnerDrawnComboBox.
7c913512 92 @param validator
4cc4bfaf 93 Window validator.
7c913512 94 @param name
4cc4bfaf 95 Window name.
3c4f71cc 96
4cc4bfaf 97 @see Create(), wxValidator
23324ae1 98 */
7c913512
FM
99 wxOwnerDrawnComboBox(wxWindow* parent, wxWindowID id,
100 const wxString& value = "",
101 const wxPoint& pos = wxDefaultPosition,
102 const wxSize& size = wxDefaultSize,
103 int n = 0,
74bf4e64 104 const wxString[] choices = NULL,
7c913512
FM
105 long style = 0,
106 const wxValidator& validator = wxDefaultValidator,
107 const wxString& name = "comboBox");
108 wxOwnerDrawnComboBox(wxWindow* parent, wxWindowID id,
109 const wxString& value,
110 const wxPoint& pos,
111 const wxSize& size,
112 const wxArrayString& choices,
113 long style = 0,
114 const wxValidator& validator = wxDefaultValidator,
115 const wxString& name = "comboBox");
23324ae1
FM
116 //@}
117
118 /**
119 Destructor, destroying the owner-drawn combobox.
120 */
121 ~wxOwnerDrawnComboBox();
122
123 //@{
124 /**
74bf4e64
FM
125 Creates the combobox for two-step construction.
126 See wxOwnerDrawnComboBox() for further details.
127
128 @remarks Derived classes should call or replace this function.
23324ae1
FM
129 */
130 bool Create(wxWindow* parent, wxWindowID id,
131 const wxString& value = "",
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize,
134 int n, const wxString choices[],
135 long style = 0,
136 const wxValidator& validator = wxDefaultValidator,
137 const wxString& name = "comboBox");
7c913512
FM
138 bool Create(wxWindow* parent, wxWindowID id,
139 const wxString& value,
140 const wxPoint& pos,
141 const wxSize& size,
142 const wxArrayString& choices,
143 long style = 0,
144 const wxValidator& validator = wxDefaultValidator,
145 const wxString& name = "comboBox");
23324ae1
FM
146 //@}
147
148 /**
149 Returns index to the widest item in the list.
150 */
328f5751 151 int GetWidestItem() const;
23324ae1
FM
152
153 /**
154 Returns width of the widest item in the list.
155 */
328f5751 156 int GetWidestItemWidth() const;
23324ae1
FM
157
158 /**
159 This method is used to draw the items background and, maybe, a border around it.
74bf4e64 160
23324ae1
FM
161 The base class version implements a reasonable default behaviour which consists
162 in drawing the selected item with the standard background colour and drawing a
163 border around the item if it is either selected or current.
3c4f71cc 164
74bf4e64 165 @remarks flags has the same meaning as with OnDrawItem().
23324ae1
FM
166 */
167 void OnDrawBackground(wxDC& dc, const wxRect& rect, int item,
328f5751 168 int flags) const;
23324ae1
FM
169
170 /**
171 The derived class may implement this function to actually draw the item
74bf4e64
FM
172 with the given index on the provided DC.
173
174 If function is not implemented, the item text is simply drawn, as if the control
175 was a normal combobox.
3c4f71cc 176
7c913512 177 @param dc
4cc4bfaf 178 The device context to use for drawing
7c913512 179 @param rect
4cc4bfaf
FM
180 The bounding rectangle for the item being drawn (DC clipping
181 region is set to this rectangle before calling this function)
7c913512 182 @param item
4cc4bfaf 183 The index of the item to be drawn
7c913512 184 @param flags
3fedffdc 185 A combination of the ::wxOwnerDrawnComboBoxPaintingFlags enumeration values.
23324ae1
FM
186 */
187 void OnDrawItem(wxDC& dc, const wxRect& rect, int item,
328f5751 188 int flags) const;
23324ae1
FM
189
190 /**
191 The derived class may implement this method to return the height of the
192 specified item (in pixels).
74bf4e64 193
23324ae1
FM
194 The default implementation returns text height, as if this control was
195 a normal combobox.
196 */
328f5751 197 wxCoord OnMeasureItem(size_t item) const;
23324ae1
FM
198
199 /**
200 The derived class may implement this method to return the width of the
201 specified item (in pixels). If -1 is returned, then the item text width
202 is used.
74bf4e64 203
23324ae1
FM
204 The default implementation returns -1.
205 */
328f5751 206 wxCoord OnMeasureItemWidth(size_t item) const;
23324ae1 207};
e54c96f1 208