1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListCtrl sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // Define a new application type
13 class MyApp
: public wxApp
16 virtual bool OnInit();
19 class MyListCtrl
: public wxListCtrl
22 MyListCtrl(wxWindow
*parent
, const wxWindowID id
, const wxPoint
& pos
,
23 const wxSize
& size
, long style
):
24 wxListCtrl(parent
, id
, pos
, size
, style
)
28 void OnColClick(wxListEvent
& event
);
29 void OnBeginDrag(wxListEvent
& event
);
30 void OnBeginRDrag(wxListEvent
& event
);
31 void OnBeginLabelEdit(wxListEvent
& event
);
32 void OnEndLabelEdit(wxListEvent
& event
);
33 void OnDeleteItem(wxListEvent
& event
);
34 void OnDeleteAllItems(wxListEvent
& event
);
35 void OnGetInfo(wxListEvent
& event
);
36 void OnSetInfo(wxListEvent
& event
);
37 void OnSelected(wxListEvent
& event
);
38 void OnDeselected(wxListEvent
& event
);
39 void OnListKeyDown(wxListEvent
& event
);
40 void OnActivated(wxListEvent
& event
);
42 void OnChar(wxKeyEvent
& event
);
45 void LogEvent(const wxListEvent
& event
, const wxChar
*eventName
);
47 virtual wxString
OnGetItemText(long item
, long column
) const;
48 virtual int OnGetItemImage(long item
) const;
53 // Define a new frame type
54 class MyFrame
: public wxFrame
57 MyListCtrl
*m_listCtrl
;
58 wxTextCtrl
*m_logWindow
;
60 MyFrame(const wxChar
*title
, int x
, int y
, int w
, int h
);
64 void OnSize(wxSizeEvent
& event
);
66 void OnQuit(wxCommandEvent
& event
);
67 void OnAbout(wxCommandEvent
& event
);
68 void OnListView(wxCommandEvent
& event
);
69 void OnReportView(wxCommandEvent
& event
);
70 void OnIconView(wxCommandEvent
& event
);
71 void OnIconTextView(wxCommandEvent
& event
);
72 void OnSmallIconView(wxCommandEvent
& event
);
73 void OnSmallIconTextView(wxCommandEvent
& event
);
74 void OnVirtualView(wxCommandEvent
& event
);
76 void OnToggleFirstSel(wxCommandEvent
& event
);
77 void OnDeselectAll(wxCommandEvent
& event
);
78 void OnSelectAll(wxCommandEvent
& event
);
79 void OnAdd(wxCommandEvent
& event
);
80 void OnDelete(wxCommandEvent
& event
);
81 void OnDeleteAll(wxCommandEvent
& event
);
82 void OnSort(wxCommandEvent
& event
);
83 void OnSetFgColour(wxCommandEvent
& event
);
84 void OnSetBgColour(wxCommandEvent
& event
);
85 void OnToggleMultiSel(wxCommandEvent
& event
);
86 void OnShowColInfo(wxCommandEvent
& event
);
87 void OnShowSelInfo(wxCommandEvent
& event
);
89 void OnUpdateShowColInfo(wxUpdateUIEvent
& event
);
91 wxImageList
*m_imageListNormal
;
92 wxImageList
*m_imageListSmall
;
95 // recreate the list control with the new flags
96 void RecreateList(long flags
, bool withText
= TRUE
);
98 // fill the control with items depending on the view
99 void InitWithListItems();
100 void InitWithReportItems();
101 void InitWithIconItems(bool withText
, bool sameIcon
= FALSE
);
102 void InitWithVirtualItems();
106 DECLARE_EVENT_TABLE()
110 // IDs for the menu commands
119 LIST_SMALL_ICON_VIEW
,
120 LIST_SMALL_ICON_TEXT_VIEW
,
132 LIST_TOGGLE_MULTI_SEL
,