From 5f34d07bc127e1f5e5cb7ef708b02bba9fd7b82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 10 Aug 2021 19:12:53 +0200 Subject: [PATCH] Revert "Fix sizing of temporarily last columns in macOS wxDataViewCtrl" This reverts commit c9221fd538540bd6d105853d0f41620ed25102a5. --- include/wx/osx/cocoa/dataview.h | 25 +------------------------ src/osx/cocoa/dataview.mm | 26 ++------------------------ src/osx/dataview_osx.cpp | 5 ----- 3 files changed, 3 insertions(+), 53 deletions(-) diff --git a/include/wx/osx/cocoa/dataview.h b/include/wx/osx/cocoa/dataview.h index 9f54e49e6d..90be1a8ae0 100644 --- a/include/wx/osx/cocoa/dataview.h +++ b/include/wx/osx/cocoa/dataview.h @@ -86,7 +86,7 @@ class wxCocoaDataViewControl; class wxDataViewColumnNativeData { public: - wxDataViewColumnNativeData() : m_NativeColumnPtr(NULL), m_isLast(false), m_prevWidth(0) + wxDataViewColumnNativeData() : m_NativeColumnPtr(NULL) { } @@ -105,32 +105,9 @@ public: m_NativeColumnPtr = newNativeColumnPtr; } - bool GetIsLast() const - { - return m_isLast; - } - - void SetIsLast(bool isLast) - { - m_isLast = isLast; - } - - int GetPrevWidth() const - { - return m_prevWidth; - } - - void SetPrevWidth(int prevWidth) - { - m_prevWidth = prevWidth; - } - private: // not owned by us NSTableColumn* m_NativeColumnPtr; - - bool m_isLast; - int m_prevWidth; }; // ============================================================================ diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index ae6fb345bb..49382f52cc 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -2243,8 +2243,7 @@ bool wxCocoaDataViewControl::InsertColumn(unsigned int pos, wxDataViewColumn* co void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos) { const int count = GetCount(); - wxDataViewColumnNativeData *nativeData = GetColumn(pos)->GetNativeData(); - NSTableColumn *column = nativeData->GetNativeColumnPtr(); + NSTableColumn *column = GetColumn(pos)->GetNativeData()->GetNativeColumnPtr(); UInt32 const noOfColumns = [[m_OutlineView tableColumns] count]; class MaxWidthCalculator @@ -2376,31 +2375,10 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos) if ( m_expanderWidth == 0 ) m_expanderWidth = calculator.GetExpanderWidth(); - const bool isLast = pos == noOfColumns - 1; - - if ( isLast ) - { - // Note that FitColumnWidthToContent() is called whenever a column is - // added, so we might also just temporarily become the last column; - // since we cannot know at this time whether we will just temporarily - // be the last column, we store our current column width in order to - // restore it later in case we suddenly are no longer the last column - // because new columns have been added --> we need to restore our - // previous width in that case because it must not get lost. - nativeData->SetPrevWidth(GetColumn(pos)->GetWidth()); - + if ( pos == noOfColumns - 1 ) [m_OutlineView sizeLastColumnToFit]; - } else if ( GetColumn(pos)->GetWidthVariable() == wxCOL_WIDTH_AUTOSIZE ) - { [column setWidth:calculator.GetMaxWidth() + m_expanderWidth]; - } - else if ( nativeData->GetIsLast() ) - { - [column setWidth:nativeData->GetPrevWidth()]; - } - - nativeData->SetIsLast(isLast); if ( !(GetDataViewCtrl()->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) ) { diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index 7ac200d45b..be92e53da1 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -438,9 +438,6 @@ bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) // otherwise ask the control to 'update' the data in the newly appended column: if (GetColumnCount() == 1) SetExpanderColumn(columnPtr); - - AdjustAutosizedColumns(); - // done: return true; } @@ -482,8 +479,6 @@ bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr) { m_ColumnPtrs.Remove(columnPtr); delete columnPtr; - - AdjustAutosizedColumns(); return true; } else