1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxListCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
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.
17 A special case of report view quite different from the other modes of the list
18 control is a virtual control in which the items data (including text, images
19 and attributes) is managed by the main program and is requested by the control
20 itself only when needed which allows to have controls with millions of items
21 without consuming much memory. To use virtual list control you must use
22 wxListCtrl::SetItemCount first and overload at least
23 wxListCtrl::OnGetItemText (and optionally
24 wxListCtrl::OnGetItemImage or wxListCtrl::OnGetItemColumnImage and
25 wxListCtrl::OnGetItemAttr) to return the information
26 about the items when the control requests it. Virtual list control can be used
27 as a normal one except that no operations which can take time proportional to
28 the number of items in the control happen -- this is required to allow having a
29 practically infinite number of items. For example, in a multiple selection
30 virtual list control, the selections won't be sent when many items are selected
31 at once because this could mean iterating over all the items.
33 Using many of wxListCtrl features is shown in the
34 @ref overview_samplelistctrl "corresponding sample".
36 To intercept events from a list control, use the event table macros described
39 @b Mac Note: Starting with 2.8, wxListCtrl uses a native implementation for
40 report mode, and uses a generic implementation for other modes. You can use the
41 generic implementation for report mode as well by setting the
42 mac.listctrl.always_use_generic wxSystemOption() to 1.
44 Column reordering (only wxMSW): In report view, the control has several columns
45 which are identified by their internal indices. By default, these indices
46 correspond to their order on screen, i.e. the column 0 appears first (in the
47 left-to-right or maybe right-to-left if the current language uses this writing
48 direction), the column 1 next and so on. However it is possible to reorder the
49 columns visual order using SetColumnsOrder() method and the user can also
50 rearrange the columns interactively by dragging them. In this case, the index
51 of the column is not the same as its order and the functions GetColumnOrder() and
52 GetColumnIndexFromOrder() should be used to translate between them.
57 Multicolumn list view, with optional small icons. Columns are
58 computed automatically, i.e. you don't set columns as in
59 wxLC_REPORT. In other words, the list wraps, unlike a wxListBox.
61 Single or multicolumn report view, with optional header.
63 The application provides items text on demand. May only be used
66 Large icon view, with optional labels.
67 @style{wxLC_SMALL_ICON}
68 Small icon view, with optional labels.
69 @style{wxLC_ALIGN_TOP}
70 Icons align to the top. Win32 default, Win32 only.
71 @style{wxLC_ALIGN_LEFT}
72 Icons align to the left.
73 @style{wxLC_AUTOARRANGE}
74 Icons arrange themselves. Win32 only.
75 @style{wxLC_EDIT_LABELS}
76 Labels are editable: the application will be notified when editing
78 @style{wxLC_NO_HEADER}
79 No header in report mode.
80 @style{wxLC_SINGLE_SEL}
81 Single selection (default is multiple).
82 @style{wxLC_SORT_ASCENDING}
83 Sort in ascending order. (You must still supply a comparison callback
84 in wxListCtrl::SortItems.)
85 @style{wxLC_SORT_DESCENDING}
86 Sort in descending order. (You must still supply a comparison callback
87 in wxListCtrl::SortItems.)
89 Draws light horizontal rules between rows in report mode.
91 Draws light vertical rules between columns in report mode.
95 @beginEventTable{wxListEvent}
96 @event{EVT_LIST_BEGIN_DRAG(id, func)}
97 Begin dragging with the left mouse button.
98 @event{EVT_LIST_BEGIN_RDRAG(id, func)}
99 Begin dragging with the right mouse button..
100 @event{EVT_BEGIN_LABEL_EDIT(id, func)}
101 Begin editing a label. This can be prevented by calling Veto().
102 @event{EVT_LIST_END_LABEL_EDIT(id, func)}
103 Finish editing a label. This can be prevented by calling Veto().
104 @event{EVT_LIST_DELETE_ITEM(id, func)}
106 @event{EVT_LIST_DELETE_ALL_ITEMS(id, func)}
107 All items were deleted.
108 @event{EVT_LIST_ITEM_SELECTED(id, func)}
109 The item has been selected.
110 @event{EVT_LIST_ITEM_DESELECTED(id, func)}
111 The item has been deselected.
112 @event{EVT_LIST_ITEM_ACTIVATED(id, func)}
113 The item has been activated (ENTER or double click).
114 @event{EVT_LIST_ITEM_FOCUSED(id, func)}
115 The currently focused item has changed.
116 @event{EVT_LIST_ITEM_MIDDLE_CLICK(id, func)}
117 The middle mouse button has been clicked on an item.
118 @event{EVT_LIST_ITEM_RIGHT_CLICK(id, func)}
119 The right mouse button has been clicked on an item.
120 @event{EVT_LIST_KEY_DOWN(id, func)}
121 A key has been pressed.
122 @event{EVT_LIST_INSERT_ITEM(id, func)}
123 An item has been inserted.
124 @event{EVT_LIST_COL_CLICK(id, func)}
125 A column (m_col) has been left-clicked.
126 @event{EVT_LIST_COL_RIGHT_CLICK(id, func)}
127 A column (m_col) has been right-clicked.
128 @event{EVT_LIST_COL_BEGIN_DRAG(id, func)}
129 The user started resizing a column - can be vetoed.
130 @event{EVT_LIST_COL_DRAGGING(id, func)}
131 The divider between columns is being dragged.
132 @event{EVT_LIST_COL_END_DRAG(id, func)}
133 A column has been resized by the user.
134 @event{EVT_LIST_CACHE_HINT(id, func)}
135 Prepare cache for a virtual list control.
141 <!-- @appearance{listctrl.png} -->
143 @see @ref overview_listctrl "wxListCtrl Overview", wxListView,
144 wxListBox, wxTreeCtrl, wxImageList, wxListEvent, wxListItem, wxEditableListBox
146 class wxListCtrl
: public wxControl
155 Constructor, creating and showing a list control.
158 Parent window. Must not be @NULL.
160 Window identifier. The value wxID_ANY indicates a default value.
164 Window size. If wxDefaultSize is specified then the window is
167 Window style. See wxListCtrl.
173 @see Create(), wxValidator
175 wxListCtrl(wxWindow
* parent
, wxWindowID id
,
176 const wxPoint
& pos
= wxDefaultPosition
,
177 const wxSize
& size
= wxDefaultSize
,
178 long style
= wxLC_ICON
,
179 const wxValidator
& validator
= wxDefaultValidator
,
180 const wxString
& name
= wxListCtrlNameStr
);
183 Destructor, destroying the list control.
188 Arranges the items in icon or small icon view. This only has effect on Win32.
191 - wxLIST_ALIGN_DEFAULT: Default alignment.
192 - wxLIST_ALIGN_LEFT: Align to the left side of the control.
193 - wxLIST_ALIGN_TOP: Align to the top side of the control.
194 - wxLIST_ALIGN_SNAP_TO_GRID: Snap to grid.
196 bool Arrange(int flag
= wxLIST_ALIGN_DEFAULT
);
199 Sets the image list associated with the control and
200 takes ownership of it (i.e. the control will, unlike when using
201 SetImageList, delete the list when destroyed). @a which is one of
202 wxIMAGE_LIST_NORMAL, wxIMAGE_LIST_SMALL, wxIMAGE_LIST_STATE (the last is
207 void AssignImageList(wxImageList
* imageList
, int which
);
210 Deletes all items and all columns.
215 Creates the list control. See wxListCtrl() for further details.
217 bool Create(wxWindow
* parent
, wxWindowID id
,
218 const wxPoint
& pos
= wxDefaultPosition
,
219 const wxSize
& size
= wxDefaultSize
,
220 long style
= wxLC_ICON
,
221 const wxValidator
& validator
= wxDefaultValidator
,
222 const wxString
& name
= wxListCtrlNameStr
);
225 Deletes all items in the list control.
226 @note This function does @e not send the
227 @c wxEVT_COMMAND_LIST_DELETE_ITEM event because deleting many items
228 from the control would be too slow then (unlike wxListCtrl::DeleteItem).
230 bool DeleteAllItems();
235 bool DeleteColumn(int col
);
238 Deletes the specified item. This function sends the
239 @c wxEVT_COMMAND_LIST_DELETE_ITEM event for the item being deleted.
240 See also: DeleteAllItems()
242 bool DeleteItem(long item
);
245 Starts editing the label of the given item. This function generates a
246 EVT_LIST_BEGIN_LABEL_EDIT event which can be vetoed so that no
247 text control will appear for in-place editing.
248 If the user changed the label (i.e. s/he does not press ESC or leave
249 the text control without changes, a EVT_LIST_END_LABEL_EDIT event
250 will be sent which can be vetoed as well.
252 void EditLabel(long item
);
255 Ensures this item is visible.
257 bool EnsureVisible(long item
);
260 Find an item nearest this position in the specified direction,
261 starting from @a start or the beginning if @a start is -1.
263 long FindItem(long start
, const wxString
& str
,
264 bool partial
= false);
266 Find an item nearest this position in the specified direction,
267 starting from @a start or the beginning if @a start is -1.
269 long FindItem(long start
, long data
);
271 Find an item nearest this position in the specified direction,
272 starting from @a start or the beginning if @a start is -1.
274 long FindItem(long start
, const wxPoint
& pt
, int direction
);
277 Gets information about this column. See SetItem() for more
280 bool GetColumn(int col
, wxListItem
& item
) const;
283 Returns the number of columns.
285 int GetColumnCount() const;
288 Gets the column number by visual order index (report view only).
290 int GetColumnIndexFromOrder(int order
) const;
293 Gets the column visual order index (valid in report view only).
295 int GetColumnOrder(int col
) const;
298 Gets the column width (report view only).
300 int GetColumnWidth(int col
) const;
303 Returns the array containing the orders of all columns. On error, an empty
306 wxArrayInt
GetColumnsOrder() const;
309 Gets the number of items that can fit vertically in the
310 visible area of the list control (list or report view)
311 or the total number of items in the list control (icon
314 int GetCountPerPage() const;
317 Returns the edit control being currently used to edit a label. Returns @NULL
318 if no label is being edited.
319 @note It is currently only implemented for wxMSW and the generic version,
320 not for the native Mac OS X version.
322 wxTextCtrl
* GetEditControl() const;
325 Returns the specified image list. @a which may be one of:
327 - wxIMAGE_LIST_NORMAL: The normal (large icon) image list.
328 - wxIMAGE_LIST_SMALL: The small icon image list.
329 - wxIMAGE_LIST_STATE: The user-defined state image list (unimplemented).
331 wxImageList
* GetImageList(int which
) const;
334 Gets information about the item. See SetItem() for more
336 You must call @e info.SetId() to the ID of item you're interested in
337 before calling this method.
339 bool GetItem(wxListItem
& info
) const;
342 Returns the colour for this item. If the item has no specific colour, returns
343 an invalid colour (and not the default background control of the control
346 @see GetItemTextColour()
348 wxColour
GetItemBackgroundColour(long item
) const;
351 Returns the number of items in the list control.
353 int GetItemCount() const;
356 Gets the application-defined data associated with this item.
358 long GetItemData(long item
) const;
361 Returns the item's font.
363 wxFont
GetItemFont(long item
) const;
366 Returns the position of the item, in icon or small icon view.
368 bool GetItemPosition(long item
, wxPoint
& pos
) const;
371 Returns the rectangle representing the item's size and position, in physical
373 @a code is one of wxLIST_RECT_BOUNDS, wxLIST_RECT_ICON, wxLIST_RECT_LABEL.
375 bool GetItemRect(long item
, wxRect
& rect
,
376 int code
= wxLIST_RECT_BOUNDS
) const;
379 Retrieves the spacing between icons in pixels: horizontal spacing is returned
380 as @c x component of the wxSize object and the vertical
381 spacing as its @c y component.
383 wxSize
GetItemSpacing() const;
386 Gets the item state. For a list of state flags, see SetItem().
387 The @b stateMask indicates which state flags are of interest.
389 int GetItemState(long item
, long stateMask
) const;
392 Gets the item text for this item.
394 wxString
GetItemText(long item
) const;
397 Returns the colour for this item. If the item has no specific colour, returns
398 an invalid colour (and not the default foreground control of the control itself
399 as this wouldn't allow distinguishing between items having the same colour as
400 the current control foreground and items with default colour which, hence, have
401 always the same colour as the control).
403 wxColour
GetItemTextColour(long item
) const;
406 Searches for an item with the given geometry or state, starting from
407 @a item but excluding the @a item itself. If @a item is -1,
408 the first item that matches the specified flags will be returned.
409 Returns the first item with given state following @a item or -1 if
411 This function may be used to find all selected items in the control like this:
413 @a geometry can be one of:
417 Searches for an item above the specified item.
421 Searches for subsequent item by index.
425 Searches for an item below the specified item.
429 Searches for an item to the left of the specified item.
433 Searches for an item to the right of the specified item.
435 @note this parameter is only supported by wxMSW currently and ignored on
437 @a state can be a bitlist of the following:
439 wxLIST_STATE_DONTCARE
441 Don't care what the state is.
443 wxLIST_STATE_DROPHILITED
445 The item indicates it is a drop target.
449 The item has the focus.
451 wxLIST_STATE_SELECTED
453 The item is selected.
457 The item is selected as part of a cut and paste operation.
459 long GetNextItem(long item
, int geometry
= wxLIST_NEXT_ALL
,
460 int state
= wxLIST_STATE_DONTCARE
) const;
463 Returns the number of selected items in the list control.
465 int GetSelectedItemCount() const;
468 Returns the rectangle representing the size and position, in physical
469 coordinates, of the given subitem, i.e. the part of the row @a item in the
471 This method is only meaningfull when the wxListCtrl is in the report mode. If
472 @a subItem parameter is equal to the special value
473 @c wxLIST_GETSUBITEMRECT_WHOLEITEM the return value is the same as
475 @a code can be one of @c wxLIST_RECT_BOUNDS,
476 @c wxLIST_RECT_ICON or @c wxLIST_RECT_LABEL.
480 bool GetSubItemRect(long item
, long subItem
, wxRect
& rect
,
481 int code
= wxLIST_RECT_BOUNDS
) const;
484 Gets the text colour of the list control.
486 wxColour
GetTextColour() const;
489 Gets the index of the topmost visible item when in
492 long GetTopItem() const;
495 Returns the rectangle taken by all items in the control. In other words, if the
496 controls client size were equal to the size of this rectangle, no scrollbars
497 would be needed and no free space would be left.
498 Note that this function only works in the icon and small icon views, not in
499 list or report views (this is a limitation of the native Win32 control).
501 wxRect
GetViewRect() const;
504 Determines which item (if any) is at the specified point,
505 giving details in @e flags. Returns index of the item or @c wxNOT_FOUND
506 if no item is at the specified point.
507 @a flags will be a combination of the following flags:
511 Above the client area.
515 Below the client area.
517 wxLIST_HITTEST_NOWHERE
519 In the client area but below the last item.
521 wxLIST_HITTEST_ONITEMICON
523 On the bitmap associated with an item.
525 wxLIST_HITTEST_ONITEMLABEL
527 On the label (string) associated with an item.
529 wxLIST_HITTEST_ONITEMRIGHT
531 In the area to the right of an item.
533 wxLIST_HITTEST_ONITEMSTATEICON
535 On the state icon for a tree view item that is in a user-defined state.
537 wxLIST_HITTEST_TOLEFT
539 To the right of the client area.
541 wxLIST_HITTEST_TORIGHT
543 To the left of the client area.
545 wxLIST_HITTEST_ONITEM
547 Combination of wxLIST_HITTEST_ONITEMICON, wxLIST_HITTEST_ONITEMLABEL,
548 wxLIST_HITTEST_ONITEMSTATEICON.
550 If @a ptrSubItem is not @NULL and the wxListCtrl is in the report
551 mode the subitem (or column) number will also be provided.
552 This feature is only available in version 2.7.0 or higher and is currently only
553 implemented under wxMSW and requires at least comctl32.dll of verion 4.70 on
554 the host system or the value stored in @a ptrSubItem will be always -1. To
555 compile this feature into wxWidgets library you need to have access to
556 commctrl.h of version 4.70 that is provided by Microsoft.
558 long HitTest(const wxPoint
& point
, int& flags
,
559 long* ptrSubItem
) const;
562 For report view mode (only), inserts a column. For more details, see SetItem().
564 long InsertColumn(long col
, wxListItem
& info
);
566 For report view mode (only), inserts a column. For more details, see SetItem().
568 long InsertColumn(long col
, const wxString
& heading
,
569 int format
= wxLIST_FORMAT_LEFT
,
577 long InsertItem(wxListItem
& info
);
580 Insert an string item.
582 Index of the new item, supplied by the application
586 long InsertItem(long index
, const wxString
& label
);
589 Insert an image item.
591 Index of the new item, supplied by the application
593 Index into the image list associated with this control and view style
595 long InsertItem(long index
, int imageIndex
);
598 Insert an image/string item.
600 Index of the new item, supplied by the application
604 Index into the image list associated with this control and view style
606 long InsertItem(long index
, const wxString
& label
,
610 This function may be overloaded in the derived class for a control with
611 @c wxLC_VIRTUAL style. It should return the attribute for the
612 for the specified @c item or @NULL to use the default appearance
614 wxListCtrl will not delete the pointer or keep a reference of it. You can
615 return the same wxListItemAttr pointer for every OnGetItemAttr call.
616 The base class version always returns @NULL.
618 @see OnGetItemImage(), OnGetItemColumnImage(),
621 virtual wxListItemAttr
* OnGetItemAttr(long item
) const;
624 Overload this function in the derived class for a control with
625 @c wxLC_VIRTUAL and @c wxLC_REPORT styles in order to specify the image
626 index for the given line and column.
627 The base class version always calls OnGetItemImage for the first column, else
630 @see OnGetItemText(), OnGetItemImage(),
633 virtual int OnGetItemColumnImage(long item
, long column
) const;
636 This function must be overloaded in the derived class for a control with
637 @c wxLC_VIRTUAL style having an @ref SetImageList() "image list"
638 (if the control doesn't have an image list, it is not necessary to overload
639 it). It should return the index of the items image in the controls image list
641 In a control with @c wxLC_REPORT style, OnGetItemImage only gets called for
642 the first column of each line.
643 The base class version always returns -1.
645 @see OnGetItemText(), OnGetItemColumnImage(),
648 virtual int OnGetItemImage(long item
) const;
651 This function @b must be overloaded in the derived class for a control with
652 @c wxLC_VIRTUAL style. It should return the string containing the text of
653 the given @a column for the specified @c item.
655 @see SetItemCount(), OnGetItemImage(),
656 OnGetItemColumnImage(), OnGetItemAttr()
658 virtual wxString
OnGetItemText(long item
, long column
) const;
661 Redraws the given @e item. This is only useful for the virtual list controls
662 as without calling this function the displayed value of the item doesn't change
663 even when the underlying data does change.
667 void RefreshItem(long item
);
670 Redraws the items between @a itemFrom and @e itemTo. The starting item
671 must be less than or equal to the ending one.
672 Just as RefreshItem() this is only useful for
673 virtual list controls.
675 void RefreshItems(long itemFrom
, long itemTo
);
678 Scrolls the list control. If in icon, small icon or report view mode,
679 @a dx specifies the number of pixels to scroll. If in list view mode,
680 @a dx specifies the number of columns to scroll. @a dy always specifies
681 the number of pixels to scroll vertically.
682 @note This method is currently only implemented in the Windows version.
684 bool ScrollList(int dx
, int dy
);
687 Sets the background colour (GetBackgroundColour already implicit in
690 void SetBackgroundColour(const wxColour
& col
);
693 Sets information about this column. See SetItem() for more
696 bool SetColumn(int col
, wxListItem
& item
);
699 Sets the column width.
700 @a width can be a width in pixels or wxLIST_AUTOSIZE (-1) or
701 wxLIST_AUTOSIZE_USEHEADER (-2).
702 wxLIST_AUTOSIZE will resize the column to the length of its longest item.
703 wxLIST_AUTOSIZE_USEHEADER
704 will resize the column to the length of the header (Win32) or 80 pixels (other
706 In small or normal icon view, @a col must be -1, and the column width is set
709 bool SetColumnWidth(int col
, int width
);
712 Sets the order of all columns at once. The @a orders array must have the
713 same number elements as the number of columns and contain each position exactly
715 This function is valid in report view only.
717 bool SetColumnOrder(const wxArrayInt
& orders
) const;
720 Sets the image list associated with the control. @a which is one of
721 wxIMAGE_LIST_NORMAL, wxIMAGE_LIST_SMALL, wxIMAGE_LIST_STATE (the last is
723 This method does not take ownership of the image list, you have to
726 @see AssignImageList()
728 void SetImageList(wxImageList
* imageList
, int which
);
731 Sets the data of an item.
733 wxListItem is a class with the following members
735 - long m_mask: Indicates which fields are valid. See below.
736 - long m_itemId: Zero based item position.
737 - int m_col: Zero based column index.
738 - long m_state: The state of the item: See below for valid state flags.
739 - long m_stateMask: A mask indicating which state flags are valid. See below.
740 - wxStrign m_text: the label (or header for columns)
741 - int m_image: The zero based index into an image list
742 - long m_data: Application defined data
743 - int m_format: For columns only: Either of wxLIST_FORMAT_LEFT, wxLIST_FORMAT_RIGHT, wxLIST_FORMAT_CENTRE
744 - int m_width: For columns only: the width of the column
746 The @b m_mask member contains a bitlist specifying which of the other fields
747 are valid. The flags are:
748 - wxLIST_MASK_STATE: The m_state field is valid.
749 - wxLIST_MASK_TEXT: The m_text field is valid.
750 - wxLIST_MASK_IMAGE: The m_image field is valid.
751 - wxLIST_MASK_DATA: The m_data field is valid.
752 - wxLIST_MASK_WIDTH: The m_width field is valid.
753 - wxLIST_MASK_FORMAT: The m_format field is valid.
755 The @b m_stateMask and @b m_state members take flags from the following:
757 - wxLIST_STATE_DONTCARE: Don't care what the state is. Win32 only.
758 - wxLIST_STATE_DROPHILITED: The item is highlighted to receive a drop event. Win32 only.
759 - wxLIST_STATE_FOCUSED: The item has the focus.
760 - wxLIST_STATE_SELECTED: The item is selected.
761 - wxLIST_STATE_CUT: The item is in the cut state. Win32 only.
763 The wxListItem object can also contain item-specific colour and font
764 information: for this you need to call one of SetTextColour(),
765 SetBackgroundColour() or SetFont() functions on it passing it the colour/font
766 to use. If the colour/font is not specified, the default list control
769 bool SetItem(wxListItem
& info
);
772 Sets a string field at a particular column.
774 long SetItem(long index
, int col
, const wxString
& label
,
778 Sets the background colour for this item. This function only works
779 in report view. The colour can be retrieved using GetItemBackgroundColour().
781 void SetItemBackgroundColour(long item
, const wxColour
& col
);
784 Sets the image associated with the item. In report view, you can
785 specify the column. The image is an index into the image list
786 associated with the list control.
788 bool SetItemColumnImage(long item
, long column
, int image
);
791 This method can only be used with virtual list controls.
793 It is used to indicate to the control the number of items it contains.
794 After calling it, the main program should be ready to handle calls to
795 various item callbacks (such as wxListCtrl::OnGetItemText) for all
796 items in the range from 0 to @a count.
798 Notice that the control is not necessarily redrawn after this call as
799 it may be undesirable if an item which is not visible on the screen
800 anyhow was added to or removed from a control displaying many items, if
801 you do need to refresh the display you can just call Refresh() manually.
803 void SetItemCount(long count
);
806 Associates application-defined data with this item.
807 Notice that this function cannot be used to associate pointers with the control
808 items, use SetItemPtrData() instead.
810 bool SetItemData(long item
, long data
);
813 Sets the item's font.
815 void SetItemFont(long item
, const wxFont
& font
);
818 Sets the unselected and selected images associated with the item. The
819 images are indices into the image list associated with the list control.
821 bool SetItemImage(long item
, int image
);
824 Sets the unselected and selected images associated with the item. The
825 images are indices into the image list associated with the list control.
826 This form is deprecated: @a selImage is not used.
828 bool SetItemImage(long item
, int image
, int selImage
);
831 Sets the position of the item, in icon or small icon view. Windows only.
833 bool SetItemPosition(long item
, const wxPoint
& pos
);
836 Associates application-defined data with this item. The @a data parameter may
837 be either an integer or a pointer cast to the @c wxUIntPtr type which is
838 guaranteed to be large enough to be able to contain all integer types and
843 bool SetItemPtrData(long item
, wxUIntPtr data
);
846 Sets the item state. For a list of state flags, see SetItem().
847 The @b stateMask indicates which state flags are valid.
849 bool SetItemState(long item
, long state
, long stateMask
);
852 Sets the item text for this item.
854 void SetItemText(long item
, const wxString
& text
);
857 Sets the colour for this item. This function only works in report view.
858 The colour can be retrieved using
861 void SetItemTextColour(long item
, const wxColour
& col
);
864 Adds or removes a single window style.
866 void SetSingleStyle(long style
, bool add
= true);
869 Sets the text colour of the list control.
871 void SetTextColour(const wxColour
& col
);
874 Sets the whole window style, deleting all items.
876 void SetWindowStyleFlag(long style
);
879 Call this function to sort the items in the list control. Sorting is done
880 using the specified @a fnSortCallBack function. This function must have the
883 It is called each time when the two items must be compared and should return 0
884 if the items are equal, negative value if the first item is less than the
885 second one and positive value if the first one is greater than the second one
886 (the same convention as used by @c qsort(3)).
889 client data associated with the first item (NOT the index).
891 client data associated with the second item (NOT the index).
893 the value passed to SortItems() itself.
895 bool SortItems(wxListCtrlCompare fnSortCallBack
, long data
);
903 A list event holds information about events associated with wxListCtrl objects.
910 class wxListEvent
: public wxNotifyEvent
916 wxListEvent(wxEventType commandType
= 0, int id
= 0);
919 For @c EVT_LIST_CACHE_HINT event only: return the first item which the
920 list control advises us to cache.
922 long GetCacheFrom() const;
925 For @c EVT_LIST_CACHE_HINT event only: return the last item (inclusive)
926 which the list control advises us to cache.
928 long GetCacheTo() const;
931 The column position: it is only used with @c COL events. For the column
932 dragging events, it is the column to the left of the divider being dragged, for
933 the column click events it may be -1 if the user clicked in the list control
934 header outside any column.
936 int GetColumn() const;
941 long GetData() const;
946 int GetImage() const;
951 long GetIndex() const;
954 An item object, used by some events. See also wxListCtrl::SetItem.
956 const wxListItem
GetItem() const;
959 Key code if the event is a keypress event.
961 int GetKeyCode() const;
964 The (new) item label for @c EVT_LIST_END_LABEL_EDIT event.
966 const wxString
GetLabel() const;
971 long GetMask() const;
974 The position of the mouse pointer if the event is a drag event.
976 wxPoint
GetPoint() const;
981 const wxString
GetText() const;
984 This method only makes sense for @c EVT_LIST_END_LABEL_EDIT message
985 and returns @true if it the label editing has been cancelled by the user
986 (GetLabel() returns an empty string in this case
987 but it doesn't allow the application to distinguish between really cancelling
989 the admittedly rare case when the user wants to rename it to an empty string).
991 bool IsEditCancelled() const;
997 @class wxListItemAttr
999 Represents the attributes (color, font, ...) of a
1000 wxListCtrl wxListItem.
1005 @see @ref overview_listctrl "wxListCtrl Overview", wxListCtrl,
1008 class wxListItemAttr
1012 Default Constructor.
1016 Construct a wxListItemAttr with the specified foreground and
1017 background colors and font.
1019 wxListItemAttr(const wxColour colText
,
1020 const wxColour colBack
,
1024 Returns the currently set background color.
1026 const wxColour
GetBackgroundColour() const;
1029 Returns the currently set font.
1031 const wxFont
GetFont() const;
1034 Returns the currently set text color.
1036 const wxColour
GetTextColour() const;
1039 Returns @true if the currently set background color is valid.
1041 bool HasBackgroundColour() const;
1044 Returns @true if the currently set font is valid.
1046 bool HasFont() const;
1049 Returns @true if the currently set text color is valid.
1051 bool HasTextColour() const;
1054 Sets a new background color.
1056 void SetBackgroundColour(const wxColour
& colour
);
1061 void SetFont(const wxFont
& font
);
1064 Sets a new text color.
1066 void SetTextColour(const wxColour
& colour
);
1074 This class currently simply presents a simpler to use interface for the
1075 wxListCtrl -- it can be thought of as a @e faade
1076 for that complicated class. Using it is preferable to using
1077 wxListCtrl directly whenever possible because in the
1078 future some ports might implement wxListView but not the full set of wxListCtrl
1081 Other than different interface, this class is identical to wxListCtrl. In
1082 particular, it uses the same events, same window styles and so on.
1086 <!-- @appearance{listview.png} -->
1088 @see wxListView::SetColumnImage
1090 class wxListView
: public wxListCtrl
1094 Resets the column image -- after calling this function, no image will be shown.
1097 the column to clear image for
1099 @see SetColumnImage()
1101 void ClearColumnImage(int col
);
1104 Sets focus to the item with the given @e index.
1106 void Focus(long index
);
1109 Returns the first selected item in a (presumably) multiple selection control.
1110 Together with GetNextSelected() it can be
1111 used to iterate over all selected items in the control.
1113 @return The first selected item, if any, -1 otherwise.
1115 long GetFirstSelected() const;
1118 Returns the currently focused item or -1 if none.
1120 @see IsSelected(), Focus()
1122 long GetFocusedItem() const;
1125 Used together with GetFirstSelected() to
1126 iterate over all selected items in the control.
1128 @return Returns the next selected item or -1 if there are no more of
1131 long GetNextSelected(long item
) const;
1134 Returns @true if the item with the given @a index is selected,
1137 @see GetFirstSelected(), GetNextSelected()
1139 bool IsSelected(long index
) const;
1142 Selects or unselects the given item.
1145 the item to select or unselect
1147 if @true (default), selects the item, otherwise unselects it
1149 @see wxListCtrl::SetItemState
1151 void Select(long n
, bool on
= true);
1154 Sets the column image for the specified column. To use the column images, the
1155 control must have a valid image list with at least one image.
1158 the column to set image for
1160 the index of the column image in the controls image list
1162 void SetColumnImage(int col
, int image
);
1170 This class stores information about a wxListCtrl item or column.
1175 class wxListItem
: public wxObject
1184 Resets the item state to the default.
1189 Returns the alignment for this item. Can be one of
1190 wxLIST_FORMAT_LEFT, wxLIST_FORMAT_RIGHT or wxLIST_FORMAT_CENTRE.
1192 wxListColumnFormat
GetAlign() const;
1195 Returns the background colour for this item.
1197 wxColour
GetBackgroundColour() const;
1200 Returns the zero-based column; meaningful only in report mode.
1202 int GetColumn() const;
1205 Returns client data associated with the control. Please note that
1206 client data is associated with the item and not with subitems.
1208 long GetData() const;
1211 Returns the font used to display the item.
1213 wxFont
GetFont() const;
1216 Returns the zero-based item position.
1221 Returns the zero-based index of the image
1222 associated with the item into the image list.
1224 int GetImage() const;
1227 Returns a bit mask indicating which fields of the structure are valid;
1228 can be any combination of the following values:
1232 @b GetState is valid.
1236 @b GetText is valid.
1240 @b GetImage is valid.
1244 @b GetData is valid.
1248 @b GetWidth is valid.
1252 @b GetFormat is valid.
1254 long GetMask() const;
1257 Returns a bit field representing the state of the item. Can be any
1260 wxLIST_STATE_DONTCARE
1262 Don't care what the state is. Win32 only.
1264 wxLIST_STATE_DROPHILITED
1266 The item is highlighted to receive a drop event. Win32 only.
1268 wxLIST_STATE_FOCUSED
1270 The item has the focus.
1272 wxLIST_STATE_SELECTED
1274 The item is selected.
1278 The item is in the cut state. Win32 only.
1280 long GetState() const;
1283 Returns the label/header text.
1285 const wxString
GetText() const;
1288 Returns the text colour.
1290 wxColour
GetTextColour() const;
1293 Meaningful only for column headers in report mode. Returns the column width.
1295 int GetWidth() const;
1298 Sets the alignment for the item. See also
1301 void SetAlign(wxListColumnFormat align
);
1304 Sets the background colour for the item.
1306 void SetBackgroundColour(const wxColour
& colBack
);
1309 Sets the zero-based column. Meaningful only in report mode.
1311 void SetColumn(int col
);
1315 Sets client data for the item. Please note that
1316 client data is associated with the item and not with subitems.
1318 void SetData(long data
);
1319 void SetData(void* data
);
1323 Sets the font for the item.
1325 void SetFont(const wxFont
& font
);
1328 Sets the zero-based item position.
1330 void SetId(long id
);
1333 Sets the zero-based index of the image associated with the item
1334 into the image list.
1336 void SetImage(int image
);
1339 Sets the mask of valid fields. See GetMask().
1341 void SetMask(long mask
);
1344 Sets the item state flags (note that the valid state flags are influenced
1345 by the value of the state mask, see
1346 wxListItem::SetStateMask).
1347 See GetState() for valid flag
1350 void SetState(long state
);
1353 Sets the bitmask that is used to determine which of the state flags
1354 are to be set. See also SetState().
1356 void SetStateMask(long stateMask
);
1359 Sets the text label for the item.
1361 void SetText(const wxString
& text
);
1364 Sets the text colour for the item.
1366 void SetTextColour(const wxColour
& colText
);
1369 Meaningful only for column headers in report mode. Sets the column width.
1371 void SetWidth(int width
);