more wxListCtrl fixes: inserting/deleting items now works again (tested in the sample) but I somehow broke the scrolling

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10914 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-07-09 15:58:24 +00:00
parent 371684d3f7
commit 5cd891743e
3 changed files with 286 additions and 246 deletions

View File

@@ -354,18 +354,9 @@ void MyFrame::InitWithReportItems()
wxStopWatch sw;
wxString buf;
for ( int i = 0; i < NUM_ITEMS; i++ )
{
buf.Printf(_T("This is item %d"), i);
long tmp = m_listCtrl->InsertItem(i, buf, 0);
m_listCtrl->SetItemData(tmp, i);
buf.Printf(_T("Col 1, item %d"), i);
tmp = m_listCtrl->SetItem(i, 1, buf);
buf.Printf(_T("Item %d in column 2"), i);
tmp = m_listCtrl->SetItem(i, 2, buf);
m_listCtrl->InsertItemInReportView(i);
}
m_logWindow->WriteText(wxString::Format(_T("%d items inserted in %ldms\n"),
@@ -664,9 +655,33 @@ void MyListCtrl::OnActivated(wxListEvent& event)
void MyListCtrl::OnListKeyDown(wxListEvent& event)
{
LogEvent(event, _T("OnListKeyDown"));
switch ( event.GetCode() )
{
case WXK_DELETE:
DeleteItem(event.GetIndex());
event.Skip();
wxLogMessage(_T("Item %d deleted"), event.GetIndex());
break;
case WXK_INSERT:
if ( GetWindowStyle() & wxLC_REPORT )
{
if ( GetWindowStyle() & wxLC_VIRTUAL )
{
SetItemCount(GetItemCount() + 1);
}
else // !virtual
{
InsertItemInReportView(event.GetIndex());
}
}
//else: fall through
default:
LogEvent(event, _T("OnListKeyDown"));
event.Skip();
}
}
void MyListCtrl::OnChar(wxKeyEvent& event)
@@ -693,3 +708,17 @@ int MyListCtrl::OnGetItemImage(long item) const
return 0;
}
void MyListCtrl::InsertItemInReportView(int i)
{
wxString buf;
buf.Printf(_T("This is item %d"), i);
long tmp = InsertItem(i, buf, 0);
SetItemData(tmp, i);
buf.Printf(_T("Col 1, item %d"), i);
SetItem(i, 1, buf);
buf.Printf(_T("Item %d in column 2"), i);
SetItem(i, 2, buf);
}