]>
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$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
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: | |
16 | virtual bool OnInit(); | |
457814b5 JS |
17 | }; |
18 | ||
19 | class MyListCtrl: public wxListCtrl | |
20 | { | |
21 | public: | |
6c02c329 VZ |
22 | MyListCtrl(wxWindow *parent, |
23 | const wxWindowID id, | |
24 | const wxPoint& pos, | |
25 | const wxSize& size, | |
26 | long style) | |
27 | : wxListCtrl(parent, id, pos, size, style), | |
a92b0cfd | 28 | m_attr(*wxBLUE, *wxLIGHT_GREY, wxNullFont) |
5ea47806 VZ |
29 | { |
30 | } | |
fa5f6926 | 31 | |
5cd89174 VZ |
32 | // add one item to the listctrl in report mode |
33 | void InsertItemInReportView(int i); | |
34 | ||
8636aed8 | 35 | void OnColClick(wxListEvent& event); |
11358d39 VZ |
36 | void OnColRightClick(wxListEvent& event); |
37 | void OnColBeginDrag(wxListEvent& event); | |
38 | void OnColDragging(wxListEvent& event); | |
39 | void OnColEndDrag(wxListEvent& event); | |
5ea47806 VZ |
40 | void OnBeginDrag(wxListEvent& event); |
41 | void OnBeginRDrag(wxListEvent& event); | |
42 | void OnBeginLabelEdit(wxListEvent& event); | |
43 | void OnEndLabelEdit(wxListEvent& event); | |
44 | void OnDeleteItem(wxListEvent& event); | |
12c1b46a | 45 | void OnDeleteAllItems(wxListEvent& event); |
5ea47806 VZ |
46 | void OnGetInfo(wxListEvent& event); |
47 | void OnSetInfo(wxListEvent& event); | |
48 | void OnSelected(wxListEvent& event); | |
49 | void OnDeselected(wxListEvent& event); | |
50 | void OnListKeyDown(wxListEvent& event); | |
51 | void OnActivated(wxListEvent& event); | |
0ddefeb0 | 52 | void OnFocused(wxListEvent& event); |
614391dc | 53 | void OnCacheHint(wxListEvent& event); |
457814b5 | 54 | |
88ac883a VZ |
55 | void OnChar(wxKeyEvent& event); |
56 | ||
c41ea66a | 57 | private: |
6f806543 VZ |
58 | void SetColumnImage(int col, int image); |
59 | ||
c41ea66a VZ |
60 | void LogEvent(const wxListEvent& event, const wxChar *eventName); |
61 | ||
98ec9dbe VZ |
62 | virtual wxString OnGetItemText(long item, long column) const; |
63 | virtual int OnGetItemImage(long item) const; | |
6c02c329 VZ |
64 | virtual wxListItemAttr *OnGetItemAttr(long item) const; |
65 | ||
66 | wxListItemAttr m_attr; | |
98ec9dbe | 67 | |
5ea47806 | 68 | DECLARE_EVENT_TABLE() |
457814b5 JS |
69 | }; |
70 | ||
71 | // Define a new frame type | |
72 | class MyFrame: public wxFrame | |
5ea47806 VZ |
73 | { |
74 | public: | |
457814b5 JS |
75 | MyListCtrl *m_listCtrl; |
76 | wxTextCtrl *m_logWindow; | |
77 | ||
c41ea66a | 78 | MyFrame(const wxChar *title, int x, int y, int w, int h); |
5ea47806 VZ |
79 | ~MyFrame(); |
80 | ||
81 | public: | |
98ec9dbe VZ |
82 | void OnSize(wxSizeEvent& event); |
83 | ||
457814b5 JS |
84 | void OnQuit(wxCommandEvent& event); |
85 | void OnAbout(wxCommandEvent& event); | |
86 | void OnListView(wxCommandEvent& event); | |
87 | void OnReportView(wxCommandEvent& event); | |
88 | void OnIconView(wxCommandEvent& event); | |
89 | void OnIconTextView(wxCommandEvent& event); | |
90 | void OnSmallIconView(wxCommandEvent& event); | |
91 | void OnSmallIconTextView(wxCommandEvent& event); | |
98ec9dbe VZ |
92 | void OnVirtualView(wxCommandEvent& event); |
93 | ||
88b792af | 94 | void OnFocusLast(wxCommandEvent& event); |
58b3bdc9 | 95 | void OnToggleFirstSel(wxCommandEvent& event); |
c4771147 KB |
96 | void OnDeselectAll(wxCommandEvent& event); |
97 | void OnSelectAll(wxCommandEvent& event); | |
cf1dfa6b | 98 | void OnAdd(wxCommandEvent& event); |
bec0a261 | 99 | void OnDelete(wxCommandEvent& event); |
5ea47806 | 100 | void OnDeleteAll(wxCommandEvent& event); |
fa5f6926 | 101 | void OnSort(wxCommandEvent& event); |
11f26ea0 VZ |
102 | void OnSetFgColour(wxCommandEvent& event); |
103 | void OnSetBgColour(wxCommandEvent& event); | |
7b848b0d | 104 | void OnToggleMultiSel(wxCommandEvent& event); |
f6bcfd97 | 105 | void OnShowColInfo(wxCommandEvent& event); |
b54e41c5 | 106 | void OnShowSelInfo(wxCommandEvent& event); |
c5c528fc VZ |
107 | void OnFreeze(wxCommandEvent& event); |
108 | void OnThaw(wxCommandEvent& event); | |
5ea47806 | 109 | |
98ec9dbe | 110 | void OnUpdateShowColInfo(wxUpdateUIEvent& event); |
5ea47806 | 111 | |
c41ea66a VZ |
112 | wxImageList *m_imageListNormal; |
113 | wxImageList *m_imageListSmall; | |
114 | ||
115 | private: | |
776a33cf VZ |
116 | // recreate the list control with the new flags |
117 | void RecreateList(long flags, bool withText = TRUE); | |
118 | ||
119 | // fill the control with items depending on the view | |
120 | void InitWithListItems(); | |
121 | void InitWithReportItems(); | |
122 | void InitWithIconItems(bool withText, bool sameIcon = FALSE); | |
123 | void InitWithVirtualItems(); | |
124 | ||
c41ea66a VZ |
125 | wxLog *m_logOld; |
126 | ||
5ea47806 | 127 | DECLARE_EVENT_TABLE() |
457814b5 JS |
128 | }; |
129 | ||
130 | ||
98ec9dbe | 131 | // IDs for the menu commands |
fa5f6926 VZ |
132 | enum |
133 | { | |
cf1dfa6b | 134 | LIST_ABOUT, |
98ec9dbe | 135 | LIST_QUIT, |
cf1dfa6b | 136 | |
98ec9dbe VZ |
137 | LIST_LIST_VIEW, |
138 | LIST_ICON_VIEW, | |
139 | LIST_ICON_TEXT_VIEW, | |
140 | LIST_SMALL_ICON_VIEW, | |
141 | LIST_SMALL_ICON_TEXT_VIEW, | |
cf1dfa6b | 142 | LIST_REPORT_VIEW, |
98ec9dbe VZ |
143 | LIST_VIRTUAL_VIEW, |
144 | ||
98ec9dbe VZ |
145 | LIST_DESELECT_ALL, |
146 | LIST_SELECT_ALL, | |
98ec9dbe | 147 | LIST_DELETE_ALL, |
bec0a261 | 148 | LIST_DELETE, |
cf1dfa6b | 149 | LIST_ADD, |
fa5f6926 | 150 | LIST_SORT, |
11f26ea0 VZ |
151 | LIST_SET_FG_COL, |
152 | LIST_SET_BG_COL, | |
7b848b0d | 153 | LIST_TOGGLE_MULTI_SEL, |
58b3bdc9 | 154 | LIST_TOGGLE_FIRST, |
f6bcfd97 | 155 | LIST_SHOW_COL_INFO, |
b54e41c5 | 156 | LIST_SHOW_SEL_INFO, |
88b792af | 157 | LIST_FOCUS_LAST, |
c5c528fc VZ |
158 | LIST_FREEZE, |
159 | LIST_THAW, | |
457814b5 | 160 | |
fa5f6926 VZ |
161 | LIST_CTRL = 1000 |
162 | }; | |
457814b5 | 163 |