1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListCtrl sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
29 #include "mondrian.xpm"
32 #include "wx/listctrl.h"
33 #include "wx/timer.h" // for wxStopWatch
34 #include "wx/colordlg.h" // for wxGetColourFromUser
38 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
39 EVT_MENU(BUSY_ON
, MyFrame::BusyOn
)
40 EVT_MENU(BUSY_OFF
, MyFrame::BusyOff
)
41 EVT_MENU(LIST_QUIT
, MyFrame::OnQuit
)
42 EVT_MENU(LIST_ABOUT
, MyFrame::OnAbout
)
43 EVT_MENU(LIST_LIST_VIEW
, MyFrame::OnListView
)
44 EVT_MENU(LIST_REPORT_VIEW
, MyFrame::OnReportView
)
45 EVT_MENU(LIST_ICON_VIEW
, MyFrame::OnIconView
)
46 EVT_MENU(LIST_ICON_TEXT_VIEW
, MyFrame::OnIconTextView
)
47 EVT_MENU(LIST_SMALL_ICON_VIEW
, MyFrame::OnSmallIconView
)
48 EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW
, MyFrame::OnSmallIconTextView
)
49 EVT_MENU(LIST_DESELECT_ALL
, MyFrame::OnDeselectAll
)
50 EVT_MENU(LIST_SELECT_ALL
, MyFrame::OnSelectAll
)
51 EVT_MENU(LIST_DELETE_ALL
, MyFrame::OnDeleteAll
)
52 EVT_MENU(LIST_SORT
, MyFrame::OnSort
)
53 EVT_MENU(LIST_SET_FG_COL
, MyFrame::OnSetFgColour
)
54 EVT_MENU(LIST_SET_BG_COL
, MyFrame::OnSetBgColour
)
55 EVT_MENU(LIST_TOGGLE_MULTI_SEL
, MyFrame::OnToggleMultiSel
)
58 BEGIN_EVENT_TABLE(MyListCtrl
, wxListCtrl
)
59 EVT_LIST_BEGIN_DRAG(LIST_CTRL
, MyListCtrl::OnBeginDrag
)
60 EVT_LIST_BEGIN_RDRAG(LIST_CTRL
, MyListCtrl::OnBeginRDrag
)
61 EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnBeginLabelEdit
)
62 EVT_LIST_END_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnEndLabelEdit
)
63 EVT_LIST_DELETE_ITEM(LIST_CTRL
, MyListCtrl::OnDeleteItem
)
64 EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL
, MyListCtrl::OnDeleteAllItems
)
65 EVT_LIST_GET_INFO(LIST_CTRL
, MyListCtrl::OnGetInfo
)
66 EVT_LIST_SET_INFO(LIST_CTRL
, MyListCtrl::OnSetInfo
)
67 EVT_LIST_ITEM_SELECTED(LIST_CTRL
, MyListCtrl::OnSelected
)
68 EVT_LIST_ITEM_DESELECTED(LIST_CTRL
, MyListCtrl::OnDeselected
)
69 EVT_LIST_KEY_DOWN(LIST_CTRL
, MyListCtrl::OnListKeyDown
)
70 EVT_LIST_ITEM_ACTIVATED(LIST_CTRL
, MyListCtrl::OnActivated
)
71 EVT_LIST_COL_CLICK(LIST_CTRL
, MyListCtrl::OnColClick
)
76 int wxCALLBACK
MyCompareFunction(long item1
, long item2
, long sortData
)
82 // `Main program' equivalent, creating windows and returning main app frame
85 // Create the main frame window
86 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, "wxListCtrl Test", 50, 50, 450, 340);
89 frame
->SetIcon( wxICON(mondrian
) );
91 // Make an image list containing large icons
92 m_imageListNormal
= new wxImageList(32, 32, TRUE
);
93 m_imageListSmall
= new wxImageList(16, 16, TRUE
);
96 m_imageListNormal
->Add( wxIcon("icon1", wxBITMAP_TYPE_ICO_RESOURCE
) );
97 m_imageListNormal
->Add( wxIcon("icon2", wxBITMAP_TYPE_ICO_RESOURCE
) );
98 m_imageListNormal
->Add( wxIcon("icon3", wxBITMAP_TYPE_ICO_RESOURCE
) );
99 m_imageListNormal
->Add( wxIcon("icon4", wxBITMAP_TYPE_ICO_RESOURCE
) );
100 m_imageListNormal
->Add( wxIcon("icon5", wxBITMAP_TYPE_ICO_RESOURCE
) );
101 m_imageListNormal
->Add( wxIcon("icon6", wxBITMAP_TYPE_ICO_RESOURCE
) );
102 m_imageListNormal
->Add( wxIcon("icon7", wxBITMAP_TYPE_ICO_RESOURCE
) );
103 m_imageListNormal
->Add( wxIcon("icon8", wxBITMAP_TYPE_ICO_RESOURCE
) );
104 m_imageListNormal
->Add( wxIcon("icon9", wxBITMAP_TYPE_ICO_RESOURCE
) );
106 m_imageListSmall
->Add( wxIcon("iconsmall", wxBITMAP_TYPE_ICO_RESOURCE
) );
110 #include "bitmaps/toolbrai.xpm"
111 m_imageListNormal
->Add( wxIcon( toolbrai_xpm
) );
112 #include "bitmaps/toolchar.xpm"
113 m_imageListNormal
->Add( wxIcon( toolchar_xpm
) );
114 #include "bitmaps/tooldata.xpm"
115 m_imageListNormal
->Add( wxIcon( tooldata_xpm
) );
116 #include "bitmaps/toolnote.xpm"
117 m_imageListNormal
->Add( wxIcon( toolnote_xpm
) );
118 #include "bitmaps/tooltodo.xpm"
119 m_imageListNormal
->Add( wxIcon( tooltodo_xpm
) );
120 #include "bitmaps/toolchec.xpm"
121 m_imageListNormal
->Add( wxIcon( toolchec_xpm
) );
122 #include "bitmaps/toolgame.xpm"
123 m_imageListNormal
->Add( wxIcon( toolgame_xpm
) );
124 #include "bitmaps/tooltime.xpm"
125 m_imageListNormal
->Add( wxIcon( tooltime_xpm
) );
126 #include "bitmaps/toolword.xpm"
127 m_imageListNormal
->Add( wxIcon( toolword_xpm
) );
129 #include "bitmaps/small1.xpm"
130 m_imageListSmall
->Add( wxIcon( small1_xpm
) );
135 wxMenu
*menuFile
= new wxMenu
;
136 menuFile
->Append(LIST_ABOUT
, "&About");
137 menuFile
->AppendSeparator();
138 #if 0 // what is this for? (VZ)
139 menuFile
->Append(BUSY_ON
, "&Busy cursor on");
140 menuFile
->Append(BUSY_OFF
, "&Busy cursor off");
141 menuFile
->AppendSeparator();
143 menuFile
->Append(LIST_QUIT
, "E&xit\tAlt-X");
145 wxMenu
*menuView
= new wxMenu
;
146 menuView
->Append(LIST_LIST_VIEW
, "&List view\tF1");
147 menuView
->Append(LIST_REPORT_VIEW
, "&Report view\tF2");
148 menuView
->Append(LIST_ICON_VIEW
, "&Icon view\tF3");
149 menuView
->Append(LIST_ICON_TEXT_VIEW
, "Icon view with &text\tF4");
150 menuView
->Append(LIST_SMALL_ICON_VIEW
, "&Small icon view\tF5");
151 menuView
->Append(LIST_SMALL_ICON_TEXT_VIEW
, "Small icon &view with text\tF6");
153 wxMenu
*menuList
= new wxMenu
;
154 menuList
->Append(LIST_DESELECT_ALL
, "&Deselect All\tCtrl-D");
155 menuList
->Append(LIST_SELECT_ALL
, "S&elect All\tCtrl-A");
156 menuList
->AppendSeparator();
157 menuList
->Append(LIST_SORT
, "&Sort\tCtrl-S");
158 menuList
->AppendSeparator();
159 menuList
->Append(LIST_DELETE_ALL
, "Delete &all items");
160 menuList
->AppendSeparator();
161 menuList
->Append(LIST_TOGGLE_MULTI_SEL
, "&Multiple selection\tCtrl-M",
162 "Toggle multiple selection", TRUE
);
164 wxMenu
*menuCol
= new wxMenu
;
165 menuCol
->Append(LIST_SET_FG_COL
, "&Foreground colour...");
166 menuCol
->Append(LIST_SET_BG_COL
, "&Background colour...");
168 wxMenuBar
*menubar
= new wxMenuBar
;
169 menubar
->Append(menuFile
, "&File");
170 menubar
->Append(menuView
, "&View");
171 menubar
->Append(menuList
, "&List");
172 menubar
->Append(menuCol
, "&Colour");
173 frame
->SetMenuBar(menubar
);
175 frame
->m_listCtrl
= new MyListCtrl(frame
, LIST_CTRL
,
176 wxPoint(0, 0), wxSize(400, 200),
180 // wxLC_USER_TEXT requires app to supply all text on demand
185 frame
->m_logWindow
= new wxTextCtrl(frame
, -1, "", wxPoint(0, 0), wxSize(400, 200), wxTE_MULTILINE
|wxSUNKEN_BORDER
);
187 wxLayoutConstraints
*c
= new wxLayoutConstraints
;
188 c
->top
.SameAs (frame
, wxTop
);
189 c
->left
.SameAs (frame
, wxLeft
);
190 c
->right
.SameAs (frame
, wxRight
);
191 c
->height
.PercentOf (frame
, wxHeight
, 66);
192 frame
->m_listCtrl
->SetConstraints(c
);
194 c
= new wxLayoutConstraints
;
195 c
->top
.Below (frame
->m_listCtrl
);
196 c
->left
.SameAs (frame
, wxLeft
);
197 c
->right
.SameAs (frame
, wxRight
);
198 c
->bottom
.SameAs (frame
, wxBottom
);
199 frame
->m_logWindow
->SetConstraints(c
);
200 frame
->SetAutoLayout(TRUE
);
203 for ( int i
=0; i
< 30; i
++)
206 wxSprintf(buf
, _T("Item %d"), i
);
207 frame
->m_listCtrl
->InsertItem(i
, buf
);
210 frame
->CreateStatusBar(3);
220 // My frame constructor
221 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
)
222 : wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
224 m_listCtrl
= (MyListCtrl
*) NULL
;
225 m_logWindow
= (wxTextCtrl
*) NULL
;
230 delete wxGetApp().m_imageListNormal
;
231 delete wxGetApp().m_imageListSmall
;
234 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
239 void MyFrame::BusyOn(wxCommandEvent
& WXUNUSED(event
))
244 void MyFrame::BusyOff(wxCommandEvent
& WXUNUSED(event
))
249 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
251 wxMessageDialog
dialog(this, "List test sample\nJulian Smart (c) 1997",
252 "About list test", wxOK
|wxCANCEL
);
257 void MyFrame::OnDeselectAll(wxCommandEvent
& WXUNUSED(event
))
259 int n
= m_listCtrl
->GetItemCount();
260 for (int i
= 0; i
< n
; i
++)
261 m_listCtrl
->SetItemState(i
,0,wxLIST_STATE_SELECTED
);
264 void MyFrame::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
266 int n
= m_listCtrl
->GetItemCount();
267 for (int i
= 0; i
< n
; i
++)
268 m_listCtrl
->SetItemState(i
,wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
271 void MyFrame::OnListView(wxCommandEvent
& WXUNUSED(event
))
273 m_listCtrl
->ClearAll();
274 m_logWindow
->Clear();
276 m_listCtrl
->SetSingleStyle(wxLC_LIST
);
277 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_NORMAL
);
278 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_SMALL
);
280 for ( int i
=0; i
< 30; i
++)
283 wxSprintf(buf
, _T("Item %d"), i
);
284 m_listCtrl
->InsertItem(i
, buf
);
288 void MyFrame::OnReportView(wxCommandEvent
& WXUNUSED(event
))
290 m_logWindow
->Clear();
291 m_listCtrl
->ClearAll();
293 m_listCtrl
->SetSingleStyle(wxLC_REPORT
);
294 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_NORMAL
);
295 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
297 m_listCtrl
->InsertColumn(0, "Column 1"); // , wxLIST_FORMAT_LEFT, 140);
298 m_listCtrl
->InsertColumn(1, "Column 2"); // , wxLIST_FORMAT_LEFT, 140);
299 m_listCtrl
->InsertColumn(2, "One More Column (2)"); // , wxLIST_FORMAT_LEFT, 140);
301 // to speed up inserting we hide the control temporarily
307 static const int NUM_ITEMS
= 3000;
308 for ( int i
= 0; i
< NUM_ITEMS
; i
++ )
310 buf
.Printf(_T("This is item %d"), i
);
311 long tmp
= m_listCtrl
->InsertItem(i
, buf
, 0);
312 m_listCtrl
->SetItemData(tmp
, i
);
314 buf
.Printf(_T("Col 1, item %d"), i
);
315 tmp
= m_listCtrl
->SetItem(i
, 1, buf
);
317 buf
.Printf(_T("Item %d in column 2"), i
);
318 tmp
= m_listCtrl
->SetItem(i
, 2, buf
);
321 m_logWindow
->WriteText(wxString::Format(_T("%d items inserted in %ldms\n"),
322 NUM_ITEMS
, sw
.Time()));
325 // we leave all mask fields to 0 and only change the colour
328 item
.SetTextColour(*wxRED
);
329 m_listCtrl
->SetItem( item
);
332 item
.SetTextColour(*wxGREEN
);
333 m_listCtrl
->SetItem( item
);
335 item
.SetTextColour(*wxLIGHT_GREY
);
336 item
.SetFont(*wxITALIC_FONT
);
337 item
.SetBackgroundColour(*wxRED
);
338 m_listCtrl
->SetItem( item
);
340 m_listCtrl
->SetTextColour(*wxBLUE
);
341 m_listCtrl
->SetBackgroundColour(*wxLIGHT_GREY
);
343 m_listCtrl
->SetColumnWidth( 0, wxLIST_AUTOSIZE
);
344 m_listCtrl
->SetColumnWidth( 1, wxLIST_AUTOSIZE
);
345 m_listCtrl
->SetColumnWidth( 2, wxLIST_AUTOSIZE
);
348 void MyFrame::OnIconView(wxCommandEvent
& WXUNUSED(event
))
350 m_logWindow
->Clear();
351 m_listCtrl
->ClearAll();
353 m_listCtrl
->SetSingleStyle(wxLC_ICON
);
354 m_listCtrl
->SetImageList(wxGetApp().m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
355 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
357 for ( int i
=0; i
< 9; i
++)
359 m_listCtrl
->InsertItem(i
, i
);
363 void MyFrame::OnIconTextView(wxCommandEvent
& WXUNUSED(event
))
365 m_logWindow
->Clear();
366 m_listCtrl
->ClearAll();
368 m_listCtrl
->SetSingleStyle(wxLC_ICON
);
369 m_listCtrl
->SetImageList(wxGetApp().m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
370 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
372 for ( int i
=0; i
< 9; i
++)
375 wxSprintf(buf
, _T("Label %d"), i
);
376 m_listCtrl
->InsertItem(i
, buf
, i
);
380 void MyFrame::OnSmallIconView(wxCommandEvent
& WXUNUSED(event
))
382 m_logWindow
->Clear();
383 m_listCtrl
->ClearAll();
385 m_listCtrl
->SetSingleStyle(wxLC_SMALL_ICON
);
386 m_listCtrl
->SetImageList(wxGetApp().m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
387 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
389 for ( int i
=0; i
< 9; i
++)
391 m_listCtrl
->InsertItem(i
, 0);
395 void MyFrame::OnSmallIconTextView(wxCommandEvent
& WXUNUSED(event
))
397 m_logWindow
->Clear();
398 m_listCtrl
->ClearAll();
400 m_listCtrl
->SetSingleStyle(wxLC_SMALL_ICON
);
401 m_listCtrl
->SetImageList(wxGetApp().m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
402 m_listCtrl
->SetImageList(wxGetApp().m_imageListSmall
, wxIMAGE_LIST_SMALL
);
404 for ( int i
=0; i
< 9; i
++)
406 m_listCtrl
->InsertItem(i
, "Label", 0);
410 void MyFrame::OnSort(wxCommandEvent
& WXUNUSED(event
))
414 m_listCtrl
->SortItems(MyCompareFunction
, 0);
416 m_logWindow
->WriteText(wxString::Format(_T("Sorting %d items took %ld ms\n"),
417 m_listCtrl
->GetItemCount(),
421 void MyFrame::OnToggleMultiSel(wxCommandEvent
& WXUNUSED(event
))
423 m_logWindow
->WriteText("Current selection mode: ");
425 long flags
= m_listCtrl
->GetWindowStyleFlag();
426 if ( flags
& wxLC_SINGLE_SEL
)
428 m_listCtrl
->SetWindowStyleFlag(flags
& ~wxLC_SINGLE_SEL
);
429 m_logWindow
->WriteText("multiple");
433 m_listCtrl
->SetWindowStyleFlag(flags
| wxLC_SINGLE_SEL
);
434 m_logWindow
->WriteText("single");
437 m_logWindow
->WriteText("\nRecreate the control now\n");
440 void MyFrame::OnSetFgColour(wxCommandEvent
& WXUNUSED(event
))
442 m_listCtrl
->SetForegroundColour(wxGetColourFromUser(this));
443 m_listCtrl
->Refresh();
446 void MyFrame::OnSetBgColour(wxCommandEvent
& WXUNUSED(event
))
448 m_listCtrl
->SetBackgroundColour(wxGetColourFromUser(this));
449 m_listCtrl
->Refresh();
452 void MyFrame::OnDeleteAll(wxCommandEvent
& WXUNUSED(event
))
456 m_listCtrl
->DeleteAllItems();
458 m_logWindow
->WriteText(wxString::Format(_T("Deleting %d items took %ld ms\n"),
459 m_listCtrl
->GetItemCount(),
465 void MyListCtrl::OnColClick(wxListEvent
& event
)
467 if ( !wxGetApp().GetTopWindow() )
470 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
475 msg
.Printf( "OnColumnClick at %d.\n", event
.GetColumn() );
476 text
->WriteText(msg
);
479 void MyListCtrl::OnBeginDrag(wxListEvent
& event
)
481 if ( !wxGetApp().GetTopWindow() )
484 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
489 msg
.Printf( "OnBeginDrag at %d,%d.\n", event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
490 text
->WriteText(msg
);
493 void MyListCtrl::OnBeginRDrag(wxListEvent
& event
)
495 if ( !wxGetApp().GetTopWindow() )
498 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
503 msg
.Printf( "OnBeginRDrag at %d,%d.\n", event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
504 text
->WriteText(msg
);
507 void MyListCtrl::OnBeginLabelEdit(wxListEvent
& event
)
509 if ( !wxGetApp().GetTopWindow() )
512 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
516 text
->WriteText("OnBeginLabelEdit: ");
517 text
->WriteText(event
.m_item
.m_text
);
518 text
->WriteText("\n");
521 void MyListCtrl::OnEndLabelEdit(wxListEvent
& event
)
523 if ( !wxGetApp().GetTopWindow() )
526 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
530 text
->WriteText("OnEndLabelEdit: ");
531 text
->WriteText(event
.m_item
.m_text
);
532 text
->WriteText("\n");
535 void MyListCtrl::OnDeleteItem(wxListEvent
& event
)
537 if ( !wxGetApp().GetTopWindow() )
540 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
544 text
->WriteText(wxString::Format("%ld OnDeleteItem\n", event
.GetIndex()));
547 void MyListCtrl::OnDeleteAllItems(wxListEvent
& WXUNUSED(event
))
549 if ( !wxGetApp().GetTopWindow() )
552 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
556 text
->WriteText("OnDeleteAllItems\n");
559 void MyListCtrl::OnGetInfo(wxListEvent
& event
)
561 if ( !wxGetApp().GetTopWindow() )
564 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
568 text
->WriteText("OnGetInfo\n");
570 (*text
) << "OnGetInfo (" << event
.m_item
.m_itemId
<< ", " << event
.m_item
.m_col
<< ")";
571 if ( event
.m_item
.m_mask
& wxLIST_MASK_STATE
)
572 (*text
) << " wxLIST_MASK_STATE";
573 if ( event
.m_item
.m_mask
& wxLIST_MASK_TEXT
)
574 (*text
) << " wxLIST_MASK_TEXT";
575 if ( event
.m_item
.m_mask
& wxLIST_MASK_IMAGE
)
576 (*text
) << " wxLIST_MASK_IMAGE";
577 if ( event
.m_item
.m_mask
& wxLIST_MASK_DATA
)
578 (*text
) << " wxLIST_MASK_DATA";
579 if ( event
.m_item
.m_mask
& wxLIST_SET_ITEM
)
580 (*text
) << " wxLIST_SET_ITEM";
581 if ( event
.m_item
.m_mask
& wxLIST_MASK_WIDTH
)
582 (*text
) << " wxLIST_MASK_WIDTH";
583 if ( event
.m_item
.m_mask
& wxLIST_MASK_FORMAT
)
584 (*text
) << " wxLIST_MASK_WIDTH";
586 if ( event
.m_item
.m_mask
& wxLIST_MASK_TEXT
)
588 event
.m_item
.m_text
= "My callback text";
593 void MyListCtrl::OnSetInfo(wxListEvent
& event
)
595 if ( !wxGetApp().GetTopWindow() )
598 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
602 text
->WriteText(wxString::Format("%ld OnSetInfo\n", event
.GetIndex()));
605 void MyListCtrl::OnSelected(wxListEvent
& event
)
607 if ( !wxGetApp().GetTopWindow() )
610 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
614 if ( GetWindowStyle() & wxLC_REPORT
)
617 info
.m_itemId
= event
.m_itemIndex
;
619 info
.m_mask
= wxLIST_MASK_TEXT
;
622 *text
<< "Value of the 2nd field of the selected item: "
623 << info
.m_text
<< '\n';
627 wxFAIL_MSG("wxListCtrl::GetItem() failed");
631 text
->WriteText(wxString::Format("%ld OnSelected\n", event
.GetIndex()));
634 void MyListCtrl::OnDeselected(wxListEvent
& event
)
636 if ( !wxGetApp().GetTopWindow() )
639 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
643 text
->WriteText(wxString::Format("%ld OnDeselected\n", event
.GetIndex()));
646 void MyListCtrl::OnActivated(wxListEvent
& event
)
648 if ( !wxGetApp().GetTopWindow() )
651 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
655 text
->WriteText(wxString::Format("%ld OnActivated\n", event
.GetIndex()));
658 void MyListCtrl::OnListKeyDown(wxListEvent
& event
)
660 if ( !wxGetApp().GetTopWindow() )
663 wxTextCtrl
*text
= ((MyFrame
*)wxGetApp().GetTopWindow())->m_logWindow
;
667 text
->WriteText(wxString::Format("%ld OnListKeyDown\n", event
.GetIndex()));