1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxListCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A list control presents lists in a number of formats: list view, report view,
14 icon view and small icon view. In any case, elements are numbered from zero.
15 For all these modes, the items are stored in the control and must be added to
16 it using wxListCtrl::InsertItem method.
18 A special case of report view quite different from the other modes of the list
19 control is a virtual control in which the items data (including text, images
20 and attributes) is managed by the main program and is requested by the control
21 itself only when needed which allows to have controls with millions of items
22 without consuming much memory. To use virtual list control you must use
23 wxListCtrl::SetItemCount first and overload at least
24 wxListCtrl::OnGetItemText (and optionally
25 wxListCtrl::OnGetItemImage or wxListCtrl::OnGetItemColumnImage and
26 wxListCtrl::OnGetItemAttr) to return the information
27 about the items when the control requests it. Virtual list control can be used
28 as a normal one except that no operations which can take time proportional to
29 the number of items in the control happen -- this is required to allow having a
30 practically infinite number of items. For example, in a multiple selection
31 virtual list control, the selections won't be sent when many items are selected
32 at once because this could mean iterating over all the items.
34 Using many of wxListCtrl features is shown in the
35 @ref overview_samplelistctrl "corresponding sample".
37 To intercept events from a list control, use the event table macros described
40 @b Mac Note: Starting with 2.8, wxListCtrl uses a native implementation for
41 report mode, and uses a generic implementation for other modes. You can use the
42 generic implementation for report mode as well by setting the
43 mac.listctrl.always_use_generic wxSystemOption() to
48 Multicolumn list view, with optional small icons. Columns are
49 computed automatically, i.e. you don't set columns as in
50 wxLC_REPORT. In other words, the list wraps, unlike a wxListBox.
52 Single or multicolumn report view, with optional header.
54 The application provides items text on demand. May only be used
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
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.)
80 Draws light horizontal rules between rows in report mode.
82 Draws light vertical rules between columns in report mode.
87 <!-- @appearance{listctrl.png} -->
89 @see @ref overview_listctrl "wxListCtrl Overview", wxListView,
90 wxListBox, wxTreeCtrl, wxImageList, wxListEvent, wxListItem
92 class wxListCtrl
: public wxControl
97 Constructor, creating and showing a list control.
102 Constructor, creating and showing a list control.
105 Parent window. Must not be @NULL.
107 Window identifier. The value wxID_ANY indicates a default value.
111 Window size. If wxDefaultSize is specified then the window is
114 Window style. See wxListCtrl.
120 @see Create(), wxValidator
122 wxListCtrl(wxWindow
* parent
, wxWindowID id
,
123 const wxPoint
& pos
= wxDefaultPosition
,
124 const wxSize
& size
= wxDefaultSize
,
125 long style
= wxLC_ICON
,
126 const wxValidator
& validator
= wxDefaultValidator
,
127 const wxString
& name
= wxListCtrlNameStr
);
131 Destructor, destroying the list control.
136 Arranges the items in icon or small icon view. This only has effect on Win32.
145 Align to the left side of the control.
149 Align to the top side of the control.
151 wxLIST_ALIGN_SNAP_TO_GRID
155 bool Arrange(int flag
= wxLIST_ALIGN_DEFAULT
);
158 Sets the image list associated with the control and
159 takes ownership of it (i.e. the control will, unlike when using
160 SetImageList, delete the list when destroyed). @a which is one of
161 wxIMAGE_LIST_NORMAL, wxIMAGE_LIST_SMALL, wxIMAGE_LIST_STATE (the last is
166 void AssignImageList(wxImageList
* imageList
, int which
);
169 Deletes all items and all columns.
174 Creates the list control. See wxListCtrl() for further details.
176 bool Create(wxWindow
* parent
, wxWindowID id
,
177 const wxPoint
& pos
= wxDefaultPosition
,
178 const wxSize
& size
= wxDefaultSize
,
179 long style
= wxLC_ICON
,
180 const wxValidator
& validator
= wxDefaultValidator
,
181 const wxString
& name
= wxListCtrlNameStr
);
184 Deletes all items in the list control.
185 @note This function does @e not send the
186 @c wxEVT_COMMAND_LIST_DELETE_ITEM event because deleting many items
187 from the control would be too slow then (unlike wxListCtrl::DeleteItem).
189 bool DeleteAllItems();
194 bool DeleteColumn(int col
);
197 Deletes the specified item. This function sends the
198 @c wxEVT_COMMAND_LIST_DELETE_ITEM event for the item being deleted.
199 See also: DeleteAllItems()
201 bool DeleteItem(long item
);
204 Starts editing the label of the given item. This function generates a
205 EVT_LIST_BEGIN_LABEL_EDIT event which can be vetoed so that no
206 text control will appear for in-place editing.
207 If the user changed the label (i.e. s/he does not press ESC or leave
208 the text control without changes, a EVT_LIST_END_LABEL_EDIT event
209 will be sent which can be vetoed as well.
211 void EditLabel(long item
);
214 Ensures this item is visible.
216 bool EnsureVisible(long item
);
220 Find an item nearest this position in the specified direction, starting from
221 @a start or the beginning if @a start is -1.
224 @b FindItem( start, str, partial = @false )
227 @b FindItemData( start, data )
230 @b FindItemAtPos( start, point, direction )
232 long FindItem(long start
, const wxString
& str
,
233 bool partial
= false);
234 long FindItem(long start
, long data
);
235 long FindItem(long start
, const wxPoint
& pt
, int direction
);
239 Gets information about this column. See SetItem() for more
242 bool GetColumn(int col
, wxListItem
& item
) const;
245 Returns the number of columns.
247 int GetColumnCount() const;
250 Gets the column number by visual order index (report view only).
252 int GetColumnIndexFromOrder(int order
) const;
255 Gets the column visual order index (valid in report view only).
257 int GetColumnOrder(int col
) const;
260 Gets the column width (report view only).
262 int GetColumnWidth(int col
) const;
265 Returns the array containing the orders of all columns. On error, an empty
268 wxArrayInt
GetColumnsOrder() const;
271 Gets the number of items that can fit vertically in the
272 visible area of the list control (list or report view)
273 or the total number of items in the list control (icon
276 int GetCountPerPage() const;
279 Returns the edit control being currently used to edit a label. Returns @NULL
280 if no label is being edited.
281 @note It is currently only implemented for wxMSW and the generic version,
282 not for the native Mac OS X version.
284 wxTextCtrl
* GetEditControl() const;
287 Returns the specified image list. @a which may be one of:
289 @b wxIMAGE_LIST_NORMAL
291 The normal (large icon) image list.
293 @b wxIMAGE_LIST_SMALL
295 The small icon image list.
297 @b wxIMAGE_LIST_STATE
299 The user-defined state image list (unimplemented).
301 wxImageList
* GetImageList(int which
) const;
304 Gets information about the item. See SetItem() for more
306 You must call @e info.SetId() to the ID of item you're interested in
307 before calling this method.
309 bool GetItem(wxListItem
& info
) const;
312 Returns the colour for this item. If the item has no specific colour, returns
313 an invalid colour (and not the default background control of the control
316 @see GetItemTextColour()
318 wxColour
GetItemBackgroundColour(long item
) const;
321 Returns the number of items in the list control.
323 int GetItemCount() const;
326 Gets the application-defined data associated with this item.
328 long GetItemData(long item
) const;
331 Returns the item's font.
333 wxFont
GetItemFont(long item
) const;
336 Returns the position of the item, in icon or small icon view.
338 bool GetItemPosition(long item
, wxPoint
& pos
) const;
341 Returns the rectangle representing the item's size and position, in physical
343 @a code is one of wxLIST_RECT_BOUNDS, wxLIST_RECT_ICON, wxLIST_RECT_LABEL.
345 bool GetItemRect(long item
, wxRect
& rect
,
346 int code
= wxLIST_RECT_BOUNDS
) const;
349 Retrieves the spacing between icons in pixels: horizontal spacing is returned
350 as @c x component of the wxSize object and the vertical
351 spacing as its @c y component.
353 wxSize
GetItemSpacing() const;
356 Gets the item state. For a list of state flags, see SetItem().
357 The @b stateMask indicates which state flags are of interest.
359 int GetItemState(long item
, long stateMask
) const;
362 Gets the item text for this item.
364 wxString
GetItemText(long item
) const;
367 Returns the colour for this item. If the item has no specific colour, returns
368 an invalid colour (and not the default foreground control of the control itself
369 as this wouldn't allow distinguishing between items having the same colour as
370 the current control foreground and items with default colour which, hence, have
371 always the same colour as the control).
373 wxColour
GetItemTextColour(long item
) const;
376 Searches for an item with the given geometry or state, starting from
377 @a item but excluding the @a item itself. If @a item is -1,
378 the first item that matches the specified flags will be returned.
379 Returns the first item with given state following @a item or -1 if
381 This function may be used to find all selected items in the control like this:
383 @a geometry can be one of:
387 Searches for an item above the specified item.
391 Searches for subsequent item by index.
395 Searches for an item below the specified item.
399 Searches for an item to the left of the specified item.
403 Searches for an item to the right of the specified item.
405 @note this parameter is only supported by wxMSW currently and ignored on
407 @a state can be a bitlist of the following:
409 wxLIST_STATE_DONTCARE
411 Don't care what the state is.
413 wxLIST_STATE_DROPHILITED
415 The item indicates it is a drop target.
419 The item has the focus.
421 wxLIST_STATE_SELECTED
423 The item is selected.
427 The item is selected as part of a cut and paste operation.
429 long GetNextItem(long item
, int geometry
= wxLIST_NEXT_ALL
,
430 int state
= wxLIST_STATE_DONTCARE
) const;
433 Returns the number of selected items in the list control.
435 int GetSelectedItemCount() const;
438 Returns the rectangle representing the size and position, in physical
439 coordinates, of the given subitem, i.e. the part of the row @a item in the
441 This method is only meaningfull when the wxListCtrl is in the report mode. If
442 @a subItem parameter is equal to the special value
443 @c wxLIST_GETSUBITEMRECT_WHOLEITEM the return value is the same as
445 @a code can be one of @c wxLIST_RECT_BOUNDS,
446 @c wxLIST_RECT_ICON or @c wxLIST_RECT_LABEL.
450 bool GetSubItemRect(long item
, long subItem
, wxRect
& rect
,
451 int code
= wxLIST_RECT_BOUNDS
) const;
454 Gets the text colour of the list control.
456 wxColour
GetTextColour() const;
459 Gets the index of the topmost visible item when in
462 long GetTopItem() const;
465 Returns the rectangle taken by all items in the control. In other words, if the
466 controls client size were equal to the size of this rectangle, no scrollbars
467 would be needed and no free space would be left.
468 Note that this function only works in the icon and small icon views, not in
469 list or report views (this is a limitation of the native Win32 control).
471 wxRect
GetViewRect() const;
474 Determines which item (if any) is at the specified point,
475 giving details in @e flags. Returns index of the item or @c wxNOT_FOUND
476 if no item is at the specified point.
477 @a flags will be a combination of the following flags:
481 Above the client area.
485 Below the client area.
487 wxLIST_HITTEST_NOWHERE
489 In the client area but below the last item.
491 wxLIST_HITTEST_ONITEMICON
493 On the bitmap associated with an item.
495 wxLIST_HITTEST_ONITEMLABEL
497 On the label (string) associated with an item.
499 wxLIST_HITTEST_ONITEMRIGHT
501 In the area to the right of an item.
503 wxLIST_HITTEST_ONITEMSTATEICON
505 On the state icon for a tree view item that is in a user-defined state.
507 wxLIST_HITTEST_TOLEFT
509 To the right of the client area.
511 wxLIST_HITTEST_TORIGHT
513 To the left of the client area.
515 wxLIST_HITTEST_ONITEM
517 Combination of wxLIST_HITTEST_ONITEMICON, wxLIST_HITTEST_ONITEMLABEL,
518 wxLIST_HITTEST_ONITEMSTATEICON.
520 If @a ptrSubItem is not @NULL and the wxListCtrl is in the report
521 mode the subitem (or column) number will also be provided.
522 This feature is only available in version 2.7.0 or higher and is currently only
523 implemented under wxMSW and requires at least comctl32.dll of verion 4.70 on
524 the host system or the value stored in @a ptrSubItem will be always -1. To
525 compile this feature into wxWidgets library you need to have access to
526 commctrl.h of version 4.70 that is provided by Microsoft.
528 long HitTest(const wxPoint
& point
, int& flags
,
529 long* ptrSubItem
) const;
533 For report view mode (only), inserts a column. For more details, see SetItem().
535 long InsertColumn(long col
, wxListItem
& info
);
536 long InsertColumn(long col
, const wxString
& heading
,
537 int format
= wxLIST_FORMAT_LEFT
,
547 long InsertItem(wxListItem
& info
);
550 Insert an string item.
552 Index of the new item, supplied by the application
556 long InsertItem(long index
, const wxString
& label
);
559 Insert an image item.
561 Index of the new item, supplied by the application
563 Index into the image list associated with this control and view style
565 long InsertItem(long index
, int imageIndex
);
568 Insert an image/string item.
570 Index of the new item, supplied by the application
574 Index into the image list associated with this control and view style
576 long InsertItem(long index
, const wxString
& label
,
581 This function may be overloaded in the derived class for a control with
582 @c wxLC_VIRTUAL style. It should return the attribute for the
583 for the specified @c item or @NULL to use the default appearance
585 wxListCtrl will not delete the pointer or keep a reference of it. You can
586 return the same wxListItemAttr pointer for every OnGetItemAttr call.
587 The base class version always returns @NULL.
589 @see OnGetItemImage(), OnGetItemColumnImage(),
592 virtual wxListItemAttr
* OnGetItemAttr(long item
) const;
595 Overload this function in the derived class for a control with
596 @c wxLC_VIRTUAL and @c wxLC_REPORT styles in order to specify the image
597 index for the given line and column.
598 The base class version always calls OnGetItemImage for the first column, else
601 @see OnGetItemText(), OnGetItemImage(),
604 virtual int OnGetItemColumnImage(long item
, long column
) const;
607 This function must be overloaded in the derived class for a control with
608 @c wxLC_VIRTUAL style having an @ref SetImageList() "image list"
609 (if the control doesn't have an image list, it is not necessary to overload
610 it). It should return the index of the items image in the controls image list
612 In a control with @c wxLC_REPORT style, OnGetItemImage only gets called for
613 the first column of each line.
614 The base class version always returns -1.
616 @see OnGetItemText(), OnGetItemColumnImage(),
619 virtual int OnGetItemImage(long item
) const;
622 This function @b must be overloaded in the derived class for a control with
623 @c wxLC_VIRTUAL style. It should return the string containing the text of
624 the given @a column for the specified @c item.
626 @see SetItemCount(), OnGetItemImage(),
627 OnGetItemColumnImage(), OnGetItemAttr()
629 virtual wxString
OnGetItemText(long item
, long column
) const;
632 Redraws the given @e item. This is only useful for the virtual list controls
633 as without calling this function the displayed value of the item doesn't change
634 even when the underlying data does change.
638 void RefreshItem(long item
);
641 Redraws the items between @a itemFrom and @e itemTo. The starting item
642 must be less than or equal to the ending one.
643 Just as RefreshItem() this is only useful for
644 virtual list controls.
646 void RefreshItems(long itemFrom
, long itemTo
);
649 Scrolls the list control. If in icon, small icon or report view mode,
650 @a dx specifies the number of pixels to scroll. If in list view mode,
651 @a dx specifies the number of columns to scroll. @a dy always specifies
652 the number of pixels to scroll vertically.
653 @note This method is currently only implemented in the Windows version.
655 bool ScrollList(int dx
, int dy
);
658 Sets the background colour (GetBackgroundColour already implicit in
661 void SetBackgroundColour(const wxColour
& col
);
664 Sets information about this column. See SetItem() for more
667 bool SetColumn(int col
, wxListItem
& item
);
670 Sets the column width.
671 @a width can be a width in pixels or wxLIST_AUTOSIZE (-1) or
672 wxLIST_AUTOSIZE_USEHEADER (-2).
673 wxLIST_AUTOSIZE will resize the column to the length of its longest item.
674 wxLIST_AUTOSIZE_USEHEADER
675 will resize the column to the length of the header (Win32) or 80 pixels (other
677 In small or normal icon view, @a col must be -1, and the column width is set
680 bool SetColumnWidth(int col
, int width
);
683 Sets the order of all columns at once. The @a orders array must have the
684 same number elements as the number of columns and contain each position exactly
686 This function is valid in report view only.
688 bool SetColumnOrder(const wxArrayInt
& orders
) const;
691 Sets the image list associated with the control. @a which is one of
692 wxIMAGE_LIST_NORMAL, wxIMAGE_LIST_SMALL, wxIMAGE_LIST_STATE (the last is
694 This method does not take ownership of the image list, you have to
697 @see AssignImageList()
699 void SetImageList(wxImageList
* imageList
, int which
);
703 Sets a string field at a particular column.
705 bool SetItem(wxListItem
& info
);
706 long SetItem(long index
, int col
, const wxString
& label
,
708 m_mask m_state field is valid
.
719 The m_text field is valid
.
730 The m_image field is valid
.
741 The m_data field is valid
.
752 The m_width field is valid
.
763 The m_format field is valid
.
769 The m_stateMask
and m_state members take flags from the following
:
777 wxLIST_STATE_DONTCARE
782 Don
't care what the state is. Win32 only.
788 wxLIST_STATE_DROPHILITED
793 The item is highlighted to receive a drop event. Win32 only.
804 The item has the focus.
810 wxLIST_STATE_SELECTED
815 The item is selected.
826 The item is in the cut state. Win32 only.
832 The wxListItem object can also contain item-specific colour and font
833 information: for this you need to call one of SetTextColour(),
834 SetBackgroundColour() or SetFont() functions on it passing it the colour/font
835 to use. If the colour/font is not specified, the default list control
837 long SetItem(long index, int col, const wxString& label,
842 Sets the background colour for this item. This function only works in report
844 The colour can be retrieved using
845 GetItemBackgroundColour().
847 void SetItemBackgroundColour(long item, const wxColour& col);
850 Sets the image associated with the item. In report view, you can specify the
852 The image is an index into the image list associated with the list control.
854 bool SetItemColumnImage(long item, long column, int image);
857 This method can only be used with virtual list controls.
859 It is used to indicate to the control the number of items it contains.
860 After calling it, the main program should be ready to handle calls to
861 various item callbacks (such as wxListCtrl::OnGetItemText) for all
862 items in the range from 0 to @a count.
864 Notice that the control is not necessarily redrawn after this call as
865 it may be undesirable if an item which is not visible on the screen
866 anyhow was added to or removed from a control displaying many items, if
867 you do need to refresh the display you can just call Refresh() manually.
869 void SetItemCount(long count);
872 Associates application-defined data with this item.
873 Notice that this function cannot be used to associate pointers with the control
874 items, use SetItemPtrData() instead.
876 bool SetItemData(long item, long data);
879 Sets the item's font
.
881 void SetItemFont(long item
, const wxFont
& font
);
885 Sets the unselected and selected images associated with the item. The images
887 image list associated with the list control. This form is deprecated: @a
891 bool SetItemImage(long item
, int image
);
892 bool SetItemImage(long item
, int image
, int selImage
);
896 Sets the position of the item, in icon or small icon view. Windows only.
898 bool SetItemPosition(long item
, const wxPoint
& pos
);
901 Associates application-defined data with this item. The @a data parameter may
902 be either an integer or a pointer cast to the @c wxUIntPtr type which is
903 guaranteed to be large enough to be able to contain all integer types and
908 bool SetItemPtrData(long item
, wxUIntPtr data
);
911 Sets the item state. For a list of state flags, see SetItem().
912 The @b stateMask indicates which state flags are valid.
914 bool SetItemState(long item
, long state
, long stateMask
);
917 Sets the item text for this item.
919 void SetItemText(long item
, const wxString
& text
);
922 Sets the colour for this item. This function only works in report view.
923 The colour can be retrieved using
926 void SetItemTextColour(long item
, const wxColour
& col
);
929 Adds or removes a single window style.
931 void SetSingleStyle(long style
, bool add
= true);
934 Sets the text colour of the list control.
936 void SetTextColour(const wxColour
& col
);
939 Sets the whole window style, deleting all items.
941 void SetWindowStyleFlag(long style
);
944 Call this function to sort the items in the list control. Sorting is done
945 using the specified @a fnSortCallBack function. This function must have the
948 It is called each time when the two items must be compared and should return 0
949 if the items are equal, negative value if the first item is less than the
950 second one and positive value if the first one is greater than the second one
951 (the same convention as used by @c qsort(3)).
954 client data associated with the first item (NOT the index).
956 client data associated with the second item (NOT the index).
958 the value passed to SortItems() itself.
960 bool SortItems(wxListCtrlCompare fnSortCallBack
, long data
);
967 @wxheader{listctrl.h}
969 A list event holds information about events associated with wxListCtrl objects.
976 class wxListEvent
: public wxNotifyEvent
982 wxListEvent(wxEventType commandType
= 0, int id
= 0);
985 For @c EVT_LIST_CACHE_HINT event only: return the first item which the
986 list control advises us to cache.
988 long GetCacheFrom() const;
991 For @c EVT_LIST_CACHE_HINT event only: return the last item (inclusive)
992 which the list control advises us to cache.
994 long GetCacheTo() const;
997 The column position: it is only used with @c COL events. For the column
998 dragging events, it is the column to the left of the divider being dragged, for
999 the column click events it may be -1 if the user clicked in the list control
1000 header outside any column.
1002 int GetColumn() const;
1007 long GetData() const;
1012 int GetImage() const;
1017 long GetIndex() const;
1020 An item object, used by some events. See also wxListCtrl::SetItem.
1022 const wxListItem
GetItem() const;
1025 Key code if the event is a keypress event.
1027 int GetKeyCode() const;
1030 The (new) item label for @c EVT_LIST_END_LABEL_EDIT event.
1032 const wxString
GetLabel() const;
1037 long GetMask() const;
1040 The position of the mouse pointer if the event is a drag event.
1042 wxPoint
GetPoint() const;
1047 const wxString
GetText() const;
1050 This method only makes sense for @c EVT_LIST_END_LABEL_EDIT message
1051 and returns @true if it the label editing has been cancelled by the user
1052 (GetLabel() returns an empty string in this case
1053 but it doesn't allow the application to distinguish between really cancelling
1055 the admittedly rare case when the user wants to rename it to an empty string).
1057 bool IsEditCancelled() const;
1063 @class wxListItemAttr
1064 @wxheader{listctrl.h}
1066 Represents the attributes (color, font, ...) of a
1067 wxListCtrl wxListItem.
1072 @see @ref overview_listctrl "wxListCtrl Overview", wxListCtrl,
1075 class wxListItemAttr
1080 Construct a wxListItemAttr with the specified foreground and
1081 background colors and font.
1084 wxListItemAttr(const wxColour colText
,
1085 const wxColour colBack
,
1090 Returns the currently set background color.
1092 const wxColour
GetBackgroundColour() const;
1095 Returns the currently set font.
1097 const wxFont
GetFont() const;
1100 Returns the currently set text color.
1102 const wxColour
GetTextColour() const;
1105 Returns @true if the currently set background color is valid.
1107 bool HasBackgroundColour() const;
1110 Returns @true if the currently set font is valid.
1112 bool HasFont() const;
1115 Returns @true if the currently set text color is valid.
1117 bool HasTextColour() const;
1120 Sets a new background color.
1122 void SetBackgroundColour(const wxColour
& colour
);
1127 void SetFont(const wxFont
& font
);
1130 Sets a new text color.
1132 void SetTextColour(const wxColour
& colour
);
1139 @wxheader{listctrl.h}
1141 This class currently simply presents a simpler to use interface for the
1142 wxListCtrl -- it can be thought of as a @e faade
1143 for that complicated class. Using it is preferable to using
1144 wxListCtrl directly whenever possible because in the
1145 future some ports might implement wxListView but not the full set of wxListCtrl
1148 Other than different interface, this class is identical to wxListCtrl. In
1149 particular, it uses the same events, same window styles and so on.
1153 <!-- @appearance{listview.png} -->
1155 @see wxListView::SetColumnImage
1157 class wxListView
: public wxListCtrl
1161 Resets the column image -- after calling this function, no image will be shown.
1164 the column to clear image for
1166 @see SetColumnImage()
1168 void ClearColumnImage(int col
);
1171 Sets focus to the item with the given @e index.
1173 void Focus(long index
);
1176 Returns the first selected item in a (presumably) multiple selection control.
1177 Together with GetNextSelected() it can be
1178 used to iterate over all selected items in the control.
1180 @return The first selected item, if any, -1 otherwise.
1182 long GetFirstSelected() const;
1185 Returns the currently focused item or -1 if none.
1187 @see IsSelected(), Focus()
1189 long GetFocusedItem() const;
1192 Used together with GetFirstSelected() to
1193 iterate over all selected items in the control.
1195 @return Returns the next selected item or -1 if there are no more of
1198 long GetNextSelected(long item
) const;
1201 Returns @true if the item with the given @a index is selected,
1204 @see GetFirstSelected(), GetNextSelected()
1206 bool IsSelected(long index
) const;
1209 Selects or unselects the given item.
1212 the item to select or unselect
1214 if @true (default), selects the item, otherwise unselects it
1216 @see wxListCtrl::SetItemState
1218 void Select(bool on
= true);
1221 Sets the column image for the specified column. To use the column images, the
1222 control must have a valid image list with at least one image.
1225 the column to set image for
1227 the index of the column image in the controls image list
1229 void SetColumnImage(int col
, int image
);
1236 @wxheader{listctrl.h}
1238 This class stores information about a wxListCtrl item or column.
1243 class wxListItem
: public wxObject
1252 Resets the item state to the default.
1257 Returns the alignment for this item. Can be one of
1258 wxLIST_FORMAT_LEFT, wxLIST_FORMAT_RIGHT or wxLIST_FORMAT_CENTRE.
1260 wxListColumnFormat
GetAlign() const;
1263 Returns the background colour for this item.
1265 wxColour
GetBackgroundColour() const;
1268 Returns the zero-based column; meaningful only in report mode.
1270 int GetColumn() const;
1273 Returns client data associated with the control. Please note that
1274 client data is associated with the item and not with subitems.
1276 long GetData() const;
1279 Returns the font used to display the item.
1281 wxFont
GetFont() const;
1284 Returns the zero-based item position.
1289 Returns the zero-based index of the image
1290 associated with the item into the image list.
1292 int GetImage() const;
1295 Returns a bit mask indicating which fields of the structure are valid;
1296 can be any combination of the following values:
1300 @b GetState is valid.
1304 @b GetText is valid.
1308 @b GetImage is valid.
1312 @b GetData is valid.
1316 @b GetWidth is valid.
1320 @b GetFormat is valid.
1322 long GetMask() const;
1325 Returns a bit field representing the state of the item. Can be any
1328 wxLIST_STATE_DONTCARE
1330 Don't care what the state is. Win32 only.
1332 wxLIST_STATE_DROPHILITED
1334 The item is highlighted to receive a drop event. Win32 only.
1336 wxLIST_STATE_FOCUSED
1338 The item has the focus.
1340 wxLIST_STATE_SELECTED
1342 The item is selected.
1346 The item is in the cut state. Win32 only.
1348 long GetState() const;
1351 Returns the label/header text.
1353 const wxString
GetText() const;
1356 Returns the text colour.
1358 wxColour
GetTextColour() const;
1361 Meaningful only for column headers in report mode. Returns the column width.
1363 int GetWidth() const;
1366 Sets the alignment for the item. See also
1369 void SetAlign(wxListColumnFormat align
);
1372 Sets the background colour for the item.
1374 void SetBackgroundColour(const wxColour
& colBack
);
1377 Sets the zero-based column. Meaningful only in report mode.
1379 void SetColumn(int col
);
1383 Sets client data for the item. Please note that
1384 client data is associated with the item and not with subitems.
1386 void SetData(long data
);
1387 void SetData(void* data
);
1391 Sets the font for the item.
1393 void SetFont(const wxFont
& font
);
1396 Sets the zero-based item position.
1398 void SetId(long id
);
1401 Sets the zero-based index of the image associated with the item
1402 into the image list.
1404 void SetImage(int image
);
1407 Sets the mask of valid fields. See GetMask().
1409 void SetMask(long mask
);
1412 Sets the item state flags (note that the valid state flags are influenced
1413 by the value of the state mask, see
1414 wxListItem::SetStateMask).
1415 See GetState() for valid flag
1418 void SetState(long state
);
1421 Sets the bitmask that is used to determine which of the state flags
1422 are to be set. See also SetState().
1424 void SetStateMask(long stateMask
);
1427 Sets the text label for the item.
1429 void SetText(const wxString
& text
);
1432 Sets the text colour for the item.
1434 void SetTextColour(const wxColour
& colText
);
1437 Meaningful only for column headers in report mode. Sets the column width.
1439 void SetWidth(int width
);