Don't call CacheBestSize() from DoGetBestSize() implementations

This is unnecessary, wxWindow::GetBestSize() already does this, so calling it
from DoGetBestSize() called by it too is just useless.
This commit is contained in:
Vadim Zeitlin
2016-04-03 17:46:44 +02:00
parent c1cd1e01b5
commit 25c9b032a8
36 changed files with 23 additions and 97 deletions

View File

@@ -146,9 +146,7 @@ wxSize wxBookCtrlBase::DoGetBestSize() const
// convert display area to window area, adding the size necessary for the // convert display area to window area, adding the size necessary for the
// tabs // tabs
wxSize best = CalcSizeFromPage(bestSize); return CalcSizeFromPage(bestSize);
CacheBestSize(best);
return best;
} }
wxRect wxBookCtrlBase::GetPageRect() const wxRect wxBookCtrlBase::GetPageRect() const

View File

@@ -584,15 +584,9 @@ wxStaticBitmapBase::~wxStaticBitmapBase()
wxSize wxStaticBitmapBase::DoGetBestSize() const wxSize wxStaticBitmapBase::DoGetBestSize() const
{ {
wxSize best; // the fall back size is completely arbitrary
wxBitmap bmp = GetBitmap(); const wxBitmap bmp = GetBitmap();
if ( bmp.IsOk() ) return bmp.IsOk() ? bmp.GetScaledSize() : wxSize(16, 16);
best = bmp.GetScaledSize();
else
// this is completely arbitrary
best = wxSize(16, 16);
CacheBestSize(best);
return best;
} }
#endif // wxUSE_STATBMP #endif // wxUSE_STATBMP

View File

@@ -279,14 +279,9 @@ wxSize wxTreeCtrlBase::DoGetBestSize() const
// need some minimal size even for empty tree // need some minimal size even for empty tree
if ( !size.x || !size.y ) if ( !size.x || !size.y )
size = wxControl::DoGetBestSize(); size = wxControl::DoGetBestSize();
else else // add border size
{
// Add border size
size += GetWindowBorderSize(); size += GetWindowBorderSize();
CacheBestSize(size);
}
return size; return size;
} }

View File

@@ -278,8 +278,6 @@ wxSize wxBitmapComboBox::DoGetBestSize() const
if ( h2 > sz.y ) if ( h2 > sz.y )
sz.y = h2; sz.y = h2;
CacheBestSize(sz);
} }
return sz; return sz;

View File

@@ -709,8 +709,6 @@ wxSize wxGenericCalendarCtrl::DoGetBestSize() const
best += GetWindowBorderSize(); best += GetWindowBorderSize();
} }
CacheBestSize(best);
return best; return best;
} }

View File

@@ -135,11 +135,9 @@ wxSize wxHeaderCtrl::DoGetBestSize() const
// the vertical size is rather arbitrary but it looks better if we leave // the vertical size is rather arbitrary but it looks better if we leave
// some space around the text // some space around the text
const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x return wxSize(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
: GetColEnd(GetColumnCount() - 1), : GetColEnd(GetColumnCount() - 1),
height ); // (7*GetCharHeight())/4); height); // (7*GetCharHeight())/4);
CacheBestSize(size);
return size;
} }
int wxHeaderCtrl::GetColStart(unsigned int idx) const int wxHeaderCtrl::GetColStart(unsigned int idx) const

View File

@@ -4153,9 +4153,6 @@ wxSize wxGenericTreeCtrl::DoGetBestSize() const
if ( dy ) if ( dy )
size.y += PIXELS_PER_UNIT - dy; size.y += PIXELS_PER_UNIT - dy;
// we need to update the cache too as the base class cached its own value
CacheBestSize(size);
return size; return size;
} }

View File

@@ -175,10 +175,8 @@ wxSize wxBitmapComboBox::DoGetBestSize() const
int delta = GetBitmapSize().y - GetCharHeight(); int delta = GetBitmapSize().y - GetCharHeight();
if ( delta > 0 ) if ( delta > 0 )
{
best.y += delta; best.y += delta;
CacheBestSize(best);
}
return best; return best;
} }

View File

@@ -320,7 +320,6 @@ wxSize wxButton::DoGetBestSize() const
ret.y = defaultSize.y; ret.y = defaultSize.y;
} }
CacheBestSize(ret);
return ret; return ret;
} }

View File

@@ -77,7 +77,6 @@ wxSize wxGauge::DoGetBestSize() const
best = wxSize(28, 100); best = wxSize(28, 100);
else else
best = wxSize(100, 28); best = wxSize(100, 28);
CacheBestSize(best);
return best; return best;
} }

View File

@@ -886,9 +886,7 @@ wxSize wxListBox::DoGetBestSize() const
// Don't make the listbox too tall but don't make it too small neither // Don't make the listbox too tall but don't make it too small neither
lbHeight = (cy+4) * wxMin(wxMax(count, 3), 10); lbHeight = (cy+4) * wxMin(wxMax(count, 3), 10);
wxSize best(lbWidth, lbHeight); return wxSize(lbWidth, lbHeight);
CacheBestSize(best);
return best;
} }
// static // static

