X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8d96f54dfd81a2934774257cc00be98ebdcd5e79..beee38cb41aa2ce4fbe9052bf4f70e1be184b553:/src/osx/dataview_osx.cpp diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index 1dabd9f4bc..490f6d9fd7 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -76,6 +76,8 @@ protected: void AdjustRowHeight(wxDataViewItem const& item); // ... and the same method for a couple of items: void AdjustRowHeights(wxDataViewItemArray const& items); + // adjust wxCOL_WIDTH_AUTOSIZE columns to fit the data + void AdjustAutosizedColumns(); private: wxDataViewCtrl* m_DataViewCtrlPtr; @@ -130,6 +132,7 @@ bool wxOSXDataViewModelNotifier::ItemChanged(wxDataViewItem const& item) m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); // row height may have to be adjusted: AdjustRowHeight(item); + AdjustAutosizedColumns(); // done return true; } @@ -156,6 +159,7 @@ bool wxOSXDataViewModelNotifier::ItemsChanged(wxDataViewItemArray const& items) return false; // if this location is reached all items have been updated: AdjustRowHeights(items); + AdjustAutosizedColumns(); // done: return true; } @@ -174,6 +178,8 @@ bool wxOSXDataViewModelNotifier::ItemDeleted(wxDataViewItem const& parent, wxDat noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,item); // enable automatic updating again: m_DataViewCtrlPtr->SetDeleting(false); + + AdjustAutosizedColumns(); // done: return noFailureFlag; } @@ -192,6 +198,8 @@ bool wxOSXDataViewModelNotifier::ItemsDeleted(wxDataViewItem const& parent, wxDa noFailureFlag = m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent,items); // enable automatic updating again: m_DataViewCtrlPtr->SetDeleting(false); + + AdjustAutosizedColumns(); // done: return noFailureFlag; } @@ -209,6 +217,8 @@ bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsign dataViewEvent.SetItem(item); // send the equivalent wxWidget event: m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); + + AdjustAutosizedColumns(); // done return true; } @@ -292,6 +302,18 @@ void wxOSXDataViewModelNotifier::AdjustRowHeights(wxDataViewItemArray const& ite } } +void wxOSXDataViewModelNotifier::AdjustAutosizedColumns() +{ + unsigned count = m_DataViewCtrlPtr->GetColumnCount(); + for ( unsigned col = 0; col < count; col++ ) + { + wxDataViewColumn *column = m_DataViewCtrlPtr->GetColumnPtr(col); + + if ( column->GetWidthVariable() == wxCOL_WIDTH_AUTOSIZE ) + m_DataViewCtrlPtr->GetDataViewPeer()->FitColumnWidthToContent(col); + } +} + // --------------------------------------------------------- // wxDataViewCustomRenderer // The constructor, the implementation macro and environment @@ -329,7 +351,6 @@ void wxDataViewCtrl::Init() { m_CustomRendererPtr = NULL; m_Deleting = false; - m_macIsUserPane = false; m_cgContext = NULL; } @@ -341,9 +362,10 @@ bool wxDataViewCtrl::Create(wxWindow *parent, const wxValidator& validator, const wxString& name) { + DontCreatePeer(); if (!(wxControl::Create(parent,id,pos,size,style,validator,name))) return false; - m_peer = ::CreateDataView(this,parent,id,pos,size,style,GetExtraStyle()); + SetPeer(::CreateDataView(this,parent,id,pos,size,style,GetExtraStyle())); MacPostControlCreate(pos,size); @@ -385,8 +407,7 @@ bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) wxCHECK_MSG(columnPtr != NULL, false,"Column pointer must not be NULL."); wxCHECK_MSG(columnPtr->GetRenderer() != NULL, false,"Column does not have a renderer."); wxCHECK_MSG(GetModel() != NULL, false,"No model associated with control."); - wxCHECK_MSG((columnPtr->GetModelColumn() >= 0) && - (columnPtr->GetModelColumn() < GetModel()->GetColumnCount()),false,"Column's model column has no equivalent in the associated model."); + wxCHECK_MSG(columnPtr->GetModelColumn() < GetModel()->GetColumnCount(),false,"Column's model column has no equivalent in the associated model."); // add column to wxWidget's internal structure: if (wxDataViewCtrlBase::InsertColumn(pos,columnPtr)) @@ -514,15 +535,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 @@ -612,6 +627,11 @@ void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem) (void) GetModel()->ItemsAdded(parentItem,items); } +void wxDataViewCtrl::StartEditor( const wxDataViewItem & item, unsigned int column ) +{ + GetDataViewPeer()->StartEditor(item, column); +} + void wxDataViewCtrl::FinishCustomItemEditing() { if (GetCustomRendererItem().IsOk())