diff --git a/include/wx/dataview.h b/include/wx/dataview.h index b9bc7320d0..86218f0d08 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -257,6 +257,7 @@ public: virtual bool HasDefaultCompare() const { return false; } // internal + virtual bool IsListModel() const { return false; } virtual bool IsVirtualListModel() const { return false; } protected: @@ -328,6 +329,8 @@ public: { return GetAttrByRow( GetRow(item), col, attr ); } + + virtual bool IsListModel() const { return true; } }; // --------------------------------------------------------- diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 32846cda9c..8f53d7663d 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -411,6 +411,7 @@ public: const wxString &name = wxT("wxdataviewctrlmainwindow") ); virtual ~wxDataViewMainWindow(); + bool IsList() const { return GetOwner()->GetModel()->IsListModel(); } bool IsVirtualList() const { return m_root == NULL; } // notifications from wxDataViewModel @@ -1497,7 +1498,7 @@ wxBitmap wxDataViewMainWindow::CreateItemBitmap( unsigned int row, int &indent ) } indent = 0; - if (!IsVirtualList()) + if (!IsList()) { wxDataViewTreeNode *node = GetTreeNodeByRow(row); indent = GetOwner()->GetIndent() * node->GetIndentLevel(); @@ -1764,7 +1765,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) // deal with the expander int indent = 0; - if ((!IsVirtualList()) && (col == expander)) + if ((!IsList()) && (col == expander)) { // Calculate the indent first indent = GetOwner()->GetIndent() * node->GetIndentLevel(); @@ -2795,7 +2796,7 @@ wxDataViewEvent wxDataViewMainWindow::SendExpanderEvent( wxEventType type, bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const { - if (IsVirtualList()) + if (IsList()) return false; wxDataViewTreeNode * node = GetTreeNodeByRow(row); @@ -2813,7 +2814,7 @@ bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const bool wxDataViewMainWindow::HasChildren( unsigned int row ) const { - if (IsVirtualList()) + if (IsList()) return false; wxDataViewTreeNode * node = GetTreeNodeByRow(row); @@ -2831,7 +2832,7 @@ bool wxDataViewMainWindow::HasChildren( unsigned int row ) const void wxDataViewMainWindow::Expand( unsigned int row ) { - if (IsVirtualList()) + if (IsList()) return; wxDataViewTreeNode * node = GetTreeNodeByRow(row); @@ -2887,7 +2888,7 @@ void wxDataViewMainWindow::Expand( unsigned int row ) void wxDataViewMainWindow::Collapse(unsigned int row) { - if (IsVirtualList()) + if (IsList()) return; wxDataViewTreeNode *node = GetTreeNodeByRow(row); @@ -3086,7 +3087,7 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & 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(); @@ -3332,7 +3333,7 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event ) // Add the process for tree expanding/collapsing case WXK_LEFT: { - if (IsVirtualList()) + if (IsList()) break; wxDataViewTreeNode* node = GetTreeNodeByRow(m_currentRow); @@ -3473,7 +3474,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) // 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() ) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index dc98b83b90..8389e4dc68 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -3502,10 +3502,15 @@ bool wxDataViewCtrlInternal::ValueChanged( const wxDataViewItem &item, unsigned 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 )