View File

@@ -204,7 +204,6 @@ wxSize wxSpinButton::DoGetBestSize() const
w = 6; w = 6;
best.x = w + 2 * m_widget->style->xthickness; best.x = w + 2 * m_widget->style->xthickness;
#endif #endif
CacheBestSize(best);
return best; return best;
} }

View File

@@ -255,7 +255,6 @@ wxSize wxStaticText::DoGetBestSize() const
// Adding 1 to width to workaround GTK sometimes wrapping the text needlessly // Adding 1 to width to workaround GTK sometimes wrapping the text needlessly
size.x++; size.x++;
CacheBestSize(size);
return size; return size;
} }

View File

@@ -242,7 +242,6 @@ wxSize wxToggleButton::DoGetBestSize() const
if (ret.x < 80) ret.x = 80; if (ret.x < 80) ret.x = 80;
} }
CacheBestSize(ret);
return ret; return ret;
} }

View File

@@ -238,7 +238,6 @@ wxSize wxButton::DoGetBestSize() const
if (ret.y < defaultSize.y) ret.y = defaultSize.y; if (ret.y < defaultSize.y) ret.y = defaultSize.y;
} }
CacheBestSize(ret);
return ret; return ret;
} }

View File

@@ -541,7 +541,6 @@ wxSize wxChoice::DoGetBestSize() const
if (ret.y <= 18) if (ret.y <= 18)
ret.y = 8 + GetCharHeight(); ret.y = 8 + GetCharHeight();
CacheBestSize(ret);
return ret; return ret;
} }

View File

@@ -895,7 +895,6 @@ wxSize wxComboBox::DoGetBestSize() const
if ( ret.x < 100 ) if ( ret.x < 100 )
ret.x = 100; ret.x = 100;
CacheBestSize(ret);
return ret; return ret;
} }

View File

@@ -64,9 +64,7 @@ wxSize wxControl::DoGetBestSize() const
(* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request ) (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
(m_widget, &req ); (m_widget, &req );
wxSize best(req.width, req.height); return wxSize(req.width, req.height);
CacheBestSize(best);
return best;
} }

View File

@@ -70,7 +70,6 @@ wxSize wxGauge::DoGetBestSize() const
best = wxSize(28, 100); best = wxSize(28, 100);
else else
best = wxSize(100, 28); best = wxSize(100, 28);
CacheBestSize(best);
return best; return best;
} }

View File

@@ -1102,9 +1102,7 @@ wxSize wxListBox::DoGetBestSize() const
// make it too small neither // make it too small neither
lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10); lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
wxSize best(lbWidth, lbHeight); return wxSize(lbWidth, lbHeight);
CacheBestSize(best);
return best;
} }
void wxListBox::FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y) void wxListBox::FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y)

View File

@@ -221,9 +221,7 @@ bool wxSpinButton::IsOwnGtkWindow( GdkWindow *window )
wxSize wxSpinButton::DoGetBestSize() const wxSize wxSpinButton::DoGetBestSize() const
{ {
wxSize best(15, 26); // FIXME return wxSize(15, 26); // FIXME
CacheBestSize(best);
return best;
} }
// static // static

View File

@@ -330,10 +330,7 @@ bool wxSpinCtrl::IsOwnGtkWindow( GdkWindow *window )
wxSize wxSpinCtrl::DoGetBestSize() const wxSize wxSpinCtrl::DoGetBestSize() const
{ {
wxSize ret( wxControl::DoGetBestSize() ); return wxSize(95, wxControl::DoGetBestSize().y);
wxSize best(95, ret.y);
CacheBestSize(best);
return best;
} }
bool wxSpinCtrl::SetBase(int base) bool wxSpinCtrl::SetBase(int base)

View File

@@ -1255,10 +1255,7 @@ void wxTextCtrl::OnInternalIdle()
wxSize wxTextCtrl::DoGetBestSize() const wxSize wxTextCtrl::DoGetBestSize() const
{ {
// FIXME should be different for multi-line controls... // FIXME should be different for multi-line controls...
wxSize ret( wxControl::DoGetBestSize() ); return wxSize(80, wxControl::DoGetBestSize().y);
wxSize best(80, ret.y);
CacheBestSize(best);
return best;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -208,7 +208,6 @@ wxSize wxToggleBitmapButton::DoGetBestSize() const
best.x = m_bitmap.GetWidth()+border; best.x = m_bitmap.GetWidth()+border;
best.y = m_bitmap.GetHeight()+border; best.y = m_bitmap.GetHeight()+border;
} }
CacheBestSize(best);
return best; return best;
} }
@@ -348,7 +347,6 @@ wxSize wxToggleButton::DoGetBestSize() const
if (ret.x < 80) ret.x = 80; if (ret.x < 80) ret.x = 80;
} }
CacheBestSize(ret);
return ret; return ret;
} }

