X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1d156af3247c862e51a7c62f569a3fd302052a42..7c60222510bc5e197b12f153c4bf05db66cb0f4a:/src/osx/dataview_osx.cpp diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index 490f6d9fd7..d840376145 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" @@ -124,7 +127,7 @@ bool wxOSXDataViewModelNotifier::ItemChanged(wxDataViewItem const& item) if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item)) { // sent the equivalent wxWidget event: - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); dataViewEvent.SetEventObject(m_DataViewCtrlPtr); dataViewEvent.SetItem(item); @@ -144,7 +147,7 @@ bool wxOSXDataViewModelNotifier::ItemsChanged(wxDataViewItemArray const& items) { size_t const noOfItems = items.GetCount(); - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); dataViewEvent.SetEventObject(m_DataViewCtrlPtr); @@ -210,7 +213,7 @@ bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsign wxCHECK_MSG(GetOwner() != NULL,false,"Owner not initialized."); if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item)) { - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); dataViewEvent.SetEventObject(m_DataViewCtrlPtr); dataViewEvent.SetColumn(col); @@ -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)) @@ -627,9 +650,9 @@ void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem) (void) GetModel()->ItemsAdded(parentItem,items); } -void wxDataViewCtrl::StartEditor( const wxDataViewItem & item, unsigned int column ) +void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) { - GetDataViewPeer()->StartEditor(item, column); + GetDataViewPeer()->StartEditor(item, GetColumnPosition(column)); } void wxDataViewCtrl::FinishCustomItemEditing() @@ -706,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; @@ -736,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) @@ -750,7 +772,6 @@ void wxDataViewCtrl::OnMouse(wxMouseEvent& event) } } - SetCursor( *wxSTANDARD_CURSOR ); #endif }