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