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"
31 #include "bitmaps/toolbrai.xpm"
32 #include "bitmaps/toolchar.xpm"
33 #include "bitmaps/tooldata.xpm"
34 #include "bitmaps/toolnote.xpm"
35 #include "bitmaps/tooltodo.xpm"
36 #include "bitmaps/toolchec.xpm"
37 #include "bitmaps/toolgame.xpm"
38 #include "bitmaps/tooltime.xpm"
39 #include "bitmaps/toolword.xpm"
40 #include "bitmaps/small1.xpm"
43 #include "wx/imaglist.h"
44 #include "wx/listctrl.h"
45 #include "wx/timer.h" // for wxStopWatch
46 #include "wx/colordlg.h" // for wxGetColourFromUser
50 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
51 EVT_MENU(BUSY_ON
, MyFrame::BusyOn
)
52 EVT_MENU(BUSY_OFF
, MyFrame::BusyOff
)
53 EVT_MENU(LIST_QUIT
, MyFrame::OnQuit
)
54 EVT_MENU(LIST_ABOUT
, MyFrame::OnAbout
)
55 EVT_MENU(LIST_LIST_VIEW
, MyFrame::OnListView
)
56 EVT_MENU(LIST_REPORT_VIEW
, MyFrame::OnReportView
)
57 EVT_MENU(LIST_ICON_VIEW
, MyFrame::OnIconView
)
58 EVT_MENU(LIST_ICON_TEXT_VIEW
, MyFrame::OnIconTextView
)
59 EVT_MENU(LIST_SMALL_ICON_VIEW
, MyFrame::OnSmallIconView
)
60 EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW
, MyFrame::OnSmallIconTextView
)
61 EVT_MENU(LIST_TOGGLE_FIRST
, MyFrame::OnToggleFirstSel
)
62 EVT_MENU(LIST_DESELECT_ALL
, MyFrame::OnDeselectAll
)
63 EVT_MENU(LIST_SELECT_ALL
, MyFrame::OnSelectAll
)
64 EVT_MENU(LIST_DELETE
, MyFrame::OnDelete
)
65 EVT_MENU(LIST_DELETE_ALL
, MyFrame::OnDeleteAll
)
66 EVT_MENU(LIST_SORT
, MyFrame::OnSort
)
67 EVT_MENU(LIST_SET_FG_COL
, MyFrame::OnSetFgColour
)
68 EVT_MENU(LIST_SET_BG_COL
, MyFrame::OnSetBgColour
)
69 EVT_MENU(LIST_TOGGLE_MULTI_SEL
, MyFrame::OnToggleMultiSel
)
70 EVT_MENU(LIST_SHOW_COL_INFO
, MyFrame::OnShowColInfo
)
71 EVT_UPDATE_UI(LIST_SHOW_COL_INFO
, MyFrame::OnUpdateShowColInfo
)
74 BEGIN_EVENT_TABLE(MyListCtrl
, wxListCtrl
)
75 EVT_LIST_BEGIN_DRAG(LIST_CTRL
, MyListCtrl::OnBeginDrag
)
76 EVT_LIST_BEGIN_RDRAG(LIST_CTRL
, MyListCtrl::OnBeginRDrag
)
77 EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnBeginLabelEdit
)
78 EVT_LIST_END_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnEndLabelEdit
)
79 EVT_LIST_DELETE_ITEM(LIST_CTRL
, MyListCtrl::OnDeleteItem
)
80 EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL
, MyListCtrl::OnDeleteAllItems
)
81 EVT_LIST_GET_INFO(LIST_CTRL
, MyListCtrl::OnGetInfo
)
82 EVT_LIST_SET_INFO(LIST_CTRL
, MyListCtrl::OnSetInfo
)
83 EVT_LIST_ITEM_SELECTED(LIST_CTRL
, MyListCtrl::OnSelected
)
84 EVT_LIST_ITEM_DESELECTED(LIST_CTRL
, MyListCtrl::OnDeselected
)
85 EVT_LIST_KEY_DOWN(LIST_CTRL
, MyListCtrl::OnListKeyDown
)
86 EVT_LIST_ITEM_ACTIVATED(LIST_CTRL
, MyListCtrl::OnActivated
)
87 EVT_LIST_COL_CLICK(LIST_CTRL
, MyListCtrl::OnColClick
)
89 EVT_CHAR(MyListCtrl::OnChar
)
94 int wxCALLBACK
MyCompareFunction(long item1
, long item2
, long sortData
)
100 // `Main program' equivalent, creating windows and returning main app frame
103 // Create the main frame window
104 MyFrame
*frame
= new MyFrame("wxListCtrl Test", 50, 50, 450, 340);
114 // My frame constructor
115 MyFrame::MyFrame(const wxChar
*title
, int x
, int y
, int w
, int h
)
116 : wxFrame((wxFrame
*)NULL
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
118 m_listCtrl
= (MyListCtrl
*) NULL
;
119 m_logWindow
= (wxTextCtrl
*) NULL
;
122 SetIcon( wxICON(mondrian
) );
124 // Make an image list containing large icons
125 m_imageListNormal
= new wxImageList(32, 32, TRUE
);
126 m_imageListSmall
= new wxImageList(16, 16, TRUE
);
129 m_imageListNormal
->Add( wxIcon("icon1", wxBITMAP_TYPE_ICO_RESOURCE
) );
130 m_imageListNormal
->Add( wxIcon("icon2", wxBITMAP_TYPE_ICO_RESOURCE
) );
131 m_imageListNormal
->Add( wxIcon("icon3", wxBITMAP_TYPE_ICO_RESOURCE
) );
132 m_imageListNormal
->Add( wxIcon("icon4", wxBITMAP_TYPE_ICO_RESOURCE
) );
133 m_imageListNormal
->Add( wxIcon("icon5", wxBITMAP_TYPE_ICO_RESOURCE
) );
134 m_imageListNormal
->Add( wxIcon("icon6", wxBITMAP_TYPE_ICO_RESOURCE
) );
135 m_imageListNormal
->Add( wxIcon("icon7", wxBITMAP_TYPE_ICO_RESOURCE
) );
136 m_imageListNormal
->Add( wxIcon("icon8", wxBITMAP_TYPE_ICO_RESOURCE
) );
137 m_imageListNormal
->Add( wxIcon("icon9", wxBITMAP_TYPE_ICO_RESOURCE
) );
139 m_imageListSmall
->Add( wxIcon("iconsmall", wxBITMAP_TYPE_ICO_RESOURCE
) );
142 m_imageListNormal
->Add( wxIcon( toolbrai_xpm
) );
143 m_imageListNormal
->Add( wxIcon( toolchar_xpm
) );
144 m_imageListNormal
->Add( wxIcon( tooldata_xpm
) );
145 m_imageListNormal
->Add( wxIcon( toolnote_xpm
) );
146 m_imageListNormal
->Add( wxIcon( tooltodo_xpm
) );
147 m_imageListNormal
->Add( wxIcon( toolchec_xpm
) );
148 m_imageListNormal
->Add( wxIcon( toolgame_xpm
) );
149 m_imageListNormal
->Add( wxIcon( tooltime_xpm
) );
150 m_imageListNormal
->Add( wxIcon( toolword_xpm
) );
152 m_imageListSmall
->Add( wxIcon( small1_xpm
) );
156 wxMenu
*menuFile
= new wxMenu
;
157 menuFile
->Append(LIST_ABOUT
, "&About");
158 menuFile
->AppendSeparator();
159 #if 0 // what is this for? (VZ)
160 menuFile
->Append(BUSY_ON
, "&Busy cursor on");
161 menuFile
->Append(BUSY_OFF
, "&Busy cursor off");
162 menuFile
->AppendSeparator();
164 menuFile
->Append(LIST_QUIT
, "E&xit\tAlt-X");
166 wxMenu
*menuView
= new wxMenu
;
167 menuView
->Append(LIST_LIST_VIEW
, "&List view\tF1");
168 menuView
->Append(LIST_REPORT_VIEW
, "&Report view\tF2");
169 menuView
->Append(LIST_ICON_VIEW
, "&Icon view\tF3");
170 menuView
->Append(LIST_ICON_TEXT_VIEW
, "Icon view with &text\tF4");
171 menuView
->Append(LIST_SMALL_ICON_VIEW
, "&Small icon view\tF5");
172 menuView
->Append(LIST_SMALL_ICON_TEXT_VIEW
, "Small icon &view with text\tF6");
174 wxMenu
*menuList
= new wxMenu
;
175 menuList
->Append(LIST_TOGGLE_FIRST
, "&Toggle first item\tCtrl-T");
176 menuList
->Append(LIST_DESELECT_ALL
, "&Deselect All\tCtrl-D");
177 menuList
->Append(LIST_SELECT_ALL
, "S&elect All\tCtrl-A");
178 menuList
->Append(LIST_SHOW_COL_INFO
, "Show &column info\tCtrl-C");
179 menuList
->AppendSeparator();
180 menuList
->Append(LIST_SORT
, "&Sort\tCtrl-S");
181 menuList
->AppendSeparator();
182 menuList
->Append(LIST_DELETE
, "&Delete first item");
183 menuList
->Append(LIST_DELETE_ALL
, "Delete &all items");
184 menuList
->AppendSeparator();
185 menuList
->Append(LIST_TOGGLE_MULTI_SEL
, "&Multiple selection\tCtrl-M",
186 "Toggle multiple selection", TRUE
);
188 wxMenu
*menuCol
= new wxMenu
;
189 menuCol
->Append(LIST_SET_FG_COL
, "&Foreground colour...");
190 menuCol
->Append(LIST_SET_BG_COL
, "&Background colour...");
192 wxMenuBar
*menubar
= new wxMenuBar
;
193 menubar
->Append(menuFile
, "&File");
194 menubar
->Append(menuView
, "&View");
195 menubar
->Append(menuList
, "&List");
196 menubar
->Append(menuCol
, "&Colour");
199 m_listCtrl
= new MyListCtrl(this, LIST_CTRL
,
200 wxDefaultPosition
, wxDefaultSize
,
204 // wxLC_USER_TEXT requires app to supply all
210 m_logWindow
= new wxTextCtrl(this, -1, wxEmptyString
,
211 wxDefaultPosition
, wxDefaultSize
,
212 wxTE_MULTILINE
| wxSUNKEN_BORDER
);
214 m_logOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_logWindow
));
216 wxLayoutConstraints
*c
= new wxLayoutConstraints
;
217 c
->top
.SameAs (this, wxTop
);
218 c
->left
.SameAs (this, wxLeft
);
219 c
->right
.SameAs (this, wxRight
);
220 c
->height
.PercentOf (this, wxHeight
, 66);
221 m_listCtrl
->SetConstraints(c
);
223 c
= new wxLayoutConstraints
;
224 c
->top
.Below (m_listCtrl
);
225 c
->left
.SameAs (this, wxLeft
);
226 c
->right
.SameAs (this, wxRight
);
227 c
->bottom
.SameAs (this, wxBottom
);
228 m_logWindow
->SetConstraints(c
);
231 for ( int i
= 0; i
< 30; i
++ )
233 long idx
= m_listCtrl
->InsertItem(i
, wxString::Format(_T("Item %d"), i
));
234 m_listCtrl
->SetItemData(idx
, i
*i
);
242 delete wxLog::SetActiveTarget(m_logOld
);
244 delete m_imageListNormal
;
245 delete m_imageListSmall
;
248 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
253 void MyFrame::BusyOn(wxCommandEvent
& WXUNUSED(event
))
258 void MyFrame::BusyOff(wxCommandEvent
& WXUNUSED(event
))
263 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
265 wxMessageDialog
dialog(this, "List test sample\nJulian Smart (c) 1997",
266 "About list test", wxOK
|wxCANCEL
);
271 void MyFrame::OnToggleFirstSel(wxCommandEvent
& WXUNUSED(event
))
273 m_listCtrl
->SetItemState(0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
276 void MyFrame::OnDeselectAll(wxCommandEvent
& WXUNUSED(event
))
278 int n
= m_listCtrl
->GetItemCount();
279 for (int i
= 0; i
< n
; i
++)
280 m_listCtrl
->SetItemState(i
,0,wxLIST_STATE_SELECTED
);
283 void MyFrame::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
285 int n
= m_listCtrl
->GetItemCount();
286 for (int i
= 0; i
< n
; i
++)
287 m_listCtrl
->SetItemState(i
,wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
290 void MyFrame::OnListView(wxCommandEvent
& WXUNUSED(event
))
292 m_listCtrl
->ClearAll();
293 m_logWindow
->Clear();
295 m_listCtrl
->SetSingleStyle(wxLC_LIST
);
296 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_NORMAL
);
297 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_SMALL
);
299 for ( int i
=0; i
< 30; i
++)
302 wxSprintf(buf
, _T("Item %d"), i
);
303 m_listCtrl
->InsertItem(i
, buf
);
307 void MyFrame::OnReportView(wxCommandEvent
& WXUNUSED(event
))
309 m_logWindow
->Clear();
310 m_listCtrl
->ClearAll();
312 m_listCtrl
->SetSingleStyle(wxLC_REPORT
);
313 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_NORMAL
);
314 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
316 m_listCtrl
->InsertColumn(0, "Column 1"); // , wxLIST_FORMAT_LEFT, 140);
317 m_listCtrl
->InsertColumn(1, "Column 2"); // , wxLIST_FORMAT_LEFT, 140);
318 m_listCtrl
->InsertColumn(2, "One More Column (2)"); // , wxLIST_FORMAT_LEFT, 140);
320 // to speed up inserting we hide the control temporarily
326 static const int NUM_ITEMS
= 30;//00;
327 for ( int i
= 0; i
< NUM_ITEMS
; i
++ )
329 buf
.Printf(_T("This is item %d"), i
);
330 long tmp
= m_listCtrl
->InsertItem(i
, buf
, 0);
331 m_listCtrl
->SetItemData(tmp
, i
);
333 buf
.Printf(_T("Col 1, item %d"), i
);
334 tmp
= m_listCtrl
->SetItem(i
, 1, buf
);
336 buf
.Printf(_T("Item %d in column 2"), i
);
337 tmp
= m_listCtrl
->SetItem(i
, 2, buf
);
340 m_logWindow
->WriteText(wxString::Format(_T("%d items inserted in %ldms\n"),
341 NUM_ITEMS
, sw
.Time()));
344 // we leave all mask fields to 0 and only change the colour
347 item
.SetTextColour(*wxRED
);
348 m_listCtrl
->SetItem( item
);
351 item
.SetTextColour(*wxGREEN
);
352 m_listCtrl
->SetItem( item
);
354 item
.SetTextColour(*wxLIGHT_GREY
);
355 item
.SetFont(*wxITALIC_FONT
);
356 item
.SetBackgroundColour(*wxRED
);
357 m_listCtrl
->SetItem( item
);
359 m_listCtrl
->SetTextColour(*wxBLUE
);
360 m_listCtrl
->SetBackgroundColour(*wxLIGHT_GREY
);
362 m_listCtrl
->SetColumnWidth( 0, wxLIST_AUTOSIZE
);
363 m_listCtrl
->SetColumnWidth( 1, wxLIST_AUTOSIZE
);
364 m_listCtrl
->SetColumnWidth( 2, wxLIST_AUTOSIZE
);
367 void MyFrame::OnIconView(wxCommandEvent
& WXUNUSED(event
))
369 m_logWindow
->Clear();
370 m_listCtrl
->ClearAll();
372 m_listCtrl
->SetSingleStyle(wxLC_ICON
);
373 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
374 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
376 for ( int i
=0; i
< 9; i
++)
378 m_listCtrl
->InsertItem(i
, i
);
382 void MyFrame::OnIconTextView(wxCommandEvent
& WXUNUSED(event
))
384 m_logWindow
->Clear();
385 m_listCtrl
->ClearAll();
387 m_listCtrl
->SetSingleStyle(wxLC_ICON
);
388 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
389 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
391 for ( int i
=0; i
< 9; i
++)
394 wxSprintf(buf
, _T("Label %d"), i
);
395 m_listCtrl
->InsertItem(i
, buf
, i
);
399 void MyFrame::OnSmallIconView(wxCommandEvent
& WXUNUSED(event
))
401 m_logWindow
->Clear();
402 m_listCtrl
->ClearAll();
404 m_listCtrl
->SetSingleStyle(wxLC_SMALL_ICON
);
405 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
406 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
408 for ( int i
=0; i
< 9; i
++)
410 m_listCtrl
->InsertItem(i
, 0);
414 void MyFrame::OnSmallIconTextView(wxCommandEvent
& WXUNUSED(event
))
416 m_logWindow
->Clear();
417 m_listCtrl
->ClearAll();
419 m_listCtrl
->SetSingleStyle(wxLC_SMALL_ICON
);
420 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
421 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
423 for ( int i
=0; i
< 9; i
++)
425 m_listCtrl
->InsertItem(i
, "Label", 0);
429 void MyFrame::OnSort(wxCommandEvent
& WXUNUSED(event
))
433 m_listCtrl
->SortItems(MyCompareFunction
, 0);
435 m_logWindow
->WriteText(wxString::Format(_T("Sorting %d items took %ld ms\n"),
436 m_listCtrl
->GetItemCount(),
440 void MyFrame::OnShowColInfo(wxCommandEvent
& event
)
442 int count
= m_listCtrl
->GetColumnCount();
443 wxLogMessage("%d columns:", count
);
444 for ( int c
= 0; c
< count
; c
++ )
446 wxLogMessage("\tcolumn %d has width %d", c
,
447 m_listCtrl
->GetColumnWidth(c
));
451 void MyFrame::OnUpdateShowColInfo(wxUpdateUIEvent
& event
)
453 event
.Enable( (m_listCtrl
->GetWindowStyleFlag() & wxLC_REPORT
) != 0 );
456 void MyFrame::OnToggleMultiSel(wxCommandEvent
& WXUNUSED(event
))
458 m_logWindow
->WriteText("Current selection mode: ");
460 long flags
= m_listCtrl
->GetWindowStyleFlag();
461 if ( flags
& wxLC_SINGLE_SEL
)
463 m_listCtrl
->SetWindowStyleFlag(flags
& ~wxLC_SINGLE_SEL
);
464 m_logWindow
->WriteText("multiple");
468 m_listCtrl
->SetWindowStyleFlag(flags
| wxLC_SINGLE_SEL
);
469 m_logWindow
->WriteText("single");
472 m_logWindow
->WriteText("\nRecreate the control now\n");
475 void MyFrame::OnSetFgColour(wxCommandEvent
& WXUNUSED(event
))
477 m_listCtrl
->SetForegroundColour(wxGetColourFromUser(this));
478 m_listCtrl
->Refresh();
481 void MyFrame::OnSetBgColour(wxCommandEvent
& WXUNUSED(event
))
483 m_listCtrl
->SetBackgroundColour(wxGetColourFromUser(this));
484 m_listCtrl
->Refresh();
487 void MyFrame::OnDelete(wxCommandEvent
& WXUNUSED(event
))
489 if ( m_listCtrl
->GetItemCount() )
491 m_listCtrl
->DeleteItem(0);
495 m_logWindow
->WriteText("Nothing to delete");
499 void MyFrame::OnDeleteAll(wxCommandEvent
& WXUNUSED(event
))
503 m_listCtrl
->DeleteAllItems();
505 m_logWindow
->WriteText(wxString::Format(_T("Deleting %d items took %ld ms\n"),
506 m_listCtrl
->GetItemCount(),
512 void MyListCtrl::OnColClick(wxListEvent
& event
)
514 wxLogMessage( "OnColumnClick at %d.", event
.GetColumn() );
517 void MyListCtrl::OnBeginDrag(wxListEvent
& event
)
519 wxLogMessage( "OnBeginDrag at %d,%d.",
520 event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
523 void MyListCtrl::OnBeginRDrag(wxListEvent
& event
)
525 wxLogMessage( "OnBeginRDrag at %d,%d.",
526 event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
529 void MyListCtrl::OnBeginLabelEdit(wxListEvent
& event
)
531 wxLogMessage("OnBeginLabelEdit: %s", event
.m_item
.m_text
.c_str());
534 void MyListCtrl::OnEndLabelEdit(wxListEvent
& event
)
536 wxLogMessage("OnEndLabelEdit: %s", event
.m_item
.m_text
.c_str());
539 void MyListCtrl::OnDeleteItem(wxListEvent
& event
)
541 LogEvent(event
, _T("OnDeleteItem"));
544 void MyListCtrl::OnDeleteAllItems(wxListEvent
& event
)
546 LogEvent(event
, _T("OnDeleteAllItems"));
549 void MyListCtrl::OnGetInfo(wxListEvent
& event
)
553 msg
<< "OnGetInfo (" << event
.m_item
.m_itemId
<< ", " << event
.m_item
.m_col
<< ")";
554 if ( event
.m_item
.m_mask
& wxLIST_MASK_STATE
)
555 msg
<< " wxLIST_MASK_STATE";
556 if ( event
.m_item
.m_mask
& wxLIST_MASK_TEXT
)
557 msg
<< " wxLIST_MASK_TEXT";
558 if ( event
.m_item
.m_mask
& wxLIST_MASK_IMAGE
)
559 msg
<< " wxLIST_MASK_IMAGE";
560 if ( event
.m_item
.m_mask
& wxLIST_MASK_DATA
)
561 msg
<< " wxLIST_MASK_DATA";
562 if ( event
.m_item
.m_mask
& wxLIST_SET_ITEM
)
563 msg
<< " wxLIST_SET_ITEM";
564 if ( event
.m_item
.m_mask
& wxLIST_MASK_WIDTH
)
565 msg
<< " wxLIST_MASK_WIDTH";
566 if ( event
.m_item
.m_mask
& wxLIST_MASK_FORMAT
)
567 msg
<< " wxLIST_MASK_WIDTH";
569 if ( event
.m_item
.m_mask
& wxLIST_MASK_TEXT
)
571 event
.m_item
.m_text
= "My callback text";
577 void MyListCtrl::OnSetInfo(wxListEvent
& event
)
579 LogEvent(event
, _T("OnSetInfo"));
582 void MyListCtrl::OnSelected(wxListEvent
& event
)
584 LogEvent(event
, _T("OnSelected"));
586 if ( GetWindowStyle() & wxLC_REPORT
)
589 info
.m_itemId
= event
.m_itemIndex
;
591 info
.m_mask
= wxLIST_MASK_TEXT
;
594 wxLogMessage("Value of the 2nd field of the selected item: %s",
595 info
.m_text
.c_str());
599 wxFAIL_MSG("wxListCtrl::GetItem() failed");
604 void MyListCtrl::OnDeselected(wxListEvent
& event
)
606 LogEvent(event
, _T("OnDeselected"));
609 void MyListCtrl::OnActivated(wxListEvent
& event
)
611 LogEvent(event
, _T("OnActivated"));
614 void MyListCtrl::OnListKeyDown(wxListEvent
& event
)
616 LogEvent(event
, _T("OnListKeyDown"));
621 void MyListCtrl::OnChar(wxKeyEvent
& event
)
623 wxLogMessage(_T("Got char event."));
628 void MyListCtrl::LogEvent(const wxListEvent
& event
, const wxChar
*eventName
)
630 wxLogMessage(_T("Item %ld: %s (item text = %s, data = %ld)"),
631 event
.GetIndex(), eventName
,
632 event
.GetText().c_str(), event
.GetData());