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
,
27 : wxListCtrl(parent
, id
, pos
, size
, style
),
28 m_attr(*wxCYAN
, *wxLIGHT_GREY
, wxNullFont
)
32 // add one item to the listctrl in report mode
33 void InsertItemInReportView(int i
);
35 void OnColClick(wxListEvent
& event
);
36 void OnBeginDrag(wxListEvent
& event
);
37 void OnBeginRDrag(wxListEvent
& event
);
38 void OnBeginLabelEdit(wxListEvent
& event
);
39 void OnEndLabelEdit(wxListEvent
& event
);
40 void OnDeleteItem(wxListEvent
& event
);
41 void OnDeleteAllItems(wxListEvent
& event
);
42 void OnGetInfo(wxListEvent
& event
);
43 void OnSetInfo(wxListEvent
& event
);
44 void OnSelected(wxListEvent
& event
);
45 void OnDeselected(wxListEvent
& event
);
46 void OnListKeyDown(wxListEvent
& event
);
47 void OnActivated(wxListEvent
& event
);
48 void OnCacheHint(wxListEvent
& event
);
50 void OnChar(wxKeyEvent
& event
);
53 void LogEvent(const wxListEvent
& event
, const wxChar
*eventName
);
55 virtual wxString
OnGetItemText(long item
, long column
) const;
56 virtual int OnGetItemImage(long item
) const;
57 virtual wxListItemAttr
*OnGetItemAttr(long item
) const;
59 wxListItemAttr m_attr
;
64 // Define a new frame type
65 class MyFrame
: public wxFrame
68 MyListCtrl
*m_listCtrl
;
69 wxTextCtrl
*m_logWindow
;
71 MyFrame(const wxChar
*title
, int x
, int y
, int w
, int h
);
75 void OnSize(wxSizeEvent
& event
);
77 void OnQuit(wxCommandEvent
& event
);
78 void OnAbout(wxCommandEvent
& event
);
79 void OnListView(wxCommandEvent
& event
);
80 void OnReportView(wxCommandEvent
& event
);
81 void OnIconView(wxCommandEvent
& event
);
82 void OnIconTextView(wxCommandEvent
& event
);
83 void OnSmallIconView(wxCommandEvent
& event
);
84 void OnSmallIconTextView(wxCommandEvent
& event
);
85 void OnVirtualView(wxCommandEvent
& event
);
87 void OnToggleFirstSel(wxCommandEvent
& event
);
88 void OnDeselectAll(wxCommandEvent
& event
);
89 void OnSelectAll(wxCommandEvent
& event
);
90 void OnAdd(wxCommandEvent
& event
);
91 void OnDelete(wxCommandEvent
& event
);
92 void OnDeleteAll(wxCommandEvent
& event
);
93 void OnSort(wxCommandEvent
& event
);
94 void OnSetFgColour(wxCommandEvent
& event
);
95 void OnSetBgColour(wxCommandEvent
& event
);
96 void OnToggleMultiSel(wxCommandEvent
& event
);
97 void OnShowColInfo(wxCommandEvent
& event
);
98 void OnShowSelInfo(wxCommandEvent
& event
);
100 void OnUpdateShowColInfo(wxUpdateUIEvent
& event
);
102 wxImageList
*m_imageListNormal
;
103 wxImageList
*m_imageListSmall
;
106 // recreate the list control with the new flags
107 void RecreateList(long flags
, bool withText
= TRUE
);
109 // fill the control with items depending on the view
110 void InitWithListItems();
111 void InitWithReportItems();
112 void InitWithIconItems(bool withText
, bool sameIcon
= FALSE
);
113 void InitWithVirtualItems();
117 DECLARE_EVENT_TABLE()
121 // IDs for the menu commands
130 LIST_SMALL_ICON_VIEW
,
131 LIST_SMALL_ICON_TEXT_VIEW
,
143 LIST_TOGGLE_MULTI_SEL
,