Have page-specific splitter setup flags in order to fix bug that caused splitter change in one page to affect others. Also fixed a regression in splitter auto-centering.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62374 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli
2009-10-11 15:30:03 +00:00
parent b5e184c6ff
commit 0da1f1c4cc
5 changed files with 67 additions and 39 deletions

View File

@@ -549,8 +549,6 @@ enum wxPG_KEYBOARD_ACTIONS
#define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
// Set when help string is shown in status bar
#define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
// Splitter position has been custom-set by the user
#define wxPG_FL_SPLITTER_PRE_SET 0x00400000
// Validation failed. Clear on modify event.
#define wxPG_FL_VALIDATION_FAILED 0x00800000
// Auto sort is enabled (for categorized mode)
@@ -1172,7 +1170,7 @@ public:
void SetSplitterPosition( int newxpos, int col = 0 )
{
DoSetSplitterPosition_(newxpos, true, col);
m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
m_pState->m_isSplitterPreSet = true;
}
/**
@@ -2465,7 +2463,6 @@ protected:
#undef wxPG_FL_MOUSE_CAPTURED
#undef wxPG_FL_INITIALIZED
#undef wxPG_FL_ACTIVATION_BY_CLICK
#undef wxPG_FL_DONT_CENTER_SPLITTER
#undef wxPG_SUPPORT_TOOLTIPS
#undef wxPG_DOUBLE_BUFFER
#undef wxPG_ICON_WIDTH

View File

@@ -738,6 +738,12 @@ protected:
unsigned char m_vhCalcPending;
/** True if splitter has been pre-set by the application. */
bool m_isSplitterPreSet;
/** Used to (temporarily) disable splitter centering. */
bool m_dontCenterSplitter;
private:
/** Only inits arrays, doesn't migrate things or such. */
void InitNonCatMode();

View File

@@ -815,6 +815,9 @@ wxPropertyGridPage* wxPropertyGridManager::InsertPage( int index,
pageObj->m_id = m_nextTbInd;
if ( !HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
pageObj->m_dontCenterSplitter = true;
if ( isPageInserted )
m_arrPages.push_back( pageObj );
@@ -1548,12 +1551,11 @@ void wxPropertyGridManager::SetSplitterLeft( bool subProps, bool allPages )
maxW += m_pPropGrid->m_marginWidth;
if ( maxW > highest )
highest = maxW;
m_pState->m_dontCenterSplitter = true;
}
if ( highest > 0 )
m_pPropGrid->SetSplitterPosition( highest );
m_pPropGrid->m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER;
}
}
@@ -1575,12 +1577,30 @@ void wxPropertyGridManager::OnResize( wxSizeEvent& WXUNUSED(event) )
{
int width, height;
GetClientSize(&width,&height);
GetClientSize(&width, &height);
if ( m_width == -12345 )
RecreateControls();
RecalculatePositions(width,height);
RecalculatePositions(width, height);
if ( m_pPropGrid && m_pPropGrid->m_parent )
{
int pgWidth, pgHeight;
m_pPropGrid->GetClientSize(&pgWidth, &pgHeight);
// Regenerate splitter positions for non-current pages
for ( unsigned int i=0; i<GetPageCount(); i++ )
{
wxPropertyGridPage* page = GetPage(i);
if ( page != m_pPropGrid->GetState() )
{
page->OnClientWidthChange(pgWidth,
pgWidth - page->m_width,
true);
}
}
}
}
// -----------------------------------------------------------------------
@@ -1718,9 +1738,8 @@ void wxPropertyGridManager::SetSplitterPosition( int pos, int splitterColumn )
{
wxPropertyGridPage* page = GetPage(i);
page->DoSetSplitterPosition( pos, splitterColumn, false );
page->m_isSplitterPreSet = true;
}
m_pPropGrid->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET);
}
// -----------------------------------------------------------------------

View File

