#include "wx/wx.h"
#endif
-#ifndef __WXMSW__
+#if !defined(__WXMSW__) && !defined(__WXPM__)
#include "mondrian.xpm"
+#endif
+#ifndef __WXMSW__
#include "bitmaps/toolbrai.xpm"
#include "bitmaps/toolchar.xpm"
#include "bitmaps/tooldata.xpm"
EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
- EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
+ EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
m_listCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE );
+
+ // test SetItemFont too
+ m_listCtrl->SetItemFont(0, *wxITALIC_FONT);
}
void MyFrame::InitWithIconItems(bool withText, bool sameIcon)
void MyListCtrl::OnColClick(wxListEvent& event)
{
int col = event.GetColumn();
- SetColumnImage(col, 0);
+
+ // set or unset image
+ static bool x = false;
+ x = !x;
+ SetColumnImage(col, x ? 0 : -1);
wxLogMessage( wxT("OnColumnClick at %d."), col );
}
// Show popupmenu at position
wxMenu menu(wxT("Test"));
menu.Append(LIST_ABOUT, _T("&About"));
- PopupMenu(&menu, event.GetPoint());
+ PopupMenu(&menu, event.GetPoint());
wxLogMessage( wxT("OnColumnRightClick at %d."), event.GetColumn() );
}
void MyListCtrl::OnListKeyDown(wxListEvent& event)
{
+ long item;
+
switch ( event.GetKeyCode() )
{
case 'c': // colorize
case 'n': // next
case 'N':
+ item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
+ if ( item++ == GetItemCount() - 1 )
+ {
+ item = 0;
+ }
+
+ wxLogMessage(_T("Focusing item %ld"), item);
+
+ SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
+ EnsureVisible(item);
+ break;
+
+ case 'r': // show bounding Rect
+ case 'R':
{
- long item = GetNextItem(-1,
- wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
- if ( item++ == GetItemCount() - 1 )
+ item = event.GetIndex();
+ wxRect r;
+ if ( !GetItemRect(item, r) )
{
- item = 0;
+ wxLogError(_T("Failed to retrieve rect of item %ld"), item);
+ break;
}
- wxLogMessage(_T("Focusing item %ld"), item);
-
- SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
- EnsureVisible(item);
+ wxLogMessage(_T("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
+ item, r.x, r.y, r.x + r.width, r.y + r.height);
}
break;
case WXK_DELETE:
+ item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ while ( item != -1 )
{
- long item = GetNextItem(-1,
- wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- while ( item != -1 )
- {
- DeleteItem(item);
+ DeleteItem(item);
- wxLogMessage(_T("Item %ld deleted"), item);
+ wxLogMessage(_T("Item %ld deleted"), item);
- // -1 because the indices were shifted by DeleteItem()
- item = GetNextItem(item - 1,
- wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- }
+ // -1 because the indices were shifted by DeleteItem()
+ item = GetNextItem(item - 1,
+ wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
}
break;
buf.Printf(_T("Item %d in column 2"), i);
SetItem(i, 2, buf);
}
-