X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/efe23391ab9462d85e35493f4727a1c0a7f69444..c31752dadfe04a196339ee6c592d9971b87539c9:/samples/listctrl/listtest.cpp?ds=sidebyside diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index 40a0d7655e..3777ac5c16 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -117,7 +117,9 @@ static const int NUM_ICONS = 9; int wxCALLBACK MyCompareFunction(long item1, long item2, long sortData) { // inverse the order - return item1 < item2; + if (item1 < item2) return -1; + if (item1 > item2) return 1; + return 0; } // `Main program' equivalent, creating windows and returning main app frame @@ -223,7 +225,8 @@ MyFrame::MyFrame(const wxChar *title, int x, int y, int w, int h) menubar->Append(menuCol, _T("&Colour")); SetMenuBar(menubar); - m_logWindow = new wxTextCtrl(this, -1, wxEmptyString, + m_panel = new wxPanel(this, -1); + m_logWindow = new wxTextCtrl(m_panel, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxSUNKEN_BORDER); @@ -328,7 +331,7 @@ void MyFrame::RecreateList(long flags, bool withText) { delete m_listCtrl; - m_listCtrl = new MyListCtrl(this, LIST_CTRL, + m_listCtrl = new MyListCtrl(m_panel, LIST_CTRL, wxDefaultPosition, wxDefaultSize, flags | wxSUNKEN_BORDER | wxLC_EDIT_LABELS); @@ -491,6 +494,8 @@ void MyFrame::OnVirtualView(wxCommandEvent& WXUNUSED(event)) void MyFrame::InitWithVirtualItems() { + m_listCtrl->SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL); + m_listCtrl->InsertColumn(0, _T("First Column")); m_listCtrl->InsertColumn(1, _T("Second Column")); m_listCtrl->SetColumnWidth(0, 150); @@ -656,19 +661,30 @@ void MyListCtrl::OnColRightClick(wxListEvent& event) wxLogMessage( wxT("OnColumnRightClick at %d."), event.GetColumn() ); } +void MyListCtrl::LogColEvent(const wxListEvent& event, const wxChar *name) +{ + const int col = event.GetColumn(); + + wxLogMessage(wxT("%s: column %d (width = %d or %d)."), + name, + col, + event.GetItem().GetWidth(), + GetColumnWidth(col)); +} + void MyListCtrl::OnColBeginDrag(wxListEvent& event) { - wxLogMessage( wxT("OnColBeginDrag: column %d."), event.GetColumn() ); + LogColEvent( event, wxT("OnColBeginDrag") ); } void MyListCtrl::OnColDragging(wxListEvent& event) { - wxLogMessage( wxT("OnColDragging: column %d."), event.GetColumn() ); + LogColEvent( event, wxT("OnColDragging") ); } void MyListCtrl::OnColEndDrag(wxListEvent& event) { - wxLogMessage( wxT("OnColEndDrag: column %d."), event.GetColumn() ); + LogColEvent( event, wxT("OnColEndDrag") ); } void MyListCtrl::OnBeginDrag(wxListEvent& event) @@ -774,11 +790,13 @@ void MyListCtrl::OnActivated(wxListEvent& event) void MyListCtrl::OnFocused(wxListEvent& event) { LogEvent(event, _T("OnFocused")); + + event.Skip(); } void MyListCtrl::OnListKeyDown(wxListEvent& event) { - switch ( event.GetCode() ) + switch ( event.GetKeyCode() ) { case 'c': // colorize case 'C':