-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
listctrl.h
1468 lines (1194 loc) · 48.9 KB
/
listctrl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/////////////////////////////////////////////////////////////////////////////
// Name: wx/listctrl.h
// Purpose: interface of wxListCtrl
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxListCtrl
A list control presents lists in a number of formats: list view, report view,
icon view and small icon view. In any case, elements are numbered from zero.
For all these modes, the items are stored in the control and must be added to
it using wxListCtrl::InsertItem method.
A special case of report view quite different from the other modes of the list
control is a virtual control in which the items data (including text, images
and attributes) is managed by the main program and is requested by the control
itself only when needed which allows to have controls with millions of items
without consuming much memory. To use virtual list control you must use
wxListCtrl::SetItemCount first and overload at least wxListCtrl::OnGetItemText
(and optionally wxListCtrl::OnGetItemImage or wxListCtrl::OnGetItemColumnImage and
wxListCtrl::OnGetItemAttr) to return the information about the items when the
control requests it.
Virtual list control can be used as a normal one except that no operations
which can take time proportional to the number of items in the control happen
-- this is required to allow having a practically infinite number of items.
For example, in a multiple selection virtual list control, the selections won't
be sent when many items are selected at once because this could mean iterating
over all the items.
Using many of wxListCtrl features is shown in the
@ref page_samples_listctrl "corresponding sample".
To intercept events from a list control, use the event table macros described
in wxListEvent.
<b>wxMac Note</b>: Starting with wxWidgets 2.8, wxListCtrl uses a native
implementation for report mode, and uses a generic implementation for other
modes. You can use the generic implementation for report mode as well by setting
the @c mac.listctrl.always_use_generic system option (see wxSystemOptions) to 1.
@beginStyleTable
@style{wxLC_LIST}
Multicolumn list view, with optional small icons. Columns are
computed automatically, i.e. you don't set columns as in
@c wxLC_REPORT. In other words, the list wraps, unlike a wxListBox.
@style{wxLC_REPORT}
Single or multicolumn report view, with optional header.
@style{wxLC_VIRTUAL}
The application provides items text on demand. May only be used
with @c wxLC_REPORT.
@style{wxLC_ICON}
Large icon view, with optional labels.
@style{wxLC_SMALL_ICON}
Small icon view, with optional labels.
@style{wxLC_ALIGN_TOP}
Icons align to the top. Win32 default, Win32 only.
@style{wxLC_ALIGN_LEFT}
Icons align to the left.
@style{wxLC_AUTOARRANGE}
Icons arrange themselves. Win32 only.
@style{wxLC_EDIT_LABELS}
Labels are editable: the application will be notified when editing
starts.
@style{wxLC_NO_HEADER}
No header in report mode.
@style{wxLC_SINGLE_SEL}
Single selection (default is multiple).
@style{wxLC_SORT_ASCENDING}
Sort in ascending order. (You must still supply a comparison callback
in wxListCtrl::SortItems.)
@style{wxLC_SORT_DESCENDING}
Sort in descending order. (You must still supply a comparison callback
in wxListCtrl::SortItems.)
@style{wxLC_HRULES}
Draws light horizontal rules between rows in report mode.
@style{wxLC_VRULES}
Draws light vertical rules between columns in report mode.
@endStyleTable
@beginEventEmissionTable{wxListEvent}
@event{EVT_LIST_BEGIN_DRAG(id, func)}
Begin dragging with the left mouse button.
@event{EVT_LIST_BEGIN_RDRAG(id, func)}
Begin dragging with the right mouse button..
@event{EVT_BEGIN_LABEL_EDIT(id, func)}
Begin editing a label. This can be prevented by calling Veto().
@event{EVT_LIST_END_LABEL_EDIT(id, func)}
Finish editing a label. This can be prevented by calling Veto().
@event{EVT_LIST_DELETE_ITEM(id, func)}
An item was deleted.
@event{EVT_LIST_DELETE_ALL_ITEMS(id, func)}
All items were deleted.
@event{EVT_LIST_ITEM_SELECTED(id, func)}
The item has been selected.
@event{EVT_LIST_ITEM_DESELECTED(id, func)}
The item has been deselected.
@event{EVT_LIST_ITEM_ACTIVATED(id, func)}
The item has been activated (ENTER or double click).
@event{EVT_LIST_ITEM_FOCUSED(id, func)}
The currently focused item has changed.
@event{EVT_LIST_ITEM_MIDDLE_CLICK(id, func)}
The middle mouse button has been clicked on an item.
@event{EVT_LIST_ITEM_RIGHT_CLICK(id, func)}
The right mouse button has been clicked on an item.
@event{EVT_LIST_KEY_DOWN(id, func)}
A key has been pressed.
@event{EVT_LIST_INSERT_ITEM(id, func)}
An item has been inserted.
@event{EVT_LIST_COL_CLICK(id, func)}
A column (m_col) has been left-clicked.
@event{EVT_LIST_COL_RIGHT_CLICK(id, func)}
A column (m_col) has been right-clicked.
@event{EVT_LIST_COL_BEGIN_DRAG(id, func)}
The user started resizing a column - can be vetoed.
@event{EVT_LIST_COL_DRAGGING(id, func)}
The divider between columns is being dragged.
@event{EVT_LIST_COL_END_DRAG(id, func)}
A column has been resized by the user.
@event{EVT_LIST_CACHE_HINT(id, func)}
Prepare cache for a virtual list control.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{listctrl.png}
@see @ref overview_listctrl, wxListView, wxListBox, wxTreeCtrl, wxImageList,
wxListEvent, wxListItem, wxEditableListBox
*/
class wxListCtrl : public wxControl
{
public:
/**
Default constructor.
*/
wxListCtrl();
/**
Constructor, creating and showing a list control.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param pos
Window position.
@param size
Window size.
If wxDefaultSize is specified then the window is sized appropriately.
@param style
Window style. See wxListCtrl.
@param validator
Window validator.
@param name
Window name.
@see Create(), wxValidator
*/
wxListCtrl(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListCtrlNameStr);
/**
Destructor, destroying the list control.
*/
virtual ~wxListCtrl();
/**
Arranges the items in icon or small icon view.
This only has effect on Win32. @a flag is one of:
- wxLIST_ALIGN_DEFAULT: Default alignment.
- wxLIST_ALIGN_LEFT: Align to the left side of the control.
- wxLIST_ALIGN_TOP: Align to the top side of the control.
- wxLIST_ALIGN_SNAP_TO_GRID: Snap to grid.
*/
bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
/**
Sets the image list associated with the control and takes ownership of it
(i.e. the control will, unlike when using SetImageList(), delete the list
when destroyed). @a which is one of @c wxIMAGE_LIST_NORMAL, @c wxIMAGE_LIST_SMALL,
@c wxIMAGE_LIST_STATE (the last is unimplemented).
@see SetImageList()
*/
void AssignImageList(wxImageList* imageList, int which);
/**
Deletes all items and all columns.
*/
void ClearAll();
/**
Creates the list control. See wxListCtrl() for further details.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListCtrlNameStr);
/**
Deletes all items in the list control.
@note This function does @e not send the @c wxEVT_COMMAND_LIST_DELETE_ITEM
event because deleting many items from the control would be too slow
then (unlike wxListCtrl::DeleteItem).
*/
bool DeleteAllItems();
/**
Deletes a column.
*/
bool DeleteColumn(int col);
/**
Deletes the specified item.
This function sends the @c wxEVT_COMMAND_LIST_DELETE_ITEM event for the
item being deleted.
@see DeleteAllItems()
*/
bool DeleteItem(long item);
/**
Starts editing the label of the given item.
This function generates a @c EVT_LIST_BEGIN_LABEL_EDIT event which can be
vetoed so that no text control will appear for in-place editing.
If the user changed the label (i.e. s/he does not press ESC or leave
the text control without changes, a @c EVT_LIST_END_LABEL_EDIT event
will be sent which can be vetoed as well.
*/
wxTextCtrl* EditLabel(long item,
wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl));
/**
Ensures this item is visible.
*/
bool EnsureVisible(long item);
/**
Find an item whose label matches this string, starting from start or the
beginning if start is @c -1. The string comparison is case insensitive.
If @a partial is @true then this method will look for items which begin with @a str.
*/
long FindItem(long start, const wxString& str,
bool partial = false);
/**
Find an item whose data matches this data, starting from start or the
beginning if 'start' is @c -1.
*/
long FindItem(long start, wxUIntPtr data);
/**
Find an item nearest this position in the specified direction,
starting from @a start or the beginning if @a start is -1.
*/
long FindItem(long start, const wxPoint& pt, int direction);
/**
Gets information about this column.
See SetItem() for more information.
*/
bool GetColumn(int col, wxListItem& item) const;
/**
Returns the number of columns.
*/
int GetColumnCount() const;
/**
Gets the column index from its position in visual order.
After calling SetColumnsOrder(), the index returned by this function
corresponds to the value of the element number @a pos in the array
returned by GetColumnsOrder().
Please see SetColumnsOrder() documentation for an example and
additional remarks about the columns ordering.
@see GetColumnOrder()
*/
int GetColumnIndexFromOrder(int pos) const;
/**
Gets the column visual order position.
This function returns the index of the column which appears at the
given visual position, e.g. calling it with @a col equal to 0 returns
the index of the first shown column.
Please see SetColumnsOrder() documentation for an example and
additional remarks about the columns ordering.
@see GetColumnsOrder(), GetColumnIndexFromOrder()
*/
int GetColumnOrder(int col) const;
/**
Gets the column width (report view only).
*/
int GetColumnWidth(int col) const;
/**
Returns the array containing the orders of all columns.
On error, an empty array is returned.
Please see SetColumnsOrder() documentation for an example and
additional remarks about the columns ordering.
@see GetColumnOrder(), GetColumnIndexFromOrder()
*/
wxArrayInt GetColumnsOrder() const;
/**
Gets the number of items that can fit vertically in the visible area of
the list control (list or report view) or the total number of items in
the list control (icon or small icon view).
*/
int GetCountPerPage() const;
/**
Returns the edit control being currently used to edit a label.
Returns @NULL if no label is being edited.
@note It is currently only implemented for wxMSW and the generic version,
not for the native Mac OS X version.
*/
wxTextCtrl* GetEditControl() const;
/**
Returns the specified image list. @a which may be one of:
- wxIMAGE_LIST_NORMAL: The normal (large icon) image list.
- wxIMAGE_LIST_SMALL: The small icon image list.
- wxIMAGE_LIST_STATE: The user-defined state image list (unimplemented).
*/
wxImageList* GetImageList(int which) const;
/**
Gets information about the item. See SetItem() for more information.
You must call @e info.SetId() to set the ID of item you're interested in
before calling this method, and @e info.SetMask() with the flags indicating
what fields you need to retrieve from @a info.
*/
bool GetItem(wxListItem& info) const;
/**
Returns the colour for this item.
If the item has no specific colour, returns an invalid colour
(and not the default background control of the control itself).
@see GetItemTextColour()
*/
wxColour GetItemBackgroundColour(long item) const;
/**
Returns the number of items in the list control.
*/
int GetItemCount() const;
/**
Gets the application-defined data associated with this item.
*/
wxUIntPtr GetItemData(long item) const;
/**
Returns the item's font.
*/
wxFont GetItemFont(long item) const;
/**
Returns the position of the item, in icon or small icon view.
*/
bool GetItemPosition(long item, wxPoint& pos) const;
/**
Returns the rectangle representing the item's size and position, in physical
coordinates.
@a code is one of wxLIST_RECT_BOUNDS, wxLIST_RECT_ICON, wxLIST_RECT_LABEL.
*/
bool GetItemRect(long item, wxRect& rect,
int code = wxLIST_RECT_BOUNDS) const;
/**
Retrieves the spacing between icons in pixels: horizontal spacing is
returned as @c x component of the wxSize object and the vertical spacing
as its @c y component.
*/
wxSize GetItemSpacing() const;
/**
Gets the item state. For a list of state flags, see SetItem().
The @a stateMask indicates which state flags are of interest.
*/
int GetItemState(long item, long stateMask) const;
/**
Gets the item text for this item.
*/
wxString GetItemText(long item) const;
/**
Returns the colour for this item.
If the item has no specific colour, returns an invalid colour (and not the
default foreground control of the control itself as this wouldn't allow
distinguishing between items having the same colour as the current control
foreground and items with default colour which, hence, have always the
same colour as the control).
*/
wxColour GetItemTextColour(long item) const;
/**
Searches for an item with the given geometry or state, starting from
@a item but excluding the @a item itself.
If @a item is -1, the first item that matches the specified flags will be returned.
Returns the first item with given state following @a item or -1 if no such item found.
This function may be used to find all selected items in the control like this:
@code
long item = -1;
for ( ;; )
{
item = listctrl->GetNextItem(item,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
if ( item == -1 )
break;
// this item is selected - do whatever is needed with it
wxLogMessage("Item %ld is selected.", item);
}
@endcode
@a geometry can be one of:
- wxLIST_NEXT_ABOVE: Searches for an item above the specified item.
- wxLIST_NEXT_ALL: Searches for subsequent item by index.
- wxLIST_NEXT_BELOW: Searches for an item below the specified item.
- wxLIST_NEXT_LEFT: Searches for an item to the left of the specified item.
- wxLIST_NEXT_RIGHT: Searches for an item to the right of the specified item.
@note this parameter is only supported by wxMSW currently and ignored on
other platforms.
@a state can be a bitlist of the following:
- wxLIST_STATE_DONTCARE: Don't care what the state is.
- wxLIST_STATE_DROPHILITED: The item indicates it is a drop target.
- wxLIST_STATE_FOCUSED: The item has the focus.
- wxLIST_STATE_SELECTED: The item is selected.
- wxLIST_STATE_CUT: The item is selected as part of a cut and paste operation.
*/
long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL,
int state = wxLIST_STATE_DONTCARE) const;
/**
Returns the number of selected items in the list control.
*/
int GetSelectedItemCount() const;
/**
Returns the rectangle representing the size and position, in physical
coordinates, of the given subitem, i.e. the part of the row @a item in the
column @a subItem.
This method is only meaningfull when the wxListCtrl is in the report mode.
If @a subItem parameter is equal to the special value
@c wxLIST_GETSUBITEMRECT_WHOLEITEM the return value is the same as
for GetItemRect().
@a code can be one of @c wxLIST_RECT_BOUNDS, @c wxLIST_RECT_ICON or
@c wxLIST_RECT_LABEL.
@since 2.7.0
*/
bool GetSubItemRect(long item, long subItem, wxRect& rect,
int code = wxLIST_RECT_BOUNDS) const;
/**
Gets the text colour of the list control.
*/
wxColour GetTextColour() const;
/**
Gets the index of the topmost visible item when in list or report view.
*/
long GetTopItem() const;
/**
Returns the rectangle taken by all items in the control. In other words, if the
controls client size were equal to the size of this rectangle, no scrollbars
would be needed and no free space would be left.
Note that this function only works in the icon and small icon views, not in
list or report views (this is a limitation of the native Win32 control).
*/
wxRect GetViewRect() const;
/**
Determines which item (if any) is at the specified point, giving details
in @a flags. Returns index of the item or @c wxNOT_FOUND if no item is at
the specified point.
@a flags will be a combination of the following flags:
- wxLIST_HITTEST_ABOVE: Above the client area.
- wxLIST_HITTEST_BELOW: Below the client area.
- wxLIST_HITTEST_NOWHERE: In the client area but below the last item.
- wxLIST_HITTEST_ONITEMICON: On the bitmap associated with an item.
- wxLIST_HITTEST_ONITEMLABEL: On the label (string) associated with an item.
- wxLIST_HITTEST_ONITEMRIGHT: In the area to the right of an item.
- wxLIST_HITTEST_ONITEMSTATEICON: On the state icon for a tree view item
that is in a user-defined state.
- wxLIST_HITTEST_TOLEFT: To the right of the client area.
- wxLIST_HITTEST_TORIGHT: To the left of the client area.
- wxLIST_HITTEST_ONITEM: Combination of @c wxLIST_HITTEST_ONITEMICON,
@c wxLIST_HITTEST_ONITEMLABEL, @c wxLIST_HITTEST_ONITEMSTATEICON.
If @a ptrSubItem is not @NULL and the wxListCtrl is in the report
mode the subitem (or column) number will also be provided.
This feature is only available in version 2.7.0 or higher and is currently only
implemented under wxMSW and requires at least comctl32.dll of verion 4.70 on
the host system or the value stored in @a ptrSubItem will be always -1.
To compile this feature into wxWidgets library you need to have access to
commctrl.h of version 4.70 that is provided by Microsoft.
*/
long HitTest(const wxPoint& point, int& flags, long* ptrSubItem = NULL) const;
/**
For report view mode (only), inserts a column. For more details, see SetItem().
*/
long InsertColumn(long col, wxListItem& info);
/**
For report view mode (only), inserts a column. For more details, see SetItem().
*/
long InsertColumn(long col, const wxString& heading,
int format = wxLIST_FORMAT_LEFT,
int width = -1);
/**
Inserts an item, returning the index of the new item if successful, -1 otherwise.
@param info
wxListItem object
*/
long InsertItem(wxListItem& info);
/**
Insert an string item.
@param index
Index of the new item, supplied by the application
@param label
String label
*/
long InsertItem(long index, const wxString& label);
/**
Insert an image item.
@param index
Index of the new item, supplied by the application
@param imageIndex
Index into the image list associated with this control and view style
*/
long InsertItem(long index, int imageIndex);
/**
Insert an image/string item.
@param index
Index of the new item, supplied by the application
@param label
String label
@param imageIndex
Index into the image list associated with this control and view style
*/
long InsertItem(long index, const wxString& label,
int imageIndex);
/**
Redraws the given @e item.
This is only useful for the virtual list controls as without calling this
function the displayed value of the item doesn't change even when the
underlying data does change.
@see RefreshItems()
*/
void RefreshItem(long item);
/**
Redraws the items between @a itemFrom and @e itemTo.
The starting item must be less than or equal to the ending one.
Just as RefreshItem() this is only useful for virtual list controls.
*/
void RefreshItems(long itemFrom, long itemTo);
/**
Scrolls the list control. If in icon, small icon or report view mode,
@a dx specifies the number of pixels to scroll. If in list view mode,
@a dx specifies the number of columns to scroll. @a dy always specifies
the number of pixels to scroll vertically.
@note This method is currently only implemented in the Windows version.
*/
bool ScrollList(int dx, int dy);
/**
Sets the background colour.
Note that the wxWindow::GetBackgroundColour() function of wxWindow base
class can be used to retrieve the current background colour.
*/
virtual bool SetBackgroundColour(const wxColour& col);
/**
Sets information about this column.
See SetItem() for more information.
*/
bool SetColumn(int col, wxListItem& item);
/**
Sets the column width.
@a width can be a width in pixels or @c wxLIST_AUTOSIZE (-1) or
@c wxLIST_AUTOSIZE_USEHEADER (-2).
@c wxLIST_AUTOSIZE will resize the column to the length of its longest item.
@c wxLIST_AUTOSIZE_USEHEADER will resize the column to the length of the
header (Win32) or 80 pixels (other platforms).
In small or normal icon view, @a col must be -1, and the column width is set
for all columns.
*/
bool SetColumnWidth(int col, int width);
/**
Changes the order in which the columns are shown.
By default, the columns of a list control appear on the screen in order
of their indices, i.e. the column 0 appears first, the column 1 next
and so on. However by using this function it is possible to arbitrarily
reorder the columns visual order and the user can also rearrange the
columns interactively by dragging them. In this case, the index of the
column is not the same as its order and the functions GetColumnOrder()
and GetColumnIndexFromOrder() should be used to translate between them.
Notice that all the other functions still work with the column indices,
i.e. the visual positioning of the columns on screen doesn't affect the
code setting or getting their values for example.
The @a orders array must have the same number elements as the number of
columns and contain each position exactly once. Its n-th element
contains the index of the column to be shown in n-th position, so for a
control with three columns passing an array with elements 2, 0 and 1
results in the third column being displayed first, the first one next
and the second one last.
Example of using it:
@code
wxListCtrl *list = new wxListCtrl(...);
for ( int i = 0; i < 3; i++ )
list->InsertColumn(i, wxString::Format("Column %d", i));
wxArrayInt order(3);
order[0] = 2;
order[1] = 0;
order[2] = 1;
list->SetColumnsOrder(order);
// now list->GetColumnsOrder() will return order and
// list->GetColumnIndexFromOrder(n) will return order[n] and
// list->GetColumnOrder() will return 1, 2 and 0 for the column 0,
// 1 and 2 respectively
@endcode
Please notice that this function makes sense for report view only and
currently is only implemented in wxMSW port. To avoid explicit tests
for @c __WXMSW__ in your code, please use @c wxHAS_LISTCTRL_COLUMN_ORDER
as this will allow it to start working under the other platforms when
support for the column reordering is added there.
@see GetColumnsOrder()
*/
bool SetColumnsOrder(const wxArrayInt& orders) const;
/**
Sets the image list associated with the control.
@a which is one of @c wxIMAGE_LIST_NORMAL, @c wxIMAGE_LIST_SMALL,
@c wxIMAGE_LIST_STATE (the last is unimplemented).
This method does not take ownership of the image list, you have to
delete it yourself.
@see AssignImageList()
*/
void SetImageList(wxImageList* imageList, int which);
/**
Sets the data of an item.
Using the wxListItem's mask and state mask, you can change only selected
attributes of a wxListCtrl item.
*/
bool SetItem(wxListItem& info);
/**
Sets an item string field at a particular column.
*/
long SetItem(long index, int column, const wxString& label, int imageId = -1);
/**
Sets the background colour for this item.
This function only works in report view mode.
The colour can be retrieved using GetItemBackgroundColour().
*/
void SetItemBackgroundColour(long item, const wxColour& col);
/**
Sets the image associated with the item.
In report view, you can specify the column.
The image is an index into the image list associated with the list control.
*/
bool SetItemColumnImage(long item, long column, int image);
/**
This method can only be used with virtual list controls.
It is used to indicate to the control the number of items it contains.
After calling it, the main program should be ready to handle calls to
various item callbacks (such as wxListCtrl::OnGetItemText) for all
items in the range from 0 to @a count.
Notice that the control is not necessarily redrawn after this call as
it may be undesirable if an item which is not visible on the screen
anyhow was added to or removed from a control displaying many items, if
you do need to refresh the display you can just call Refresh() manually.
*/
void SetItemCount(long count);
/**
Associates application-defined data with this item.
Notice that this function cannot be used to associate pointers with the control
items, use SetItemPtrData() instead.
*/
bool SetItemData(long item, long data);
/**
Sets the item's font.
*/
void SetItemFont(long item, const wxFont& font);
/**
Sets the unselected and selected images associated with the item.
The images are indices into the image list associated with the list control.
*/
bool SetItemImage(long item, int image, int selImage = -1);
/**
Sets the unselected and selected images associated with the item.
The images are indices into the image list associated with the list control.
@deprecated
This form is deprecated: @a selImage is not used; use the other
SetItemImage() overload.
*/
bool SetItemImage(long item, int image, int selImage = -1);
/**
Sets the position of the item, in icon or small icon view. Windows only.
*/
bool SetItemPosition(long item, const wxPoint& pos);
/**
Associates application-defined data with this item.
The @a data parameter may be either an integer or a pointer cast to the
@c wxUIntPtr type which is guaranteed to be large enough to be able to
contain all integer types and pointers.
@since 2.8.4
*/
bool SetItemPtrData(long item, wxUIntPtr data);
/**
Sets the item state. For a list of state flags, see SetItem().
The @b stateMask indicates which state flags are valid.
*/
bool SetItemState(long item, long state, long stateMask);
/**
Sets the item text for this item.
*/
void SetItemText(long item, const wxString& text);
/**
Sets the colour for this item.
This function only works in report view.
The colour can be retrieved using GetItemTextColour().
*/
void SetItemTextColour(long item, const wxColour& col);
/**
Adds or removes a single window style.
*/
void SetSingleStyle(long style, bool add = true);
/**
Sets the text colour of the list control.
*/
void SetTextColour(const wxColour& col);
/**
Sets the whole window style, deleting all items.
*/
void SetWindowStyleFlag(long style);
/**
Call this function to sort the items in the list control. Sorting is done
using the specified @a fnSortCallBack function. This function must have the
following prototype:
@code
int wxCALLBACK wxListCompareFunction(long item1, long item2, long sortData)
@endcode
It is called each time when the two items must be compared and should return 0
if the items are equal, negative value if the first item is less than the
second one and positive value if the first one is greater than the second one
(the same convention as used by @c qsort(3)).
The parameter @e item1 is the client data associated with the first item (NOT the index).
The parameter @e item2 is the client data associated with the second item (NOT the index).
The parameter @e data is the value passed to SortItems() itself.
Notice that the control may only be sorted on client data associated with
the items, so you must use SetItemData if you want to be able to sort the
items in the control.
Please see the @ref page_samples_listctrl for an example of using this function.
*/
bool SortItems(wxListCtrlCompare fnSortCallBack, long data);
protected:
/**
This function may be overloaded in the derived class for a control with
@c wxLC_VIRTUAL style. It should return the attribute for the specified
@c item or @NULL to use the default appearance parameters.
wxListCtrl will not delete the pointer or keep a reference of it.
You can return the same wxListItemAttr pointer for every OnGetItemAttr() call.
The base class version always returns @NULL.
@see OnGetItemImage(), OnGetItemColumnImage(), OnGetItemText(),
OnGetItemColumnAttr()
*/
virtual wxListItemAttr* OnGetItemAttr(long item) const;
/**
This function may be overridden in the derived class for a control with
@c wxLC_VIRTUAL style.
It should return the attribute for the for the specified @a item and @a
column or @NULL to use the default appearance parameters.
The base class version returns @c OnGetItemAttr(item).
@note Currently this function is only called under wxMSW, the other
ports only support OnGetItemAttr()
@see OnGetItemAttr(), OnGetItemText(),
OnGetItemImage(), OnGetItemColumnImage(),
*/
virtual wxListItemAttr* OnGetItemColumnAttr(long item, long column) const;
/**
Overload this function in the derived class for a control with
@c wxLC_VIRTUAL and @c wxLC_REPORT styles in order to specify the image
index for the given line and column.
The base class version always calls OnGetItemImage() for the first column, else
it returns -1.
@see OnGetItemText(), OnGetItemImage(), OnGetItemAttr(),
OnGetItemColumnAttr()
*/
virtual int OnGetItemColumnImage(long item, long column) const;
/**
This function must be overloaded in the derived class for a control with
@c wxLC_VIRTUAL style having an "image list" (see SetImageList(); if the
control doesn't have an image list, it is not necessary to overload it).
It should return the index of the items image in the controls image list
or -1 for no image.
In a control with @c wxLC_REPORT style, OnGetItemImage() only gets called for
the first column of each line.
The base class version always returns -1.
@see OnGetItemText(), OnGetItemColumnImage(), OnGetItemAttr()
*/
virtual int OnGetItemImage(long item) const;
/**
This function @b must be overloaded in the derived class for a control with
@c wxLC_VIRTUAL style. It should return the string containing the text of
the given @a column for the specified @c item.
@see SetItemCount(), OnGetItemImage(), OnGetItemColumnImage(), OnGetItemAttr()
*/
virtual wxString OnGetItemText(long item, long column) const;
};
/**
@class wxListEvent
A list event holds information about events associated with wxListCtrl objects.
@beginEventTable{wxListEvent}
@event{EVT_LIST_BEGIN_DRAG(id, func)}
Begin dragging with the left mouse button.
@event{EVT_LIST_BEGIN_RDRAG(id, func)}
Begin dragging with the right mouse button.
@event{EVT_LIST_BEGIN_LABEL_EDIT(id, func)}
Begin editing a label. This can be prevented by calling Veto().
@event{EVT_LIST_END_LABEL_EDIT(id, func)}
Finish editing a label. This can be prevented by calling Veto().
@event{EVT_LIST_DELETE_ITEM(id, func)}
Delete an item.
@event{EVT_LIST_DELETE_ALL_ITEMS(id, func)}
Delete all items.
@event{EVT_LIST_ITEM_SELECTED(id, func)}
The item has been selected.
@event{EVT_LIST_ITEM_DESELECTED(id, func)}
The item has been deselected.
@event{EVT_LIST_ITEM_ACTIVATED(id, func)}
The item has been activated (ENTER or double click).
@event{EVT_LIST_ITEM_FOCUSED(id, func)}
The currently focused item has changed.
@event{EVT_LIST_ITEM_MIDDLE_CLICK(id, func)}
The middle mouse button has been clicked on an item.
@event{EVT_LIST_ITEM_RIGHT_CLICK(id, func)}
The right mouse button has been clicked on an item.
@event{EVT_LIST_KEY_DOWN(id, func)}
A key has been pressed.
@event{EVT_LIST_INSERT_ITEM(id, func)}
An item has been inserted.
@event{EVT_LIST_COL_CLICK(id, func)}
A column (m_col) has been left-clicked.
@event{EVT_LIST_COL_RIGHT_CLICK(id, func)}
A column (m_col) (which can be -1 if the click occurred outside any column)
has been right-clicked.
@event{EVT_LIST_COL_BEGIN_DRAG(id, func)}
The user started resizing a column - can be vetoed.
@event{EVT_LIST_COL_DRAGGING(id, func)}
The divider between columns is being dragged.
@event{EVT_LIST_COL_END_DRAG(id, func)}
A column has been resized by the user.
@event{EVT_LIST_CACHE_HINT(id, func)}
Prepare cache for a virtual list control
@endEventTable
@library{wxbase}
@category{events}
@see wxListCtrl
*/
class wxListEvent : public wxNotifyEvent
{
public:
/**
Constructor.
*/