fix best size caching

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-12 16:31:39 +00:00
parent 3246a508ab
commit 7bf5be6b56

View File

@@ -115,9 +115,14 @@ void wxHeaderCtrl::DoSetCount(unsigned int count)
m_colIndices = colIndices; m_colIndices = colIndices;
} }
else // count didn't really change
{
return;
}
m_numColumns = count; m_numColumns = count;
InvalidateBestSize();
Refresh(); Refresh();
} }
@@ -128,6 +133,8 @@ unsigned int wxHeaderCtrl::DoGetCount() const
void wxHeaderCtrl::DoUpdate(unsigned int idx) void wxHeaderCtrl::DoUpdate(unsigned int idx)
{ {
InvalidateBestSize();
// we need to refresh not only this column but also the ones after it in // we need to refresh not only this column but also the ones after it in
// case it was shown or hidden or its width changed -- it would be nice to // case it was shown or hidden or its width changed -- it would be nice to
// avoid doing this unnecessary by storing the old column width (TODO) // avoid doing this unnecessary by storing the old column width (TODO)
@@ -154,9 +161,11 @@ 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
return wxSize(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
: GetColEnd(GetColumnCount() - 1), : GetColEnd(GetColumnCount() - 1),
(7*GetCharHeight())/4); (7*GetCharHeight())/4);
CacheBestSize(size);
return size;
} }
int wxHeaderCtrl::GetColStart(unsigned int idx) const int wxHeaderCtrl::GetColStart(unsigned int idx) const