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:
@@ -549,8 +549,6 @@ enum wxPG_KEYBOARD_ACTIONS
|
|||||||
#define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
|
#define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
|
||||||
// Set when help string is shown in status bar
|
// Set when help string is shown in status bar
|
||||||
#define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
|
#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.
|
// Validation failed. Clear on modify event.
|
||||||
#define wxPG_FL_VALIDATION_FAILED 0x00800000
|
#define wxPG_FL_VALIDATION_FAILED 0x00800000
|
||||||
// Auto sort is enabled (for categorized mode)
|
// Auto sort is enabled (for categorized mode)
|
||||||
@@ -1172,7 +1170,7 @@ public:
|
|||||||
void SetSplitterPosition( int newxpos, int col = 0 )
|
void SetSplitterPosition( int newxpos, int col = 0 )
|
||||||
{
|
{
|
||||||
DoSetSplitterPosition_(newxpos, true, col);
|
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_MOUSE_CAPTURED
|
||||||
#undef wxPG_FL_INITIALIZED
|
#undef wxPG_FL_INITIALIZED
|
||||||
#undef wxPG_FL_ACTIVATION_BY_CLICK
|
#undef wxPG_FL_ACTIVATION_BY_CLICK
|
||||||
#undef wxPG_FL_DONT_CENTER_SPLITTER
|
|
||||||
#undef wxPG_SUPPORT_TOOLTIPS
|
#undef wxPG_SUPPORT_TOOLTIPS
|
||||||
#undef wxPG_DOUBLE_BUFFER
|
#undef wxPG_DOUBLE_BUFFER
|
||||||
#undef wxPG_ICON_WIDTH
|
#undef wxPG_ICON_WIDTH
|
||||||
|
@@ -738,6 +738,12 @@ protected:
|
|||||||
|
|
||||||
unsigned char m_vhCalcPending;
|
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:
|
private:
|
||||||
/** Only inits arrays, doesn't migrate things or such. */
|
/** Only inits arrays, doesn't migrate things or such. */
|
||||||
void InitNonCatMode();
|
void InitNonCatMode();
|
||||||
|
@@ -815,6 +815,9 @@ wxPropertyGridPage* wxPropertyGridManager::InsertPage( int index,
|
|||||||
|
|
||||||
pageObj->m_id = m_nextTbInd;
|
pageObj->m_id = m_nextTbInd;
|
||||||
|
|
||||||
|
if ( !HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
|
||||||
|
pageObj->m_dontCenterSplitter = true;
|
||||||
|
|
||||||
if ( isPageInserted )
|
if ( isPageInserted )
|
||||||
m_arrPages.push_back( pageObj );
|
m_arrPages.push_back( pageObj );
|
||||||
|
|
||||||
@@ -1548,12 +1551,11 @@ void wxPropertyGridManager::SetSplitterLeft( bool subProps, bool allPages )
|
|||||||
maxW += m_pPropGrid->m_marginWidth;
|
maxW += m_pPropGrid->m_marginWidth;
|
||||||
if ( maxW > highest )
|
if ( maxW > highest )
|
||||||
highest = maxW;
|
highest = maxW;
|
||||||
|
m_pState->m_dontCenterSplitter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( highest > 0 )
|
if ( highest > 0 )
|
||||||
m_pPropGrid->SetSplitterPosition( highest );
|
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;
|
int width, height;
|
||||||
|
|
||||||
GetClientSize(&width,&height);
|
GetClientSize(&width, &height);
|
||||||
|
|
||||||
if ( m_width == -12345 )
|
if ( m_width == -12345 )
|
||||||
RecreateControls();
|
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);
|
wxPropertyGridPage* page = GetPage(i);
|
||||||
page->DoSetSplitterPosition( pos, splitterColumn, false );
|
page->DoSetSplitterPosition( pos, splitterColumn, false );
|
||||||
|
page->m_isSplitterPreSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pPropGrid->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
@@ -406,7 +406,7 @@ void wxPropertyGrid::Init2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !(m_windowStyle & wxPG_SPLITTER_AUTO_CENTER) )
|
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 )
|
if ( m_windowStyle & wxPG_HIDE_CATEGORIES )
|
||||||
{
|
{
|
||||||
@@ -2634,10 +2634,11 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState )
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Just in case, fully re-center splitter
|
// Just in case, fully re-center splitter
|
||||||
if ( HasFlag( wxPG_SPLITTER_AUTO_CENTER ) )
|
//if ( HasFlag( wxPG_SPLITTER_AUTO_CENTER ) )
|
||||||
pNewState->m_fSplitterX = -1.0;
|
// pNewState->m_fSplitterX = -1.0;
|
||||||
|
|
||||||
pNewState->OnClientWidthChange( pgWidth, pgWidth - pNewState->m_width );
|
pNewState->OnClientWidthChange(pgWidth,
|
||||||
|
pgWidth - pNewState->m_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_propHover = NULL;
|
m_propHover = NULL;
|
||||||
@@ -2668,7 +2669,9 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState )
|
|||||||
|
|
||||||
// Call to SetSplitterPosition will always disable splitter auto-centering
|
// Call to SetSplitterPosition will always disable splitter auto-centering
|
||||||
// if parent window is shown.
|
// 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 ) )
|
if ( ( newxpos < wxPG_DRAG_MARGIN ) )
|
||||||
return;
|
return;
|
||||||
@@ -2690,9 +2693,9 @@ void wxPropertyGrid::DoSetSplitterPosition_( int newxpos, bool refresh, int spli
|
|||||||
|
|
||||||
void wxPropertyGrid::CenterSplitter( bool enableAutoCentering )
|
void wxPropertyGrid::CenterSplitter( bool enableAutoCentering )
|
||||||
{
|
{
|
||||||
SetSplitterPosition( m_width/2, true );
|
SetSplitterPosition( m_width/2 );
|
||||||
if ( enableAutoCentering && ( m_windowStyle & wxPG_SPLITTER_AUTO_CENTER ) )
|
if ( enableAutoCentering && HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
|
||||||
m_iFlags &= ~(wxPG_FL_DONT_CENTER_SPLITTER);
|
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
|
// Store dont-center-splitter flag 'cause we need to temporarily set it
|
||||||
wxUint32 old_flag = m_iFlags & wxPG_FL_DONT_CENTER_SPLITTER;
|
bool prevDontCenterSplitter = m_pState->m_dontCenterSplitter;
|
||||||
m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER;
|
m_pState->m_dontCenterSplitter = true;
|
||||||
|
|
||||||
bool res = m_pState->DoCollapse(pwc);
|
bool res = m_pState->DoCollapse(pwc);
|
||||||
|
|
||||||
@@ -4101,8 +4104,7 @@ bool wxPropertyGrid::DoCollapse( wxPGProperty* p, bool sendEvents )
|
|||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear dont-center-splitter flag if it wasn't set
|
m_pState->m_dontCenterSplitter = prevDontCenterSplitter;
|
||||||
m_iFlags = (m_iFlags & ~wxPG_FL_DONT_CENTER_SPLITTER) | old_flag;
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -4116,8 +4118,8 @@ bool wxPropertyGrid::DoExpand( wxPGProperty* p, bool sendEvents )
|
|||||||
wxPGProperty* pwc = (wxPGProperty*)p;
|
wxPGProperty* pwc = (wxPGProperty*)p;
|
||||||
|
|
||||||
// Store dont-center-splitter flag 'cause we need to temporarily set it
|
// Store dont-center-splitter flag 'cause we need to temporarily set it
|
||||||
wxUint32 old_flag = m_iFlags & wxPG_FL_DONT_CENTER_SPLITTER;
|
bool prevDontCenterSplitter = m_pState->m_dontCenterSplitter;
|
||||||
m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER;
|
m_pState->m_dontCenterSplitter = true;
|
||||||
|
|
||||||
bool res = m_pState->DoExpand(pwc);
|
bool res = m_pState->DoExpand(pwc);
|
||||||
|
|
||||||
@@ -4130,8 +4132,7 @@ bool wxPropertyGrid::DoExpand( wxPGProperty* p, bool sendEvents )
|
|||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear dont-center-splitter flag if it wasn't set
|
m_pState->m_dontCenterSplitter = prevDontCenterSplitter;
|
||||||
m_iFlags = (m_iFlags & ~wxPG_FL_DONT_CENTER_SPLITTER) | old_flag;
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -4620,7 +4621,7 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y,
|
|||||||
if ( newSplitterX != splitterX )
|
if ( newSplitterX != splitterX )
|
||||||
{
|
{
|
||||||
// Move everything
|
// Move everything
|
||||||
SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER);
|
state->m_dontCenterSplitter = true;
|
||||||
state->DoSetSplitterPosition(newSplitterX,
|
state->DoSetSplitterPosition(newSplitterX,
|
||||||
m_draggedSplitter,
|
m_draggedSplitter,
|
||||||
false);
|
false);
|
||||||
@@ -4849,7 +4850,7 @@ bool wxPropertyGrid::HandleMouseUp( int x, unsigned int WXUNUSED(y),
|
|||||||
//splitterX = x;
|
//splitterX = x;
|
||||||
|
|
||||||
// Disable splitter auto-centering
|
// Disable splitter auto-centering
|
||||||
m_iFlags |= wxPG_FL_DONT_CENTER_SPLITTER;
|
state->m_dontCenterSplitter = true;
|
||||||
|
|
||||||
// This is necessary to return cursor
|
// This is necessary to return cursor
|
||||||
if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED )
|
if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED )
|
||||||
|
@@ -218,6 +218,9 @@ wxPropertyGridPageState::wxPropertyGridPageState()
|
|||||||
m_colWidths.push_back( wxPG_DEFAULT_SPLITTERX );
|
m_colWidths.push_back( wxPG_DEFAULT_SPLITTERX );
|
||||||
m_fSplitterX = wxPG_DEFAULT_SPLITTERX;
|
m_fSplitterX = wxPG_DEFAULT_SPLITTERX;
|
||||||
|
|
||||||
|
m_isSplitterPreSet = false;
|
||||||
|
m_dontCenterSplitter = false;
|
||||||
|
|
||||||
// By default, we only have the 'value' column editable
|
// By default, we only have the 'value' column editable
|
||||||
m_editableColumns.push_back(1);
|
m_editableColumns.push_back(1);
|
||||||
}
|
}
|
||||||
@@ -351,8 +354,7 @@ void wxPropertyGridPageState::OnClientWidthChange( int newWidth, int widthChange
|
|||||||
widthChange = 0;
|
widthChange = 0;
|
||||||
CheckColumnWidths(widthChange);
|
CheckColumnWidths(widthChange);
|
||||||
|
|
||||||
if ( !(GetGrid()->GetInternalFlags() & wxPG_FL_SPLITTER_PRE_SET) &&
|
if ( !m_isSplitterPreSet && m_dontCenterSplitter )
|
||||||
(GetGrid()->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER) )
|
|
||||||
{
|
{
|
||||||
long timeSinceCreation = (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated).ToLong();
|
long timeSinceCreation = (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated).ToLong();
|
||||||
|
|
||||||
@@ -366,7 +368,7 @@ void wxPropertyGridPageState::OnClientWidthChange( int newWidth, int widthChange
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
DoSetSplitterPosition( newWidth / 2 );
|
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;
|
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];
|
int origWidth = m_colWidths[column];
|
||||||
m_colWidths[column] -= decrease;
|
m_colWidths[column] -= decrease;
|
||||||
@@ -832,7 +836,10 @@ void wxPropertyGridPageState::PropagateColSizeDec( int column, int decrease, int
|
|||||||
PropagateColSizeDec( column, more, dir );
|
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();
|
wxPropertyGrid* pg = GetGrid();
|
||||||
|
|
||||||
@@ -870,8 +877,7 @@ void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos, int splitterCo
|
|||||||
if ( !fromAutoCenter )
|
if ( !fromAutoCenter )
|
||||||
{
|
{
|
||||||
// Don't allow initial splitter auto-positioning after this.
|
// Don't allow initial splitter auto-positioning after this.
|
||||||
if ( pg->GetState() == this )
|
m_isSplitterPreSet = true;
|
||||||
pg->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET);
|
|
||||||
|
|
||||||
CheckColumnWidths();
|
CheckColumnWidths();
|
||||||
}
|
}
|
||||||
@@ -892,7 +898,7 @@ void wxPropertyGridPageState::SetSplitterLeft( bool subProps )
|
|||||||
DoSetSplitterPosition( maxW );
|
DoSetSplitterPosition( maxW );
|
||||||
}
|
}
|
||||||
|
|
||||||
pg->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER);
|
m_dontCenterSplitter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize) )
|
wxSize wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize) )
|
||||||
@@ -923,7 +929,7 @@ wxSize wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize) )
|
|||||||
int remaining = m_width - accWid;
|
int remaining = m_width - accWid;
|
||||||
m_colWidths[GetColumnCount()-1] += remaining;
|
m_colWidths[GetColumnCount()-1] += remaining;
|
||||||
|
|
||||||
pg->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER);
|
m_dontCenterSplitter = true;
|
||||||
|
|
||||||
int firstSplitterX = marginWidth + m_colWidths[0];
|
int firstSplitterX = marginWidth + m_colWidths[0];
|
||||||
m_fSplitterX = (double) firstSplitterX;
|
m_fSplitterX = (double) firstSplitterX;
|
||||||
@@ -1036,8 +1042,7 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Auto center splitter
|
// Auto center splitter
|
||||||
if ( !(pg->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER) &&
|
if ( !m_dontCenterSplitter && m_colWidths.size() == 2 )
|
||||||
m_colWidths.size() == 2 )
|
|
||||||
{
|
{
|
||||||
float centerX = (float)(pg->m_width/2);
|
float centerX = (float)(pg->m_width/2);
|
||||||
float splitterX;
|
float splitterX;
|
||||||
|
Reference in New Issue
Block a user