Add optional columns autosizing to wxDataViewCtrl.

Only implemented in the generic and GTK+ versions at the moment, OS X
support will be added later.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65948 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2010-10-30 15:57:41 +00:00
parent 9aebcb5e44
commit d0154e3a5a
6 changed files with 131 additions and 26 deletions

View File

@@ -17,6 +17,7 @@
#include "wx/control.h"
#include "wx/scrolwin.h"
#include "wx/icon.h"
#include "wx/vector.h"
class WXDLLIMPEXP_FWD_ADV wxDataViewMainWindow;
class WXDLLIMPEXP_FWD_ADV wxDataViewHeaderWindow;
@@ -56,7 +57,7 @@ public:
virtual wxString GetTitle() const { return m_title; }
virtual void SetWidth(int width) { m_width = width; UpdateDisplay(); }
virtual int GetWidth() const { return m_width; }
virtual int GetWidth() const;
virtual void SetMinWidth(int minWidth) { m_minWidth = minWidth; UpdateDisplay(); }
virtual int GetMinWidth() const { return m_minWidth; }
@@ -206,10 +207,7 @@ protected:
public: // utility functions not part of the API
// returns the "best" width for the idx-th column
unsigned int GetBestColumnWidth(int WXUNUSED(idx)) const
{
return GetClientSize().GetWidth() / GetColumnCount();
}
unsigned int GetBestColumnWidth(int idx) const;
// called by header window after reorder
void ColumnMoved( wxDataViewColumn* col, unsigned int new_pos );
@@ -232,7 +230,13 @@ private:
virtual wxDataViewItem DoGetCurrentItem() const;
virtual void DoSetCurrentItem(const wxDataViewItem& item);
void InvalidateColBestWidths();
void InvalidateColBestWidth(int idx);
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;
wxDataViewModelNotifier *m_notifier;
wxDataViewMainWindow *m_clientArea;
wxDataViewHeaderWindow *m_headerArea;