]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/dataview.cpp
fix the definition of many static functions marked as 'const' or functions which...
[wxWidgets.git] / src / osx / carbon / dataview.cpp
index ec8ae3baef178e1f16078d5241bc9c6a83766076..dd3cebff16042060f4c128ac85773d36d14efb00 100644 (file)
@@ -1183,6 +1183,8 @@ void wxDataViewCtrl::Collapse(wxDataViewItem const& item)
 
 void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr)
 {
 
 void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr)
 {
+  ExpandAncestors(item);
+
   if (item.IsOk())
   {
     DataBrowserPropertyID propertyID;
   if (item.IsOk())
   {
     DataBrowserPropertyID propertyID;
@@ -1204,6 +1206,23 @@ void wxDataViewCtrl::Expand(wxDataViewItem const& item)
   MacDataViewListCtrlPtr->OpenContainer(reinterpret_cast<DataBrowserItemID>(item.GetID()));
 }
 
   MacDataViewListCtrlPtr->OpenContainer(reinterpret_cast<DataBrowserItemID>(item.GetID()));
 }
 
+bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const
+{
+  if (item.IsOk())
+  {
+    wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+
+    DataBrowserItemState state = 0;
+    OSStatus err = ::GetDataBrowserItemState( 
+       MacDataViewListCtrlPtr->GetControlRef(), 
+       reinterpret_cast<DataBrowserItemID>(item.GetID()),
+       &state );
+    if ((err == 0) && (state & kDataBrowserContainerIsOpen))
+       return true;
+  }
+  return false;
+}
+
 wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const
 {
   DataBrowserPropertyID propertyID;
 wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const
 {
   DataBrowserPropertyID propertyID;
@@ -1315,6 +1334,8 @@ void wxDataViewCtrl::Select(wxDataViewItem const& item)
 {
   if (item.IsOk())
   {
 {
   if (item.IsOk())
   {
+    ExpandAncestors(item);
+  
     DataBrowserItemID                              itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
     wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
 
     DataBrowserItemID                              itemID(reinterpret_cast<DataBrowserItemID>(item.GetID()));
     wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
 
@@ -1324,18 +1345,31 @@ void wxDataViewCtrl::Select(wxDataViewItem const& item)
 
 void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel)
 {
 
 void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel)
 {
-  size_t const NoOfSelections = sel.GetCount();
+    size_t const NoOfSelections = sel.GetCount();
 
 
-  DataBrowserItemID* itemIDs;
+    wxDataViewItem last_parent;
 
 
-  wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
+    size_t i;
+    for (i = 0; i < NoOfSelections; i++)
+    {
+        wxDataViewItem item = sel[i];
+        wxDataViewItem parent = GetModel()->GetParent( item );
+        if (parent)
+        {
+            if (parent != last_parent)
+                ExpandAncestors(item);
+        }
+        last_parent = parent;
+    }
 
 
+    DataBrowserItemID* itemIDs;
+    wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(m_peer));
 
 
-  itemIDs = new DataBrowserItemID[NoOfSelections];
-  for (size_t i=0; i<NoOfSelections; ++i)
-    itemIDs[i] = reinterpret_cast<DataBrowserItemID>(sel[i].GetID());
-  MacDataViewListCtrlPtr->SetSelectedItems(NoOfSelections,itemIDs,kDataBrowserItemsAssign);
-  delete[] itemIDs;
+    itemIDs = new DataBrowserItemID[NoOfSelections];
+    for (i=0; i<NoOfSelections; ++i)
+      itemIDs[i] = reinterpret_cast<DataBrowserItemID>(sel[i].GetID());
+    MacDataViewListCtrlPtr->SetSelectedItems(NoOfSelections,itemIDs,kDataBrowserItemsAssign);
+    delete[] itemIDs;
 }
 
 void wxDataViewCtrl::Unselect(wxDataViewItem const& item)
 }
 
 void wxDataViewCtrl::Unselect(wxDataViewItem const& item)