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