]>
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); |
3614a8dc | 51 | #if WXWIN_COMPATIBILITY_2_4 |
5ea47806 VZ |
52 | void OnGetInfo(wxListEvent& event); |
53 | void OnSetInfo(wxListEvent& event); | |
3614a8dc | 54 | #endif |
5ea47806 VZ |
55 | void OnSelected(wxListEvent& event); |
56 | void OnDeselected(wxListEvent& event); | |
57 | void OnListKeyDown(wxListEvent& event); | |
58 | void OnActivated(wxListEvent& event); | |
0ddefeb0 | 59 | void OnFocused(wxListEvent& event); |
614391dc | 60 | void OnCacheHint(wxListEvent& event); |
457814b5 | 61 | |
88ac883a VZ |
62 | void OnChar(wxKeyEvent& event); |
63 | ||
c41ea66a | 64 | private: |
6f806543 VZ |
65 | void SetColumnImage(int col, int image); |
66 | ||
c41ea66a | 67 | void LogEvent(const wxListEvent& event, const wxChar *eventName); |
2b5f62a0 | 68 | void LogColEvent(const wxListEvent& event, const wxChar *eventName); |
c41ea66a | 69 | |
98ec9dbe VZ |
70 | virtual wxString OnGetItemText(long item, long column) const; |
71 | virtual int OnGetItemImage(long item) const; | |
6c02c329 VZ |
72 | virtual wxListItemAttr *OnGetItemAttr(long item) const; |
73 | ||
74 | wxListItemAttr m_attr; | |
98ec9dbe | 75 | |
c71963cd | 76 | DECLARE_NO_COPY_CLASS(MyListCtrl) |
5ea47806 | 77 | DECLARE_EVENT_TABLE() |
457814b5 JS |
78 | }; |
79 | ||
80 | // Define a new frame type | |
81 | class MyFrame: public wxFrame | |
5ea47806 VZ |
82 | { |
83 | public: | |
c41ea66a | 84 | MyFrame(const wxChar *title, int x, int y, int w, int h); |
07bf769e VZ |
85 | virtual ~MyFrame(); |
86 | ||
87 | void DoSize(); | |
5ea47806 | 88 | |
2b5f62a0 | 89 | protected: |
98ec9dbe VZ |
90 | void OnSize(wxSizeEvent& event); |
91 | ||
457814b5 JS |
92 | void OnQuit(wxCommandEvent& event); |
93 | void OnAbout(wxCommandEvent& event); | |
94 | void OnListView(wxCommandEvent& event); | |
95 | void OnReportView(wxCommandEvent& event); | |
96 | void OnIconView(wxCommandEvent& event); | |
97 | void OnIconTextView(wxCommandEvent& event); | |
98 | void OnSmallIconView(wxCommandEvent& event); | |
99 | void OnSmallIconTextView(wxCommandEvent& event); | |
98ec9dbe | 100 | void OnVirtualView(wxCommandEvent& event); |
b0401bea | 101 | void OnSmallVirtualView(wxCommandEvent& event); |
98ec9dbe | 102 | |
88b792af | 103 | void OnFocusLast(wxCommandEvent& event); |
58b3bdc9 | 104 | void OnToggleFirstSel(wxCommandEvent& event); |
c4771147 KB |
105 | void OnDeselectAll(wxCommandEvent& event); |
106 | void OnSelectAll(wxCommandEvent& event); | |
cf1dfa6b | 107 | void OnAdd(wxCommandEvent& event); |
efe23391 | 108 | void OnEdit(wxCommandEvent& event); |
bec0a261 | 109 | void OnDelete(wxCommandEvent& event); |
5ea47806 | 110 | void OnDeleteAll(wxCommandEvent& event); |
fa5f6926 | 111 | void OnSort(wxCommandEvent& event); |
11f26ea0 VZ |
112 | void OnSetFgColour(wxCommandEvent& event); |
113 | void OnSetBgColour(wxCommandEvent& event); | |
7b848b0d | 114 | void OnToggleMultiSel(wxCommandEvent& event); |
f6bcfd97 | 115 | void OnShowColInfo(wxCommandEvent& event); |
b54e41c5 | 116 | void OnShowSelInfo(wxCommandEvent& event); |
c5c528fc VZ |
117 | void OnFreeze(wxCommandEvent& event); |
118 | void OnThaw(wxCommandEvent& event); | |
494ab5de | 119 | void OnToggleLines(wxCommandEvent& event); |
5ea47806 | 120 | |
98ec9dbe | 121 | void OnUpdateShowColInfo(wxUpdateUIEvent& event); |
ae403b11 | 122 | void OnUpdateToggleMultiSel(wxUpdateUIEvent& event); |
5ea47806 | 123 | |
c41ea66a VZ |
124 | wxImageList *m_imageListNormal; |
125 | wxImageList *m_imageListSmall; | |
126 | ||
2b5f62a0 VZ |
127 | wxPanel *m_panel; |
128 | MyListCtrl *m_listCtrl; | |
129 | wxTextCtrl *m_logWindow; | |
130 | ||
c41ea66a | 131 | private: |
776a33cf | 132 | // recreate the list control with the new flags |
1550e402 | 133 | void RecreateList(long flags, bool withText = true); |
776a33cf VZ |
134 | |
135 | // fill the control with items depending on the view | |
136 | void InitWithListItems(); | |
137 | void InitWithReportItems(); | |
1550e402 | 138 | void InitWithIconItems(bool withText, bool sameIcon = false); |
776a33cf VZ |
139 | void InitWithVirtualItems(); |
140 | ||
68457180 VZ |
141 | // return true if the control is not in virtual view, give an error message |
142 | // and return false if it is | |
143 | bool CheckNonVirtual() const; | |
144 | ||
145 | ||
c41ea66a VZ |
146 | wxLog *m_logOld; |
147 | ||
b0401bea VZ |
148 | bool m_smallVirtual; |
149 | ||
c71963cd | 150 | DECLARE_NO_COPY_CLASS(MyFrame) |
5ea47806 | 151 | DECLARE_EVENT_TABLE() |
457814b5 JS |
152 | }; |
153 | ||
154 | ||
98ec9dbe | 155 | // IDs for the menu commands |
fa5f6926 VZ |
156 | enum |
157 | { | |
658070d1 JS |
158 | LIST_ABOUT = wxID_ABOUT, |
159 | LIST_QUIT = wxID_EXIT, | |
cf1dfa6b | 160 | |
658070d1 | 161 | LIST_LIST_VIEW = wxID_HIGHEST, |
98ec9dbe VZ |
162 | LIST_ICON_VIEW, |
163 | LIST_ICON_TEXT_VIEW, | |
164 | LIST_SMALL_ICON_VIEW, | |
165 | LIST_SMALL_ICON_TEXT_VIEW, | |
cf1dfa6b | 166 | LIST_REPORT_VIEW, |
98ec9dbe | 167 | LIST_VIRTUAL_VIEW, |
b0401bea | 168 | LIST_SMALL_VIRTUAL_VIEW, |
98ec9dbe | 169 | |
98ec9dbe VZ |
170 | LIST_DESELECT_ALL, |
171 | LIST_SELECT_ALL, | |
98ec9dbe | 172 | LIST_DELETE_ALL, |
bec0a261 | 173 | LIST_DELETE, |
cf1dfa6b | 174 | LIST_ADD, |
efe23391 | 175 | LIST_EDIT, |
fa5f6926 | 176 | LIST_SORT, |
11f26ea0 VZ |
177 | LIST_SET_FG_COL, |
178 | LIST_SET_BG_COL, | |
7b848b0d | 179 | LIST_TOGGLE_MULTI_SEL, |
58b3bdc9 | 180 | LIST_TOGGLE_FIRST, |
f6bcfd97 | 181 | LIST_SHOW_COL_INFO, |
b54e41c5 | 182 | LIST_SHOW_SEL_INFO, |
88b792af | 183 | LIST_FOCUS_LAST, |
c5c528fc VZ |
184 | LIST_FREEZE, |
185 | LIST_THAW, | |
494ab5de | 186 | LIST_TOGGLE_LINES, |
457814b5 | 187 | |
fa5f6926 VZ |
188 | LIST_CTRL = 1000 |
189 | }; | |
457814b5 | 190 |