diff --git a/include/wx/treelist.h b/include/wx/treelist.h index 1f013e8a37..9b315c57de 100644 --- a/include/wx/treelist.h +++ b/include/wx/treelist.h @@ -322,6 +322,18 @@ public: wxCheckBoxState state) const; + + // View window functions. + // ---------------------- + + // This control itself is entirely covered by the "view window" which is + // currently a wxDataViewCtrl but if you want to avoid relying on this to + // allow your code to work with later versions which might not be + // wxDataViewCtrl-based, use the first function only and only use the + // second one if you really need to call wxDataViewCtrl methods on it. + wxWindow* GetView() const; + wxDataViewCtrl* GetDataView() const { return m_view; } + private: // Common part of all ctors. void Init(); diff --git a/interface/wx/treelist.h b/interface/wx/treelist.h index 66f8610314..5a70301d0a 100644 --- a/interface/wx/treelist.h +++ b/interface/wx/treelist.h @@ -664,6 +664,36 @@ public: wxCheckBoxState state) const; //@} + + /** + View window. + + This control itself is entirely covered by the "view window" which is + currently a wxDataViewCtrl but if you want to avoid relying on this to + allow your code to work with later versions which might not be + wxDataViewCtrl-based, use GetView() function only and only use + GetDataView() if you really need to call wxDataViewCtrl methods on it. + */ + //@{ + + /** + Return the view part of this control as a wxWindow. + + This method always returns non-@NULL pointer once the window was + created. + */ + wxWindow* GetView() const; + + /** + Return the view part of this control as wxDataViewCtrl. + + This method may return @NULL in the future, non wxDataViewCtrl-based, + versions of this class, use GetView() unless you really need to use + wxDataViewCtrl methods on the returned object. + */ + wxDataViewCtrl* GetDataView() const; + + //@} }; /** diff --git a/src/generic/treelist.cpp b/src/generic/treelist.cpp index 806ae748ba..69245fd31d 100644 --- a/src/generic/treelist.cpp +++ b/src/generic/treelist.cpp @@ -1548,6 +1548,15 @@ void wxTreeListCtrl::OnSize(wxSizeEvent& event) } } +wxWindow* wxTreeListCtrl::GetView() const +{ +#ifdef wxHAS_GENERIC_DATAVIEWCTRL + return m_view->GetMainWindow(); +#else + return m_view; +#endif +} + // ============================================================================ // wxTreeListEvent implementation // ============================================================================