]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listctrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxListCtrl |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxListCtrl | |
7c913512 | 11 | |
23324ae1 FM |
12 | A list control presents lists in a number of formats: list view, report view, |
13 | icon view and small icon view. In any case, elements are numbered from zero. | |
14 | For all these modes, the items are stored in the control and must be added to | |
15 | it using wxListCtrl::InsertItem method. | |
7c913512 | 16 | |
23324ae1 FM |
17 | A special case of report view quite different from the other modes of the list |
18 | control is a virtual control in which the items data (including text, images | |
19 | and attributes) is managed by the main program and is requested by the control | |
20 | itself only when needed which allows to have controls with millions of items | |
21 | without consuming much memory. To use virtual list control you must use | |
22 | wxListCtrl::SetItemCount first and overload at least | |
23 | wxListCtrl::OnGetItemText (and optionally | |
24 | wxListCtrl::OnGetItemImage or wxListCtrl::OnGetItemColumnImage and | |
25 | wxListCtrl::OnGetItemAttr) to return the information | |
26 | about the items when the control requests it. Virtual list control can be used | |
27 | as a normal one except that no operations which can take time proportional to | |
28 | the number of items in the control happen -- this is required to allow having a | |
29 | practically infinite number of items. For example, in a multiple selection | |
30 | virtual list control, the selections won't be sent when many items are selected | |
31 | at once because this could mean iterating over all the items. | |
7c913512 | 32 | |
23324ae1 FM |
33 | Using many of wxListCtrl features is shown in the |
34 | @ref overview_samplelistctrl "corresponding sample". | |
7c913512 | 35 | |
23324ae1 FM |
36 | To intercept events from a list control, use the event table macros described |
37 | in wxListEvent. | |
7c913512 FM |
38 | |
39 | @b Mac Note: Starting with 2.8, wxListCtrl uses a native implementation for | |
23324ae1 FM |
40 | report mode, and uses a generic implementation for other modes. You can use the |
41 | generic implementation for report mode as well by setting the | |
e54c96f1 | 42 | mac.listctrl.always_use_generic wxSystemOption() to |
23324ae1 | 43 | 1. |
7c913512 | 44 | |
23324ae1 | 45 | @beginStyleTable |
8c6791e4 | 46 | @style{wxLC_LIST} |
23324ae1 FM |
47 | Multicolumn list view, with optional small icons. Columns are |
48 | computed automatically, i.e. you don't set columns as in | |
49 | wxLC_REPORT. In other words, the list wraps, unlike a wxListBox. | |
8c6791e4 | 50 | @style{wxLC_REPORT} |
23324ae1 | 51 | Single or multicolumn report view, with optional header. |
8c6791e4 | 52 | @style{wxLC_VIRTUAL} |
23324ae1 FM |
53 | The application provides items text on demand. May only be used |
54 | with wxLC_REPORT. | |
8c6791e4 | 55 | @style{wxLC_ICON} |
23324ae1 | 56 | Large icon view, with optional labels. |
8c6791e4 | 57 | @style{wxLC_SMALL_ICON} |
23324ae1 | 58 | Small icon view, with optional labels. |
8c6791e4 | 59 | @style{wxLC_ALIGN_TOP} |
23324ae1 | 60 | Icons align to the top. Win32 default, Win32 only. |
8c6791e4 | 61 | @style{wxLC_ALIGN_LEFT} |
23324ae1 | 62 | Icons align to the left. |
8c6791e4 | 63 | @style{wxLC_AUTOARRANGE} |
23324ae1 | 64 | Icons arrange themselves. Win32 only. |
8c6791e4 | 65 | @style{wxLC_EDIT_LABELS} |
23324ae1 FM |
66 | Labels are editable: the application will be notified when editing |
67 | starts. | |
8c6791e4 | 68 | @style{wxLC_NO_HEADER} |
23324ae1 | 69 | No header in report mode. |
8c6791e4 | 70 | @style{wxLC_SINGLE_SEL} |
23324ae1 | 71 | Single selection (default is multiple). |
8c6791e4 | 72 | @style{wxLC_SORT_ASCENDING} |
b45506e8 VZ |
73 | Sort in ascending order. (You must still supply a comparison callback |
74 | in wxListCtrl::SortItems.) | |
8c6791e4 | 75 | @style{wxLC_SORT_DESCENDING} |
b45506e8 VZ |
76 | Sort in descending order. (You must still supply a comparison callback |
77 | in wxListCtrl::SortItems.) | |
8c6791e4 | 78 | @style{wxLC_HRULES} |
23324ae1 | 79 | Draws light horizontal rules between rows in report mode. |
8c6791e4 | 80 | @style{wxLC_VRULES} |
23324ae1 FM |
81 | Draws light vertical rules between columns in report mode. |
82 | @endStyleTable | |
7c913512 | 83 | |
23324ae1 FM |
84 | @library{wxcore} |
85 | @category{ctrl} | |
0c7fe6f2 | 86 | <!-- @appearance{listctrl.png} --> |
7c913512 | 87 | |
b45506e8 | 88 | @see @ref overview_listctrl "wxListCtrl Overview", wxListView, |
e54c96f1 | 89 | wxListBox, wxTreeCtrl, wxImageList, wxListEvent, wxListItem |
23324ae1 FM |
90 | */ |
91 | class wxListCtrl : public wxControl | |
92 | { | |
93 | public: | |
94 | //@{ | |
b45506e8 VZ |
95 | /** |
96 | Constructor, creating and showing a list control. | |
97 | */ | |
98 | wxListCtrl(); | |
99 | ||
23324ae1 FM |
100 | /** |
101 | Constructor, creating and showing a list control. | |
3c4f71cc | 102 | |
7c913512 | 103 | @param parent |
4cc4bfaf | 104 | Parent window. Must not be @NULL. |
7c913512 | 105 | @param id |
4cc4bfaf | 106 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 107 | @param pos |
4cc4bfaf | 108 | Window position. |
7c913512 | 109 | @param size |
4cc4bfaf | 110 | Window size. If wxDefaultSize is specified then the window is |
b45506e8 | 111 | sized appropriately. |
7c913512 | 112 | @param style |
4cc4bfaf | 113 | Window style. See wxListCtrl. |
7c913512 | 114 | @param validator |
4cc4bfaf | 115 | Window validator. |
7c913512 | 116 | @param name |
4cc4bfaf | 117 | Window name. |
3c4f71cc | 118 | |
4cc4bfaf | 119 | @see Create(), wxValidator |
23324ae1 | 120 | */ |
7c913512 FM |
121 | wxListCtrl(wxWindow* parent, wxWindowID id, |
122 | const wxPoint& pos = wxDefaultPosition, | |
123 | const wxSize& size = wxDefaultSize, | |
124 | long style = wxLC_ICON, | |
125 | const wxValidator& validator = wxDefaultValidator, | |
126 | const wxString& name = wxListCtrlNameStr); | |
23324ae1 FM |
127 | //@} |
128 | ||
129 | /** | |
130 | Destructor, destroying the list control. | |
131 | */ | |
132 | ~wxListCtrl(); | |
133 | ||
134 | /** | |
135 | Arranges the items in icon or small icon view. This only has effect on Win32. | |
4cc4bfaf | 136 | @a flag is one of: |
3c4f71cc | 137 | |
23324ae1 | 138 | wxLIST_ALIGN_DEFAULT |
3c4f71cc | 139 | |
23324ae1 | 140 | Default alignment. |
3c4f71cc | 141 | |
23324ae1 | 142 | wxLIST_ALIGN_LEFT |
3c4f71cc | 143 | |
23324ae1 | 144 | Align to the left side of the control. |
3c4f71cc | 145 | |
23324ae1 | 146 | wxLIST_ALIGN_TOP |
3c4f71cc | 147 | |
23324ae1 | 148 | Align to the top side of the control. |
3c4f71cc | 149 | |
23324ae1 | 150 | wxLIST_ALIGN_SNAP_TO_GRID |
3c4f71cc | 151 | |
23324ae1 FM |
152 | Snap to grid. |
153 | */ | |
154 | bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); | |
155 | ||
156 | /** | |
157 | Sets the image list associated with the control and | |
158 | takes ownership of it (i.e. the control will, unlike when using | |
4cc4bfaf | 159 | SetImageList, delete the list when destroyed). @a which is one of |
23324ae1 FM |
160 | wxIMAGE_LIST_NORMAL, wxIMAGE_LIST_SMALL, wxIMAGE_LIST_STATE (the last is |
161 | unimplemented). | |
3c4f71cc | 162 | |
4cc4bfaf | 163 | @see SetImageList() |
23324ae1 FM |
164 | */ |
165 | void AssignImageList(wxImageList* imageList, int which); | |
166 | ||
167 | /** | |
168 | Deletes all items and all columns. | |
169 | */ | |
170 | void ClearAll(); | |
171 | ||
172 | /** | |
173 | Creates the list control. See wxListCtrl() for further details. | |
174 | */ | |
175 | bool Create(wxWindow* parent, wxWindowID id, | |
176 | const wxPoint& pos = wxDefaultPosition, | |
177 | const wxSize& size = wxDefaultSize, | |
178 | long style = wxLC_ICON, | |
179 | const wxValidator& validator = wxDefaultValidator, | |
180 | const wxString& name = wxListCtrlNameStr); | |
181 | ||
182 | /** | |
183 | Deletes all items in the list control. | |
1f1d2182 | 184 | @note This function does @e not send the |
23324ae1 FM |
185 | @c wxEVT_COMMAND_LIST_DELETE_ITEM event because deleting many items |
186 | from the control would be too slow then (unlike wxListCtrl::DeleteItem). | |
187 | */ | |
188 | bool DeleteAllItems(); | |
189 | ||
190 | /** | |
191 | Deletes a column. | |
192 | */ | |
193 | bool DeleteColumn(int col); | |
194 | ||
195 | /** | |
196 | Deletes the specified item. This function sends the | |
197 | @c wxEVT_COMMAND_LIST_DELETE_ITEM event for the item being deleted. | |
23324ae1 FM |
198 | See also: DeleteAllItems() |
199 | */ | |
200 | bool DeleteItem(long item); | |
201 | ||
202 | /** | |
203 | Starts editing the label of the given item. This function generates a | |
204 | EVT_LIST_BEGIN_LABEL_EDIT event which can be vetoed so that no | |
205 | text control will appear for in-place editing. | |
23324ae1 FM |
206 | If the user changed the label (i.e. s/he does not press ESC or leave |
207 | the text control without changes, a EVT_LIST_END_LABEL_EDIT event | |
208 | will be sent which can be vetoed as well. | |
209 | */ | |
210 | void EditLabel(long item); | |
211 | ||
212 | /** | |
213 | Ensures this item is visible. | |
214 | */ | |
215 | bool EnsureVisible(long item); | |
216 | ||
217 | //@{ | |
218 | /** | |
219 | Find an item nearest this position in the specified direction, starting from | |
4cc4bfaf | 220 | @a start or the beginning if @a start is -1. |
3c4f71cc VS |
221 | |
222 | ||
23324ae1 | 223 | @b FindItem( start, str, partial = @false ) |
3c4f71cc VS |
224 | |
225 | ||
23324ae1 | 226 | @b FindItemData( start, data ) |
3c4f71cc VS |
227 | |
228 | ||
23324ae1 FM |
229 | @b FindItemAtPos( start, point, direction ) |
230 | */ | |
231 | long FindItem(long start, const wxString& str, | |
4cc4bfaf | 232 | bool partial = false); |
7c913512 FM |
233 | long FindItem(long start, long data); |
234 | long FindItem(long start, const wxPoint& pt, int direction); | |
23324ae1 FM |
235 | //@} |
236 | ||
237 | /** | |
238 | Gets information about this column. See SetItem() for more | |
239 | information. | |
240 | */ | |
328f5751 | 241 | bool GetColumn(int col, wxListItem& item) const; |
23324ae1 FM |
242 | |
243 | /** | |
244 | Returns the number of columns. | |
245 | */ | |
328f5751 | 246 | int GetColumnCount() const; |
23324ae1 FM |
247 | |
248 | /** | |
249 | Gets the column number by visual order index (report view only). | |
250 | */ | |
328f5751 | 251 | int GetColumnIndexFromOrder(int order) const; |
23324ae1 FM |
252 | |
253 | /** | |
254 | Gets the column visual order index (valid in report view only). | |
255 | */ | |
328f5751 | 256 | int GetColumnOrder(int col) const; |
23324ae1 FM |
257 | |
258 | /** | |
259 | Gets the column width (report view only). | |
260 | */ | |
328f5751 | 261 | int GetColumnWidth(int col) const; |
23324ae1 FM |
262 | |
263 | /** | |
264 | Returns the array containing the orders of all columns. On error, an empty | |
265 | array is returned. | |
266 | */ | |
328f5751 | 267 | wxArrayInt GetColumnsOrder() const; |
23324ae1 FM |
268 | |
269 | /** | |
270 | Gets the number of items that can fit vertically in the | |
271 | visible area of the list control (list or report view) | |
272 | or the total number of items in the list control (icon | |
273 | or small icon view). | |
274 | */ | |
328f5751 | 275 | int GetCountPerPage() const; |
23324ae1 FM |
276 | |
277 | /** | |
278 | Returns the edit control being currently used to edit a label. Returns @NULL | |
279 | if no label is being edited. | |
1f1d2182 | 280 | @note It is currently only implemented for wxMSW and the generic version, |
23324ae1 FM |
281 | not for the native Mac OS X version. |
282 | */ | |
328f5751 | 283 | wxTextCtrl* GetEditControl() const; |
23324ae1 FM |
284 | |
285 | /** | |
4cc4bfaf | 286 | Returns the specified image list. @a which may be one of: |
3c4f71cc | 287 | |
23324ae1 | 288 | @b wxIMAGE_LIST_NORMAL |
3c4f71cc | 289 | |
23324ae1 | 290 | The normal (large icon) image list. |
3c4f71cc | 291 | |
23324ae1 | 292 | @b wxIMAGE_LIST_SMALL |
3c4f71cc | 293 | |
23324ae1 | 294 | The small icon image list. |
3c4f71cc | 295 | |
23324ae1 | 296 | @b wxIMAGE_LIST_STATE |
3c4f71cc | 297 | |
23324ae1 FM |
298 | The user-defined state image list (unimplemented). |
299 | */ | |
328f5751 | 300 | wxImageList* GetImageList(int which) const; |
23324ae1 FM |
301 | |
302 | /** | |
303 | Gets information about the item. See SetItem() for more | |
304 | information. | |
23324ae1 FM |
305 | You must call @e info.SetId() to the ID of item you're interested in |
306 | before calling this method. | |
307 | */ | |
328f5751 | 308 | bool GetItem(wxListItem& info) const; |
23324ae1 FM |
309 | |
310 | /** | |
311 | Returns the colour for this item. If the item has no specific colour, returns | |
312 | an invalid colour (and not the default background control of the control | |
313 | itself). | |
3c4f71cc | 314 | |
4cc4bfaf | 315 | @see GetItemTextColour() |
23324ae1 | 316 | */ |
328f5751 | 317 | wxColour GetItemBackgroundColour(long item) const; |
23324ae1 FM |
318 | |
319 | /** | |
320 | Returns the number of items in the list control. | |
321 | */ | |
328f5751 | 322 | int GetItemCount() const; |
23324ae1 FM |
323 | |
324 | /** | |
325 | Gets the application-defined data associated with this item. | |
326 | */ | |
328f5751 | 327 | long GetItemData(long item) const; |
23324ae1 FM |
328 | |
329 | /** | |
330 | Returns the item's font. | |
331 | */ | |
328f5751 | 332 | wxFont GetItemFont(long item) const; |
23324ae1 FM |
333 | |
334 | /** | |
335 | Returns the position of the item, in icon or small icon view. | |
336 | */ | |
328f5751 | 337 | bool GetItemPosition(long item, wxPoint& pos) const; |
23324ae1 FM |
338 | |
339 | /** | |
340 | Returns the rectangle representing the item's size and position, in physical | |
341 | coordinates. | |
4cc4bfaf | 342 | @a code is one of wxLIST_RECT_BOUNDS, wxLIST_RECT_ICON, wxLIST_RECT_LABEL. |
23324ae1 FM |
343 | */ |
344 | bool GetItemRect(long item, wxRect& rect, | |
328f5751 | 345 | int code = wxLIST_RECT_BOUNDS) const; |
23324ae1 FM |
346 | |
347 | /** | |
348 | Retrieves the spacing between icons in pixels: horizontal spacing is returned | |
349 | as @c x component of the wxSize object and the vertical | |
350 | spacing as its @c y component. | |
351 | */ | |
328f5751 | 352 | wxSize GetItemSpacing() const; |
23324ae1 FM |
353 | |
354 | /** | |
355 | Gets the item state. For a list of state flags, see SetItem(). | |
23324ae1 FM |
356 | The @b stateMask indicates which state flags are of interest. |
357 | */ | |
328f5751 | 358 | int GetItemState(long item, long stateMask) const; |
23324ae1 FM |
359 | |
360 | /** | |
361 | Gets the item text for this item. | |
362 | */ | |
328f5751 | 363 | wxString GetItemText(long item) const; |
23324ae1 FM |
364 | |
365 | /** | |
366 | Returns the colour for this item. If the item has no specific colour, returns | |
367 | an invalid colour (and not the default foreground control of the control itself | |
368 | as this wouldn't allow distinguishing between items having the same colour as | |
369 | the current control foreground and items with default colour which, hence, have | |
370 | always the same colour as the control). | |
371 | */ | |
328f5751 | 372 | wxColour GetItemTextColour(long item) const; |
23324ae1 FM |
373 | |
374 | /** | |
375 | Searches for an item with the given geometry or state, starting from | |
4cc4bfaf | 376 | @a item but excluding the @a item itself. If @a item is -1, |
23324ae1 | 377 | the first item that matches the specified flags will be returned. |
4cc4bfaf | 378 | Returns the first item with given state following @a item or -1 if |
23324ae1 | 379 | no such item found. |
23324ae1 | 380 | This function may be used to find all selected items in the control like this: |
3c4f71cc | 381 | |
4cc4bfaf | 382 | @a geometry can be one of: |
3c4f71cc | 383 | |
23324ae1 | 384 | wxLIST_NEXT_ABOVE |
3c4f71cc | 385 | |
23324ae1 | 386 | Searches for an item above the specified item. |
3c4f71cc | 387 | |
23324ae1 | 388 | wxLIST_NEXT_ALL |
3c4f71cc | 389 | |
23324ae1 | 390 | Searches for subsequent item by index. |
3c4f71cc | 391 | |
23324ae1 | 392 | wxLIST_NEXT_BELOW |
3c4f71cc | 393 | |
23324ae1 | 394 | Searches for an item below the specified item. |
3c4f71cc | 395 | |
23324ae1 | 396 | wxLIST_NEXT_LEFT |
3c4f71cc | 397 | |
23324ae1 | 398 | Searches for an item to the left of the specified item. |
3c4f71cc | 399 | |
23324ae1 | 400 | wxLIST_NEXT_RIGHT |
3c4f71cc | 401 | |
23324ae1 | 402 | Searches for an item to the right of the specified item. |
3c4f71cc | 403 | |
1f1d2182 | 404 | @note this parameter is only supported by wxMSW currently and ignored on |
23324ae1 | 405 | other platforms. |
4cc4bfaf | 406 | @a state can be a bitlist of the following: |
3c4f71cc | 407 | |
23324ae1 | 408 | wxLIST_STATE_DONTCARE |
3c4f71cc | 409 | |
23324ae1 | 410 | Don't care what the state is. |
3c4f71cc | 411 | |
23324ae1 | 412 | wxLIST_STATE_DROPHILITED |
3c4f71cc | 413 | |
23324ae1 | 414 | The item indicates it is a drop target. |
3c4f71cc | 415 | |
23324ae1 | 416 | wxLIST_STATE_FOCUSED |
3c4f71cc | 417 | |
23324ae1 | 418 | The item has the focus. |
3c4f71cc | 419 | |
23324ae1 | 420 | wxLIST_STATE_SELECTED |
3c4f71cc | 421 | |
23324ae1 | 422 | The item is selected. |
3c4f71cc | 423 | |
23324ae1 | 424 | wxLIST_STATE_CUT |
3c4f71cc | 425 | |
23324ae1 FM |
426 | The item is selected as part of a cut and paste operation. |
427 | */ | |
428 | long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, | |
328f5751 | 429 | int state = wxLIST_STATE_DONTCARE) const; |
23324ae1 FM |
430 | |
431 | /** | |
432 | Returns the number of selected items in the list control. | |
433 | */ | |
328f5751 | 434 | int GetSelectedItemCount() const; |
23324ae1 FM |
435 | |
436 | /** | |
437 | Returns the rectangle representing the size and position, in physical | |
4cc4bfaf | 438 | coordinates, of the given subitem, i.e. the part of the row @a item in the |
23324ae1 | 439 | column @e subItem. |
23324ae1 | 440 | This method is only meaningfull when the wxListCtrl is in the report mode. If |
4cc4bfaf | 441 | @a subItem parameter is equal to the special value |
23324ae1 FM |
442 | @c wxLIST_GETSUBITEMRECT_WHOLEITEM the return value is the same as |
443 | for GetItemRect(). | |
4cc4bfaf | 444 | @a code can be one of @c wxLIST_RECT_BOUNDS, |
23324ae1 | 445 | @c wxLIST_RECT_ICON or @c wxLIST_RECT_LABEL. |
3c4f71cc | 446 | |
1e24c2af | 447 | @since 2.7.0 |
23324ae1 FM |
448 | */ |
449 | bool GetSubItemRect(long item, long subItem, wxRect& rect, | |
328f5751 | 450 | int code = wxLIST_RECT_BOUNDS) const; |
23324ae1 FM |
451 | |
452 | /** | |
453 | Gets the text colour of the list control. | |
454 | */ | |
328f5751 | 455 | wxColour GetTextColour() const; |
23324ae1 FM |
456 | |
457 | /** | |
458 | Gets the index of the topmost visible item when in | |
459 | list or report view. | |
460 | */ | |
328f5751 | 461 | long GetTopItem() const; |
23324ae1 FM |
462 | |
463 | /** | |
464 | Returns the rectangle taken by all items in the control. In other words, if the | |
465 | controls client size were equal to the size of this rectangle, no scrollbars | |
466 | would be needed and no free space would be left. | |
23324ae1 FM |
467 | Note that this function only works in the icon and small icon views, not in |
468 | list or report views (this is a limitation of the native Win32 control). | |
469 | */ | |
328f5751 | 470 | wxRect GetViewRect() const; |
23324ae1 FM |
471 | |
472 | /** | |
473 | Determines which item (if any) is at the specified point, | |
474 | giving details in @e flags. Returns index of the item or @c wxNOT_FOUND | |
475 | if no item is at the specified point. | |
4cc4bfaf | 476 | @a flags will be a combination of the following flags: |
3c4f71cc | 477 | |
23324ae1 | 478 | wxLIST_HITTEST_ABOVE |
3c4f71cc | 479 | |
23324ae1 | 480 | Above the client area. |
3c4f71cc | 481 | |
23324ae1 | 482 | wxLIST_HITTEST_BELOW |
3c4f71cc | 483 | |
23324ae1 | 484 | Below the client area. |
3c4f71cc | 485 | |
23324ae1 | 486 | wxLIST_HITTEST_NOWHERE |
3c4f71cc | 487 | |
23324ae1 | 488 | In the client area but below the last item. |
3c4f71cc | 489 | |
23324ae1 | 490 | wxLIST_HITTEST_ONITEMICON |
3c4f71cc | 491 | |
23324ae1 | 492 | On the bitmap associated with an item. |
3c4f71cc | 493 | |
23324ae1 | 494 | wxLIST_HITTEST_ONITEMLABEL |
3c4f71cc | 495 | |
23324ae1 | 496 | On the label (string) associated with an item. |
3c4f71cc | 497 | |
23324ae1 | 498 | wxLIST_HITTEST_ONITEMRIGHT |
3c4f71cc | 499 | |
23324ae1 | 500 | In the area to the right of an item. |
3c4f71cc | 501 | |
23324ae1 | 502 | wxLIST_HITTEST_ONITEMSTATEICON |
3c4f71cc | 503 | |
23324ae1 | 504 | On the state icon for a tree view item that is in a user-defined state. |
3c4f71cc | 505 | |
23324ae1 | 506 | wxLIST_HITTEST_TOLEFT |
3c4f71cc | 507 | |
23324ae1 | 508 | To the right of the client area. |
3c4f71cc | 509 | |
23324ae1 | 510 | wxLIST_HITTEST_TORIGHT |
3c4f71cc | 511 | |
23324ae1 | 512 | To the left of the client area. |
3c4f71cc | 513 | |
23324ae1 | 514 | wxLIST_HITTEST_ONITEM |
3c4f71cc | 515 | |
23324ae1 FM |
516 | Combination of wxLIST_HITTEST_ONITEMICON, wxLIST_HITTEST_ONITEMLABEL, |
517 | wxLIST_HITTEST_ONITEMSTATEICON. | |
3c4f71cc | 518 | |
4cc4bfaf | 519 | If @a ptrSubItem is not @NULL and the wxListCtrl is in the report |
7c913512 | 520 | mode the subitem (or column) number will also be provided. |
23324ae1 FM |
521 | This feature is only available in version 2.7.0 or higher and is currently only |
522 | implemented under wxMSW and requires at least comctl32.dll of verion 4.70 on | |
4cc4bfaf | 523 | the host system or the value stored in @a ptrSubItem will be always -1. To |
23324ae1 FM |
524 | compile this feature into wxWidgets library you need to have access to |
525 | commctrl.h of version 4.70 that is provided by Microsoft. | |
526 | */ | |
527 | long HitTest(const wxPoint& point, int& flags, | |
328f5751 | 528 | long* ptrSubItem) const; |
23324ae1 FM |
529 | |
530 | //@{ | |
531 | /** | |
532 | For report view mode (only), inserts a column. For more details, see SetItem(). | |
533 | */ | |
534 | long InsertColumn(long col, wxListItem& info); | |
7c913512 FM |
535 | long InsertColumn(long col, const wxString& heading, |
536 | int format = wxLIST_FORMAT_LEFT, | |
537 | int width = -1); | |
23324ae1 FM |
538 | //@} |
539 | ||
540 | //@{ | |
541 | /** | |
b45506e8 | 542 | Insert a wxListItem. |
7c913512 | 543 | @param info |
4cc4bfaf | 544 | wxListItem object |
b45506e8 VZ |
545 | */ |
546 | long InsertItem(wxListItem& info); | |
547 | ||
548 | /** | |
549 | Insert an string item. | |
7c913512 | 550 | @param index |
4cc4bfaf | 551 | Index of the new item, supplied by the application |
7c913512 | 552 | @param label |
4cc4bfaf | 553 | String label |
23324ae1 | 554 | */ |
7c913512 | 555 | long InsertItem(long index, const wxString& label); |
b45506e8 VZ |
556 | |
557 | /** | |
558 | Insert an image item. | |
559 | @param index | |
560 | Index of the new item, supplied by the application | |
561 | @param imageIndex | |
562 | Index into the image list associated with this control and view style | |
563 | */ | |
7c913512 | 564 | long InsertItem(long index, int imageIndex); |
b45506e8 VZ |
565 | |
566 | /** | |
567 | Insert an image/string item. | |
568 | @param index | |
569 | Index of the new item, supplied by the application | |
570 | @param label | |
571 | String label | |
572 | @param imageIndex | |
573 | Index into the image list associated with this control and view style | |
574 | */ | |
7c913512 FM |
575 | long InsertItem(long index, const wxString& label, |
576 | int imageIndex); | |
23324ae1 FM |
577 | //@} |
578 | ||
579 | /** | |
580 | This function may be overloaded in the derived class for a control with | |
581 | @c wxLC_VIRTUAL style. It should return the attribute for the | |
582 | for the specified @c item or @NULL to use the default appearance | |
583 | parameters. | |
7c913512 | 584 | wxListCtrl will not delete the pointer or keep a reference of it. You can |
23324ae1 | 585 | return the same wxListItemAttr pointer for every OnGetItemAttr call. |
23324ae1 | 586 | The base class version always returns @NULL. |
3c4f71cc | 587 | |
4cc4bfaf FM |
588 | @see OnGetItemImage(), OnGetItemColumnImage(), |
589 | OnGetItemText() | |
23324ae1 | 590 | */ |
328f5751 | 591 | virtual wxListItemAttr* OnGetItemAttr(long item) const; |
23324ae1 FM |
592 | |
593 | /** | |
594 | Overload this function in the derived class for a control with | |
595 | @c wxLC_VIRTUAL and @c wxLC_REPORT styles in order to specify the image | |
596 | index for the given line and column. | |
23324ae1 FM |
597 | The base class version always calls OnGetItemImage for the first column, else |
598 | it returns -1. | |
3c4f71cc | 599 | |
4cc4bfaf FM |
600 | @see OnGetItemText(), OnGetItemImage(), |
601 | OnGetItemAttr() | |
23324ae1 | 602 | */ |
328f5751 | 603 | virtual int OnGetItemColumnImage(long item, long column) const; |
23324ae1 FM |
604 | |
605 | /** | |
606 | This function must be overloaded in the derived class for a control with | |
b45506e8 | 607 | @c wxLC_VIRTUAL style having an @ref SetImageList() "image list" |
23324ae1 FM |
608 | (if the control doesn't have an image list, it is not necessary to overload |
609 | it). It should return the index of the items image in the controls image list | |
610 | or -1 for no image. | |
611 | In a control with @c wxLC_REPORT style, OnGetItemImage only gets called for | |
612 | the first column of each line. | |
23324ae1 | 613 | The base class version always returns -1. |
3c4f71cc | 614 | |
4cc4bfaf FM |
615 | @see OnGetItemText(), OnGetItemColumnImage(), |
616 | OnGetItemAttr() | |
23324ae1 | 617 | */ |
328f5751 | 618 | virtual int OnGetItemImage(long item) const; |
23324ae1 FM |
619 | |
620 | /** | |
621 | This function @b must be overloaded in the derived class for a control with | |
622 | @c wxLC_VIRTUAL style. It should return the string containing the text of | |
4cc4bfaf | 623 | the given @a column for the specified @c item. |
3c4f71cc | 624 | |
4cc4bfaf FM |
625 | @see SetItemCount(), OnGetItemImage(), |
626 | OnGetItemColumnImage(), OnGetItemAttr() | |
23324ae1 | 627 | */ |
328f5751 | 628 | virtual wxString OnGetItemText(long item, long column) const; |
23324ae1 FM |
629 | |
630 | /** | |
631 | Redraws the given @e item. This is only useful for the virtual list controls | |
632 | as without calling this function the displayed value of the item doesn't change | |
633 | even when the underlying data does change. | |
3c4f71cc | 634 | |
4cc4bfaf | 635 | @see RefreshItems() |
23324ae1 FM |
636 | */ |
637 | void RefreshItem(long item); | |
638 | ||
639 | /** | |
4cc4bfaf | 640 | Redraws the items between @a itemFrom and @e itemTo. The starting item |
23324ae1 | 641 | must be less than or equal to the ending one. |
23324ae1 FM |
642 | Just as RefreshItem() this is only useful for |
643 | virtual list controls. | |
644 | */ | |
645 | void RefreshItems(long itemFrom, long itemTo); | |
646 | ||
647 | /** | |
648 | Scrolls the list control. If in icon, small icon or report view mode, | |
4cc4bfaf FM |
649 | @a dx specifies the number of pixels to scroll. If in list view mode, |
650 | @a dx specifies the number of columns to scroll. @a dy always specifies | |
23324ae1 | 651 | the number of pixels to scroll vertically. |
1f1d2182 | 652 | @note This method is currently only implemented in the Windows version. |
23324ae1 FM |
653 | */ |
654 | bool ScrollList(int dx, int dy); | |
655 | ||
656 | /** | |
657 | Sets the background colour (GetBackgroundColour already implicit in | |
658 | wxWindow class). | |
659 | */ | |
660 | void SetBackgroundColour(const wxColour& col); | |
661 | ||
662 | /** | |
663 | Sets information about this column. See SetItem() for more | |
664 | information. | |
665 | */ | |
666 | bool SetColumn(int col, wxListItem& item); | |
667 | ||
668 | /** | |
669 | Sets the column width. | |
4cc4bfaf | 670 | @a width can be a width in pixels or wxLIST_AUTOSIZE (-1) or |
23324ae1 FM |
671 | wxLIST_AUTOSIZE_USEHEADER (-2). |
672 | wxLIST_AUTOSIZE will resize the column to the length of its longest item. | |
673 | wxLIST_AUTOSIZE_USEHEADER | |
674 | will resize the column to the length of the header (Win32) or 80 pixels (other | |
675 | platforms). | |
4cc4bfaf | 676 | In small or normal icon view, @a col must be -1, and the column width is set |
23324ae1 FM |
677 | for all columns. |
678 | */ | |
679 | bool SetColumnWidth(int col, int width); | |
680 | ||
681 | /** | |
4cc4bfaf | 682 | Sets the order of all columns at once. The @a orders array must have the |
23324ae1 FM |
683 | same number elements as the number of columns and contain each position exactly |
684 | once. | |
23324ae1 FM |
685 | This function is valid in report view only. |
686 | */ | |
328f5751 | 687 | bool SetColumnOrder(const wxArrayInt& orders) const; |
23324ae1 FM |
688 | |
689 | /** | |
4cc4bfaf | 690 | Sets the image list associated with the control. @a which is one of |
23324ae1 FM |
691 | wxIMAGE_LIST_NORMAL, wxIMAGE_LIST_SMALL, wxIMAGE_LIST_STATE (the last is |
692 | unimplemented). | |
23324ae1 FM |
693 | This method does not take ownership of the image list, you have to |
694 | delete it yourself. | |
3c4f71cc | 695 | |
4cc4bfaf | 696 | @see AssignImageList() |
23324ae1 FM |
697 | */ |
698 | void SetImageList(wxImageList* imageList, int which); | |
699 | ||
700 | //@{ | |
701 | /** | |
702 | Sets a string field at a particular column. | |
703 | */ | |
704 | bool SetItem(wxListItem& info); | |
b45506e8 | 705 | long SetItem(long index, int col, const wxString& label, |
7c913512 FM |
706 | int imageId = -1); |
707 | m_mask m_state field is valid. | |
23324ae1 FM |
708 | |
709 | ||
710 | ||
711 | ||
712 | ||
7c913512 | 713 | wxLIST_MASK_TEXT |
23324ae1 FM |
714 | |
715 | ||
716 | ||
717 | ||
7c913512 | 718 | The m_text field is valid. |
23324ae1 FM |
719 | |
720 | ||
721 | ||
722 | ||
723 | ||
7c913512 | 724 | wxLIST_MASK_IMAGE |
23324ae1 FM |
725 | |
726 | ||
727 | ||
728 | ||
7c913512 | 729 | The m_image field is valid. |
23324ae1 FM |
730 | |
731 | ||
732 | ||
733 | ||
734 | ||
7c913512 | 735 | wxLIST_MASK_DATA |
23324ae1 FM |
736 | |
737 | ||
738 | ||
739 | ||
7c913512 | 740 | The m_data field is valid. |
23324ae1 FM |
741 | |
742 | ||
743 | ||
744 | ||
745 | ||
7c913512 | 746 | wxLIST_MASK_WIDTH |
23324ae1 FM |
747 | |
748 | ||
749 | ||
750 | ||
7c913512 | 751 | The m_width field is valid. |
23324ae1 FM |
752 | |
753 | ||
754 | ||
755 | ||
756 | ||
7c913512 | 757 | wxLIST_MASK_FORMAT |
23324ae1 FM |
758 | |
759 | ||
760 | ||
761 | ||
7c913512 | 762 | The m_format field is valid. |
23324ae1 FM |
763 | |
764 | ||
765 | ||
766 | ||
767 | ||
768 | The m_stateMask and m_state members take flags from the following: | |
769 | ||
770 | ||
771 | ||
772 | ||
773 | ||
774 | ||
775 | ||
7c913512 | 776 | wxLIST_STATE_DONTCARE |
23324ae1 FM |
777 | |
778 | ||
779 | ||
780 | ||
7c913512 | 781 | Don't care what the state is. Win32 only. |
23324ae1 FM |
782 | |
783 | ||
784 | ||
785 | ||
786 | ||
7c913512 | 787 | wxLIST_STATE_DROPHILITED |
23324ae1 FM |
788 | |
789 | ||
790 | ||
791 | ||
7c913512 | 792 | The item is highlighted to receive a drop event. Win32 only. |
23324ae1 FM |
793 | |
794 | ||
795 | ||
796 | ||
797 | ||
7c913512 | 798 | wxLIST_STATE_FOCUSED |
23324ae1 FM |
799 | |
800 | ||
801 | ||
802 | ||
7c913512 | 803 | The item has the focus. |
23324ae1 FM |
804 | |
805 | ||
806 | ||
807 | ||
808 | ||
7c913512 | 809 | wxLIST_STATE_SELECTED |
23324ae1 FM |
810 | |
811 | ||
812 | ||
813 | ||
7c913512 | 814 | The item is selected. |
23324ae1 FM |
815 | |
816 | ||
817 | ||
818 | ||
819 | ||
7c913512 | 820 | wxLIST_STATE_CUT |
23324ae1 FM |
821 | |
822 | ||
823 | ||
824 | ||
7c913512 | 825 | The item is in the cut state. Win32 only. |
23324ae1 FM |
826 | |
827 | ||
828 | ||
829 | ||
830 | ||
7c913512 FM |
831 | The wxListItem object can also contain item-specific colour and font |
832 | information: for this you need to call one of SetTextColour(), | |
833 | SetBackgroundColour() or SetFont() functions on it passing it the colour/font | |
834 | to use. If the colour/font is not specified, the default list control | |
835 | colour/font is used. | |
836 | long SetItem(long index, int col, const wxString& label, | |
837 | int imageId = -1); | |
23324ae1 FM |
838 | //@} |
839 | ||
840 | /** | |
7c913512 FM |
841 | Sets the background colour for this item. This function only works in report |
842 | view. | |
7c913512 FM |
843 | The colour can be retrieved using |
844 | GetItemBackgroundColour(). | |
23324ae1 FM |
845 | */ |
846 | void SetItemBackgroundColour(long item, const wxColour& col); | |
847 | ||
848 | /** | |
7c913512 FM |
849 | Sets the image associated with the item. In report view, you can specify the |
850 | column. | |
851 | The image is an index into the image list associated with the list control. | |
23324ae1 FM |
852 | */ |
853 | bool SetItemColumnImage(long item, long column, int image); | |
854 | ||
855 | /** | |
558a6e06 VZ |
856 | This method can only be used with virtual list controls. |
857 | ||
858 | It is used to indicate to the control the number of items it contains. | |
859 | After calling it, the main program should be ready to handle calls to | |
860 | various item callbacks (such as wxListCtrl::OnGetItemText) for all | |
861 | items in the range from 0 to @a count. | |
862 | ||
863 | Notice that the control is not necessarily redrawn after this call as | |
864 | it may be undesirable if an item which is not visible on the screen | |
865 | anyhow was added to or removed from a control displaying many items, if | |
866 | you do need to refresh the display you can just call Refresh() manually. | |
23324ae1 FM |
867 | */ |
868 | void SetItemCount(long count); | |
869 | ||
870 | /** | |
7c913512 | 871 | Associates application-defined data with this item. |
7c913512 FM |
872 | Notice that this function cannot be used to associate pointers with the control |
873 | items, use SetItemPtrData() instead. | |
23324ae1 FM |
874 | */ |
875 | bool SetItemData(long item, long data); | |
876 | ||
877 | /** | |
7c913512 | 878 | Sets the item's font. |
23324ae1 FM |
879 | */ |
880 | void SetItemFont(long item, const wxFont& font); | |
881 | ||
882 | //@{ | |
883 | /** | |
884 | Sets the unselected and selected images associated with the item. The images | |
885 | are indices into the | |
4cc4bfaf | 886 | image list associated with the list control. This form is deprecated: @a |
23324ae1 FM |
887 | selImage is not |
888 | used. | |
889 | */ | |
890 | bool SetItemImage(long item, int image); | |
7c913512 | 891 | bool SetItemImage(long item, int image, int selImage); |
23324ae1 FM |
892 | //@} |
893 | ||
894 | /** | |
895 | Sets the position of the item, in icon or small icon view. Windows only. | |
896 | */ | |
897 | bool SetItemPosition(long item, const wxPoint& pos); | |
898 | ||
899 | /** | |
4cc4bfaf | 900 | Associates application-defined data with this item. The @a data parameter may |
23324ae1 FM |
901 | be either an integer or a pointer cast to the @c wxUIntPtr type which is |
902 | guaranteed to be large enough to be able to contain all integer types and | |
903 | pointers. | |
3c4f71cc | 904 | |
1e24c2af | 905 | @since 2.8.4 |
23324ae1 FM |
906 | */ |
907 | bool SetItemPtrData(long item, wxUIntPtr data); | |
908 | ||
909 | /** | |
910 | Sets the item state. For a list of state flags, see SetItem(). | |
23324ae1 FM |
911 | The @b stateMask indicates which state flags are valid. |
912 | */ | |
913 | bool SetItemState(long item, long state, long stateMask); | |
914 | ||
915 | /** | |
916 | Sets the item text for this item. | |
917 | */ | |
918 | void SetItemText(long item, const wxString& text); | |
919 | ||
920 | /** | |
921 | Sets the colour for this item. This function only works in report view. | |
23324ae1 FM |
922 | The colour can be retrieved using |
923 | GetItemTextColour(). | |
924 | */ | |
925 | void SetItemTextColour(long item, const wxColour& col); | |
926 | ||
927 | /** | |
928 | Adds or removes a single window style. | |
929 | */ | |
4cc4bfaf | 930 | void SetSingleStyle(long style, bool add = true); |
23324ae1 FM |
931 | |
932 | /** | |
933 | Sets the text colour of the list control. | |
934 | */ | |
935 | void SetTextColour(const wxColour& col); | |
936 | ||
937 | /** | |
938 | Sets the whole window style, deleting all items. | |
939 | */ | |
940 | void SetWindowStyleFlag(long style); | |
941 | ||
942 | /** | |
943 | Call this function to sort the items in the list control. Sorting is done | |
4cc4bfaf | 944 | using the specified @a fnSortCallBack function. This function must have the |
23324ae1 | 945 | following prototype: |
3c4f71cc | 946 | |
23324ae1 FM |
947 | It is called each time when the two items must be compared and should return 0 |
948 | if the items are equal, negative value if the first item is less than the | |
949 | second one and positive value if the first one is greater than the second one | |
950 | (the same convention as used by @c qsort(3)). | |
3c4f71cc | 951 | |
7c913512 | 952 | @param item1 |
4cc4bfaf | 953 | client data associated with the first item (NOT the index). |
7c913512 | 954 | @param item2 |
4cc4bfaf | 955 | client data associated with the second item (NOT the index). |
7c913512 | 956 | @param data |
4cc4bfaf | 957 | the value passed to SortItems() itself. |
23324ae1 FM |
958 | */ |
959 | bool SortItems(wxListCtrlCompare fnSortCallBack, long data); | |
960 | }; | |
961 | ||
962 | ||
e54c96f1 | 963 | |
23324ae1 FM |
964 | /** |
965 | @class wxListEvent | |
7c913512 | 966 | |
23324ae1 | 967 | A list event holds information about events associated with wxListCtrl objects. |
7c913512 | 968 | |
23324ae1 FM |
969 | @library{wxbase} |
970 | @category{events} | |
7c913512 | 971 | |
e54c96f1 | 972 | @see wxListCtrl |
23324ae1 FM |
973 | */ |
974 | class wxListEvent : public wxNotifyEvent | |
975 | { | |
976 | public: | |
977 | /** | |
978 | Constructor. | |
979 | */ | |
1d497b99 | 980 | wxListEvent(wxEventType commandType = 0, int id = 0); |
23324ae1 FM |
981 | |
982 | /** | |
983 | For @c EVT_LIST_CACHE_HINT event only: return the first item which the | |
984 | list control advises us to cache. | |
985 | */ | |
328f5751 | 986 | long GetCacheFrom() const; |
23324ae1 FM |
987 | |
988 | /** | |
989 | For @c EVT_LIST_CACHE_HINT event only: return the last item (inclusive) | |
990 | which the list control advises us to cache. | |
991 | */ | |
328f5751 | 992 | long GetCacheTo() const; |
23324ae1 FM |
993 | |
994 | /** | |
995 | The column position: it is only used with @c COL events. For the column | |
996 | dragging events, it is the column to the left of the divider being dragged, for | |
997 | the column click events it may be -1 if the user clicked in the list control | |
998 | header outside any column. | |
999 | */ | |
328f5751 | 1000 | int GetColumn() const; |
23324ae1 FM |
1001 | |
1002 | /** | |
1003 | The data. | |
1004 | */ | |
328f5751 | 1005 | long GetData() const; |
23324ae1 FM |
1006 | |
1007 | /** | |
1008 | The image. | |
1009 | */ | |
328f5751 | 1010 | int GetImage() const; |
23324ae1 FM |
1011 | |
1012 | /** | |
1013 | The item index. | |
1014 | */ | |
328f5751 | 1015 | long GetIndex() const; |
23324ae1 FM |
1016 | |
1017 | /** | |
1018 | An item object, used by some events. See also wxListCtrl::SetItem. | |
1019 | */ | |
328f5751 | 1020 | const wxListItem GetItem() const; |
23324ae1 FM |
1021 | |
1022 | /** | |
1023 | Key code if the event is a keypress event. | |
1024 | */ | |
328f5751 | 1025 | int GetKeyCode() const; |
23324ae1 FM |
1026 | |
1027 | /** | |
1028 | The (new) item label for @c EVT_LIST_END_LABEL_EDIT event. | |
1029 | */ | |
328f5751 | 1030 | const wxString GetLabel() const; |
23324ae1 FM |
1031 | |
1032 | /** | |
1033 | The mask. | |
1034 | */ | |
328f5751 | 1035 | long GetMask() const; |
23324ae1 FM |
1036 | |
1037 | /** | |
1038 | The position of the mouse pointer if the event is a drag event. | |
1039 | */ | |
328f5751 | 1040 | wxPoint GetPoint() const; |
23324ae1 FM |
1041 | |
1042 | /** | |
1043 | The text. | |
1044 | */ | |
328f5751 | 1045 | const wxString GetText() const; |
23324ae1 FM |
1046 | |
1047 | /** | |
1048 | This method only makes sense for @c EVT_LIST_END_LABEL_EDIT message | |
1049 | and returns @true if it the label editing has been cancelled by the user | |
1050 | (GetLabel() returns an empty string in this case | |
1051 | but it doesn't allow the application to distinguish between really cancelling | |
1052 | the edit and | |
1053 | the admittedly rare case when the user wants to rename it to an empty string). | |
1054 | */ | |
328f5751 | 1055 | bool IsEditCancelled() const; |
23324ae1 FM |
1056 | }; |
1057 | ||
1058 | ||
e54c96f1 | 1059 | |
23324ae1 FM |
1060 | /** |
1061 | @class wxListItemAttr | |
7c913512 | 1062 | |
23324ae1 FM |
1063 | Represents the attributes (color, font, ...) of a |
1064 | wxListCtrl wxListItem. | |
7c913512 | 1065 | |
23324ae1 FM |
1066 | @library{wxbase} |
1067 | @category{FIXME} | |
7c913512 | 1068 | |
b45506e8 | 1069 | @see @ref overview_listctrl "wxListCtrl Overview", wxListCtrl, |
e54c96f1 | 1070 | wxListItem |
23324ae1 | 1071 | */ |
7c913512 | 1072 | class wxListItemAttr |
23324ae1 FM |
1073 | { |
1074 | public: | |
1075 | //@{ | |
1076 | /** | |
1077 | Construct a wxListItemAttr with the specified foreground and | |
1078 | background colors and font. | |
1079 | */ | |
1080 | wxListItemAttr(); | |
7c913512 FM |
1081 | wxListItemAttr(const wxColour colText, |
1082 | const wxColour colBack, | |
1083 | const wxFont font); | |
23324ae1 FM |
1084 | //@} |
1085 | ||
1086 | /** | |
1087 | Returns the currently set background color. | |
1088 | */ | |
328f5751 | 1089 | const wxColour GetBackgroundColour() const; |
23324ae1 FM |
1090 | |
1091 | /** | |
1092 | Returns the currently set font. | |
1093 | */ | |
328f5751 | 1094 | const wxFont GetFont() const; |
23324ae1 FM |
1095 | |
1096 | /** | |
1097 | Returns the currently set text color. | |
1098 | */ | |
328f5751 | 1099 | const wxColour GetTextColour() const; |
23324ae1 FM |
1100 | |
1101 | /** | |
1102 | Returns @true if the currently set background color is valid. | |
1103 | */ | |
328f5751 | 1104 | bool HasBackgroundColour() const; |
23324ae1 FM |
1105 | |
1106 | /** | |
1107 | Returns @true if the currently set font is valid. | |
1108 | */ | |
328f5751 | 1109 | bool HasFont() const; |
23324ae1 FM |
1110 | |
1111 | /** | |
1112 | Returns @true if the currently set text color is valid. | |
1113 | */ | |
328f5751 | 1114 | bool HasTextColour() const; |
23324ae1 FM |
1115 | |
1116 | /** | |
1117 | Sets a new background color. | |
1118 | */ | |
1119 | void SetBackgroundColour(const wxColour& colour); | |
1120 | ||
1121 | /** | |
1122 | Sets a new font. | |
1123 | */ | |
1124 | void SetFont(const wxFont& font); | |
1125 | ||
1126 | /** | |
1127 | Sets a new text color. | |
1128 | */ | |
1129 | void SetTextColour(const wxColour& colour); | |
1130 | }; | |
1131 | ||
1132 | ||
e54c96f1 | 1133 | |
23324ae1 FM |
1134 | /** |
1135 | @class wxListView | |
7c913512 FM |
1136 | |
1137 | This class currently simply presents a simpler to use interface for the | |
23324ae1 | 1138 | wxListCtrl -- it can be thought of as a @e faade |
7c913512 | 1139 | for that complicated class. Using it is preferable to using |
23324ae1 FM |
1140 | wxListCtrl directly whenever possible because in the |
1141 | future some ports might implement wxListView but not the full set of wxListCtrl | |
1142 | features. | |
7c913512 | 1143 | |
23324ae1 FM |
1144 | Other than different interface, this class is identical to wxListCtrl. In |
1145 | particular, it uses the same events, same window styles and so on. | |
7c913512 | 1146 | |
23324ae1 FM |
1147 | @library{wxcore} |
1148 | @category{ctrl} | |
0c7fe6f2 | 1149 | <!-- @appearance{listview.png} --> |
7c913512 | 1150 | |
e54c96f1 | 1151 | @see wxListView::SetColumnImage |
23324ae1 FM |
1152 | */ |
1153 | class wxListView : public wxListCtrl | |
1154 | { | |
1155 | public: | |
1156 | /** | |
1157 | Resets the column image -- after calling this function, no image will be shown. | |
3c4f71cc | 1158 | |
7c913512 | 1159 | @param col |
4cc4bfaf | 1160 | the column to clear image for |
3c4f71cc | 1161 | |
4cc4bfaf | 1162 | @see SetColumnImage() |
23324ae1 FM |
1163 | */ |
1164 | void ClearColumnImage(int col); | |
1165 | ||
1166 | /** | |
1167 | Sets focus to the item with the given @e index. | |
1168 | */ | |
1169 | void Focus(long index); | |
1170 | ||
1171 | /** | |
1172 | Returns the first selected item in a (presumably) multiple selection control. | |
1173 | Together with GetNextSelected() it can be | |
1174 | used to iterate over all selected items in the control. | |
3c4f71cc | 1175 | |
d29a9a8a | 1176 | @return The first selected item, if any, -1 otherwise. |
23324ae1 | 1177 | */ |
328f5751 | 1178 | long GetFirstSelected() const; |
23324ae1 FM |
1179 | |
1180 | /** | |
1181 | Returns the currently focused item or -1 if none. | |
3c4f71cc | 1182 | |
4cc4bfaf | 1183 | @see IsSelected(), Focus() |
23324ae1 | 1184 | */ |
328f5751 | 1185 | long GetFocusedItem() const; |
23324ae1 FM |
1186 | |
1187 | /** | |
1188 | Used together with GetFirstSelected() to | |
1189 | iterate over all selected items in the control. | |
3c4f71cc | 1190 | |
d29a9a8a | 1191 | @return Returns the next selected item or -1 if there are no more of |
4cc4bfaf | 1192 | them. |
23324ae1 | 1193 | */ |
328f5751 | 1194 | long GetNextSelected(long item) const; |
23324ae1 FM |
1195 | |
1196 | /** | |
4cc4bfaf | 1197 | Returns @true if the item with the given @a index is selected, |
23324ae1 | 1198 | @false otherwise. |
3c4f71cc | 1199 | |
4cc4bfaf | 1200 | @see GetFirstSelected(), GetNextSelected() |
23324ae1 | 1201 | */ |
328f5751 | 1202 | bool IsSelected(long index) const; |
23324ae1 FM |
1203 | |
1204 | /** | |
1205 | Selects or unselects the given item. | |
3c4f71cc | 1206 | |
7c913512 | 1207 | @param n |
4cc4bfaf | 1208 | the item to select or unselect |
7c913512 | 1209 | @param on |
4cc4bfaf | 1210 | if @true (default), selects the item, otherwise unselects it |
3c4f71cc | 1211 | |
4cc4bfaf | 1212 | @see wxListCtrl::SetItemState |
23324ae1 | 1213 | */ |
4cc4bfaf | 1214 | void Select(bool on = true); |
23324ae1 FM |
1215 | |
1216 | /** | |
1217 | Sets the column image for the specified column. To use the column images, the | |
1218 | control must have a valid image list with at least one image. | |
3c4f71cc | 1219 | |
7c913512 | 1220 | @param col |
4cc4bfaf | 1221 | the column to set image for |
7c913512 | 1222 | @param image |
4cc4bfaf | 1223 | the index of the column image in the controls image list |
23324ae1 FM |
1224 | */ |
1225 | void SetColumnImage(int col, int image); | |
1226 | }; | |
1227 | ||
1228 | ||
e54c96f1 | 1229 | |
23324ae1 FM |
1230 | /** |
1231 | @class wxListItem | |
7c913512 | 1232 | |
23324ae1 | 1233 | This class stores information about a wxListCtrl item or column. |
7c913512 | 1234 | |
23324ae1 FM |
1235 | @library{wxbase} |
1236 | @category{FIXME} | |
1237 | */ | |
1238 | class wxListItem : public wxObject | |
1239 | { | |
1240 | public: | |
1241 | /** | |
1242 | Constructor. | |
1243 | */ | |
1244 | wxListItem(); | |
1245 | ||
1246 | /** | |
1247 | Resets the item state to the default. | |
1248 | */ | |
1249 | void Clear(); | |
1250 | ||
1251 | /** | |
1252 | Returns the alignment for this item. Can be one of | |
1253 | wxLIST_FORMAT_LEFT, wxLIST_FORMAT_RIGHT or wxLIST_FORMAT_CENTRE. | |
1254 | */ | |
328f5751 | 1255 | wxListColumnFormat GetAlign() const; |
23324ae1 FM |
1256 | |
1257 | /** | |
1258 | Returns the background colour for this item. | |
1259 | */ | |
328f5751 | 1260 | wxColour GetBackgroundColour() const; |
23324ae1 FM |
1261 | |
1262 | /** | |
1263 | Returns the zero-based column; meaningful only in report mode. | |
1264 | */ | |
328f5751 | 1265 | int GetColumn() const; |
23324ae1 FM |
1266 | |
1267 | /** | |
1268 | Returns client data associated with the control. Please note that | |
1269 | client data is associated with the item and not with subitems. | |
1270 | */ | |
328f5751 | 1271 | long GetData() const; |
23324ae1 FM |
1272 | |
1273 | /** | |
1274 | Returns the font used to display the item. | |
1275 | */ | |
328f5751 | 1276 | wxFont GetFont() const; |
23324ae1 FM |
1277 | |
1278 | /** | |
1279 | Returns the zero-based item position. | |
1280 | */ | |
328f5751 | 1281 | long GetId() const; |
23324ae1 FM |
1282 | |
1283 | /** | |
1284 | Returns the zero-based index of the image | |
1285 | associated with the item into the image list. | |
1286 | */ | |
328f5751 | 1287 | int GetImage() const; |
23324ae1 FM |
1288 | |
1289 | /** | |
1290 | Returns a bit mask indicating which fields of the structure are valid; | |
1291 | can be any combination of the following values: | |
3c4f71cc | 1292 | |
23324ae1 | 1293 | wxLIST_MASK_STATE |
3c4f71cc | 1294 | |
23324ae1 | 1295 | @b GetState is valid. |
3c4f71cc | 1296 | |
23324ae1 | 1297 | wxLIST_MASK_TEXT |
3c4f71cc | 1298 | |
23324ae1 | 1299 | @b GetText is valid. |
3c4f71cc | 1300 | |
23324ae1 | 1301 | wxLIST_MASK_IMAGE |
3c4f71cc | 1302 | |
23324ae1 | 1303 | @b GetImage is valid. |
3c4f71cc | 1304 | |
23324ae1 | 1305 | wxLIST_MASK_DATA |
3c4f71cc | 1306 | |
23324ae1 | 1307 | @b GetData is valid. |
3c4f71cc | 1308 | |
23324ae1 | 1309 | wxLIST_MASK_WIDTH |
3c4f71cc | 1310 | |
23324ae1 | 1311 | @b GetWidth is valid. |
3c4f71cc | 1312 | |
23324ae1 | 1313 | wxLIST_MASK_FORMAT |
3c4f71cc | 1314 | |
23324ae1 FM |
1315 | @b GetFormat is valid. |
1316 | */ | |
328f5751 | 1317 | long GetMask() const; |
23324ae1 FM |
1318 | |
1319 | /** | |
1320 | Returns a bit field representing the state of the item. Can be any | |
1321 | combination of: | |
3c4f71cc | 1322 | |
23324ae1 | 1323 | wxLIST_STATE_DONTCARE |
3c4f71cc | 1324 | |
7c913512 | 1325 | Don't care what the state is. Win32 only. |
3c4f71cc | 1326 | |
23324ae1 | 1327 | wxLIST_STATE_DROPHILITED |
3c4f71cc | 1328 | |
7c913512 | 1329 | The item is highlighted to receive a drop event. Win32 only. |
3c4f71cc | 1330 | |
23324ae1 | 1331 | wxLIST_STATE_FOCUSED |
3c4f71cc | 1332 | |
23324ae1 | 1333 | The item has the focus. |
3c4f71cc | 1334 | |
23324ae1 | 1335 | wxLIST_STATE_SELECTED |
3c4f71cc | 1336 | |
23324ae1 | 1337 | The item is selected. |
3c4f71cc | 1338 | |
23324ae1 | 1339 | wxLIST_STATE_CUT |
3c4f71cc | 1340 | |
23324ae1 FM |
1341 | The item is in the cut state. Win32 only. |
1342 | */ | |
328f5751 | 1343 | long GetState() const; |
23324ae1 FM |
1344 | |
1345 | /** | |
1346 | Returns the label/header text. | |
1347 | */ | |
328f5751 | 1348 | const wxString GetText() const; |
23324ae1 FM |
1349 | |
1350 | /** | |
1351 | Returns the text colour. | |
1352 | */ | |
328f5751 | 1353 | wxColour GetTextColour() const; |
23324ae1 FM |
1354 | |
1355 | /** | |
1356 | Meaningful only for column headers in report mode. Returns the column width. | |
1357 | */ | |
328f5751 | 1358 | int GetWidth() const; |
23324ae1 FM |
1359 | |
1360 | /** | |
1361 | Sets the alignment for the item. See also | |
1362 | GetAlign() | |
1363 | */ | |
1364 | void SetAlign(wxListColumnFormat align); | |
1365 | ||
1366 | /** | |
1367 | Sets the background colour for the item. | |
1368 | */ | |
1369 | void SetBackgroundColour(const wxColour& colBack); | |
1370 | ||
1371 | /** | |
1372 | Sets the zero-based column. Meaningful only in report mode. | |
1373 | */ | |
1374 | void SetColumn(int col); | |
1375 | ||
1376 | //@{ | |
1377 | /** | |
1378 | Sets client data for the item. Please note that | |
1379 | client data is associated with the item and not with subitems. | |
1380 | */ | |
1381 | void SetData(long data); | |
7c913512 | 1382 | void SetData(void* data); |
23324ae1 FM |
1383 | //@} |
1384 | ||
1385 | /** | |
1386 | Sets the font for the item. | |
1387 | */ | |
1388 | void SetFont(const wxFont& font); | |
1389 | ||
1390 | /** | |
1391 | Sets the zero-based item position. | |
1392 | */ | |
1393 | void SetId(long id); | |
1394 | ||
1395 | /** | |
1396 | Sets the zero-based index of the image associated with the item | |
1397 | into the image list. | |
1398 | */ | |
1399 | void SetImage(int image); | |
1400 | ||
1401 | /** | |
1402 | Sets the mask of valid fields. See GetMask(). | |
1403 | */ | |
1404 | void SetMask(long mask); | |
1405 | ||
1406 | /** | |
1407 | Sets the item state flags (note that the valid state flags are influenced | |
1408 | by the value of the state mask, see | |
1409 | wxListItem::SetStateMask). | |
1410 | See GetState() for valid flag | |
1411 | values. | |
1412 | */ | |
1413 | void SetState(long state); | |
1414 | ||
1415 | /** | |
1416 | Sets the bitmask that is used to determine which of the state flags | |
1417 | are to be set. See also SetState(). | |
1418 | */ | |
1419 | void SetStateMask(long stateMask); | |
1420 | ||
1421 | /** | |
1422 | Sets the text label for the item. | |
1423 | */ | |
1424 | void SetText(const wxString& text); | |
1425 | ||
1426 | /** | |
1427 | Sets the text colour for the item. | |
1428 | */ | |
1429 | void SetTextColour(const wxColour& colText); | |
1430 | ||
1431 | /** | |
1432 | Meaningful only for column headers in report mode. Sets the column width. | |
1433 | */ | |
1434 | void SetWidth(int width); | |
1435 | }; | |
e54c96f1 | 1436 |