Avoid bool argument in wxListMainWindow::RecalculatePositions()

Use 2 separate functions instead to make the code more clear, as passing
false for indicate the refresh shouldn't be done was quite confusing.

Also get rid of a separate RefreshAll() which was called only from
RecalculatePositions().

No real changes.
This commit is contained in:
Vadim Zeitlin
2021-08-06 21:09:29 +02:00
parent 36e9576d42
commit d8fe06891e
2 changed files with 16 additions and 19 deletions

View File

@@ -695,10 +695,10 @@ public:
{ return m_small_image_list; } { return m_small_image_list; }
// set the scrollbars and update the positions of the items // set the scrollbars and update the positions of the items
void RecalculatePositions(bool noRefresh = false); void RecalculatePositions();
// refresh the window and the header // do the same thing and also call Refresh()
void RefreshAll(); void RecalculatePositionsAndRefresh();
long GetNextItem( long item, int geometry, int state ) const; long GetNextItem( long item, int geometry, int state ) const;
void DeleteItem( long index ); void DeleteItem( long index );

View File

@@ -2061,7 +2061,7 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{ {
// Calling Refresh() from inside OnPaint() doesn't work under macOS, so // Calling Refresh() from inside OnPaint() doesn't work under macOS, so
// don't do it immediately... // don't do it immediately...
RecalculatePositions(true /* no refresh */); RecalculatePositions();
// ... but schedule it for later. // ... but schedule it for later.
CallAfter(&wxWindow::Refresh, true, (const wxRect*)NULL); CallAfter(&wxWindow::Refresh, true, (const wxRect*)NULL);
@@ -3873,8 +3873,7 @@ wxListMainWindow::GetSubItemRect(long item, long subItem, wxRect& rect,
// ensure that we're laid out, otherwise we could return nonsense // ensure that we're laid out, otherwise we could return nonsense
if ( m_dirty ) if ( m_dirty )
{ {
wxConstCast(this, wxListMainWindow)-> wxConstCast(this, wxListMainWindow)->RecalculatePositions();
RecalculatePositions(true /* no refresh */);
} }
rect = GetLineRect((size_t)item); rect = GetLineRect((size_t)item);
@@ -4009,7 +4008,7 @@ bool wxListMainWindow::IsInsideCheckBox(long item, int x, int y)
// geometry calculation // geometry calculation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxListMainWindow::RecalculatePositions(bool noRefresh) void wxListMainWindow::RecalculatePositions()
{ {
const int lineHeight = GetLineHeight(); const int lineHeight = GetLineHeight();
@@ -4217,15 +4216,13 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
} }
} }
if ( !noRefresh ) m_dirty = false;
{
RefreshAll();
}
} }
void wxListMainWindow::RefreshAll() void wxListMainWindow::RecalculatePositionsAndRefresh()
{ {
m_dirty = false; RecalculatePositions();
Refresh(); Refresh();
wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin; wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin;
@@ -4449,7 +4446,7 @@ void wxListMainWindow::DeleteAllItems()
{ {
DoDeleteAllItems(); DoDeleteAllItems();
RecalculatePositions(); RecalculatePositionsAndRefresh();
} }
void wxListMainWindow::DeleteEverything() void wxListMainWindow::DeleteEverything()
@@ -4472,7 +4469,7 @@ void wxListMainWindow::EnsureVisible( long index )
// We have to call this here because the label in question might just have // We have to call this here because the label in question might just have
// been added and its position is not known yet // been added and its position is not known yet
if ( m_dirty ) if ( m_dirty )
RecalculatePositions(true /* no refresh */); RecalculatePositions();
MoveToItem((size_t)index); MoveToItem((size_t)index);
} }
@@ -5649,7 +5646,7 @@ void wxGenericListCtrl::OnSize(wxSizeEvent& WXUNUSED(event))
Layout(); Layout();
m_mainWin->RecalculatePositions(); m_mainWin->RecalculatePositionsAndRefresh();
AdjustScrollbars(); AdjustScrollbars();
} }
@@ -5659,7 +5656,7 @@ void wxGenericListCtrl::OnInternalIdle()
wxWindow::OnInternalIdle(); wxWindow::OnInternalIdle();
if (m_mainWin->m_dirty) if (m_mainWin->m_dirty)
m_mainWin->RecalculatePositions(); m_mainWin->RecalculatePositionsAndRefresh();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -5804,7 +5801,7 @@ wxSize wxGenericListCtrl::DoGetBestClientSize() const
// If we have the scrollbars we need to account for them too. And to // If we have the scrollbars we need to account for them too. And to
// make sure the scrollbars status is up to date we need to call this // make sure the scrollbars status is up to date we need to call this
// function to set them. // function to set them.
m_mainWin->RecalculatePositions(true /* no refresh */); m_mainWin->RecalculatePositions();
// Unfortunately we can't use wxWindow::HasScrollbar() here as we need // Unfortunately we can't use wxWindow::HasScrollbar() here as we need
// to use m_mainWin client/virtual size for determination of whether we // to use m_mainWin client/virtual size for determination of whether we
@@ -5905,7 +5902,7 @@ void wxGenericListCtrl::Update()
if ( m_mainWin ) if ( m_mainWin )
{ {
if ( m_mainWin->m_dirty ) if ( m_mainWin->m_dirty )
m_mainWin->RecalculatePositions(); m_mainWin->RecalculatePositionsAndRefresh();
m_mainWin->Update(); m_mainWin->Update();
} }