]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listctrl.cpp | |
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 | #ifdef __GNUG__ | |
13 | #pragma implementation | |
14 | #pragma interface | |
15 | #endif | |
16 | ||
17 | // For compilers that support precompilation, includes "wx/wx.h". | |
18 | #include "wx/wxprec.h" | |
19 | ||
20 | #ifdef __BORLANDC__ | |
21 | #pragma hdrstop | |
22 | #endif | |
23 | ||
24 | #ifndef WX_PRECOMP | |
25 | #include "wx/wx.h" | |
26 | #endif | |
27 | ||
907789a0 RR |
28 | #ifndef __WXMSW__ |
29 | #include "mondrian.xpm" | |
30 | #endif | |
31 | ||
457814b5 JS |
32 | #include "wx/listctrl.h" |
33 | #include "listtest.h" | |
34 | ||
35 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
5ea47806 VZ |
36 | EVT_MENU(BUSY_ON, MyFrame::BusyOn) |
37 | EVT_MENU(BUSY_OFF, MyFrame::BusyOff) | |
38 | EVT_MENU(LIST_QUIT, MyFrame::OnQuit) | |
39 | EVT_MENU(LIST_ABOUT, MyFrame::OnAbout) | |
40 | EVT_MENU(LIST_LIST_VIEW, MyFrame::OnListView) | |
41 | EVT_MENU(LIST_REPORT_VIEW, MyFrame::OnReportView) | |
42 | EVT_MENU(LIST_ICON_VIEW, MyFrame::OnIconView) | |
43 | EVT_MENU(LIST_ICON_TEXT_VIEW, MyFrame::OnIconTextView) | |
44 | EVT_MENU(LIST_SMALL_ICON_VIEW, MyFrame::OnSmallIconView) | |
45 | EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW, MyFrame::OnSmallIconTextView) | |
46 | EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnDeselectAll) | |
47 | EVT_MENU(LIST_SELECT_ALL, MyFrame::OnSelectAll) | |
48 | EVT_MENU(LIST_DELETE_ALL, MyFrame::OnDeleteAll) | |
457814b5 JS |
49 | END_EVENT_TABLE() |
50 | ||
51 | BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl) | |
5ea47806 VZ |
52 | EVT_LIST_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnBeginDrag) |
53 | EVT_LIST_BEGIN_RDRAG(LIST_CTRL, MyListCtrl::OnBeginRDrag) | |
54 | EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL, MyListCtrl::OnBeginLabelEdit) | |
55 | EVT_LIST_END_LABEL_EDIT(LIST_CTRL, MyListCtrl::OnEndLabelEdit) | |
56 | EVT_LIST_DELETE_ITEM(LIST_CTRL, MyListCtrl::OnDeleteItem) | |
57 | EVT_LIST_GET_INFO(LIST_CTRL, MyListCtrl::OnGetInfo) | |
58 | EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo) | |
59 | EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyListCtrl::OnSelected) | |
60 | EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected) | |
61 | EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown) | |
62 | EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated) | |
457814b5 JS |
63 | END_EVENT_TABLE() |
64 | ||
65 | IMPLEMENT_APP(MyApp) | |
66 | ||
67 | // `Main program' equivalent, creating windows and returning main app frame | |
68 | bool MyApp::OnInit(void) | |
69 | { | |
70 | // Create the main frame window | |
b00c5607 | 71 | MyFrame *frame = new MyFrame((wxFrame *) NULL, "wxListCtrl Test", 50, 50, 450, 340); |
457814b5 JS |
72 | |
73 | // This reduces flicker effects - even better would be to define OnEraseBackground | |
74 | // to do nothing. When the list control's scrollbars are show or hidden, the | |
75 | // frame is sent a background erase event. | |
907789a0 | 76 | frame->SetBackgroundColour( *wxWHITE ); |
457814b5 JS |
77 | |
78 | // Give it an icon | |
907789a0 | 79 | frame->SetIcon( wxICON(mondrian) ); |
457814b5 JS |
80 | |
81 | // Make an image list containing large icons | |
82 | m_imageListNormal = new wxImageList(32, 32, TRUE); | |
83 | m_imageListSmall = new wxImageList(16, 16, TRUE); | |
84 | ||
b0d77f43 RR |
85 | #ifdef __WXMSW__ |
86 | m_imageListNormal->Add( wxIcon("icon1", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
87 | m_imageListNormal->Add( wxIcon("icon2", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
88 | m_imageListNormal->Add( wxIcon("icon3", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
89 | m_imageListNormal->Add( wxIcon("icon4", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
90 | m_imageListNormal->Add( wxIcon("icon5", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
91 | m_imageListNormal->Add( wxIcon("icon6", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
92 | m_imageListNormal->Add( wxIcon("icon7", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
93 | m_imageListNormal->Add( wxIcon("icon8", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
94 | m_imageListNormal->Add( wxIcon("icon9", wxBITMAP_TYPE_ICO_RESOURCE) ); | |
5ea47806 | 95 | |
b0d77f43 | 96 | m_imageListSmall->Add( wxIcon("iconsmall", wxBITMAP_TYPE_ICO_RESOURCE) ); |
5ea47806 | 97 | |
b0d77f43 RR |
98 | #else |
99 | ||
100 | #include "bitmaps/toolbrai.xpm" | |
101 | m_imageListNormal->Add( wxIcon( toolbrai_xpm ) ); | |
102 | #include "bitmaps/toolchar.xpm" | |
103 | m_imageListNormal->Add( wxIcon( toolchar_xpm ) ); | |
104 | #include "bitmaps/tooldata.xpm" | |
105 | m_imageListNormal->Add( wxIcon( tooldata_xpm ) ); | |
106 | #include "bitmaps/toolnote.xpm" | |
107 | m_imageListNormal->Add( wxIcon( toolnote_xpm ) ); | |
108 | #include "bitmaps/tooltodo.xpm" | |
109 | m_imageListNormal->Add( wxIcon( tooltodo_xpm ) ); | |
110 | #include "bitmaps/toolchec.xpm" | |
111 | m_imageListNormal->Add( wxIcon( toolchec_xpm ) ); | |
112 | #include "bitmaps/toolgame.xpm" | |
113 | m_imageListNormal->Add( wxIcon( toolgame_xpm ) ); | |
114 | #include "bitmaps/tooltime.xpm" | |
115 | m_imageListNormal->Add( wxIcon( tooltime_xpm ) ); | |
116 | #include "bitmaps/toolword.xpm" | |
117 | m_imageListNormal->Add( wxIcon( toolword_xpm ) ); | |
5ea47806 | 118 | |
b0d77f43 RR |
119 | #include "bitmaps/small1.xpm" |
120 | m_imageListSmall->Add( wxIcon( small1_xpm) ); | |
5ea47806 | 121 | |
b0d77f43 | 122 | #endif |
457814b5 JS |
123 | |
124 | // Make a menubar | |
125 | wxMenu *file_menu = new wxMenu; | |
126 | ||
5ea47806 VZ |
127 | file_menu->Append(LIST_LIST_VIEW, "&List view"); |
128 | file_menu->Append(LIST_REPORT_VIEW, "&Report view"); | |
129 | file_menu->Append(LIST_ICON_VIEW, "&Icon view"); | |
130 | file_menu->Append(LIST_ICON_TEXT_VIEW, "Icon view with &text"); | |
131 | file_menu->Append(LIST_SMALL_ICON_VIEW, "&Small icon view"); | |
132 | file_menu->Append(LIST_SMALL_ICON_TEXT_VIEW, "Small icon &view with text"); | |
c4771147 KB |
133 | file_menu->Append(LIST_DESELECT_ALL, "&Deselect All"); |
134 | file_menu->Append(LIST_SELECT_ALL, "S&elect All"); | |
5ea47806 VZ |
135 | file_menu->AppendSeparator(); |
136 | file_menu->Append(LIST_DELETE_ALL, "Delete &all items"); | |
137 | file_menu->AppendSeparator(); | |
138 | file_menu->Append(BUSY_ON, "&Busy cursor on"); | |
139 | file_menu->Append(BUSY_OFF, "&Busy cursor off"); | |
457814b5 JS |
140 | file_menu->AppendSeparator(); |
141 | file_menu->Append(LIST_ABOUT, "&About"); | |
142 | file_menu->Append(LIST_QUIT, "E&xit"); | |
143 | wxMenuBar *menu_bar = new wxMenuBar; | |
144 | menu_bar->Append(file_menu, "&File"); | |
145 | frame->SetMenuBar(menu_bar); | |
146 | ||
147 | // Make a panel with a message | |
148 | frame->m_listCtrl = new MyListCtrl(frame, LIST_CTRL, wxPoint(0, 0), wxSize(400, 200), | |
e179bd65 | 149 | wxLC_LIST|wxSUNKEN_BORDER|wxLC_EDIT_LABELS); |
5ea47806 | 150 | // wxLC_LIST|wxLC_USER_TEXT|wxSUNKEN_BORDER); // wxLC_USER_TEXT requires app to supply all text on demand |
457814b5 JS |
151 | frame->m_logWindow = new wxTextCtrl(frame, -1, "", wxPoint(0, 0), wxSize(400, 200), wxTE_MULTILINE|wxSUNKEN_BORDER); |
152 | ||
153 | wxLayoutConstraints *c = new wxLayoutConstraints; | |
5ea47806 VZ |
154 | c->top.SameAs (frame, wxTop); |
155 | c->left.SameAs (frame, wxLeft); | |
156 | c->right.SameAs (frame, wxRight); | |
157 | c->height.PercentOf (frame, wxHeight, 66); | |
457814b5 JS |
158 | frame->m_listCtrl->SetConstraints(c); |
159 | ||
160 | c = new wxLayoutConstraints; | |
5ea47806 VZ |
161 | c->top.Below (frame->m_listCtrl); |
162 | c->left.SameAs (frame, wxLeft); | |
163 | c->right.SameAs (frame, wxRight); | |
164 | c->bottom.SameAs (frame, wxBottom); | |
457814b5 JS |
165 | frame->m_logWindow->SetConstraints(c); |
166 | frame->SetAutoLayout(TRUE); | |
167 | ||
168 | for ( int i=0; i < 30; i++) | |
5ea47806 VZ |
169 | { |
170 | wxChar buf[20]; | |
171 | wxSprintf(buf, _T("Item %d"), i); | |
172 | frame->m_listCtrl->InsertItem(i, buf); | |
173 | } | |
457814b5 JS |
174 | |
175 | frame->CreateStatusBar(3); | |
176 | frame->SetStatusText("", 0); | |
177 | ||
178 | // Show the frame | |
179 | frame->Show(TRUE); | |
5ea47806 | 180 | |
457814b5 JS |
181 | SetTopWindow(frame); |
182 | ||
183 | return TRUE; | |
184 | } | |
185 | ||
186 | // My frame constructor | |
187 | MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h): | |
188 | wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) | |
189 | { | |
5ea47806 VZ |
190 | m_listCtrl = (MyListCtrl *) NULL; |
191 | m_logWindow = (wxTextCtrl *) NULL; | |
457814b5 JS |
192 | } |
193 | ||
194 | MyFrame::~MyFrame(void) | |
195 | { | |
5ea47806 VZ |
196 | delete wxGetApp().m_imageListNormal; |
197 | delete wxGetApp().m_imageListSmall; | |
457814b5 JS |
198 | } |
199 | ||
b0d77f43 | 200 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) |
457814b5 JS |
201 | { |
202 | Close(TRUE); | |
203 | } | |
204 | ||
57246713 KB |
205 | void MyFrame::BusyOn(wxCommandEvent& WXUNUSED(event)) |
206 | { | |
207 | wxBeginBusyCursor(); | |
208 | } | |
209 | ||
210 | void MyFrame::BusyOff(wxCommandEvent& WXUNUSED(event)) | |
211 | { | |
212 | wxEndBusyCursor(); | |
213 | } | |
214 | ||
b0d77f43 | 215 | void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 216 | { |
5ea47806 VZ |
217 | wxMessageDialog dialog(this, "List test sample\nJulian Smart (c) 1997", |
218 | "About list test", wxOK|wxCANCEL); | |
457814b5 | 219 | |
5ea47806 | 220 | dialog.ShowModal(); |
457814b5 JS |
221 | } |
222 | ||
c4771147 KB |
223 | void MyFrame::OnDeselectAll(wxCommandEvent& WXUNUSED(event)) |
224 | { | |
5ea47806 VZ |
225 | int n = m_listCtrl->GetItemCount(); |
226 | for (int i = 0; i < n; i++) | |
227 | m_listCtrl->SetItemState(i,0,wxLIST_STATE_SELECTED); | |
c4771147 KB |
228 | } |
229 | ||
230 | void MyFrame::OnSelectAll(wxCommandEvent& WXUNUSED(event)) | |
231 | { | |
5ea47806 VZ |
232 | int n = m_listCtrl->GetItemCount(); |
233 | for (int i = 0; i < n; i++) | |
234 | m_listCtrl->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); | |
c4771147 KB |
235 | } |
236 | ||
b0d77f43 | 237 | void MyFrame::OnListView(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 238 | { |
0180dad6 RR |
239 | m_listCtrl->DeleteAllItems(); |
240 | m_logWindow->Clear(); | |
241 | m_listCtrl->SetSingleStyle(wxLC_LIST); | |
c67daf87 UR |
242 | m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_NORMAL); |
243 | m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_SMALL); | |
457814b5 | 244 | |
0180dad6 RR |
245 | for ( int i=0; i < 30; i++) |
246 | { | |
5ea47806 VZ |
247 | wxChar buf[20]; |
248 | wxSprintf(buf, _T("Item %d"), i); | |
249 | m_listCtrl->InsertItem(i, buf); | |
0180dad6 | 250 | } |
457814b5 JS |
251 | } |
252 | ||
b0d77f43 | 253 | void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 254 | { |
0180dad6 | 255 | m_listCtrl->DeleteAllItems(); |
c50f1fb9 | 256 | m_listCtrl->DeleteAllColumns(); |
0180dad6 | 257 | m_logWindow->Clear(); |
5ea47806 | 258 | |
0180dad6 | 259 | m_listCtrl->SetSingleStyle(wxLC_REPORT); |
c67daf87 | 260 | m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_NORMAL); |
457814b5 JS |
261 | m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL); |
262 | ||
0180dad6 RR |
263 | m_listCtrl->InsertColumn(0, "Column 1"); // , wxLIST_FORMAT_LEFT, 140); |
264 | m_listCtrl->InsertColumn(1, "Column 2"); // , wxLIST_FORMAT_LEFT, 140); | |
265 | m_listCtrl->InsertColumn(2, "One More Column (2)"); // , wxLIST_FORMAT_LEFT, 140); | |
266 | ||
5ea47806 | 267 | for ( int i = 0; i < 3000; i++ ) |
0180dad6 | 268 | { |
5ea47806 VZ |
269 | wxChar buf[50]; |
270 | wxSprintf(buf, _T("This is item %d"), i); | |
271 | long tmp = m_listCtrl->InsertItem(i, buf, 0); | |
272 | ||
273 | wxSprintf(buf, _T("Col 1, item %d"), i); | |
274 | tmp = m_listCtrl->SetItem(i, 1, buf); | |
275 | ||
276 | wxSprintf(buf, _T("Item %d in column 2"), i); | |
277 | tmp = m_listCtrl->SetItem(i, 2, buf); | |
0180dad6 | 278 | } |
5ea47806 | 279 | |
0180dad6 RR |
280 | m_listCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE ); |
281 | m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE ); | |
282 | m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE ); | |
457814b5 JS |
283 | } |
284 | ||
b0d77f43 | 285 | void MyFrame::OnIconView(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 286 | { |
5ea47806 VZ |
287 | m_listCtrl->DeleteAllItems(); |
288 | m_logWindow->Clear(); | |
289 | m_listCtrl->SetSingleStyle(wxLC_ICON); | |
457814b5 JS |
290 | m_listCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL); |
291 | m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL); | |
292 | ||
5ea47806 VZ |
293 | for ( int i=0; i < 9; i++) |
294 | { | |
295 | m_listCtrl->InsertItem(i, i); | |
296 | } | |
457814b5 JS |
297 | } |
298 | ||
b0d77f43 | 299 | void MyFrame::OnIconTextView(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 300 | { |
5ea47806 VZ |
301 | m_listCtrl->DeleteAllItems(); |
302 | m_logWindow->Clear(); | |
303 | m_listCtrl->SetSingleStyle(wxLC_ICON); | |
457814b5 JS |
304 | m_listCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL); |
305 | m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL); | |
306 | ||
5ea47806 VZ |
307 | for ( int i=0; i < 9; i++) |
308 | { | |
309 | wxChar buf[20]; | |
310 | wxSprintf(buf, _T("Label %d"), i); | |
311 | m_listCtrl->InsertItem(i, buf, i); | |
312 | } | |
457814b5 JS |
313 | } |
314 | ||
b0d77f43 | 315 | void MyFrame::OnSmallIconView(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 316 | { |
5ea47806 VZ |
317 | m_listCtrl->DeleteAllItems(); |
318 | m_logWindow->Clear(); | |
319 | m_listCtrl->SetSingleStyle(wxLC_SMALL_ICON); | |
457814b5 JS |
320 | m_listCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL); |
321 | m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL); | |
322 | ||
5ea47806 VZ |
323 | for ( int i=0; i < 9; i++) |
324 | { | |
325 | m_listCtrl->InsertItem(i, 0); | |
326 | } | |
457814b5 JS |
327 | } |
328 | ||
b0d77f43 | 329 | void MyFrame::OnSmallIconTextView(wxCommandEvent& WXUNUSED(event)) |
457814b5 | 330 | { |
5ea47806 VZ |
331 | m_listCtrl->DeleteAllItems(); |
332 | m_logWindow->Clear(); | |
333 | m_listCtrl->SetSingleStyle(wxLC_SMALL_ICON); | |
457814b5 JS |
334 | m_listCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL); |
335 | m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL); | |
336 | ||
5ea47806 VZ |
337 | for ( int i=0; i < 9; i++) |
338 | { | |
339 | m_listCtrl->InsertItem(i, "Label", 0); | |
340 | } | |
341 | } | |
342 | ||
343 | void MyFrame::OnDeleteAll(wxCommandEvent& WXUNUSED(event)) | |
344 | { | |
345 | (void)wxGetElapsedTime(TRUE); | |
346 | ||
347 | int nItems = m_listCtrl->GetItemCount(); | |
348 | m_listCtrl->DeleteAllItems(); | |
349 | ||
350 | wxLogMessage("Deleting %d items took %ld ms", | |
351 | nItems, wxGetElapsedTime()); | |
457814b5 JS |
352 | } |
353 | ||
354 | // MyListCtrl | |
355 | ||
cb43b372 | 356 | void MyListCtrl::OnBeginDrag(wxListEvent& WXUNUSED(event)) |
457814b5 | 357 | { |
5ea47806 VZ |
358 | if ( !wxGetApp().GetTopWindow() ) |
359 | return; | |
457814b5 | 360 | |
5ea47806 VZ |
361 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
362 | if ( !text ) | |
363 | return; | |
457814b5 | 364 | |
a367b9b3 | 365 | text->WriteText("OnBeginDrag\n"); |
457814b5 JS |
366 | } |
367 | ||
cb43b372 | 368 | void MyListCtrl::OnBeginRDrag(wxListEvent& WXUNUSED(event)) |
457814b5 | 369 | { |
5ea47806 VZ |
370 | if ( !wxGetApp().GetTopWindow() ) |
371 | return; | |
457814b5 | 372 | |
5ea47806 VZ |
373 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
374 | if ( !text ) | |
375 | return; | |
a367b9b3 | 376 | text->WriteText("OnBeginRDrag\n"); |
457814b5 JS |
377 | } |
378 | ||
cb43b372 | 379 | void MyListCtrl::OnBeginLabelEdit(wxListEvent& WXUNUSED(event)) |
457814b5 | 380 | { |
5ea47806 VZ |
381 | if ( !wxGetApp().GetTopWindow() ) |
382 | return; | |
457814b5 | 383 | |
5ea47806 VZ |
384 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
385 | if ( !text ) | |
386 | return; | |
457814b5 | 387 | |
a367b9b3 | 388 | text->WriteText("OnBeginLabelEdit\n"); |
457814b5 JS |
389 | } |
390 | ||
cb43b372 | 391 | void MyListCtrl::OnEndLabelEdit(wxListEvent& WXUNUSED(event)) |
457814b5 | 392 | { |
5ea47806 VZ |
393 | if ( !wxGetApp().GetTopWindow() ) |
394 | return; | |
457814b5 | 395 | |
5ea47806 VZ |
396 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
397 | if ( !text ) | |
398 | return; | |
457814b5 | 399 | |
a367b9b3 | 400 | text->WriteText("OnEndLabelEdit\n"); |
457814b5 JS |
401 | } |
402 | ||
cb43b372 | 403 | void MyListCtrl::OnDeleteItem(wxListEvent& WXUNUSED(event)) |
457814b5 | 404 | { |
5ea47806 VZ |
405 | if ( !wxGetApp().GetTopWindow() ) |
406 | return; | |
457814b5 | 407 | |
5ea47806 VZ |
408 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
409 | if ( !text ) | |
410 | return; | |
457814b5 | 411 | |
a367b9b3 | 412 | text->WriteText("OnDeleteItem\n"); |
457814b5 JS |
413 | } |
414 | ||
e487524e | 415 | void MyListCtrl::OnGetInfo(wxListEvent& /*event*/) |
457814b5 | 416 | { |
5ea47806 VZ |
417 | if ( !wxGetApp().GetTopWindow() ) |
418 | return; | |
457814b5 | 419 | |
5ea47806 VZ |
420 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
421 | if ( !text ) | |
422 | return; | |
457814b5 | 423 | |
a367b9b3 JS |
424 | text->WriteText("OnGetInfo\n"); |
425 | ||
426 | /* | |
5ea47806 VZ |
427 | ostream str(text); |
428 | ||
429 | str << "OnGetInfo (" << event.m_item.m_itemId << ", " << event.m_item.m_col << ")"; | |
430 | if ( event.m_item.m_mask & wxLIST_MASK_STATE ) | |
431 | str << " wxLIST_MASK_STATE"; | |
432 | if ( event.m_item.m_mask & wxLIST_MASK_TEXT ) | |
433 | str << " wxLIST_MASK_TEXT"; | |
434 | if ( event.m_item.m_mask & wxLIST_MASK_IMAGE ) | |
435 | str << " wxLIST_MASK_IMAGE"; | |
436 | if ( event.m_item.m_mask & wxLIST_MASK_DATA ) | |
437 | str << " wxLIST_MASK_DATA"; | |
438 | if ( event.m_item.m_mask & wxLIST_SET_ITEM ) | |
439 | str << " wxLIST_SET_ITEM"; | |
440 | if ( event.m_item.m_mask & wxLIST_MASK_WIDTH ) | |
441 | str << " wxLIST_MASK_WIDTH"; | |
442 | if ( event.m_item.m_mask & wxLIST_MASK_FORMAT ) | |
443 | str << " wxLIST_MASK_WIDTH"; | |
444 | ||
445 | if ( event.m_item.m_mask & wxLIST_MASK_TEXT ) | |
446 | { | |
447 | event.m_item.m_text = "My callback text"; | |
448 | } | |
449 | str << "\n"; | |
450 | str.flush(); | |
a367b9b3 | 451 | */ |
457814b5 JS |
452 | } |
453 | ||
cb43b372 | 454 | void MyListCtrl::OnSetInfo(wxListEvent& WXUNUSED(event)) |
457814b5 | 455 | { |
5ea47806 VZ |
456 | if ( !wxGetApp().GetTopWindow() ) |
457 | return; | |
457814b5 | 458 | |
5ea47806 VZ |
459 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
460 | if ( !text ) | |
461 | return; | |
457814b5 | 462 | |
5ea47806 | 463 | text->WriteText("OnSetInfo\n"); |
457814b5 JS |
464 | } |
465 | ||
cb43b372 | 466 | void MyListCtrl::OnSelected(wxListEvent& WXUNUSED(event)) |
457814b5 | 467 | { |
5ea47806 VZ |
468 | if ( !wxGetApp().GetTopWindow() ) |
469 | return; | |
457814b5 | 470 | |
5ea47806 VZ |
471 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
472 | if ( !text ) | |
473 | return; | |
457814b5 | 474 | |
5ea47806 | 475 | text->WriteText("OnSelected\n"); |
457814b5 JS |
476 | } |
477 | ||
cb43b372 | 478 | void MyListCtrl::OnDeselected(wxListEvent& WXUNUSED(event)) |
457814b5 | 479 | { |
5ea47806 VZ |
480 | if ( !wxGetApp().GetTopWindow() ) |
481 | return; | |
457814b5 | 482 | |
5ea47806 VZ |
483 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
484 | if ( !text ) | |
485 | return; | |
457814b5 | 486 | |
5ea47806 | 487 | text->WriteText("OnDeselected\n"); |
457814b5 JS |
488 | } |
489 | ||
435fe83e RR |
490 | void MyListCtrl::OnActivated(wxListEvent& WXUNUSED(event)) |
491 | { | |
5ea47806 VZ |
492 | if ( !wxGetApp().GetTopWindow() ) |
493 | return; | |
435fe83e | 494 | |
5ea47806 VZ |
495 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
496 | if ( !text ) | |
497 | return; | |
435fe83e | 498 | |
5ea47806 | 499 | text->WriteText("OnActivated\n"); |
435fe83e RR |
500 | } |
501 | ||
8e1d4f96 | 502 | void MyListCtrl::OnListKeyDown(wxListEvent& event) |
457814b5 | 503 | { |
5ea47806 VZ |
504 | if ( !wxGetApp().GetTopWindow() ) |
505 | return; | |
457814b5 | 506 | |
5ea47806 VZ |
507 | wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow; |
508 | if ( !text ) | |
509 | return; | |
457814b5 | 510 | |
5ea47806 | 511 | text->WriteText("OnListKeyDown\n"); |
457814b5 JS |
512 | } |
513 | ||
435fe83e | 514 |