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(*wxBLUE
, *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 OnColRightClick(wxListEvent
& event
);
37 void OnColBeginDrag(wxListEvent
& event
);
38 void OnColDragging(wxListEvent
& event
);
39 void OnColEndDrag(wxListEvent
& event
);
40 void OnBeginDrag(wxListEvent
& event
);
41 void OnBeginRDrag(wxListEvent
& event
);
42 void OnBeginLabelEdit(wxListEvent
& event
);
43 void OnEndLabelEdit(wxListEvent
& event
);
44 void OnDeleteItem(wxListEvent
& event
);
45 void OnDeleteAllItems(wxListEvent
& event
);
46 void OnGetInfo(wxListEvent
& event
);
47 void OnSetInfo(wxListEvent
& event
);
48 void OnSelected(wxListEvent
& event
);
49 void OnDeselected(wxListEvent
& event
);
50 void OnListKeyDown(wxListEvent
& event
);
51 void OnActivated(wxListEvent
& event
);
52 void OnFocused(wxListEvent
& event
);
53 void OnCacheHint(wxListEvent
& event
);
55 void OnChar(wxKeyEvent
& event
);
58 void SetColumnImage(int col
, int image
);
60 void LogEvent(const wxListEvent
& event
, const wxChar
*eventName
);
61 void LogColEvent(const wxListEvent
& event
, const wxChar
*eventName
);
63 virtual wxString
OnGetItemText(long item
, long column
) const;
64 virtual int OnGetItemImage(long item
) const;
65 virtual wxListItemAttr
*OnGetItemAttr(long item
) const;
67 wxListItemAttr m_attr
;
72 // Define a new frame type
73 class MyFrame
: public wxFrame
76 MyFrame(const wxChar
*title
, int x
, int y
, int w
, int h
);
80 void OnSize(wxSizeEvent
& event
);
82 void OnQuit(wxCommandEvent
& event
);
83 void OnAbout(wxCommandEvent
& event
);
84 void OnListView(wxCommandEvent
& event
);
85 void OnReportView(wxCommandEvent
& event
);
86 void OnIconView(wxCommandEvent
& event
);
87 void OnIconTextView(wxCommandEvent
& event
);
88 void OnSmallIconView(wxCommandEvent
& event
);
89 void OnSmallIconTextView(wxCommandEvent
& event
);
90 void OnVirtualView(wxCommandEvent
& event
);
92 void OnFocusLast(wxCommandEvent
& event
);
93 void OnToggleFirstSel(wxCommandEvent
& event
);
94 void OnDeselectAll(wxCommandEvent
& event
);
95 void OnSelectAll(wxCommandEvent
& event
);
96 void OnAdd(wxCommandEvent
& event
);
97 void OnEdit(wxCommandEvent
& event
);
98 void OnDelete(wxCommandEvent
& event
);
99 void OnDeleteAll(wxCommandEvent
& event
);
100 void OnSort(wxCommandEvent
& event
);
101 void OnSetFgColour(wxCommandEvent
& event
);
102 void OnSetBgColour(wxCommandEvent
& event
);
103 void OnToggleMultiSel(wxCommandEvent
& event
);
104 void OnShowColInfo(wxCommandEvent
& event
);
105 void OnShowSelInfo(wxCommandEvent
& event
);
106 void OnFreeze(wxCommandEvent
& event
);
107 void OnThaw(wxCommandEvent
& event
);
109 void OnUpdateShowColInfo(wxUpdateUIEvent
& event
);
111 wxImageList
*m_imageListNormal
;
112 wxImageList
*m_imageListSmall
;
115 MyListCtrl
*m_listCtrl
;
116 wxTextCtrl
*m_logWindow
;
119 // recreate the list control with the new flags
120 void RecreateList(long flags
, bool withText
= TRUE
);
122 // fill the control with items depending on the view
123 void InitWithListItems();
124 void InitWithReportItems();
125 void InitWithIconItems(bool withText
, bool sameIcon
= FALSE
);
126 void InitWithVirtualItems();
130 DECLARE_EVENT_TABLE()
134 // IDs for the menu commands
143 LIST_SMALL_ICON_VIEW
,
144 LIST_SMALL_ICON_TEXT_VIEW
,
157 LIST_TOGGLE_MULTI_SEL
,