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