@@ -406,7 +406,7 @@ void wxPropertyGrid::Init2()
}
if ( !(m_windowStyle & wxPG_SPLITTER_AUTO_CENTER) )
m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER;
m_pState->m_dontCenterSplitter = true;
if ( m_windowStyle & wxPG_HIDE_CATEGORIES )
{
@@ -2634,10 +2634,11 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState )
{
//
// Just in case, fully re-center splitter
if ( HasFlag( wxPG_SPLITTER_AUTO_CENTER ) )
pNewState->m_fSplitterX = -1.0;
//if ( HasFlag( wxPG_SPLITTER_AUTO_CENTER ) )
// pNewState->m_fSplitterX = -1.0;
pNewState->OnClientWidthChange( pgWidth, pgWidth - pNewState->m_width );
pNewState->OnClientWidthChange(pgWidth,
pgWidth - pNewState->m_width);
}
m_propHover = NULL;
@@ -2668,7 +2669,9 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState )
// Call to SetSplitterPosition will always disable splitter auto-centering
// if parent window is shown.
void wxPropertyGrid::DoSetSplitterPosition_( int newxpos, bool refresh, int splitterIndex, bool allPages )
void wxPropertyGrid::DoSetSplitterPosition_( int newxpos, bool refresh,
int splitterIndex,
bool allPages )
{
if ( ( newxpos < wxPG_DRAG_MARGIN ) )
return;
@@ -2690,9 +2693,9 @@ void wxPropertyGrid::DoSetSplitterPosition_( int newxpos, bool refresh, int spli
void wxPropertyGrid::CenterSplitter( bool enableAutoCentering )
{
SetSplitterPosition( m_width/2, true );
if ( enableAutoCentering && ( m_windowStyle & wxPG_SPLITTER_AUTO_CENTER ) )
m_iFlags &= ~(wxPG_FL_DONT_CENTER_SPLITTER);
SetSplitterPosition( m_width/2 );
if ( enableAutoCentering && HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
m_pState->m_dontCenterSplitter = false;
}
// -----------------------------------------------------------------------
@@ -4087,8 +4090,8 @@ bool wxPropertyGrid::DoCollapse( wxPGProperty* p, bool sendEvents )
}
// Store dont-center-splitter flag 'cause we need to temporarily set it
wxUint32 old_flag = m_iFlags & wxPG_FL_DONT_CENTER_SPLITTER;
m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER;
bool prevDontCenterSplitter = m_pState->m_dontCenterSplitter;
m_pState->m_dontCenterSplitter = true;
bool res = m_pState->DoCollapse(pwc);
@@ -4101,8 +4104,7 @@ bool wxPropertyGrid::DoCollapse( wxPGProperty* p, bool sendEvents )
Refresh();
}
// Clear dont-center-splitter flag if it wasn't set
m_iFlags = (m_iFlags & ~wxPG_FL_DONT_CENTER_SPLITTER) | old_flag;
m_pState->m_dontCenterSplitter = prevDontCenterSplitter;
return res;
}
@@ -4116,8 +4118,8 @@ bool wxPropertyGrid::DoExpand( wxPGProperty* p, bool sendEvents )
wxPGProperty* pwc = (wxPGProperty*)p;
// Store dont-center-splitter flag 'cause we need to temporarily set it
wxUint32 old_flag = m_iFlags & wxPG_FL_DONT_CENTER_SPLITTER;
m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER;
bool prevDontCenterSplitter = m_pState->m_dontCenterSplitter;
m_pState->m_dontCenterSplitter = true;
bool res = m_pState->DoExpand(pwc);
@@ -4130,8 +4132,7 @@ bool wxPropertyGrid::DoExpand( wxPGProperty* p, bool sendEvents )
Refresh();
}
// Clear dont-center-splitter flag if it wasn't set
m_iFlags = (m_iFlags & ~wxPG_FL_DONT_CENTER_SPLITTER) | old_flag;
m_pState->m_dontCenterSplitter = prevDontCenterSplitter;
return res;
}
@@ -4620,7 +4621,7 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y,
if ( newSplitterX != splitterX )
{
// Move everything
SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER);
state->m_dontCenterSplitter = true;
state->DoSetSplitterPosition(newSplitterX,
m_draggedSplitter,
false);
@@ -4849,7 +4850,7 @@ bool wxPropertyGrid::HandleMouseUp( int x, unsigned int WXUNUSED(y),
//splitterX = x;
// Disable splitter auto-centering
m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER;
state->m_dontCenterSplitter = true;
// This is necessary to return cursor
if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED )

