Revert "Fix sizing of temporarily last columns in macOS wxDataViewCtrl"

This reverts commit c9221fd538.
This commit is contained in:
Václav Slavík
2021-08-10 19:12:53 +02:00
parent ebec1ff9f6
commit 5f34d07bc1
3 changed files with 3 additions and 53 deletions

View File

@@ -86,7 +86,7 @@ class wxCocoaDataViewControl;
class wxDataViewColumnNativeData class wxDataViewColumnNativeData
{ {
public: public:
wxDataViewColumnNativeData() : m_NativeColumnPtr(NULL), m_isLast(false), m_prevWidth(0) wxDataViewColumnNativeData() : m_NativeColumnPtr(NULL)
{ {
} }
@@ -105,32 +105,9 @@ public:
m_NativeColumnPtr = newNativeColumnPtr; 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: private:
// not owned by us // not owned by us
NSTableColumn* m_NativeColumnPtr; NSTableColumn* m_NativeColumnPtr;
bool m_isLast;
int m_prevWidth;
}; };
// ============================================================================ // ============================================================================

View File

@@ -2243,8 +2243,7 @@ bool wxCocoaDataViewControl::InsertColumn(unsigned int pos, wxDataViewColumn* co
void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos) void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
{ {
const int count = GetCount(); const int count = GetCount();
wxDataViewColumnNativeData *nativeData = GetColumn(pos)->GetNativeData(); NSTableColumn *column = GetColumn(pos)->GetNativeData()->GetNativeColumnPtr();
NSTableColumn *column = nativeData->GetNativeColumnPtr();
UInt32 const noOfColumns = [[m_OutlineView tableColumns] count]; UInt32 const noOfColumns = [[m_OutlineView tableColumns] count];
class MaxWidthCalculator class MaxWidthCalculator
@@ -2376,31 +2375,10 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
if ( m_expanderWidth == 0 ) if ( m_expanderWidth == 0 )
m_expanderWidth = calculator.GetExpanderWidth(); m_expanderWidth = calculator.GetExpanderWidth();
const bool isLast = pos == noOfColumns - 1; if ( 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());
[m_OutlineView sizeLastColumnToFit]; [m_OutlineView sizeLastColumnToFit];
}
else if ( GetColumn(pos)->GetWidthVariable() == wxCOL_WIDTH_AUTOSIZE ) else if ( GetColumn(pos)->GetWidthVariable() == wxCOL_WIDTH_AUTOSIZE )
{
[column setWidth:calculator.GetMaxWidth() + m_expanderWidth]; [column setWidth:calculator.GetMaxWidth() + m_expanderWidth];
}
else if ( nativeData->GetIsLast() )
{
[column setWidth:nativeData->GetPrevWidth()];
}
nativeData->SetIsLast(isLast);
if ( !(GetDataViewCtrl()->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) ) if ( !(GetDataViewCtrl()->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) )
{ {

View File

@@ -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: // otherwise ask the control to 'update' the data in the newly appended column:
if (GetColumnCount() == 1) if (GetColumnCount() == 1)
SetExpanderColumn(columnPtr); SetExpanderColumn(columnPtr);
AdjustAutosizedColumns();
// done: // done:
return true; return true;
} }
@@ -482,8 +479,6 @@ bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr)
{ {
m_ColumnPtrs.Remove(columnPtr); m_ColumnPtrs.Remove(columnPtr);
delete columnPtr; delete columnPtr;
AdjustAutosizedColumns();
return true; return true;
} }
else else