]>
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 | ||
107ff668 JS |
12 | // not all ports have support for EVT_CONTEXT_MENU yet, don't define |
13 | // USE_CONTEXT_MENU for those which don't | |
14 | #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__) | |
15 | #define USE_CONTEXT_MENU 0 | |
16 | #else | |
17 | #define USE_CONTEXT_MENU 1 | |
18 | #endif | |
19 | ||
457814b5 JS |
20 | // Define a new application type |
21 | class MyApp: public wxApp | |
fa5f6926 VZ |
22 | { |
23 | public: | |
c71963cd VZ |
24 | MyApp() { } |
25 | ||
fa5f6926 | 26 | virtual bool OnInit(); |
c71963cd VZ |
27 | |
28 | private: | |
29 | DECLARE_NO_COPY_CLASS(MyApp) | |
457814b5 JS |
30 | }; |
31 | ||
32 | class MyListCtrl: public wxListCtrl | |
33 | { | |
34 | public: | |
6c02c329 VZ |
35 | MyListCtrl(wxWindow *parent, |
36 | const wxWindowID id, | |
37 | const wxPoint& pos, | |
38 | const wxSize& size, | |
39 | long style) | |
40 | : wxListCtrl(parent, id, pos, size, style), | |
a92b0cfd | 41 | m_attr(*wxBLUE, *wxLIGHT_GREY, wxNullFont) |
5ea47806 | 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); |
3614a8dc | 62 | #if WXWIN_COMPATIBILITY_2_4 |
5ea47806 VZ |
63 | void OnGetInfo(wxListEvent& event); |
64 | void OnSetInfo(wxListEvent& event); | |
3614a8dc | 65 | #endif |
5ea47806 VZ |
66 | void OnSelected(wxListEvent& event); |
67 | void OnDeselected(wxListEvent& event); | |
68 | void OnListKeyDown(wxListEvent& event); | |
69 | void OnActivated(wxListEvent& event); | |
0ddefeb0 | 70 | void OnFocused(wxListEvent& event); |
614391dc | 71 | void OnCacheHint(wxListEvent& event); |
457814b5 | 72 | |
88ac883a | 73 | void OnChar(wxKeyEvent& event); |
107ff668 JS |
74 | #if USE_CONTEXT_MENU |
75 | void OnContextMenu(wxContextMenuEvent& event); | |
76 | #endif | |
88ac883a | 77 | |
c41ea66a | 78 | private: |
6f806543 VZ |
79 | void SetColumnImage(int col, int image); |
80 | ||
c41ea66a | 81 | void LogEvent(const wxListEvent& event, const wxChar *eventName); |
2b5f62a0 | 82 | void LogColEvent(const wxListEvent& event, const wxChar *eventName); |
c41ea66a | 83 | |
98ec9dbe | 84 | virtual wxString OnGetItemText(long item, long column) const; |
06db67bc | 85 | virtual int OnGetItemColumnImage(long item, long column) const; |
6c02c329 VZ |
86 | virtual wxListItemAttr *OnGetItemAttr(long item) const; |
87 | ||
88 | wxListItemAttr m_attr; | |
98ec9dbe | 89 | |
c71963cd | 90 | DECLARE_NO_COPY_CLASS(MyListCtrl) |
5ea47806 | 91 | DECLARE_EVENT_TABLE() |
457814b5 JS |
92 | }; |
93 | ||
94 | // Define a new frame type | |
95 | class MyFrame: public wxFrame | |
5ea47806 VZ |
96 | { |
97 | public: | |
107ff668 | 98 | MyFrame(const wxChar *title); |
07bf769e VZ |
99 | virtual ~MyFrame(); |
100 | ||
101 | void DoSize(); | |
5ea47806 | 102 | |
2b5f62a0 | 103 | protected: |
98ec9dbe VZ |
104 | void OnSize(wxSizeEvent& event); |
105 | ||
457814b5 JS |
106 | void OnQuit(wxCommandEvent& event); |
107 | void OnAbout(wxCommandEvent& event); | |
108 | void OnListView(wxCommandEvent& event); | |
109 | void OnReportView(wxCommandEvent& event); | |
110 | void OnIconView(wxCommandEvent& event); | |
111 | void OnIconTextView(wxCommandEvent& event); | |
112 | void OnSmallIconView(wxCommandEvent& event); | |
113 | void OnSmallIconTextView(wxCommandEvent& event); | |
98ec9dbe | 114 | void OnVirtualView(wxCommandEvent& event); |
b0401bea | 115 | void OnSmallVirtualView(wxCommandEvent& event); |
98ec9dbe | 116 | |
88b792af | 117 | void OnFocusLast(wxCommandEvent& event); |
58b3bdc9 | 118 | void OnToggleFirstSel(wxCommandEvent& event); |
c4771147 KB |
119 | void OnDeselectAll(wxCommandEvent& event); |
120 | void OnSelectAll(wxCommandEvent& event); | |
cf1dfa6b | 121 | void OnAdd(wxCommandEvent& event); |
efe23391 | 122 | void OnEdit(wxCommandEvent& event); |
bec0a261 | 123 | void OnDelete(wxCommandEvent& event); |
5ea47806 | 124 | void OnDeleteAll(wxCommandEvent& event); |
fa5f6926 | 125 | void OnSort(wxCommandEvent& event); |
11f26ea0 VZ |
126 | void OnSetFgColour(wxCommandEvent& event); |
127 | void OnSetBgColour(wxCommandEvent& event); | |
7b848b0d | 128 | void OnToggleMultiSel(wxCommandEvent& event); |
f6bcfd97 | 129 | void OnShowColInfo(wxCommandEvent& event); |
b54e41c5 | 130 | void OnShowSelInfo(wxCommandEvent& event); |
c5c528fc VZ |
131 | void OnFreeze(wxCommandEvent& event); |
132 | void OnThaw(wxCommandEvent& event); | |
494ab5de | 133 | void OnToggleLines(wxCommandEvent& event); |
5ea47806 | 134 | |
98ec9dbe | 135 | void OnUpdateShowColInfo(wxUpdateUIEvent& event); |
ae403b11 | 136 | void OnUpdateToggleMultiSel(wxUpdateUIEvent& event); |
5ea47806 | 137 | |
c41ea66a VZ |
138 | wxImageList *m_imageListNormal; |
139 | wxImageList *m_imageListSmall; | |
140 | ||
2b5f62a0 VZ |
141 | wxPanel *m_panel; |
142 | MyListCtrl *m_listCtrl; | |
143 | wxTextCtrl *m_logWindow; | |
144 | ||
c41ea66a | 145 | private: |
776a33cf | 146 | // recreate the list control with the new flags |
1550e402 | 147 | void RecreateList(long flags, bool withText = true); |
776a33cf VZ |
148 | |
149 | // fill the control with items depending on the view | |
150 | void InitWithListItems(); | |
151 | void InitWithReportItems(); | |
1550e402 | 152 | void InitWithIconItems(bool withText, bool sameIcon = false); |
776a33cf VZ |
153 | void InitWithVirtualItems(); |
154 | ||
68457180 VZ |
155 | // return true if the control is not in virtual view, give an error message |
156 | // and return false if it is | |
157 | bool CheckNonVirtual() const; | |
158 | ||
159 | ||
c41ea66a VZ |
160 | wxLog *m_logOld; |
161 | ||
b0401bea VZ |
162 | bool m_smallVirtual; |
163 | ||
c71963cd | 164 | DECLARE_NO_COPY_CLASS(MyFrame) |
5ea47806 | 165 | DECLARE_EVENT_TABLE() |
457814b5 JS |
166 | }; |
167 | ||
168 | ||
98ec9dbe | 169 | // IDs for the menu commands |
fa5f6926 VZ |
170 | enum |
171 | { | |
658070d1 JS |
172 | LIST_ABOUT = wxID_ABOUT, |
173 | LIST_QUIT = wxID_EXIT, | |
cf1dfa6b | 174 | |
658070d1 | 175 | LIST_LIST_VIEW = wxID_HIGHEST, |
98ec9dbe VZ |
176 | LIST_ICON_VIEW, |
177 | LIST_ICON_TEXT_VIEW, | |
178 | LIST_SMALL_ICON_VIEW, | |
179 | LIST_SMALL_ICON_TEXT_VIEW, | |
cf1dfa6b | 180 | LIST_REPORT_VIEW, |
98ec9dbe | 181 | LIST_VIRTUAL_VIEW, |
b0401bea | 182 | LIST_SMALL_VIRTUAL_VIEW, |
98ec9dbe | 183 | |
98ec9dbe VZ |
184 | LIST_DESELECT_ALL, |
185 | LIST_SELECT_ALL, | |
98ec9dbe | 186 | LIST_DELETE_ALL, |
bec0a261 | 187 | LIST_DELETE, |
cf1dfa6b | 188 | LIST_ADD, |
efe23391 | 189 | LIST_EDIT, |
fa5f6926 | 190 | LIST_SORT, |
11f26ea0 VZ |
191 | LIST_SET_FG_COL, |
192 | LIST_SET_BG_COL, | |
7b848b0d | 193 | LIST_TOGGLE_MULTI_SEL, |
58b3bdc9 | 194 | LIST_TOGGLE_FIRST, |
f6bcfd97 | 195 | LIST_SHOW_COL_INFO, |
b54e41c5 | 196 | LIST_SHOW_SEL_INFO, |
88b792af | 197 | LIST_FOCUS_LAST, |
c5c528fc VZ |
198 | LIST_FREEZE, |
199 | LIST_THAW, | |
494ab5de | 200 | LIST_TOGGLE_LINES, |
457814b5 | 201 | |
fa5f6926 VZ |
202 | LIST_CTRL = 1000 |
203 | }; | |
457814b5 | 204 |