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