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
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);
{
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);
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);
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)
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':