fixed bug with deletion of several last items in wxListCtrl, added tests for it in the sample

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11162 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-07-23 14:57:01 +00:00
parent d9ff0f91fb
commit 91c6cc0e71
2 changed files with 34 additions and 19 deletions

View File

@@ -2403,7 +2403,7 @@ void wxListMainWindow::RefreshLines( size_t lineFrom, size_t lineTo )
rect.x = 0;
rect.y = GetLineY(lineFrom);
rect.width = GetClientSize().x;
rect.height = GetLineY(lineTo) - rect.y;
rect.height = GetLineY(lineTo) - rect.y + GetLineHeight();
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
RefreshRect( rect );
@@ -2486,11 +2486,15 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
CalcUnscrolledPosition(0, 0, &xOrig, &yOrig);
// tell the caller cache to cache the data
wxListEvent evCache(wxEVT_COMMAND_LIST_CACHE_HINT, GetParent()->GetId());
evCache.SetEventObject( GetParent() );
evCache.m_oldItemIndex = visibleFrom;
evCache.m_itemIndex = visibleTo;
GetParent()->GetEventHandler()->ProcessEvent( evCache );
if ( IsVirtual() )
{
wxListEvent evCache(wxEVT_COMMAND_LIST_CACHE_HINT,
GetParent()->GetId());
evCache.SetEventObject( GetParent() );
evCache.m_oldItemIndex = visibleFrom;
evCache.m_itemIndex = visibleTo;
GetParent()->GetEventHandler()->ProcessEvent( evCache );
}
for ( size_t line = visibleFrom; line <= visibleTo; line++ )
{
@@ -2608,7 +2612,12 @@ void wxListMainWindow::SendNotify( size_t line,
if ( point != wxDefaultPosition )
le.m_pointDrag = point;
GetLine(line)->GetItem( 0, le.m_item );
if ( command != wxEVT_COMMAND_LIST_DELETE_ITEM )
{
GetLine(line)->GetItem( 0, le.m_item );
}
//else: there may be no more such item
GetParent()->GetEventHandler()->ProcessEvent( le );
}
@@ -3796,20 +3805,12 @@ void wxListMainWindow::DeleteItem( long lindex )
size_t index = (size_t)lindex;
m_dirty = TRUE;
// select the next item when the selected one is deleted
if ( m_current == index )
if ( m_current >= index )
{
// the last valid index after deleting the item will be count-2
if ( m_current == count - 1 )
{
m_current--;
}
m_current--;
}
SendNotify( index, wxEVT_COMMAND_LIST_DELETE_ITEM );
if ( InReportView() )
{
ResetVisibleLinesRange();
@@ -3827,6 +3828,9 @@ void wxListMainWindow::DeleteItem( long lindex )
}
m_dirty = TRUE;
SendNotify( index, wxEVT_COMMAND_LIST_DELETE_ITEM );
RefreshAfter(index);
}