Avoid useless iteration on all pages in wxBookCtrlBase::DoGetBestSize().

If m_fitToCurrentPage is true, there is no need to iterate over all the pages
computing their max best size only in order to overwrite it with the best size
of the current page later.

This doesn't result in any changes in the behaviour, just avoids useless best
size computations.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72561 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-27 12:46:53 +00:00
parent 4fcad4fb6d
commit e67e249752

View File

@@ -137,26 +137,30 @@ wxSize wxBookCtrlBase::DoGetBestSize() const
{
wxSize bestSize;
// iterate over all pages, get the largest width and height
const size_t nCount = m_pages.size();
for ( size_t nPage = 0; nPage < nCount; nPage++ )
if (m_fitToCurrentPage && GetCurrentPage())
{
const wxWindow * const pPage = m_pages[nPage];
if( pPage )
bestSize = GetCurrentPage()->GetBestSize();
}
else
{
// iterate over all pages, get the largest width and height
const size_t nCount = m_pages.size();
for ( size_t nPage = 0; nPage < nCount; nPage++ )
{
wxSize childBestSize(pPage->GetBestSize());
const wxWindow * const pPage = m_pages[nPage];
if( pPage )
{
wxSize childBestSize(pPage->GetBestSize());
if ( childBestSize.x > bestSize.x )
bestSize.x = childBestSize.x;
if ( childBestSize.x > bestSize.x )
bestSize.x = childBestSize.x;
if ( childBestSize.y > bestSize.y )
bestSize.y = childBestSize.y;
if ( childBestSize.y > bestSize.y )
bestSize.y = childBestSize.y;
}
}
}
if (m_fitToCurrentPage && GetCurrentPage())
bestSize = GetCurrentPage()->GetBestSize();
// convert display area to window area, adding the size necessary for the
// tabs
wxSize best = CalcSizeFromPage(bestSize);