View File

@@ -226,10 +226,7 @@ wxSize wxBitmapComboBox::DoGetBestSize() const
wxCoord useHeightBitmap = EDIT_HEIGHT_FROM_CHAR_HEIGHT(bitmapSize.y); wxCoord useHeightBitmap = EDIT_HEIGHT_FROM_CHAR_HEIGHT(bitmapSize.y);
if ( best.y < useHeightBitmap ) if ( best.y < useHeightBitmap )
{
best.y = useHeightBitmap; best.y = useHeightBitmap;
CacheBestSize(best);
}
return best; return best;
} }

View File

@@ -173,9 +173,7 @@ wxSize wxCalendarCtrl::DoGetBestSize() const
return wxCalendarCtrlBase::DoGetBestSize(); return wxCalendarCtrlBase::DoGetBestSize();
} }
const wxSize best = wxRectFromRECT(rc).GetSize() + GetWindowBorderSize(); return wxRectFromRECT(rc).GetSize() + GetWindowBorderSize();
CacheBestSize(best);
return best;
} }
wxCalendarHitTestResult wxCalendarHitTestResult

View File

@@ -174,9 +174,7 @@ wxSize wxCheckBox::DoGetBestClientSize() const
hCheckbox = s_checkSize; hCheckbox = s_checkSize;
} }
wxSize best(wCheckbox, hCheckbox); return wxSize(wCheckbox, hCheckbox);
CacheBestSize(best);
return best;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -427,7 +427,6 @@ wxSize wxCheckListBox::DoGetBestClientSize() const
if ( best.y < size.GetHeight() ) if ( best.y < size.GetHeight() )
best.y = size.GetHeight(); best.y = size.GetHeight();
CacheBestSize(best);
return best; return best;
} }

View File

@@ -194,8 +194,6 @@ wxSize wxCommandLinkButton::DoGetBestSize() const
if ( !GetNote().empty() ) if ( !GetNote().empty() )
size.y += MAINLABEL_NOTE_MARGIN; size.y += MAINLABEL_NOTE_MARGIN;
CacheBestSize(size);
return size; return size;
} }

View File

@@ -615,9 +615,7 @@ wxSize wxRadioBox::DoGetBestSize() const
return wxSize(1, 1); return wxSize(1, 1);
} }
wxSize best = GetTotalButtonSize(GetMaxButtonSize()); return GetTotalButtonSize(GetMaxButtonSize());
CacheBestSize(best);
return best;
} }
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)

View File

@@ -267,9 +267,7 @@ wxSize wxRadioButton::DoGetBestSize() const
hRadio = s_radioSize; hRadio = s_radioSize;
} }
wxSize best(wRadio, hRadio); return wxSize(wRadio, hRadio);
CacheBestSize(best);
return best;
} }
WXDWORD wxRadioButton::MSWGetStyle(long style, WXDWORD *exstyle) const WXDWORD wxRadioButton::MSWGetStyle(long style, WXDWORD *exstyle) const

View File

@@ -215,9 +215,7 @@ wxSize wxScrollBar::DoGetBestSize() const
h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
} }
wxSize best(w, h); return wxSize(w, h);
CacheBestSize(best);
return best;
} }
WXDWORD wxScrollBar::MSWGetStyle(long style, WXDWORD *exstyle) const WXDWORD wxScrollBar::MSWGetStyle(long style, WXDWORD *exstyle) const

View File

@@ -497,9 +497,7 @@ wxSize wxStatusBar::DoGetBestSize() const
int height = GetCharHeight(); int height = GetCharHeight();
height += 4*borders.vert; height += 4*borders.vert;
wxSize best(width, height); return wxSize(width, height);
CacheBestSize(best);
return best;
} }
void wxStatusBar::DoMoveWindow(int x, int y, int width, int height) void wxStatusBar::DoMoveWindow(int x, int y, int width, int height)

View File

@@ -539,8 +539,6 @@ wxSize wxToolBar::DoGetBestSize() const
sizeBest.y ++; sizeBest.y ++;
} }
CacheBestSize(sizeBest);
return sizeBest; return sizeBest;
} }

View File

@@ -119,9 +119,7 @@ wxSize wxScrollBar::DoGetBestSize() const
h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
} }
wxSize best(w, h); return wxSize(w, h);
CacheBestSize(best);
return best;
} }
void wxScrollBar::TriggerScrollEvent( wxEventType scrollEvent ) void wxScrollBar::TriggerScrollEvent( wxEventType scrollEvent )

View File

@@ -1214,10 +1214,7 @@ wxSize wxPropertyGrid::DoGetBestSize() const
width += m_pState->GetColumnFitWidth(dc, m_pState->DoGetRoot(), i, true); width += m_pState->GetColumnFitWidth(dc, m_pState->DoGetRoot(), i, true);
} }
const wxSize sz = wxSize(width, lineHeight*numLines + 40); return wxSize(width, lineHeight*numLines + 40);
CacheBestSize(sz);
return sz;
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------