wxDataViewCtrl: always update the header when col best width changes.

Have an explicit per-column dirty flag and use that to determine whether
we need to call wxHeaderCtrl::UpdateColumn(). Previously, the lack of
computed best width was used as an indicator, but this didn't work
correctly if some code called GetWidth() after invalidation but before
wxDataViewCtrl::UpdateColWidths() was called at idle time. This resulted
in header's column widths getting out of sync with the control itself.

Fixes #14167.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71335 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2012-04-30 09:33:30 +00:00
parent b6b171522b
commit 840fc4d170
2 changed files with 34 additions and 14 deletions

View File

@@ -242,10 +242,18 @@ private:
void UpdateColWidths();
wxDataViewColumnList m_cols;
// cached column best widths or 0 if not computed, values are for
// cached column best widths information, values are for
// respective columns from m_cols and the arrays have same size
wxVector<int> m_colsBestWidths;
// m_colsBestWidths partially invalid, needs recomputing
struct CachedColWidthInfo
{
CachedColWidthInfo() : width(0), dirty(true) {}
int width; // cached width or 0 if not computed
bool dirty; // column was invalidated, header needs updating
};
wxVector<CachedColWidthInfo> m_colsBestWidths;
// This indicates that at least one entry in m_colsBestWidths has 'dirty'
// flag set. It's cheaper to check one flag in OnInternalIdle() than to
// iterate over m_colsBestWidths to check if anything needs to be done.
bool m_colsDirty;
wxDataViewModelNotifier *m_notifier;