List-only models don't have expanders and so the control shouldn't
reserve any space for them; the notion of expander column doesn't make
sense here.
Previously, this was done correctly only for wxDataViewVirtualListModel;
"ordinary" list models, such as the one used by wxDataViewListCtrl, were
treated as generic tree models and 0th column had ugly empty space
reserved for (never used) expander.
This patch fixes it by adding IsListModel() helper function in
addition to existing IsVirtualListModel(). Some of the
IsVirtualListModel() tests were changed into IsListModel() checks as
appropriate.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65140
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
virtual bool HasDefaultCompare() const { return false; }
// internal
virtual bool HasDefaultCompare() const { return false; }
// internal
+ virtual bool IsListModel() const { return false; }
virtual bool IsVirtualListModel() const { return false; }
protected:
virtual bool IsVirtualListModel() const { return false; }
protected:
{
return GetAttrByRow( GetRow(item), col, attr );
}
{
return GetAttrByRow( GetRow(item), col, attr );
}
+
+ virtual bool IsListModel() const { return true; }
};
// ---------------------------------------------------------
};
// ---------------------------------------------------------
const wxString &name = wxT("wxdataviewctrlmainwindow") );
virtual ~wxDataViewMainWindow();
const wxString &name = wxT("wxdataviewctrlmainwindow") );
virtual ~wxDataViewMainWindow();
+ bool IsList() const { return GetOwner()->GetModel()->IsListModel(); }
bool IsVirtualList() const { return m_root == NULL; }
// notifications from wxDataViewModel
bool IsVirtualList() const { return m_root == NULL; }
// notifications from wxDataViewModel
{
wxDataViewTreeNode *node = GetTreeNodeByRow(row);
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
{
wxDataViewTreeNode *node = GetTreeNodeByRow(row);
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
// deal with the expander
int indent = 0;
// deal with the expander
int indent = 0;
- if ((!IsVirtualList()) && (col == expander))
+ if ((!IsList()) && (col == expander))
{
// Calculate the indent first
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
{
// Calculate the indent first
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const
{
bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const
{
return false;
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
return false;
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
bool wxDataViewMainWindow::HasChildren( unsigned int row ) const
{
bool wxDataViewMainWindow::HasChildren( unsigned int row ) const
{
return false;
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
return false;
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
void wxDataViewMainWindow::Expand( unsigned int row )
{
void wxDataViewMainWindow::Expand( unsigned int row )
{
return;
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
return;
wxDataViewTreeNode * node = GetTreeNodeByRow(row);
void wxDataViewMainWindow::Collapse(unsigned int row)
{
void wxDataViewMainWindow::Collapse(unsigned int row)
{
return;
wxDataViewTreeNode *node = GetTreeNodeByRow(row);
return;
wxDataViewTreeNode *node = GetTreeNodeByRow(row);
// to get the correct x position where the actual text is
int indent = 0;
int row = GetRowByItem(item);
// to get the correct x position where the actual text is
int indent = 0;
int row = GetRowByItem(item);
- if (!IsVirtualList() && (column == 0 || GetOwner()->GetExpanderColumn() == column) )
+ if (!IsList() && (column == 0 || GetOwner()->GetExpanderColumn() == column) )
{
wxDataViewTreeNode* node = GetTreeNodeByRow(row);
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
{
wxDataViewTreeNode* node = GetTreeNodeByRow(row);
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
// Add the process for tree expanding/collapsing
case WXK_LEFT:
{
// Add the process for tree expanding/collapsing
case WXK_LEFT:
{
break;
wxDataViewTreeNode* node = GetTreeNodeByRow(m_currentRow);
break;
wxDataViewTreeNode* node = GetTreeNodeByRow(m_currentRow);
// Test whether the mouse is hovered on the tree item button
bool hoverOverExpander = false;
// Test whether the mouse is hovered on the tree item button
bool hoverOverExpander = false;
- if ((!IsVirtualList()) && (GetOwner()->GetExpanderColumn() == col))
+ if ((!IsList()) && (GetOwner()->GetExpanderColumn() == col))
{
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
if( node!=NULL && node->HasChildren() )
{
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
if( node!=NULL && node->HasChildren() )
GtkTreeModelFlags wxDataViewCtrlInternal::get_flags()
{
GtkTreeModelFlags wxDataViewCtrlInternal::get_flags()
{
- if (m_wx_model->IsVirtualListModel())
- return GTK_TREE_MODEL_LIST_ONLY;
- else
- return GTK_TREE_MODEL_ITERS_PERSIST;
+ int flags = 0;
+
+ if ( m_wx_model->IsListModel() )
+ flags |= GTK_TREE_MODEL_LIST_ONLY;
+
+ if ( !m_wx_model->IsVirtualListModel() )
+ flags |= GTK_TREE_MODEL_ITERS_PERSIST;
+
+ return GtkTreeModelFlags(flags);
}
gboolean wxDataViewCtrlInternal::get_iter( GtkTreeIter *iter, GtkTreePath *path )
}
gboolean wxDataViewCtrlInternal::get_iter( GtkTreeIter *iter, GtkTreePath *path )