X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8d96f54dfd81a2934774257cc00be98ebdcd5e79..8584b0e64b273273bad122d28b10176bd5a3bc84:/src/osx/dataview_osx.cpp diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index 1dabd9f4bc..199cd2e74a 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