X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d15694e8cad1d44087323bd568ca33ff5b354f2c..7740f1c7c9d0e01c96570841afcc4ee04b2329fd:/src/osx/dataview_osx.cpp diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index 08c094bd86..fd5d37e765 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -20,6 +20,9 @@ #include "wx/dcclient.h" #include "wx/icon.h" #endif +#if wxOSX_USE_CARBON +#include "wx/osx/carbon/dataview.h" +#endif #include "wx/osx/core/dataview.h" #include "wx/osx/private.h" @@ -345,6 +348,11 @@ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr) wxDataViewCtrl::~wxDataViewCtrl() { ClearColumns(); + + // Ensure that the already destructed controls is not notified about changes + // in the model any more. + if (m_ModelNotifier != NULL) + m_ModelNotifier->GetOwner()->RemoveNotifier(m_ModelNotifier); } void wxDataViewCtrl::Init() @@ -352,6 +360,7 @@ void wxDataViewCtrl::Init() m_CustomRendererPtr = NULL; m_Deleting = false; m_cgContext = NULL; + m_ModelNotifier = NULL; } bool wxDataViewCtrl::Create(wxWindow *parent, @@ -378,10 +387,19 @@ bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) wxCHECK_MSG(dataViewWidgetPtr != NULL,false,"Pointer to native control must not be NULL."); + + // We could have been associated with another model previously, break the + // association in this case. + if ( m_ModelNotifier ) + m_ModelNotifier->GetOwner()->RemoveNotifier(m_ModelNotifier); + if (wxDataViewCtrlBase::AssociateModel(model) && dataViewWidgetPtr->AssociateModel(model)) { if (model != NULL) - model->AddNotifier(new wxOSXDataViewModelNotifier(this)); + { + m_ModelNotifier = new wxOSXDataViewModelNotifier(this); + model->AddNotifier(m_ModelNotifier); + } return true; } else @@ -527,6 +545,11 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item) GetDataViewPeer()->SetCurrentItem(item); } +wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const +{ + return GetDataViewPeer()->GetCurrentColumn(); +} + wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const { if (item.IsOk() && (columnPtr != NULL)) @@ -535,15 +558,9 @@ wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn return wxRect(); } -wxDataViewItem wxDataViewCtrl::GetSelection() const +int wxDataViewCtrl::GetSelectedItemsCount() const { - wxDataViewItemArray itemIDs; - - - if (GetDataViewPeer()->GetSelections(itemIDs) > 0) - return itemIDs[0]; - else - return wxDataViewItem(); + return GetDataViewPeer()->GetSelectedItemsCount(); } int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const @@ -633,6 +650,11 @@ void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem) (void) GetModel()->ItemsAdded(parentItem,items); } +void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) +{ + GetDataViewPeer()->StartEditor(item, GetColumnPosition(column)); +} + void wxDataViewCtrl::FinishCustomItemEditing() { if (GetCustomRendererItem().IsOk()) @@ -707,12 +729,11 @@ void wxDataViewCtrl::OnMouse(wxMouseEvent& event) { event.Skip(); +#if wxOSX_USE_CARBON if (GetModel() == NULL) return; -#if 0 - // Doesn't compile anymore - wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(m_peer)); + wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(GetPeer())); int NoOfChildren; wxDataViewItemArray items; @@ -737,7 +758,7 @@ void wxDataViewCtrl::OnMouse(wxMouseEvent& event) Rect itemrect; ::GetDataBrowserItemPartBounds( MacDataViewListCtrlPtr->GetControlRef(), - reinterpret_cast(firstChild.GetID()), column->GetPropertyID(), + reinterpret_cast(firstChild.GetID()), column->GetNativeData()->GetPropertyID(), kDataBrowserPropertyEnclosingPart, &itemrect ); if (abs( event.GetX() - itemrect.right) < 3) @@ -751,7 +772,6 @@ void wxDataViewCtrl::OnMouse(wxMouseEvent& event) } } - SetCursor( *wxSTANDARD_CURSOR ); #endif }