Refactor wxGrid code to use SetNativeHeaderColXXX() functions
Add two simple helpers: SetNativeHeaderColCount() and SetNativeHeaderColOrder() and call the latter from the former to ensure that the columns order is always correct when switching to the native control.
This commit is contained in:
@@ -2382,6 +2382,12 @@ private:
|
|||||||
void DoSetRowSize( int row, int height );
|
void DoSetRowSize( int row, int height );
|
||||||
void DoSetColSize( int col, int width );
|
void DoSetColSize( int col, int width );
|
||||||
|
|
||||||
|
// These methods can only be called when m_useNativeHeader is true and call
|
||||||
|
// SetColumnCount() and Set- or ResetColumnsOrder() as necessary on the
|
||||||
|
// native wxHeaderCtrl being used. Note that the first one already calls
|
||||||
|
// the second one, so it's never necessary to call both of them.
|
||||||
|
void SetNativeHeaderColCount();
|
||||||
|
void SetNativeHeaderColOrder();
|
||||||
|
|
||||||
// these sets contain the indices of fixed, i.e. non-resizable
|
// these sets contain the indices of fixed, i.e. non-resizable
|
||||||
// interactively, grid rows or columns and are NULL if there are no fixed
|
// interactively, grid rows or columns and are NULL if there are no fixed
|
||||||
|
@@ -2438,7 +2438,7 @@ wxGrid::SetTable(wxGridTableBase *table,
|
|||||||
// Notice that this must be called after setting m_table as it uses it
|
// Notice that this must be called after setting m_table as it uses it
|
||||||
// indirectly, via wxGrid::GetColLabelValue().
|
// indirectly, via wxGrid::GetColLabelValue().
|
||||||
if ( m_useNativeHeader )
|
if ( m_useNativeHeader )
|
||||||
GetGridColHeader()->SetColumnCount(m_numCols);
|
SetNativeHeaderColCount();
|
||||||
|
|
||||||
m_selection = new wxGridSelection( this, selmode );
|
m_selection = new wxGridSelection( this, selmode );
|
||||||
if (checkSelection)
|
if (checkSelection)
|
||||||
@@ -4569,10 +4569,7 @@ void wxGrid::RefreshAfterColPosChange()
|
|||||||
// and make the changes visible
|
// and make the changes visible
|
||||||
if ( m_useNativeHeader )
|
if ( m_useNativeHeader )
|
||||||
{
|
{
|
||||||
if ( m_colAt.empty() )
|
SetNativeHeaderColOrder();
|
||||||
GetGridColHeader()->ResetColumnsOrder();
|
|
||||||
else
|
|
||||||
GetGridColHeader()->SetColumnsOrder(m_colAt);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -5950,7 +5947,8 @@ void wxGrid::UseNativeColHeader(bool native)
|
|||||||
CreateColumnWindow();
|
CreateColumnWindow();
|
||||||
|
|
||||||
if ( m_useNativeHeader )
|
if ( m_useNativeHeader )
|
||||||
GetGridColHeader()->SetColumnCount(m_numCols);
|
SetNativeHeaderColCount();
|
||||||
|
|
||||||
CalcWindowSizes();
|
CalcWindowSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8494,6 +8492,25 @@ int wxGrid::GetRowMinimalAcceptableHeight() const
|
|||||||
return m_minAcceptableRowHeight;
|
return m_minAcceptableRowHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGrid::SetNativeHeaderColCount()
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( m_useNativeHeader, "no column header window" );
|
||||||
|
|
||||||
|
GetGridColHeader()->SetColumnCount(m_numCols);
|
||||||
|
|
||||||
|
SetNativeHeaderColOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGrid::SetNativeHeaderColOrder()
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( m_useNativeHeader, "no column header window" );
|
||||||
|
|
||||||
|
if ( !m_colAt.empty() )
|
||||||
|
GetGridColHeader()->SetColumnsOrder(m_colAt);
|
||||||
|
else
|
||||||
|
GetGridColHeader()->ResetColumnsOrder();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// auto sizing
|
// auto sizing
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user