Better support for flat lists in wxTreeListCtrl.

Override wxDataViewModel::IsListModel() to return true if wxTreeListCtrl
doesn't have any depth. This results in better display when using the generic
implementation of wxDataViewCtrl as no space is reserved for the (unnecessary)
expanders in this case.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-08-30 13:40:44 +00:00
parent c46ecbe3b5
commit 2669319136
2 changed files with 31 additions and 1 deletions

View File

@@ -342,6 +342,7 @@ public:
virtual bool HasContainerColumns(const wxDataViewItem& item) const;
virtual unsigned GetChildren(const wxDataViewItem& item,
wxDataViewItemArray& children) const;
virtual bool IsListModel() const { return m_isFlat; }
private:
// The control we're associated with.
@@ -352,6 +353,11 @@ private:
// Number of columns we maintain.
unsigned m_numColumns;
// Set to false as soon as we have more than one level, i.e. as soon as any
// items with non-root item as parent are added (and currently never reset
// after this).
bool m_isFlat;
};
// ============================================================================
@@ -554,6 +560,7 @@ wxTreeListModel::wxTreeListModel(wxTreeListCtrl* treelist)
m_root(new Node(NULL))
{
m_numColumns = 0;
m_isFlat = true;
}
wxTreeListModel::~wxTreeListModel()
@@ -590,6 +597,12 @@ wxTreeListModel::InsertItem(Node* parent,
wxCHECK_MSG( previous, NULL,
"Must have a valid previous item (maybe wxTLI_FIRST/LAST?)" );
if ( m_isFlat && parent != m_root )
{
// Not flat any more, this is a second level child.
m_isFlat = false;
}
wxScopedPtr<Node>
newItem(new Node(parent, text, imageClosed, imageOpened, data));