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 // add one item to the listctrl in report mode
29 void InsertItemInReportView(int i
);
31 void OnColClick(wxListEvent
& event
);
32 void OnBeginDrag(wxListEvent
& event
);
33 void OnBeginRDrag(wxListEvent
& event
);
34 void OnBeginLabelEdit(wxListEvent
& event
);
35 void OnEndLabelEdit(wxListEvent
& event
);
36 void OnDeleteItem(wxListEvent
& event
);
37 void OnDeleteAllItems(wxListEvent
& event
);
38 void OnGetInfo(wxListEvent
& event
);
39 void OnSetInfo(wxListEvent
& event
);
40 void OnSelected(wxListEvent
& event
);
41 void OnDeselected(wxListEvent
& event
);
42 void OnListKeyDown(wxListEvent
& event
);
43 void OnActivated(wxListEvent
& event
);
45 void OnChar(wxKeyEvent
& event
);
48 void LogEvent(const wxListEvent
& event
, const wxChar
*eventName
);
50 virtual wxString
OnGetItemText(long item
, long column
) const;
51 virtual int OnGetItemImage(long item
) const;
56 // Define a new frame type
57 class MyFrame
: public wxFrame
60 MyListCtrl
*m_listCtrl
;
61 wxTextCtrl
*m_logWindow
;
63 MyFrame(const wxChar
*title
, int x
, int y
, int w
, int h
);
67 void OnSize(wxSizeEvent
& event
);
69 void OnQuit(wxCommandEvent
& event
);
70 void OnAbout(wxCommandEvent
& event
);
71 void OnListView(wxCommandEvent
& event
);
72 void OnReportView(wxCommandEvent
& event
);
73 void OnIconView(wxCommandEvent
& event
);
74 void OnIconTextView(wxCommandEvent
& event
);
75 void OnSmallIconView(wxCommandEvent
& event
);
76 void OnSmallIconTextView(wxCommandEvent
& event
);
77 void OnVirtualView(wxCommandEvent
& event
);
79 void OnToggleFirstSel(wxCommandEvent
& event
);
80 void OnDeselectAll(wxCommandEvent
& event
);
81 void OnSelectAll(wxCommandEvent
& event
);
82 void OnAdd(wxCommandEvent
& event
);
83 void OnDelete(wxCommandEvent
& event
);
84 void OnDeleteAll(wxCommandEvent
& event
);
85 void OnSort(wxCommandEvent
& event
);
86 void OnSetFgColour(wxCommandEvent
& event
);
87 void OnSetBgColour(wxCommandEvent
& event
);
88 void OnToggleMultiSel(wxCommandEvent
& event
);
89 void OnShowColInfo(wxCommandEvent
& event
);
90 void OnShowSelInfo(wxCommandEvent
& event
);
92 void OnUpdateShowColInfo(wxUpdateUIEvent
& event
);
94 wxImageList
*m_imageListNormal
;
95 wxImageList
*m_imageListSmall
;
98 // recreate the list control with the new flags
99 void RecreateList(long flags
, bool withText
= TRUE
);
101 // fill the control with items depending on the view
102 void InitWithListItems();
103 void InitWithReportItems();
104 void InitWithIconItems(bool withText
, bool sameIcon
= FALSE
);
105 void InitWithVirtualItems();
109 DECLARE_EVENT_TABLE()
113 // IDs for the menu commands
122 LIST_SMALL_ICON_VIEW
,
123 LIST_SMALL_ICON_TEXT_VIEW
,
135 LIST_TOGGLE_MULTI_SEL
,