X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/614391dc087ca70b145e07c442815217f8aa3162..0147a7c1409829913d5cdfc29d3d1588f29c64cb:/src/generic/listctrl.cpp diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 1b48ff05de..fa1cc35090 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -819,6 +819,9 @@ private: // initialize the current item if needed void UpdateCurrent(); + // delete all items but don't refresh: called from dtor + void DoDeleteAllItems(); + // called when an item is [un]focuded, i.e. becomes [not] current // // currently unused @@ -2159,7 +2162,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxListMainWindow::~wxListMainWindow() { - DeleteEverything(); + DoDeleteAllItems(); delete m_highlightBrush; @@ -2482,6 +2485,13 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) wxCoord xOrig, yOrig; 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 ); + for ( size_t line = visibleFrom; line <= visibleTo; line++ ) { rectLine = GetLineRect(line); @@ -3542,7 +3552,8 @@ void wxListMainWindow::SetItemCount(long count) ResetVisibleLinesRange(); - Refresh(); + // scrollbars must be reset + m_dirty = TRUE; } int wxListMainWindow::GetSelectedItemCount() @@ -3601,9 +3612,6 @@ bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) void wxListMainWindow::RecalculatePositions() { - if ( IsEmpty() ) - return; - wxClientDC dc( this ); dc.SetFont( GetFont() ); @@ -3832,7 +3840,7 @@ void wxListMainWindow::DeleteColumn( int col ) m_columns.DeleteNode( node ); } -void wxListMainWindow::DeleteAllItems() +void wxListMainWindow::DoDeleteAllItems() { if ( IsEmpty() ) { @@ -3864,11 +3872,13 @@ void wxListMainWindow::DeleteAllItems() } m_lines.Clear(); +} - // NB: don't just set m_dirty to TRUE here as RecalculatePositions() - // doesn't do anything if the control is empty and so we won't be - // refreshed - Refresh(); +void wxListMainWindow::DeleteAllItems() +{ + DoDeleteAllItems(); + + RecalculatePositions(); } void wxListMainWindow::DeleteEverything()