// return the column displayed at the given position in the control
wxDataViewColumn *GetColumnAt(unsigned int pos) const;
+ virtual void OnInternalIdle();
+
private:
virtual wxDataViewItem DoGetCurrentItem() const;
virtual void DoSetCurrentItem(const wxDataViewItem& item);
- void UpdateColBestWidths();
- void UpdateColBestWidth(int idx);
+ void InvalidateColBestWidths();
+ void InvalidateColBestWidth(int idx);
+ void UpdateColWidths();
wxDataViewColumnList m_cols;
// cached column best widths or 0 if not computed, values are for
// respective columns from m_cols and the arrays have same size
wxVector<int> m_colsBestWidths;
+ // m_colsBestWidths partially invalid, needs recomputing
+ bool m_colsDirty;
+
wxDataViewModelNotifier *m_notifier;
wxDataViewMainWindow *m_clientArea;
wxDataViewHeaderWindow *m_headerArea;
m_count = -1;
}
- GetOwner()->UpdateColBestWidths();
+ GetOwner()->InvalidateColBestWidths();
UpdateDisplay();
return true;
if( m_currentRow > GetRowCount() )
ChangeCurrentRow(m_count - 1);
- GetOwner()->UpdateColBestWidths();
+ GetOwner()->InvalidateColBestWidths();
UpdateDisplay();
return true;
SortPrepare();
g_model->Resort();
- GetOwner()->UpdateColBestWidths();
+ GetOwner()->InvalidateColBestWidths();
// Send event
wxWindow *parent = GetParent();
SortPrepare();
g_model->Resort();
- GetOwner()->UpdateColBestWidth(view_column);
+ GetOwner()->InvalidateColBestWidth(view_column);
// Send event
wxWindow *parent = GetParent();
SortPrepare();
BuildTree( GetModel() );
- GetOwner()->UpdateColBestWidths();
+ GetOwner()->InvalidateColBestWidths();
UpdateDisplay();
return true;
m_sortingColumnIdx = wxNOT_FOUND;
m_headerArea = NULL;
+
+ m_colsDirty = false;
}
bool wxDataViewCtrl::Create(wxWindow *parent,
return true;
}
-void wxDataViewCtrl::UpdateColBestWidth(int idx)
+void wxDataViewCtrl::InvalidateColBestWidth(int idx)
{
m_colsBestWidths[idx] = 0;
-
- if ( m_headerArea )
- m_headerArea->UpdateColumn(idx);
+ m_colsDirty = true;
}
-void wxDataViewCtrl::UpdateColBestWidths()
+void wxDataViewCtrl::InvalidateColBestWidths()
{
m_colsBestWidths.clear();
m_colsBestWidths.resize(m_cols.size());
+ m_colsDirty = true;
+}
- if ( m_headerArea )
+void wxDataViewCtrl::UpdateColWidths()
+{
+ if ( !m_headerArea )
+ return;
+
+ for ( wxVector<int>::const_iterator i = m_colsBestWidths.begin();
+ i != m_colsBestWidths.end();
+ ++i )
+ {
+ if ( m_colsBestWidths[*i] == 0 )
+ m_headerArea->UpdateColumn(*i);
+ }
+}
+
+void wxDataViewCtrl::OnInternalIdle()
+{
+ wxDataViewCtrlBase::OnInternalIdle();
+
+ if ( m_colsDirty )
{
- const unsigned cols = m_headerArea->GetColumnCount();
- for ( unsigned i = 0; i < cols; i++ )
- m_headerArea->UpdateColumn(i);
+ m_colsDirty = false;
+ UpdateColWidths();
}
}