]>
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 | |
6aa89a22 | 7 | // Copyright: (c) Julian Smart |
526954c5 | 8 | // Licence: wxWindows licence |
457814b5 JS |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
107ff668 JS |
11 | // not all ports have support for EVT_CONTEXT_MENU yet, don't define |
12 | // USE_CONTEXT_MENU for those which don't | |
f2012fa6 | 13 | #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) |
107ff668 JS |
14 | #define USE_CONTEXT_MENU 0 |
15 | #else | |
16 | #define USE_CONTEXT_MENU 1 | |
17 | #endif | |
18 | ||
457814b5 JS |
19 | // Define a new application type |
20 | class MyApp: public wxApp | |
fa5f6926 VZ |
21 | { |
22 | public: | |
c71963cd VZ |
23 | MyApp() { } |
24 | ||
fa5f6926 | 25 | virtual bool OnInit(); |
c71963cd VZ |
26 | |
27 | private: | |
c0c133e1 | 28 | wxDECLARE_NO_COPY_CLASS(MyApp); |
457814b5 JS |
29 | }; |
30 | ||
31 | class MyListCtrl: public wxListCtrl | |
32 | { | |
33 | public: | |
6c02c329 VZ |
34 | MyListCtrl(wxWindow *parent, |
35 | const wxWindowID id, | |
36 | const wxPoint& pos, | |
37 | const wxSize& size, | |
38 | long style) | |
0ee169da | 39 | : wxListCtrl(parent, id, pos, size, style) |
5ea47806 | 40 | { |
ebc9b89d VZ |
41 | m_updated = -1; |
42 | ||
107ff668 JS |
43 | #ifdef __POCKETPC__ |
44 | EnableContextMenu(); | |
45 | #endif | |
5ea47806 | 46 | } |
fa5f6926 | 47 | |
5cd89174 VZ |
48 | // add one item to the listctrl in report mode |
49 | void InsertItemInReportView(int i); | |
50 | ||
8636aed8 | 51 | void OnColClick(wxListEvent& event); |
11358d39 VZ |
52 | void OnColRightClick(wxListEvent& event); |
53 | void OnColBeginDrag(wxListEvent& event); | |
54 | void OnColDragging(wxListEvent& event); | |
55 | void OnColEndDrag(wxListEvent& event); | |
5ea47806 VZ |
56 | void OnBeginDrag(wxListEvent& event); |
57 | void OnBeginRDrag(wxListEvent& event); | |
58 | void OnBeginLabelEdit(wxListEvent& event); | |
59 | void OnEndLabelEdit(wxListEvent& event); | |
60 | void OnDeleteItem(wxListEvent& event); | |
12c1b46a | 61 | void OnDeleteAllItems(wxListEvent& event); |
5ea47806 VZ |
62 | void OnSelected(wxListEvent& event); |
63 | void OnDeselected(wxListEvent& event); | |
64 | void OnListKeyDown(wxListEvent& event); | |
65 | void OnActivated(wxListEvent& event); | |
0ddefeb0 | 66 | void OnFocused(wxListEvent& event); |
614391dc | 67 | void OnCacheHint(wxListEvent& event); |
457814b5 | 68 | |
88ac883a | 69 | void OnChar(wxKeyEvent& event); |
cfb66763 | 70 | |
107ff668 JS |
71 | #if USE_CONTEXT_MENU |
72 | void OnContextMenu(wxContextMenuEvent& event); | |
73 | #endif | |
88ac883a | 74 | |
164a7972 VZ |
75 | void OnRightClick(wxMouseEvent& event); |
76 | ||
c41ea66a | 77 | private: |
cfb66763 WS |
78 | void ShowContextMenu(const wxPoint& pos); |
79 | wxLog *m_logOld; | |
6f806543 VZ |
80 | void SetColumnImage(int col, int image); |
81 | ||
c41ea66a | 82 | void LogEvent(const wxListEvent& event, const wxChar *eventName); |
2b5f62a0 | 83 | void LogColEvent(const wxListEvent& event, const wxChar *eventName); |
c41ea66a | 84 | |
98ec9dbe | 85 | virtual wxString OnGetItemText(long item, long column) const; |
06db67bc | 86 | virtual int OnGetItemColumnImage(long item, long column) const; |
6c02c329 VZ |
87 | virtual wxListItemAttr *OnGetItemAttr(long item) const; |
88 | ||
ebc9b89d VZ |
89 | long m_updated; |
90 | ||
91 | ||
c0c133e1 | 92 | wxDECLARE_NO_COPY_CLASS(MyListCtrl); |
5ea47806 | 93 | DECLARE_EVENT_TABLE() |
457814b5 JS |
94 | }; |
95 | ||
96 | // Define a new frame type | |
97 | class MyFrame: public wxFrame | |
5ea47806 VZ |
98 | { |
99 | public: | |
107ff668 | 100 | MyFrame(const wxChar *title); |
07bf769e VZ |
101 | virtual ~MyFrame(); |
102 | ||
103 | void DoSize(); | |
5ea47806 | 104 | |
2b5f62a0 | 105 | protected: |
98ec9dbe VZ |
106 | void OnSize(wxSizeEvent& event); |
107 | ||
457814b5 JS |
108 | void OnQuit(wxCommandEvent& event); |
109 | void OnAbout(wxCommandEvent& event); | |
110 | void OnListView(wxCommandEvent& event); | |
111 | void OnReportView(wxCommandEvent& event); | |
112 | void OnIconView(wxCommandEvent& event); | |
113 | void OnIconTextView(wxCommandEvent& event); | |
114 | void OnSmallIconView(wxCommandEvent& event); | |
115 | void OnSmallIconTextView(wxCommandEvent& event); | |
98ec9dbe | 116 | void OnVirtualView(wxCommandEvent& event); |
b0401bea | 117 | void OnSmallVirtualView(wxCommandEvent& event); |
98ec9dbe | 118 | |
beb9e8f2 VZ |
119 | void OnSetItemsCount(wxCommandEvent& event); |
120 | ||
121 | ||
6ef2b230 | 122 | void OnGoTo(wxCommandEvent& event); |
88b792af | 123 | void OnFocusLast(wxCommandEvent& event); |
58b3bdc9 | 124 | void OnToggleFirstSel(wxCommandEvent& event); |
c4771147 KB |
125 | void OnDeselectAll(wxCommandEvent& event); |
126 | void OnSelectAll(wxCommandEvent& event); | |
cf1dfa6b | 127 | void OnAdd(wxCommandEvent& event); |
efe23391 | 128 | void OnEdit(wxCommandEvent& event); |
bec0a261 | 129 | void OnDelete(wxCommandEvent& event); |
5ea47806 | 130 | void OnDeleteAll(wxCommandEvent& event); |
fa5f6926 | 131 | void OnSort(wxCommandEvent& event); |
11f26ea0 VZ |
132 | void OnSetFgColour(wxCommandEvent& event); |
133 | void OnSetBgColour(wxCommandEvent& event); | |
0ee169da | 134 | void OnSetRowLines(wxCommandEvent& event); |
7b848b0d | 135 | void OnToggleMultiSel(wxCommandEvent& event); |
f6bcfd97 | 136 | void OnShowColInfo(wxCommandEvent& event); |
b54e41c5 | 137 | void OnShowSelInfo(wxCommandEvent& event); |
929b7901 | 138 | void OnShowViewRect(wxCommandEvent& event); |
80cc5fc7 VZ |
139 | #ifdef wxHAS_LISTCTRL_COLUMN_ORDER |
140 | void OnSetColOrder(wxCommandEvent& event); | |
141 | void OnGetColOrder(wxCommandEvent& event); | |
142 | #endif // wxHAS_LISTCTRL_COLUMN_ORDER | |
c5c528fc VZ |
143 | void OnFreeze(wxCommandEvent& event); |
144 | void OnThaw(wxCommandEvent& event); | |
494ab5de | 145 | void OnToggleLines(wxCommandEvent& event); |
1bab3627 | 146 | void OnToggleHeader(wxCommandEvent& event); |
d34d31f6 | 147 | void OnToggleBell(wxCommandEvent& event); |
8a3f03ff | 148 | #ifdef __WXOSX__ |
2458daa7 | 149 | void OnToggleMacUseGeneric(wxCommandEvent& event); |
8a3f03ff | 150 | #endif // __WXOSX__ |
beb9e8f2 | 151 | void OnFind(wxCommandEvent& event); |
5ea47806 | 152 | |
1bab3627 | 153 | void OnUpdateUIEnableInReport(wxUpdateUIEvent& event); |
ae403b11 | 154 | void OnUpdateToggleMultiSel(wxUpdateUIEvent& event); |
1bab3627 | 155 | void OnUpdateToggleHeader(wxUpdateUIEvent& event); |
0ee169da | 156 | void OnUpdateRowLines(wxUpdateUIEvent& event); |
5ea47806 | 157 | |
c41ea66a VZ |
158 | wxImageList *m_imageListNormal; |
159 | wxImageList *m_imageListSmall; | |
160 | ||
2b5f62a0 VZ |
161 | wxPanel *m_panel; |
162 | MyListCtrl *m_listCtrl; | |
163 | wxTextCtrl *m_logWindow; | |
164 | ||
c41ea66a | 165 | private: |
776a33cf | 166 | // recreate the list control with the new flags |
1550e402 | 167 | void RecreateList(long flags, bool withText = true); |
776a33cf VZ |
168 | |
169 | // fill the control with items depending on the view | |
170 | void InitWithListItems(); | |
171 | void InitWithReportItems(); | |
1550e402 | 172 | void InitWithIconItems(bool withText, bool sameIcon = false); |
776a33cf VZ |
173 | void InitWithVirtualItems(); |
174 | ||
68457180 VZ |
175 | // return true if the control is not in virtual view, give an error message |
176 | // and return false if it is | |
177 | bool CheckNonVirtual() const; | |
178 | ||
179 | ||
c41ea66a VZ |
180 | wxLog *m_logOld; |
181 | ||
b0401bea VZ |
182 | bool m_smallVirtual; |
183 | ||
beb9e8f2 VZ |
184 | // number of items to initialize list/report view with |
185 | int m_numListItems; | |
186 | ||
187 | ||
c0c133e1 | 188 | wxDECLARE_NO_COPY_CLASS(MyFrame); |
5ea47806 | 189 | DECLARE_EVENT_TABLE() |
457814b5 JS |
190 | }; |
191 | ||
192 | ||
98ec9dbe | 193 | // IDs for the menu commands |
fa5f6926 VZ |
194 | enum |
195 | { | |
658070d1 JS |
196 | LIST_ABOUT = wxID_ABOUT, |
197 | LIST_QUIT = wxID_EXIT, | |
cf1dfa6b | 198 | |
658070d1 | 199 | LIST_LIST_VIEW = wxID_HIGHEST, |
98ec9dbe VZ |
200 | LIST_ICON_VIEW, |
201 | LIST_ICON_TEXT_VIEW, | |
202 | LIST_SMALL_ICON_VIEW, | |
203 | LIST_SMALL_ICON_TEXT_VIEW, | |
cf1dfa6b | 204 | LIST_REPORT_VIEW, |
98ec9dbe | 205 | LIST_VIRTUAL_VIEW, |
b0401bea | 206 | LIST_SMALL_VIRTUAL_VIEW, |
beb9e8f2 | 207 | LIST_SET_ITEMS_COUNT, |
98ec9dbe | 208 | |
98ec9dbe VZ |
209 | LIST_DESELECT_ALL, |
210 | LIST_SELECT_ALL, | |
98ec9dbe | 211 | LIST_DELETE_ALL, |
bec0a261 | 212 | LIST_DELETE, |
cf1dfa6b | 213 | LIST_ADD, |
efe23391 | 214 | LIST_EDIT, |
fa5f6926 | 215 | LIST_SORT, |
beb9e8f2 | 216 | LIST_FIND, |
11f26ea0 VZ |
217 | LIST_SET_FG_COL, |
218 | LIST_SET_BG_COL, | |
0ee169da | 219 | LIST_ROW_LINES, |
7b848b0d | 220 | LIST_TOGGLE_MULTI_SEL, |
1bab3627 | 221 | LIST_TOGGLE_HEADER, |
d34d31f6 | 222 | LIST_TOGGLE_BELL, |
58b3bdc9 | 223 | LIST_TOGGLE_FIRST, |
f6bcfd97 | 224 | LIST_SHOW_COL_INFO, |
b54e41c5 | 225 | LIST_SHOW_SEL_INFO, |
929b7901 | 226 | LIST_SHOW_VIEW_RECT, |
80cc5fc7 VZ |
227 | #ifdef wxHAS_LISTCTRL_COLUMN_ORDER |
228 | LIST_SET_COL_ORDER, | |
229 | LIST_GET_COL_ORDER, | |
230 | #endif // wxHAS_LISTCTRL_COLUMN_ORDER | |
6ef2b230 | 231 | LIST_GOTO, |
88b792af | 232 | LIST_FOCUS_LAST, |
c5c528fc VZ |
233 | LIST_FREEZE, |
234 | LIST_THAW, | |
494ab5de | 235 | LIST_TOGGLE_LINES, |
8a3f03ff | 236 | #ifdef __WXOSX__ |
2458daa7 | 237 | LIST_MAC_USE_GENERIC, |
8a3f03ff | 238 | #endif |
457814b5 | 239 | |
fa5f6926 VZ |
240 | LIST_CTRL = 1000 |
241 | }; |