View File

@@ -218,6 +218,9 @@ wxPropertyGridPageState::wxPropertyGridPageState()
m_colWidths.push_back( wxPG_DEFAULT_SPLITTERX );
m_fSplitterX = wxPG_DEFAULT_SPLITTERX;
m_isSplitterPreSet = false;
m_dontCenterSplitter = false;
// By default, we only have the 'value' column editable
m_editableColumns.push_back(1);
}
@@ -351,8 +354,7 @@ void wxPropertyGridPageState::OnClientWidthChange( int newWidth, int widthChange
widthChange = 0;
CheckColumnWidths(widthChange);
if ( !(GetGrid()->GetInternalFlags() & wxPG_FL_SPLITTER_PRE_SET) &&
(GetGrid()->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER) )
if ( !m_isSplitterPreSet && m_dontCenterSplitter )
{
long timeSinceCreation = (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated).ToLong();
@@ -366,7 +368,7 @@ void wxPropertyGridPageState::OnClientWidthChange( int newWidth, int widthChange
else
{
DoSetSplitterPosition( newWidth / 2 );
GetGrid()->ClearInternalFlag(wxPG_FL_SPLITTER_PRE_SET);
m_isSplitterPreSet = false;
}
}
}
@@ -808,7 +810,9 @@ int wxPropertyGridPageState::GetColumnMinWidth( int WXUNUSED(column) ) const
return wxPG_DRAG_MARGIN;
}
void wxPropertyGridPageState::PropagateColSizeDec( int column, int decrease, int dir )
void wxPropertyGridPageState::PropagateColSizeDec( int column,
int decrease,
int dir )
{
int origWidth = m_colWidths[column];
m_colWidths[column] -= decrease;
@@ -832,7 +836,10 @@ void wxPropertyGridPageState::PropagateColSizeDec( int column, int decrease, int
PropagateColSizeDec( column, more, dir );
}
void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos, int splitterColumn, bool WXUNUSED(allPages), bool fromAutoCenter )
void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos,
int splitterColumn,
bool WXUNUSED(allPages),
bool fromAutoCenter )
{
wxPropertyGrid* pg = GetGrid();
@@ -870,8 +877,7 @@ void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos, int splitterCo
if ( !fromAutoCenter )
{
// Don't allow initial splitter auto-positioning after this.
if ( pg->GetState() == this )
pg->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET);
m_isSplitterPreSet = true;
CheckColumnWidths();
}
@@ -892,7 +898,7 @@ void wxPropertyGridPageState::SetSplitterLeft( bool subProps )
DoSetSplitterPosition( maxW );
}
pg->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER);
m_dontCenterSplitter = true;
}
wxSize wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize) )
@@ -923,7 +929,7 @@ wxSize wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize) )
int remaining = m_width - accWid;
m_colWidths[GetColumnCount()-1] += remaining;
pg->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER);
m_dontCenterSplitter = true;
int firstSplitterX = marginWidth + m_colWidths[0];
m_fSplitterX = (double) firstSplitterX;
@@ -1036,8 +1042,7 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange )
}
// Auto center splitter
if ( !(pg->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER) &&
m_colWidths.size() == 2 )
if ( !m_dontCenterSplitter && m_colWidths.size() == 2 )
{
float centerX = (float)(pg->m_width/2);
float splitterX;