X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/850ed6e7b0aa954018746242a867038ede62481f..a132a1c810bea2d37b09f01524b57440c968de1c:/src/generic/listctrl.cpp?ds=inline diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index dcbe8a8965..fa1cc35090 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -100,6 +100,7 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT) // ---------------------------------------------------------------------------- // constants @@ -818,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 @@ -2158,7 +2162,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxListMainWindow::~wxListMainWindow() { - DeleteEverything(); + DoDeleteAllItems(); delete m_highlightBrush; @@ -2481,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); @@ -3541,7 +3552,8 @@ void wxListMainWindow::SetItemCount(long count) ResetVisibleLinesRange(); - Refresh(); + // scrollbars must be reset + m_dirty = TRUE; } int wxListMainWindow::GetSelectedItemCount() @@ -3600,9 +3612,6 @@ bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) void wxListMainWindow::RecalculatePositions() { - if ( IsEmpty() ) - return; - wxClientDC dc( this ); dc.SetFont( GetFont() ); @@ -3831,7 +3840,7 @@ void wxListMainWindow::DeleteColumn( int col ) m_columns.DeleteNode( node ); } -void wxListMainWindow::DeleteAllItems() +void wxListMainWindow::DoDeleteAllItems() { if ( IsEmpty() ) { @@ -3863,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()