]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | /** | |
10 | @class wxOwnerDrawnComboBox | |
11 | @wxheader{odcombo.h} | |
7c913512 | 12 | |
23324ae1 FM |
13 | wxOwnerDrawnComboBox is a combobox with owner-drawn list items. |
14 | In essence, it is a wxComboCtrl with | |
15 | wxVListBox popup and wxControlWithItems | |
16 | interface. | |
7c913512 | 17 | |
23324ae1 FM |
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. | |
7c913512 | 22 | |
23324ae1 FM |
23 | @beginStyleTable |
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. | |
31 | @endStyleTable | |
7c913512 | 32 | |
1f1d2182 | 33 | @beginEventTable{wxCommandEvent} |
4cc4bfaf | 34 | @event{EVT_COMBOBOX(id, func)}: |
23324ae1 FM |
35 | Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on |
36 | the list is selected. Note that calling GetValue returns the new | |
37 | value of selection. | |
38 | @endEventTable | |
7c913512 | 39 | |
23324ae1 FM |
40 | @library{wxadv} |
41 | @category{ctrl} | |
42 | @appearance{ownerdrawncombobox.png} | |
7c913512 | 43 | |
e54c96f1 | 44 | @see wxComboCtrl, wxComboBox, wxVListBox, wxCommandEvent |
23324ae1 FM |
45 | */ |
46 | class wxOwnerDrawnComboBox : public wxComboCtrl | |
47 | { | |
48 | public: | |
49 | //@{ | |
50 | /** | |
51 | Constructor, creating and showing a owner-drawn combobox. | |
3c4f71cc | 52 | |
7c913512 | 53 | @param parent |
4cc4bfaf | 54 | Parent window. Must not be @NULL. |
7c913512 | 55 | @param id |
4cc4bfaf | 56 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 57 | @param value |
4cc4bfaf | 58 | Initial selection string. An empty string indicates no selection. |
7c913512 | 59 | @param pos |
4cc4bfaf | 60 | Window position. |
7c913512 | 61 | @param size |
4cc4bfaf FM |
62 | Window size. If wxDefaultSize is specified then the window is |
63 | sized | |
64 | appropriately. | |
7c913512 | 65 | @param n |
4cc4bfaf | 66 | Number of strings with which to initialise the control. |
7c913512 | 67 | @param choices |
4cc4bfaf | 68 | An array of strings with which to initialise the control. |
7c913512 | 69 | @param style |
4cc4bfaf | 70 | Window style. See wxOwnerDrawnComboBox. |
7c913512 | 71 | @param validator |
4cc4bfaf | 72 | Window validator. |
7c913512 | 73 | @param name |
4cc4bfaf | 74 | Window name. |
3c4f71cc | 75 | |
4cc4bfaf | 76 | @see Create(), wxValidator |
23324ae1 FM |
77 | */ |
78 | wxOwnerDrawnComboBox(); | |
7c913512 FM |
79 | wxOwnerDrawnComboBox(wxWindow* parent, wxWindowID id, |
80 | const wxString& value = "", | |
81 | const wxPoint& pos = wxDefaultPosition, | |
82 | const wxSize& size = wxDefaultSize, | |
83 | int n = 0, | |
4cc4bfaf | 84 | const wxString choices[] = NULL, |
7c913512 FM |
85 | long style = 0, |
86 | const wxValidator& validator = wxDefaultValidator, | |
87 | const wxString& name = "comboBox"); | |
88 | wxOwnerDrawnComboBox(wxWindow* parent, wxWindowID id, | |
89 | const wxString& value, | |
90 | const wxPoint& pos, | |
91 | const wxSize& size, | |
92 | const wxArrayString& choices, | |
93 | long style = 0, | |
94 | const wxValidator& validator = wxDefaultValidator, | |
95 | const wxString& name = "comboBox"); | |
23324ae1 FM |
96 | //@} |
97 | ||
98 | /** | |
99 | Destructor, destroying the owner-drawn combobox. | |
100 | */ | |
101 | ~wxOwnerDrawnComboBox(); | |
102 | ||
103 | //@{ | |
104 | /** | |
105 | Creates the combobox for two-step construction. Derived classes | |
106 | should call or replace this function. See | |
107 | wxOwnerDrawnComboBox() | |
108 | for further details. | |
109 | */ | |
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[], | |
115 | long style = 0, | |
116 | const wxValidator& validator = wxDefaultValidator, | |
117 | const wxString& name = "comboBox"); | |
7c913512 FM |
118 | bool Create(wxWindow* parent, wxWindowID id, |
119 | const wxString& value, | |
120 | const wxPoint& pos, | |
121 | const wxSize& size, | |
122 | const wxArrayString& choices, | |
123 | long style = 0, | |
124 | const wxValidator& validator = wxDefaultValidator, | |
125 | const wxString& name = "comboBox"); | |
23324ae1 FM |
126 | //@} |
127 | ||
128 | /** | |
129 | Returns index to the widest item in the list. | |
130 | */ | |
328f5751 | 131 | int GetWidestItem() const; |
23324ae1 FM |
132 | |
133 | /** | |
134 | Returns width of the widest item in the list. | |
135 | */ | |
328f5751 | 136 | int GetWidestItemWidth() const; |
23324ae1 FM |
137 | |
138 | /** | |
139 | This method is used to draw the items background and, maybe, a border around it. | |
23324ae1 FM |
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. | |
3c4f71cc | 143 | |
23324ae1 FM |
144 | @remarks flags has the same meaning as with OnDrawItem. |
145 | */ | |
146 | void OnDrawBackground(wxDC& dc, const wxRect& rect, int item, | |
328f5751 | 147 | int flags) const; |
23324ae1 FM |
148 | |
149 | /** | |
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. | |
3c4f71cc | 153 | |
7c913512 | 154 | @param dc |
4cc4bfaf | 155 | The device context to use for drawing |
7c913512 | 156 | @param rect |
4cc4bfaf FM |
157 | The bounding rectangle for the item being drawn (DC clipping |
158 | region is set to this rectangle before calling this function) | |
7c913512 | 159 | @param item |
4cc4bfaf | 160 | The index of the item to be drawn |
7c913512 | 161 | @param flags |
4cc4bfaf | 162 | Combines any of the following flag values: |
23324ae1 FM |
163 | */ |
164 | void OnDrawItem(wxDC& dc, const wxRect& rect, int item, | |
328f5751 | 165 | int flags) const; |
23324ae1 FM |
166 | |
167 | /** | |
168 | The derived class may implement this method to return the height of the | |
169 | specified item (in pixels). | |
23324ae1 FM |
170 | The default implementation returns text height, as if this control was |
171 | a normal combobox. | |
172 | */ | |
328f5751 | 173 | wxCoord OnMeasureItem(size_t item) const; |
23324ae1 FM |
174 | |
175 | /** | |
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 | |
178 | is used. | |
23324ae1 FM |
179 | The default implementation returns -1. |
180 | */ | |
328f5751 | 181 | wxCoord OnMeasureItemWidth(size_t item) const; |
23324ae1 | 182 | }; |
e54c96f1 | 183 |