1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListCtrl sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // Define a new application type
13 class MyApp
: public wxApp
18 virtual bool OnInit();
21 DECLARE_NO_COPY_CLASS(MyApp
)
24 class MyListCtrl
: public wxListCtrl
27 MyListCtrl(wxWindow
*parent
,
32 : wxListCtrl(parent
, id
, pos
, size
, style
),
33 m_attr(*wxBLUE
, *wxLIGHT_GREY
, wxNullFont
)
37 // add one item to the listctrl in report mode
38 void InsertItemInReportView(int i
);
40 void OnColClick(wxListEvent
& event
);
41 void OnColRightClick(wxListEvent
& event
);
42 void OnColBeginDrag(wxListEvent
& event
);
43 void OnColDragging(wxListEvent
& event
);
44 void OnColEndDrag(wxListEvent
& event
);
45 void OnBeginDrag(wxListEvent
& event
);
46 void OnBeginRDrag(wxListEvent
& event
);
47 void OnBeginLabelEdit(wxListEvent
& event
);
48 void OnEndLabelEdit(wxListEvent
& event
);
49 void OnDeleteItem(wxListEvent
& event
);
50 void OnDeleteAllItems(wxListEvent
& event
);
51 void OnGetInfo(wxListEvent
& event
);
52 void OnSetInfo(wxListEvent
& event
);
53 void OnSelected(wxListEvent
& event
);
54 void OnDeselected(wxListEvent
& event
);
55 void OnListKeyDown(wxListEvent
& event
);
56 void OnActivated(wxListEvent
& event
);
57 void OnFocused(wxListEvent
& event
);
58 void OnCacheHint(wxListEvent
& event
);
60 void OnChar(wxKeyEvent
& event
);
63 void SetColumnImage(int col
, int image
);
65 void LogEvent(const wxListEvent
& event
, const wxChar
*eventName
);
66 void LogColEvent(const wxListEvent
& event
, const wxChar
*eventName
);
68 virtual wxString
OnGetItemText(long item
, long column
) const;
69 virtual int OnGetItemImage(long item
) const;
70 virtual wxListItemAttr
*OnGetItemAttr(long item
) const;
72 wxListItemAttr m_attr
;
74 DECLARE_NO_COPY_CLASS(MyListCtrl
)
78 // Define a new frame type
79 class MyFrame
: public wxFrame
82 MyFrame(const wxChar
*title
, int x
, int y
, int w
, int h
);
86 void OnSize(wxSizeEvent
& event
);
88 void OnQuit(wxCommandEvent
& event
);
89 void OnAbout(wxCommandEvent
& event
);
90 void OnListView(wxCommandEvent
& event
);
91 void OnReportView(wxCommandEvent
& event
);
92 void OnIconView(wxCommandEvent
& event
);
93 void OnIconTextView(wxCommandEvent
& event
);
94 void OnSmallIconView(wxCommandEvent
& event
);
95 void OnSmallIconTextView(wxCommandEvent
& event
);
96 void OnVirtualView(wxCommandEvent
& event
);
98 void OnFocusLast(wxCommandEvent
& event
);
99 void OnToggleFirstSel(wxCommandEvent
& event
);
100 void OnDeselectAll(wxCommandEvent
& event
);
101 void OnSelectAll(wxCommandEvent
& event
);
102 void OnAdd(wxCommandEvent
& event
);
103 void OnEdit(wxCommandEvent
& event
);
104 void OnDelete(wxCommandEvent
& event
);
105 void OnDeleteAll(wxCommandEvent
& event
);
106 void OnSort(wxCommandEvent
& event
);
107 void OnSetFgColour(wxCommandEvent
& event
);
108 void OnSetBgColour(wxCommandEvent
& event
);
109 void OnToggleMultiSel(wxCommandEvent
& event
);
110 void OnShowColInfo(wxCommandEvent
& event
);
111 void OnShowSelInfo(wxCommandEvent
& event
);
112 void OnFreeze(wxCommandEvent
& event
);
113 void OnThaw(wxCommandEvent
& event
);
115 void OnUpdateShowColInfo(wxUpdateUIEvent
& event
);
117 wxImageList
*m_imageListNormal
;
118 wxImageList
*m_imageListSmall
;
121 MyListCtrl
*m_listCtrl
;
122 wxTextCtrl
*m_logWindow
;
125 // recreate the list control with the new flags
126 void RecreateList(long flags
, bool withText
= TRUE
);
128 // fill the control with items depending on the view
129 void InitWithListItems();
130 void InitWithReportItems();
131 void InitWithIconItems(bool withText
, bool sameIcon
= FALSE
);
132 void InitWithVirtualItems();
136 DECLARE_NO_COPY_CLASS(MyFrame
)
137 DECLARE_EVENT_TABLE()
141 // IDs for the menu commands
150 LIST_SMALL_ICON_VIEW
,
151 LIST_SMALL_ICON_TEXT_VIEW
,
164 LIST_TOGGLE_MULTI_SEL
,