From a881f34e499feadfef915b9d4c80e45a73ba37d4 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 20 Dec 2008 15:11:38 +0000 Subject: [PATCH] Call Expand on an item's parent chain in EnsureVisible git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dataview.h | 6 +++--- src/common/datavcmn.cpp | 27 ++++++++++++++++++++++++++- src/generic/datavgen.cpp | 2 ++ src/gtk/dataview.cpp | 4 +++- src/osx/carbon/dataview.cpp | 2 ++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 3f87c82485..5718981783 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -26,7 +26,7 @@ #include "wx/weakref.h" #if !(defined(__WXGTK20__) || defined(__WXMAC__)) || defined(__WXUNIVERSAL__) -//#if !(defined(__WXMAC__)) || defined(__WXUNIVERSAL__) +// #if !(defined(__WXMAC__)) || defined(__WXUNIVERSAL__) #define wxHAS_GENERIC_DATAVIEWCTRL #endif @@ -717,7 +717,7 @@ public: virtual bool IsExpanded( const wxDataViewItem & item ) const = 0; virtual void EnsureVisible( const wxDataViewItem & item, - const wxDataViewColumn *column = NULL ) = 0; + const wxDataViewColumn *column = NULL ); virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; @@ -879,7 +879,7 @@ private: long m_min,m_max; }; -#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(wxMAC) +#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__) // ------------------------------------- // wxDataViewChoiceRenderer diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 47400107e1..850772322c 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -22,6 +22,7 @@ #include "wx/choice.h" #include "wx/weakref.h" +#include "wx/vector.h" #ifndef WX_PRECOMP #include "wx/dc.h" @@ -895,6 +896,30 @@ const wxDataViewModel* wxDataViewCtrlBase::GetModel() const return m_model; } +void wxDataViewCtrlBase::EnsureVisible( const wxDataViewItem & item, + const wxDataViewColumn *WXUNUSED(column) ) +{ + if (!m_model) return; + + wxVector parentChain; + + // at first we get all the parents of the selected item + wxDataViewItem parent = m_model->GetParent(item); + while (parent.IsOk()) + { + parentChain.push_back(parent); + parent = m_model->GetParent(parent); + } + + // then we expand the parents, starting at the root + while (!parentChain.empty()) + { + Expand(parentChain.back()); + parentChain.pop_back(); + } +} + + wxDataViewColumn * wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column, wxDataViewCellMode mode, int width, wxAlignment align, int flags ) @@ -1275,7 +1300,7 @@ bool wxDataViewSpinRenderer::GetValue( wxVariant &value ) const // wxDataViewChoiceRenderer // ------------------------------------- -#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(wxMAC) +#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__) wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString& choices, wxDataViewCellMode mode, int alignment ) : wxDataViewCustomRenderer(wxT("string"), mode, alignment ) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index cbe48f53dc..8a3cdb4874 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3659,6 +3659,8 @@ void wxDataViewCtrl::EnsureVisible( int row, int column ) void wxDataViewCtrl::EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn * column ) { + wxDataViewCtrlBase::EnsureVisible( item, column ); + m_clientArea->RecalculateDisplay(); int row = m_clientArea->GetRowByItem(item); diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index dc998edd33..32bdc03dc4 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -4187,8 +4187,10 @@ void wxDataViewCtrl::UnselectAll() } void wxDataViewCtrl::EnsureVisible(const wxDataViewItem& item, - const wxDataViewColumn *WXUNUSED(column)) + const wxDataViewColumn *column) { + wxDataViewCtrlBase::EnsureVisible(item,column); + GtkTreeIter iter; iter.user_data = (gpointer) item.GetID(); GtkTreePath *path = m_internal->get_path( &iter ); diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index 11ba3ce936..bf7479c4cf 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -1183,6 +1183,8 @@ void wxDataViewCtrl::Collapse(wxDataViewItem const& item) void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) { + wxDataViewCtrlBase::EnsureVisible(item,columnPtr); + if (item.IsOk()) { DataBrowserPropertyID propertyID; -- 2.47.2