]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listctrl.h | |
3 | // Purpose: wxListCtrl sample | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
5ea47806 | 9 | // Licence: wxWindows license |
457814b5 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // Define a new application type | |
13 | class MyApp: public wxApp | |
fa5f6926 VZ |
14 | { |
15 | public: | |
c71963cd VZ |
16 | MyApp() { } |
17 | ||
fa5f6926 | 18 | virtual bool OnInit(); |
c71963cd VZ |
19 | |
20 | private: | |
21 | DECLARE_NO_COPY_CLASS(MyApp) | |
457814b5 JS |
22 | }; |
23 | ||
24 | class MyListCtrl: public wxListCtrl | |
25 | { | |
26 | public: | |
6c02c329 VZ |
27 | MyListCtrl(wxWindow *parent, |
28 | const wxWindowID id, | |
29 | const wxPoint& pos, | |
30 | const wxSize& size, | |
31 | long style) | |
32 | : wxListCtrl(parent, id, pos, size, style), | |
a92b0cfd | 33 | m_attr(*wxBLUE, *wxLIGHT_GREY, wxNullFont) |
5ea47806 VZ |
34 | { |
35 | } | |
fa5f6926 | 36 | |
5cd89174 VZ |
37 | // add one item to the listctrl in report mode |
38 | void InsertItemInReportView(int i); | |
39 | ||
8636aed8 | 40 | void OnColClick(wxListEvent& event); |
11358d39 VZ |
41 | void OnColRightClick(wxListEvent& event); |
42 | void OnColBeginDrag(wxListEvent& event); | |
43 | void OnColDragging(wxListEvent& event); | |
44 | void OnColEndDrag(wxListEvent& event); | |
5ea47806 VZ |
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); | |
12c1b46a | 50 | void OnDeleteAllItems(wxListEvent& event); |
5ea47806 VZ |
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); | |
0ddefeb0 | 57 | void OnFocused(wxListEvent& event); |
614391dc | 58 | void OnCacheHint(wxListEvent& event); |
457814b5 | 59 | |
88ac883a VZ |
60 | void OnChar(wxKeyEvent& event); |
61 | ||
c41ea66a | 62 | private: |
6f806543 VZ |
63 | void SetColumnImage(int col, int image); |
64 | ||
c41ea66a | 65 | void LogEvent(const wxListEvent& event, const wxChar *eventName); |
2b5f62a0 | 66 | void LogColEvent(const wxListEvent& event, const wxChar *eventName); |
c41ea66a | 67 | |
98ec9dbe VZ |
68 | virtual wxString OnGetItemText(long item, long column) const; |
69 | virtual int OnGetItemImage(long item) const; | |
6c02c329 VZ |
70 | virtual wxListItemAttr *OnGetItemAttr(long item) const; |
71 | ||
72 | wxListItemAttr m_attr; | |
98ec9dbe | 73 | |
c71963cd | 74 | DECLARE_NO_COPY_CLASS(MyListCtrl) |
5ea47806 | 75 | DECLARE_EVENT_TABLE() |
457814b5 JS |
76 | }; |
77 | ||
78 | // Define a new frame type | |
79 | class MyFrame: public wxFrame | |
5ea47806 VZ |
80 | { |
81 | public: | |
c41ea66a | 82 | MyFrame(const wxChar *title, int x, int y, int w, int h); |
5ea47806 VZ |
83 | ~MyFrame(); |
84 | ||
2b5f62a0 | 85 | protected: |
98ec9dbe VZ |
86 | void OnSize(wxSizeEvent& event); |
87 | ||
457814b5 JS |
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); | |
98ec9dbe VZ |
96 | void OnVirtualView(wxCommandEvent& event); |
97 | ||
88b792af | 98 | void OnFocusLast(wxCommandEvent& event); |
58b3bdc9 | 99 | void OnToggleFirstSel(wxCommandEvent& event); |
c4771147 KB |
100 | void OnDeselectAll(wxCommandEvent& event); |
101 | void OnSelectAll(wxCommandEvent& event); | |
cf1dfa6b | 102 | void OnAdd(wxCommandEvent& event); |
efe23391 | 103 | void OnEdit(wxCommandEvent& event); |
bec0a261 | 104 | void OnDelete(wxCommandEvent& event); |
5ea47806 | 105 | void OnDeleteAll(wxCommandEvent& event); |
fa5f6926 | 106 | void OnSort(wxCommandEvent& event); |
11f26ea0 VZ |
107 | void OnSetFgColour(wxCommandEvent& event); |
108 | void OnSetBgColour(wxCommandEvent& event); | |
7b848b0d | 109 | void OnToggleMultiSel(wxCommandEvent& event); |
f6bcfd97 | 110 | void OnShowColInfo(wxCommandEvent& event); |
b54e41c5 | 111 | void OnShowSelInfo(wxCommandEvent& event); |
c5c528fc VZ |
112 | void OnFreeze(wxCommandEvent& event); |
113 | void OnThaw(wxCommandEvent& event); | |
5ea47806 | 114 | |
98ec9dbe | 115 | void OnUpdateShowColInfo(wxUpdateUIEvent& event); |
5ea47806 | 116 | |
c41ea66a VZ |
117 | wxImageList *m_imageListNormal; |
118 | wxImageList *m_imageListSmall; | |
119 | ||
2b5f62a0 VZ |
120 | wxPanel *m_panel; |
121 | MyListCtrl *m_listCtrl; | |
122 | wxTextCtrl *m_logWindow; | |
123 | ||
c41ea66a | 124 | private: |
776a33cf VZ |
125 | // recreate the list control with the new flags |
126 | void RecreateList(long flags, bool withText = TRUE); | |
127 | ||
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(); | |
133 | ||
c41ea66a VZ |
134 | wxLog *m_logOld; |
135 | ||
c71963cd | 136 | DECLARE_NO_COPY_CLASS(MyFrame) |
5ea47806 | 137 | DECLARE_EVENT_TABLE() |
457814b5 JS |
138 | }; |
139 | ||
140 | ||
98ec9dbe | 141 | // IDs for the menu commands |
fa5f6926 VZ |
142 | enum |
143 | { | |
cf1dfa6b | 144 | LIST_ABOUT, |
98ec9dbe | 145 | LIST_QUIT, |
cf1dfa6b | 146 | |
98ec9dbe VZ |
147 | LIST_LIST_VIEW, |
148 | LIST_ICON_VIEW, | |
149 | LIST_ICON_TEXT_VIEW, | |
150 | LIST_SMALL_ICON_VIEW, | |
151 | LIST_SMALL_ICON_TEXT_VIEW, | |
cf1dfa6b | 152 | LIST_REPORT_VIEW, |
98ec9dbe VZ |
153 | LIST_VIRTUAL_VIEW, |
154 | ||
98ec9dbe VZ |
155 | LIST_DESELECT_ALL, |
156 | LIST_SELECT_ALL, | |
98ec9dbe | 157 | LIST_DELETE_ALL, |
bec0a261 | 158 | LIST_DELETE, |
cf1dfa6b | 159 | LIST_ADD, |
efe23391 | 160 | LIST_EDIT, |
fa5f6926 | 161 | LIST_SORT, |
11f26ea0 VZ |
162 | LIST_SET_FG_COL, |
163 | LIST_SET_BG_COL, | |
7b848b0d | 164 | LIST_TOGGLE_MULTI_SEL, |
58b3bdc9 | 165 | LIST_TOGGLE_FIRST, |
f6bcfd97 | 166 | LIST_SHOW_COL_INFO, |
b54e41c5 | 167 | LIST_SHOW_SEL_INFO, |
88b792af | 168 | LIST_FOCUS_LAST, |
c5c528fc VZ |
169 | LIST_FREEZE, |
170 | LIST_THAW, | |
457814b5 | 171 | |
fa5f6926 VZ |
172 | LIST_CTRL = 1000 |
173 | }; | |
457814b5 | 174 |