Fix adjustment of columns width in response to splitter position change in wPG.

In wxPropertyGridPageState::PropagateColSizeDec recursion is replaced with iteration and there is handled PG with more then 2 columns.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek 2014-11-18 16:34:16 +00:00
parent 00603c618b
commit 460b24e486

View File

@ -877,26 +877,40 @@ void wxPropertyGridPageState::PropagateColSizeDec( int column,
int decrease,
int dir )
{
int origWidth = m_colWidths[column];
m_colWidths[column] -= decrease;
int min = GetColumnMinWidth(column);
int more = 0;
if ( m_colWidths[column] < min )
wxASSERT( decrease >= 0 );
wxASSERT( dir == 1 || dir == -1 );
int col = column;
while(decrease > 0 && col >= 0 && col < (int)m_colWidths.size())
{
more = decrease - (origWidth - min);
m_colWidths[column] = min;
const int origWidth = m_colWidths[col];
const int min = GetColumnMinWidth(col);
m_colWidths[col] -= decrease;
if ( m_colWidths[col] < min )
{
m_colWidths[col] = min;
}
decrease -= (origWidth - m_colWidths[col]);
col += dir;
}
// As a last resort, if change of width was not fully absorbed
// on the requested side we try to do this on the other side.
col = column;
dir *= -1;
while(decrease > 0 && col >= 0 && col < (int)m_colWidths.size())
{
const int origWidth = m_colWidths[col];
const int min = GetColumnMinWidth(col);
m_colWidths[col] -= decrease;
if ( m_colWidths[col] < min )
{
m_colWidths[col] = min;
}
decrease -= (origWidth - m_colWidths[col]);
col += dir;
}
//
// FIXME: Causes erratic splitter changing, so as a workaround
// disabled if two or less columns.
if ( m_colWidths.size() <= 2 )
return;
column += dir;
if ( more && column < (int)m_colWidths.size() && column >= 0 )
PropagateColSizeDec( column, more, dir );
wxASSERT( decrease == 0 );
}
void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos,
@ -919,7 +933,7 @@ void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos,
m_colWidths[splitterColumn] += adjust;
PropagateColSizeDec( otherColumn, adjust, 1 );
}
else
else if ( adjust < 0 )
{
otherColumn = splitterColumn + 1;
if ( otherColumn == (int)m_colWidths.size() )
@ -932,6 +946,8 @@ void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos,
{
m_colWidths[splitterColumn] += adjust;
}
// Actual adjustment can be different from demanded.
newXPos = DoGetSplitterPosition(splitterColumn);
if ( splitterColumn == 0 )
m_fSplitterX = (double) newXPos;