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
m_imageListSmall = new wxImageList(16, 16, TRUE);
#ifdef __WXMSW__
- m_imageListNormal->Add( wxIcon("icon1", wxBITMAP_TYPE_ICO_RESOURCE) );
- m_imageListNormal->Add( wxIcon("icon2", wxBITMAP_TYPE_ICO_RESOURCE) );
- m_imageListNormal->Add( wxIcon("icon3", wxBITMAP_TYPE_ICO_RESOURCE) );
- m_imageListNormal->Add( wxIcon("icon4", wxBITMAP_TYPE_ICO_RESOURCE) );
- m_imageListNormal->Add( wxIcon("icon5", wxBITMAP_TYPE_ICO_RESOURCE) );
- m_imageListNormal->Add( wxIcon("icon6", wxBITMAP_TYPE_ICO_RESOURCE) );
- m_imageListNormal->Add( wxIcon("icon7", wxBITMAP_TYPE_ICO_RESOURCE) );
- m_imageListNormal->Add( wxIcon("icon8", wxBITMAP_TYPE_ICO_RESOURCE) );
- m_imageListNormal->Add( wxIcon("icon9", wxBITMAP_TYPE_ICO_RESOURCE) );
-
- m_imageListSmall->Add( wxIcon("iconsmall", wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon1"), wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon2"), wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon3"), wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon4"), wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon5"), wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon6"), wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon7"), wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon8"), wxBITMAP_TYPE_ICO_RESOURCE) );
+ m_imageListNormal->Add( wxIcon(_T("icon9"), wxBITMAP_TYPE_ICO_RESOURCE) );
+
+ m_imageListSmall->Add( wxIcon(_T("iconsmall"), wxBITMAP_TYPE_ICO_RESOURCE) );
#else
m_imageListNormal->Add( wxIcon( toolbrai_xpm ) );
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);
{
m_listCtrl->SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
- // under MSW for SetColumnWidth() to work we need to create the items with
- // images initially
-#if 1
+ // note that under MSW for SetColumnWidth() to work we need to create the
+ // items with images initially even if we specify dummy image id
wxListItem itemCol;
- itemCol.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_IMAGE;
- itemCol.m_text = _T("Column 1");
- itemCol.m_image = -1;
+ itemCol.SetText(_T("Column 1"));
+ itemCol.SetImage(-1);
m_listCtrl->InsertColumn(0, itemCol);
- itemCol.m_text = _T("Column 2");
+
+ itemCol.SetText(_T("Column 2"));
+ itemCol.SetAlign(wxLIST_FORMAT_CENTRE);
m_listCtrl->InsertColumn(1, itemCol);
- itemCol.m_text = _T("Column 3");
+
+ itemCol.SetText(_T("Column 3"));
+ itemCol.SetAlign(wxLIST_FORMAT_RIGHT);
m_listCtrl->InsertColumn(2, itemCol);
-#else
- m_listCtrl->InsertColumn(0, _T("Column 1")); // , wxLIST_FORMAT_LEFT, 140);
- m_listCtrl->InsertColumn(1, _T("Column 2")); // , wxLIST_FORMAT_LEFT, 140);
- m_listCtrl->InsertColumn(2, _T("One More Column (2)")); // , wxLIST_FORMAT_LEFT, 140);
-#endif
// to speed up inserting we hide the control temporarily
m_listCtrl->Hide();
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::OnListKeyDown(wxListEvent& event)
{
- switch ( event.GetCode() )
+ switch ( event.GetKeyCode() )
{
case 'c': // colorize
case 'C':