X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9f68fe76c9dfc0a2e24aaaea2bcc1a68eeadd03a..12b5f4b4d2d8a07962da7ba3b78c8c1ec2634a67:/src/osx/carbon/dataview.cpp diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index ec8ae3baef..739ad9cf9c 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -1051,12 +1051,12 @@ bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr) { - return InsertColumn( kDataBrowserListViewAppendColumn, columnPtr ); + return wxDataViewCtrl::InsertColumn( GetColumnCount(), columnPtr ); } bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr) { - return InsertColumn( 0, columnPtr ); + return wxDataViewCtrl::InsertColumn( 0, columnPtr ); } bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) @@ -1083,7 +1083,7 @@ bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) // full column variable initialization: columnPtr->SetPropertyID(NewPropertyID); // add column to wxWidget's internal structure: - wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr) && + wxCHECK_MSG(this->wxDataViewCtrlBase::InsertColumn(pos,columnPtr) && m_ColumnPointers.insert(ColumnPointerHashMapType::value_type(NewPropertyID,columnPtr)).second,false,_("Could not add column to internal structures.")); // create a column description and add column to the native control: wxCHECK_MSG(::InitializeColumnDescription(columnDescription,columnPtr,NewPropertyID,title), false,_("Column description could not be initialized.")); @@ -1183,6 +1183,8 @@ void wxDataViewCtrl::Collapse(wxDataViewItem const& item) void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) { + ExpandAncestors(item); + if (item.IsOk()) { DataBrowserPropertyID propertyID; @@ -1204,6 +1206,23 @@ void wxDataViewCtrl::Expand(wxDataViewItem const& item) MacDataViewListCtrlPtr->OpenContainer(reinterpret_cast(item.GetID())); } +bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const +{ + if (item.IsOk()) + { + wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(m_peer)); + + DataBrowserItemState state = 0; + OSStatus err = ::GetDataBrowserItemState( + MacDataViewListCtrlPtr->GetControlRef(), + reinterpret_cast(item.GetID()), + &state ); + if ((err == 0) && (state & kDataBrowserContainerIsOpen)) + return true; + } + return false; +} + wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const { DataBrowserPropertyID propertyID; @@ -1315,6 +1334,8 @@ void wxDataViewCtrl::Select(wxDataViewItem const& item) { if (item.IsOk()) { + ExpandAncestors(item); + DataBrowserItemID itemID(reinterpret_cast(item.GetID())); wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(m_peer)); @@ -1324,18 +1345,31 @@ void wxDataViewCtrl::Select(wxDataViewItem const& item) 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(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(m_peer)); - itemIDs = new DataBrowserItemID[NoOfSelections]; - for (size_t i=0; i(sel[i].GetID()); - MacDataViewListCtrlPtr->SetSelectedItems(NoOfSelections,itemIDs,kDataBrowserItemsAssign); - delete[] itemIDs; + itemIDs = new DataBrowserItemID[NoOfSelections]; + for (i=0; i(sel[i].GetID()); + MacDataViewListCtrlPtr->SetSelectedItems(NoOfSelections,itemIDs,kDataBrowserItemsAssign); + delete[] itemIDs; } void wxDataViewCtrl::Unselect(wxDataViewItem const& item)