EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
+ EVT_MENU(LIST_SHOW_VIEW_RECT, MyFrame::OnShowViewRect)
EVT_MENU(LIST_FREEZE, MyFrame::OnFreeze)
EVT_MENU(LIST_THAW, MyFrame::OnThaw)
EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
menuList->AppendSeparator();
menuList->Append(LIST_SHOW_COL_INFO, _T("Show &column info\tCtrl-C"));
menuList->Append(LIST_SHOW_SEL_INFO, _T("Show &selected items\tCtrl-S"));
+ menuList->Append(LIST_SHOW_VIEW_RECT, _T("Show &view rect"));
menuList->AppendSeparator();
- menuList->Append(LIST_SORT, _T("&Sort\tCtrl-S"));
+ menuList->Append(LIST_SORT, _T("Sor&t\tCtrl-T"));
menuList->AppendSeparator();
menuList->Append(LIST_ADD, _T("&Append an item\tCtrl-P"));
menuList->Append(LIST_EDIT, _T("&Edit the item\tCtrl-E"));
}
}
+void MyFrame::OnShowViewRect(wxCommandEvent& WXUNUSED(event))
+{
+ const wxRect r = m_listCtrl->GetViewRect();
+ wxLogMessage("View rect: (%d, %d)-(%d, %d)",
+ r.GetLeft(), r.GetTop(), r.GetRight(), r.GetBottom());
+}
+
void MyFrame::OnShowColInfo(wxCommandEvent& WXUNUSED(event))
{
int count = m_listCtrl->GetColumnCount();
}
break;
+ case '1': // show sub item bounding rectangle
+ case '2':
+ case '3':
+ case '4': // this column is invalid but we want to test it too
+ if ( InReportView() )
+ {
+ int subItem = event.GetKeyCode() - '1';
+ item = event.GetIndex();
+ wxRect r;
+ if ( !GetSubItemRect(item, subItem, r) )
+ {
+ wxLogError(_T("Failed to retrieve rect of item %ld column %d"), item, subItem + 1);
+ break;
+ }
+
+ wxLogMessage(_T("Bounding rect of item %ld column %d is (%d, %d)-(%d, %d)"),
+ item, subItem + 1,
+ r.x, r.y, r.x + r.width, r.y + r.height);
+ }
+ break;
+
case 'U': // update
if ( !IsVirtual() )
break;
}
break;
- case WXK_DELETE:
+ case 'D': // delete
item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while ( item != -1 )
{
}
break;
- case WXK_INSERT:
+ case 'I': // insert
if ( GetWindowStyle() & wxLC_REPORT )
{
if ( GetWindowStyle() & wxLC_VIRTUAL )
case 'R':
case 'u':
case 'U':
- case WXK_DELETE:
- case WXK_INSERT:
+ case 'd':
+ case 'D':
+ case 'i':
+ case 'I':
// these are the keys we process ourselves
break;
#if USE_CONTEXT_MENU
void MyListCtrl::OnContextMenu(wxContextMenuEvent& event)
{
- wxPoint point = event.GetPosition();
- // If from keyboard
- if (point.x == -1 && point.y == -1) {
- wxSize size = GetSize();
- point.x = size.x / 2;
- point.y = size.y / 2;
- } else {
- point = ScreenToClient(point);
+ if (GetEditControl() == NULL)
+ {
+ wxPoint point = event.GetPosition();
+ // If from keyboard
+ if ( (point.x == -1) && (point.y == -1) )
+ {
+ wxSize size = GetSize();
+ point.x = size.x / 2;
+ point.y = size.y / 2;
+ }
+ else
+ {
+ point = ScreenToClient(point);
+ }
+ ShowContextMenu(point);
+ }
+ else
+ {
+ // the user is editing:
+ // allow the text control to display its context menu
+ // if it has one (it has on Windows) rather than display our one
+ event.Skip();
}
- ShowContextMenu(point);
}
#endif