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_SIZE(MyFrame::OnSize
)
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_VIRTUAL_VIEW
, MyFrame::OnVirtualView
)
63 EVT_MENU(LIST_TOGGLE_FIRST
, MyFrame::OnToggleFirstSel
)
64 EVT_MENU(LIST_DESELECT_ALL
, MyFrame::OnDeselectAll
)
65 EVT_MENU(LIST_SELECT_ALL
, MyFrame::OnSelectAll
)
66 EVT_MENU(LIST_DELETE
, MyFrame::OnDelete
)
67 EVT_MENU(LIST_DELETE_ALL
, MyFrame::OnDeleteAll
)
68 EVT_MENU(LIST_SORT
, MyFrame::OnSort
)
69 EVT_MENU(LIST_SET_FG_COL
, MyFrame::OnSetFgColour
)
70 EVT_MENU(LIST_SET_BG_COL
, MyFrame::OnSetBgColour
)
71 EVT_MENU(LIST_TOGGLE_MULTI_SEL
, MyFrame::OnToggleMultiSel
)
72 EVT_MENU(LIST_SHOW_COL_INFO
, MyFrame::OnShowColInfo
)
74 EVT_UPDATE_UI(LIST_SHOW_COL_INFO
, MyFrame::OnUpdateShowColInfo
)
77 BEGIN_EVENT_TABLE(MyListCtrl
, wxListCtrl
)
78 EVT_LIST_BEGIN_DRAG(LIST_CTRL
, MyListCtrl::OnBeginDrag
)
79 EVT_LIST_BEGIN_RDRAG(LIST_CTRL
, MyListCtrl::OnBeginRDrag
)
80 EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnBeginLabelEdit
)
81 EVT_LIST_END_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnEndLabelEdit
)
82 EVT_LIST_DELETE_ITEM(LIST_CTRL
, MyListCtrl::OnDeleteItem
)
83 EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL
, MyListCtrl::OnDeleteAllItems
)
84 EVT_LIST_GET_INFO(LIST_CTRL
, MyListCtrl::OnGetInfo
)
85 EVT_LIST_SET_INFO(LIST_CTRL
, MyListCtrl::OnSetInfo
)
86 EVT_LIST_ITEM_SELECTED(LIST_CTRL
, MyListCtrl::OnSelected
)
87 EVT_LIST_ITEM_DESELECTED(LIST_CTRL
, MyListCtrl::OnDeselected
)
88 EVT_LIST_KEY_DOWN(LIST_CTRL
, MyListCtrl::OnListKeyDown
)
89 EVT_LIST_ITEM_ACTIVATED(LIST_CTRL
, MyListCtrl::OnActivated
)
90 EVT_LIST_COL_CLICK(LIST_CTRL
, MyListCtrl::OnColClick
)
92 EVT_CHAR(MyListCtrl::OnChar
)
97 int wxCALLBACK
MyCompareFunction(long item1
, long item2
, long sortData
)
100 return item1
< item2
;
103 // `Main program' equivalent, creating windows and returning main app frame
106 // Create the main frame window
107 MyFrame
*frame
= new MyFrame("wxListCtrl Test", 50, 50, 450, 340);
117 // My frame constructor
118 MyFrame::MyFrame(const wxChar
*title
, int x
, int y
, int w
, int h
)
119 : wxFrame((wxFrame
*)NULL
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
121 m_listCtrl
= (MyListCtrl
*) NULL
;
122 m_logWindow
= (wxTextCtrl
*) NULL
;
125 SetIcon( wxICON(mondrian
) );
127 // Make an image list containing large icons
128 m_imageListNormal
= new wxImageList(32, 32, TRUE
);
129 m_imageListSmall
= new wxImageList(16, 16, TRUE
);
132 m_imageListNormal
->Add( wxIcon("icon1", wxBITMAP_TYPE_ICO_RESOURCE
) );
133 m_imageListNormal
->Add( wxIcon("icon2", wxBITMAP_TYPE_ICO_RESOURCE
) );
134 m_imageListNormal
->Add( wxIcon("icon3", wxBITMAP_TYPE_ICO_RESOURCE
) );
135 m_imageListNormal
->Add( wxIcon("icon4", wxBITMAP_TYPE_ICO_RESOURCE
) );
136 m_imageListNormal
->Add( wxIcon("icon5", wxBITMAP_TYPE_ICO_RESOURCE
) );
137 m_imageListNormal
->Add( wxIcon("icon6", wxBITMAP_TYPE_ICO_RESOURCE
) );
138 m_imageListNormal
->Add( wxIcon("icon7", wxBITMAP_TYPE_ICO_RESOURCE
) );
139 m_imageListNormal
->Add( wxIcon("icon8", wxBITMAP_TYPE_ICO_RESOURCE
) );
140 m_imageListNormal
->Add( wxIcon("icon9", wxBITMAP_TYPE_ICO_RESOURCE
) );
142 m_imageListSmall
->Add( wxIcon("iconsmall", wxBITMAP_TYPE_ICO_RESOURCE
) );
145 m_imageListNormal
->Add( wxIcon( toolbrai_xpm
) );
146 m_imageListNormal
->Add( wxIcon( toolchar_xpm
) );
147 m_imageListNormal
->Add( wxIcon( tooldata_xpm
) );
148 m_imageListNormal
->Add( wxIcon( toolnote_xpm
) );
149 m_imageListNormal
->Add( wxIcon( tooltodo_xpm
) );
150 m_imageListNormal
->Add( wxIcon( toolchec_xpm
) );
151 m_imageListNormal
->Add( wxIcon( toolgame_xpm
) );
152 m_imageListNormal
->Add( wxIcon( tooltime_xpm
) );
153 m_imageListNormal
->Add( wxIcon( toolword_xpm
) );
155 m_imageListSmall
->Add( wxIcon( small1_xpm
) );
159 wxMenu
*menuFile
= new wxMenu
;
160 menuFile
->Append(LIST_ABOUT
, _T("&About"));
161 menuFile
->AppendSeparator();
162 menuFile
->Append(LIST_QUIT
, _T("E&xit\tAlt-X"));
164 wxMenu
*menuView
= new wxMenu
;
165 menuView
->Append(LIST_LIST_VIEW
, _T("&List view\tF1"));
166 menuView
->Append(LIST_REPORT_VIEW
, _T("&Report view\tF2"));
167 menuView
->Append(LIST_ICON_VIEW
, _T("&Icon view\tF3"));
168 menuView
->Append(LIST_ICON_TEXT_VIEW
, _T("Icon view with &text\tF4"));
169 menuView
->Append(LIST_SMALL_ICON_VIEW
, _T("&Small icon view\tF5"));
170 menuView
->Append(LIST_SMALL_ICON_TEXT_VIEW
, _T("Small icon &view with text\tF6"));
171 menuView
->Append(LIST_VIRTUAL_VIEW
, _T("Virtual view\tF7"));
173 wxMenu
*menuList
= new wxMenu
;
174 menuList
->Append(LIST_TOGGLE_FIRST
, _T("&Toggle first item\tCtrl-T"));
175 menuList
->Append(LIST_DESELECT_ALL
, _T("&Deselect All\tCtrl-D"));
176 menuList
->Append(LIST_SELECT_ALL
, _T("S&elect All\tCtrl-A"));
177 menuList
->Append(LIST_SHOW_COL_INFO
, _T("Show &column info\tCtrl-C"));
178 menuList
->AppendSeparator();
179 menuList
->Append(LIST_SORT
, _T("&Sort\tCtrl-S"));
180 menuList
->AppendSeparator();
181 menuList
->Append(LIST_DELETE
, _T("&Delete first item"));
182 menuList
->Append(LIST_DELETE_ALL
, _T("Delete &all items"));
183 menuList
->AppendSeparator();
184 menuList
->Append(LIST_TOGGLE_MULTI_SEL
, _T("&Multiple selection\tCtrl-M"),
185 _T("Toggle multiple selection"), TRUE
);
187 wxMenu
*menuCol
= new wxMenu
;
188 menuCol
->Append(LIST_SET_FG_COL
, _T("&Foreground colour..."));
189 menuCol
->Append(LIST_SET_BG_COL
, _T("&Background colour..."));
191 wxMenuBar
*menubar
= new wxMenuBar
;
192 menubar
->Append(menuFile
, _T("&File"));
193 menubar
->Append(menuView
, _T("&View"));
194 menubar
->Append(menuList
, _T("&List"));
195 menubar
->Append(menuCol
, _T("&Colour"));
198 m_listCtrl
= new MyListCtrl(this, LIST_CTRL
,
199 wxDefaultPosition
, wxDefaultSize
,
206 m_logWindow
= new wxTextCtrl(this, -1, wxEmptyString
,
207 wxDefaultPosition
, wxDefaultSize
,
208 wxTE_MULTILINE
| wxSUNKEN_BORDER
);
210 m_logOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_logWindow
));
212 for ( int i
= 0; i
< 30; i
++ )
214 long idx
= m_listCtrl
->InsertItem(i
, wxString::Format(_T("Item %d"), i
));
215 m_listCtrl
->SetItemData(idx
, i
*i
);
223 delete wxLog::SetActiveTarget(m_logOld
);
225 delete m_imageListNormal
;
226 delete m_imageListSmall
;
229 void MyFrame::OnSize(wxSizeEvent
& event
)
234 wxSize size
= GetClientSize();
235 wxCoord y
= (2*size
.y
)/3;
236 m_listCtrl
->SetSize(0, 0, size
.x
, y
);
237 m_logWindow
->SetSize(0, y
+ 1, size
.x
, size
.y
- y
);
242 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
247 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
249 wxMessageDialog
dialog(this, "List test sample\nJulian Smart (c) 1997",
250 "About list test", wxOK
|wxCANCEL
);
255 void MyFrame::OnToggleFirstSel(wxCommandEvent
& WXUNUSED(event
))
257 m_listCtrl
->SetItemState(0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
260 void MyFrame::OnDeselectAll(wxCommandEvent
& WXUNUSED(event
))
262 int n
= m_listCtrl
->GetItemCount();
263 for (int i
= 0; i
< n
; i
++)
264 m_listCtrl
->SetItemState(i
,0,wxLIST_STATE_SELECTED
);
267 void MyFrame::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
269 int n
= m_listCtrl
->GetItemCount();
270 for (int i
= 0; i
< n
; i
++)
271 m_listCtrl
->SetItemState(i
,wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
274 void MyFrame::OnListView(wxCommandEvent
& WXUNUSED(event
))
276 m_listCtrl
->ClearAll();
277 m_logWindow
->Clear();
279 m_listCtrl
->SetSingleStyle(wxLC_LIST
);
280 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_NORMAL
);
281 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_SMALL
);
283 for ( int i
=0; i
< 30; i
++)
285 m_listCtrl
->InsertItem(i
, wxString::Format(_T("Item %d"), i
));
289 void MyFrame::OnReportView(wxCommandEvent
& WXUNUSED(event
))
291 m_logWindow
->Clear();
292 m_listCtrl
->ClearAll();
294 m_listCtrl
->SetSingleStyle(wxLC_REPORT
);
295 m_listCtrl
->SetImageList((wxImageList
*) NULL
, wxIMAGE_LIST_NORMAL
);
296 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
298 m_listCtrl
->InsertColumn(0, "Column 1"); // , wxLIST_FORMAT_LEFT, 140);
299 m_listCtrl
->InsertColumn(1, "Column 2"); // , wxLIST_FORMAT_LEFT, 140);
300 m_listCtrl
->InsertColumn(2, "One More Column (2)"); // , wxLIST_FORMAT_LEFT, 140);
302 // to speed up inserting we hide the control temporarily
308 static const int NUM_ITEMS
= 30;//00;
309 for ( int i
= 0; i
< NUM_ITEMS
; i
++ )
311 buf
.Printf(_T("This is item %d"), i
);
312 long tmp
= m_listCtrl
->InsertItem(i
, buf
, 0);
313 m_listCtrl
->SetItemData(tmp
, i
);
315 buf
.Printf(_T("Col 1, item %d"), i
);
316 tmp
= m_listCtrl
->SetItem(i
, 1, buf
);
318 buf
.Printf(_T("Item %d in column 2"), i
);
319 tmp
= m_listCtrl
->SetItem(i
, 2, buf
);
322 m_logWindow
->WriteText(wxString::Format(_T("%d items inserted in %ldms\n"),
323 NUM_ITEMS
, sw
.Time()));
326 // we leave all mask fields to 0 and only change the colour
329 item
.SetTextColour(*wxRED
);
330 m_listCtrl
->SetItem( item
);
333 item
.SetTextColour(*wxGREEN
);
334 m_listCtrl
->SetItem( item
);
336 item
.SetTextColour(*wxLIGHT_GREY
);
337 item
.SetFont(*wxITALIC_FONT
);
338 item
.SetBackgroundColour(*wxRED
);
339 m_listCtrl
->SetItem( item
);
341 m_listCtrl
->SetTextColour(*wxBLUE
);
342 m_listCtrl
->SetBackgroundColour(*wxLIGHT_GREY
);
344 m_listCtrl
->SetColumnWidth( 0, wxLIST_AUTOSIZE
);
345 m_listCtrl
->SetColumnWidth( 1, wxLIST_AUTOSIZE
);
346 m_listCtrl
->SetColumnWidth( 2, wxLIST_AUTOSIZE
);
349 void MyFrame::OnIconView(wxCommandEvent
& WXUNUSED(event
))
351 m_logWindow
->Clear();
352 m_listCtrl
->ClearAll();
354 m_listCtrl
->SetSingleStyle(wxLC_ICON
);
355 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
356 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
358 for ( int i
=0; i
< 9; i
++)
360 m_listCtrl
->InsertItem(i
, i
);
364 void MyFrame::OnIconTextView(wxCommandEvent
& WXUNUSED(event
))
366 m_logWindow
->Clear();
367 m_listCtrl
->ClearAll();
369 m_listCtrl
->SetSingleStyle(wxLC_ICON
);
370 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
371 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
373 for ( int i
=0; i
< 9; i
++)
376 wxSprintf(buf
, _T("Label %d"), i
);
377 m_listCtrl
->InsertItem(i
, buf
, i
);
381 void MyFrame::OnSmallIconView(wxCommandEvent
& WXUNUSED(event
))
383 m_logWindow
->Clear();
384 m_listCtrl
->ClearAll();
386 m_listCtrl
->SetSingleStyle(wxLC_SMALL_ICON
);
387 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
388 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
390 for ( int i
=0; i
< 9; i
++)
392 m_listCtrl
->InsertItem(i
, 0);
396 void MyFrame::OnSmallIconTextView(wxCommandEvent
& WXUNUSED(event
))
398 m_logWindow
->Clear();
399 m_listCtrl
->ClearAll();
401 m_listCtrl
->SetSingleStyle(wxLC_SMALL_ICON
);
402 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
403 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
405 for ( int i
=0; i
< 9; i
++)
407 m_listCtrl
->InsertItem(i
, "Label", 0);
411 void MyFrame::OnVirtualView(wxCommandEvent
& WXUNUSED(event
))
414 m_logWindow
->Clear();
416 // we really have to recreate it
419 m_listCtrl
= new MyListCtrl(this, LIST_CTRL
,
420 wxDefaultPosition
, wxDefaultSize
,
427 m_listCtrl
->InsertColumn(0, "First Column");
428 m_listCtrl
->InsertColumn(1, "Second Column");
429 m_listCtrl
->SetColumnWidth(0, 150);
430 m_listCtrl
->SetColumnWidth(1, 150);
432 m_listCtrl
->SetItemCount(1000000);
436 wxLogError(_T("Sorry, not implemented"));
440 void MyFrame::OnSort(wxCommandEvent
& WXUNUSED(event
))
444 m_listCtrl
->SortItems(MyCompareFunction
, 0);
446 m_logWindow
->WriteText(wxString::Format(_T("Sorting %d items took %ld ms\n"),
447 m_listCtrl
->GetItemCount(),
451 void MyFrame::OnShowColInfo(wxCommandEvent
& event
)
453 int count
= m_listCtrl
->GetColumnCount();
454 wxLogMessage("%d columns:", count
);
455 for ( int c
= 0; c
< count
; c
++ )
457 wxLogMessage("\tcolumn %d has width %d", c
,
458 m_listCtrl
->GetColumnWidth(c
));
462 void MyFrame::OnUpdateShowColInfo(wxUpdateUIEvent
& event
)
464 event
.Enable( (m_listCtrl
->GetWindowStyleFlag() & wxLC_REPORT
) != 0 );
467 void MyFrame::OnToggleMultiSel(wxCommandEvent
& WXUNUSED(event
))
469 m_logWindow
->WriteText("Current selection mode: ");
471 long flags
= m_listCtrl
->GetWindowStyleFlag();
472 if ( flags
& wxLC_SINGLE_SEL
)
474 m_listCtrl
->SetWindowStyleFlag(flags
& ~wxLC_SINGLE_SEL
);
475 m_logWindow
->WriteText("multiple");
479 m_listCtrl
->SetWindowStyleFlag(flags
| wxLC_SINGLE_SEL
);
480 m_logWindow
->WriteText("single");
483 m_logWindow
->WriteText("\nRecreate the control now\n");
486 void MyFrame::OnSetFgColour(wxCommandEvent
& WXUNUSED(event
))
488 m_listCtrl
->SetForegroundColour(wxGetColourFromUser(this));
489 m_listCtrl
->Refresh();
492 void MyFrame::OnSetBgColour(wxCommandEvent
& WXUNUSED(event
))
494 m_listCtrl
->SetBackgroundColour(wxGetColourFromUser(this));
495 m_listCtrl
->Refresh();
498 void MyFrame::OnDelete(wxCommandEvent
& WXUNUSED(event
))
500 if ( m_listCtrl
->GetItemCount() )
502 m_listCtrl
->DeleteItem(0);
506 m_logWindow
->WriteText("Nothing to delete");
510 void MyFrame::OnDeleteAll(wxCommandEvent
& WXUNUSED(event
))
514 m_listCtrl
->DeleteAllItems();
516 m_logWindow
->WriteText(wxString::Format(_T("Deleting %d items took %ld ms\n"),
517 m_listCtrl
->GetItemCount(),
523 void MyListCtrl::OnColClick(wxListEvent
& event
)
525 wxLogMessage( "OnColumnClick at %d.", event
.GetColumn() );
528 void MyListCtrl::OnBeginDrag(wxListEvent
& event
)
530 wxLogMessage( "OnBeginDrag at %d,%d.",
531 event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
534 void MyListCtrl::OnBeginRDrag(wxListEvent
& event
)
536 wxLogMessage( "OnBeginRDrag at %d,%d.",
537 event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
540 void MyListCtrl::OnBeginLabelEdit(wxListEvent
& event
)
542 wxLogMessage("OnBeginLabelEdit: %s", event
.m_item
.m_text
.c_str());
545 void MyListCtrl::OnEndLabelEdit(wxListEvent
& event
)
547 wxLogMessage("OnEndLabelEdit: %s", event
.m_item
.m_text
.c_str());
550 void MyListCtrl::OnDeleteItem(wxListEvent
& event
)
552 LogEvent(event
, _T("OnDeleteItem"));
555 void MyListCtrl::OnDeleteAllItems(wxListEvent
& event
)
557 LogEvent(event
, _T("OnDeleteAllItems"));
560 void MyListCtrl::OnGetInfo(wxListEvent
& event
)
564 msg
<< "OnGetInfo (" << event
.m_item
.m_itemId
<< ", " << event
.m_item
.m_col
<< ")";
565 if ( event
.m_item
.m_mask
& wxLIST_MASK_STATE
)
566 msg
<< " wxLIST_MASK_STATE";
567 if ( event
.m_item
.m_mask
& wxLIST_MASK_TEXT
)
568 msg
<< " wxLIST_MASK_TEXT";
569 if ( event
.m_item
.m_mask
& wxLIST_MASK_IMAGE
)
570 msg
<< " wxLIST_MASK_IMAGE";
571 if ( event
.m_item
.m_mask
& wxLIST_MASK_DATA
)
572 msg
<< " wxLIST_MASK_DATA";
573 if ( event
.m_item
.m_mask
& wxLIST_SET_ITEM
)
574 msg
<< " wxLIST_SET_ITEM";
575 if ( event
.m_item
.m_mask
& wxLIST_MASK_WIDTH
)
576 msg
<< " wxLIST_MASK_WIDTH";
577 if ( event
.m_item
.m_mask
& wxLIST_MASK_FORMAT
)
578 msg
<< " wxLIST_MASK_WIDTH";
580 if ( event
.m_item
.m_mask
& wxLIST_MASK_TEXT
)
582 event
.m_item
.m_text
= "My callback text";
588 void MyListCtrl::OnSetInfo(wxListEvent
& event
)
590 LogEvent(event
, _T("OnSetInfo"));
593 void MyListCtrl::OnSelected(wxListEvent
& event
)
595 LogEvent(event
, _T("OnSelected"));
597 if ( GetWindowStyle() & wxLC_REPORT
)
600 info
.m_itemId
= event
.m_itemIndex
;
602 info
.m_mask
= wxLIST_MASK_TEXT
;
605 wxLogMessage("Value of the 2nd field of the selected item: %s",
606 info
.m_text
.c_str());
610 wxFAIL_MSG("wxListCtrl::GetItem() failed");
615 void MyListCtrl::OnDeselected(wxListEvent
& event
)
617 LogEvent(event
, _T("OnDeselected"));
620 void MyListCtrl::OnActivated(wxListEvent
& event
)
622 LogEvent(event
, _T("OnActivated"));
625 void MyListCtrl::OnListKeyDown(wxListEvent
& event
)
627 LogEvent(event
, _T("OnListKeyDown"));
632 void MyListCtrl::OnChar(wxKeyEvent
& event
)
634 wxLogMessage(_T("Got char event."));
639 void MyListCtrl::LogEvent(const wxListEvent
& event
, const wxChar
*eventName
)
641 wxLogMessage(_T("Item %ld: %s (item text = %s, data = %ld)"),
642 event
.GetIndex(), eventName
,
643 event
.GetText().c_str(), event
.GetData());
646 wxString
MyListCtrl::OnGetItemText(long item
, long column
) const
648 return wxString::Format(_T("Column %ld of item %ld"), column
, item
);
651 int MyListCtrl::OnGetItemImage(long item
) const