]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datavcmn.cpp
make wxRearrangeDialog more customizable and add an example of customizing it to...
[wxWidgets.git] / src / common / datavcmn.cpp
index 567eb55d576e77b8216ec6086b891946731644c4..949ffa233fb3844ef035f4e45297e40665af6d00 100644 (file)
@@ -22,6 +22,7 @@
 #include "wx/choice.h"
 
 #include "wx/weakref.h"
+#include "wx/vector.h"
 
 #ifndef WX_PRECOMP
     #include "wx/dc.h"
@@ -832,38 +833,8 @@ void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event )
 // wxDataViewColumnBase
 // ---------------------------------------------------------
 
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
-
-wxDataViewColumnBase::wxDataViewColumnBase(const wxString& title,
-                                           wxDataViewRenderer *renderer,
-                                           unsigned int model_column,
-                                           int width,
-                                           wxAlignment align,
-                                           int flags)
-#ifdef wxHAS_GENERIC_DATAVIEWCTRL
-                    : wxHeaderColumn(title, width, align, flags)
-#endif
-{
-    m_renderer = renderer;
-    m_model_column = model_column;
-    m_owner = NULL;
-    m_renderer->SetOwner( (wxDataViewColumn*) this );
-
-    // NOTE: the wxDataViewColumn's ctor must store the width, align, flags
-    //       parameters inside the native control!
-}
-
-wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap,
-                                           wxDataViewRenderer *renderer,
-                                           unsigned int model_column,
-                                           int width,
-                                           wxAlignment align,
-                                           int flags)
-#ifdef wxHAS_GENERIC_DATAVIEWCTRL
-                    : wxHeaderColumn(bitmap, width, align, flags)
-#else
-                    : m_bitmap(bitmap)
-#endif
+void wxDataViewColumnBase::Init(wxDataViewRenderer *renderer,
+                                unsigned int model_column)
 {
     m_renderer = renderer;
     m_model_column = model_column;
@@ -925,6 +896,30 @@ const wxDataViewModel* wxDataViewCtrlBase::GetModel() const
     return m_model;
 }
 
+void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item )
+{
+    if (!m_model) return;
+    
+    if (!item.IsOk()) return;
+
+    wxVector<wxDataViewItem> 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 )
@@ -1305,7 +1300,7 @@ bool wxDataViewSpinRenderer::GetValue( wxVariant &value ) const
 // wxDataViewChoiceRenderer
 // -------------------------------------
 
-#ifndef __WXGTK20__
+#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__)
 
 wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString& choices, wxDataViewCellMode mode, int alignment ) :
    wxDataViewCustomRenderer(wxT("string"), mode, alignment )
@@ -1917,10 +1912,12 @@ void wxDataViewTreeCtrl::OnCollapsed( wxDataViewEvent &event )
 void wxDataViewTreeCtrl::OnSize( wxSizeEvent &event )
 {
 #if defined(wxUSE_GENERICDATAVIEWCTRL)
-    wxSize size = GetClientSize();
-    wxDataViewColumn *col = GetColumn( 0 );
-    if (col)
-       col->SetWidth( size.x );
+    // automatically resize our only column to take the entire control width
+    if ( GetColumnCount() )
+    {
+        wxSize size = GetClientSize();
+        GetColumn(0)->SetWidth(size.x);
+    }
 #endif
     event.Skip( true );
 }