Make DoGetBestSize cache the value of GetSize() the first time it is called
for the case when the control is a regular window with no children. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26583 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1077,6 +1077,9 @@ protected:
|
|||||||
#if wxUSE_ACCESSIBILITY
|
#if wxUSE_ACCESSIBILITY
|
||||||
wxAccessible* m_accessible;
|
wxAccessible* m_accessible;
|
||||||
#endif
|
#endif
|
||||||
|
// Best size for controls which fail to implement DoGetBestSize()
|
||||||
|
wxSize m_bestSize;
|
||||||
|
|
||||||
// Virtual size (scrolling)
|
// Virtual size (scrolling)
|
||||||
wxSize m_virtualSize;
|
wxSize m_virtualSize;
|
||||||
|
|
||||||
|
@@ -110,6 +110,7 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
// the default initialization
|
// the default initialization
|
||||||
wxWindowBase::wxWindowBase()
|
wxWindowBase::wxWindowBase()
|
||||||
|
: m_bestSize(wxDefaultSize)
|
||||||
{
|
{
|
||||||
// no window yet, no parent nor children
|
// no window yet, no parent nor children
|
||||||
m_parent = (wxWindow *)NULL;
|
m_parent = (wxWindow *)NULL;
|
||||||
@@ -585,9 +586,18 @@ wxSize wxWindowBase::DoGetBestSize() const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// for a generic window there is no natural best size - just use the
|
// Windows which don't implement DoGetBestSize and aren't parents.
|
||||||
// current one
|
// This emulates the behavior of a wxSizer without wxADJUST_MINSIZE
|
||||||
return GetSize();
|
|
||||||
|
// If you get the following message you should do one of two things
|
||||||
|
// 1. Do what it says (best)
|
||||||
|
// 2. m_bestSize = GetSize() at end of Create() (hack)
|
||||||
|
if(m_bestSize == wxDefaultSize)
|
||||||
|
{
|
||||||
|
wxLogDebug(wxT("Class %s (or superclass) should implement DoGetBestSize()"),GetClassInfo()->GetClassName());
|
||||||
|
wxConstCast(this,wxWindowBase)->m_bestSize = GetSize();
|
||||||
|
}
|
||||||
|
return m_bestSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user