Fixed auto-resizing behavior when double-clicking a splitter; Added wxPropertyGrid::ResetColumnSizes(); wxPropertyGrid::GetSplitterPosition() got splitterIndex argument
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63502 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -735,11 +735,12 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Centers the splitter.
|
Centers the splitter.
|
||||||
|
|
||||||
If argument is true, automatic splitter centering is enabled (only
|
@param enableAutoResizing
|
||||||
applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
|
If @true, automatic column resizing is enabled (only applicapple
|
||||||
|
if window style wxPG_SPLITTER_AUTO_CENTER is used).
|
||||||
*/
|
*/
|
||||||
void CenterSplitter( bool enable_auto_centering = false );
|
void CenterSplitter( bool enableAutoResizing = false );
|
||||||
|
|
||||||
/** Deletes all properties.
|
/** Deletes all properties.
|
||||||
*/
|
*/
|
||||||
@@ -937,9 +938,13 @@ public:
|
|||||||
/** Returns current selection text colour. */
|
/** Returns current selection text colour. */
|
||||||
wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
|
wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
|
||||||
|
|
||||||
/** Returns current splitter x position. */
|
/**
|
||||||
int GetSplitterPosition() const
|
Returns current splitter x position.
|
||||||
{ return m_pState->DoGetSplitterPosition(0); }
|
*/
|
||||||
|
int GetSplitterPosition( unsigned int splitterIndex = 0 ) const
|
||||||
|
{
|
||||||
|
return m_pState->DoGetSplitterPosition(splitterIndex);
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns wxTextCtrl active in currently selected property, if any. Takes
|
/** Returns wxTextCtrl active in currently selected property, if any. Takes
|
||||||
into account wxOwnerDrawnComboBox.
|
into account wxOwnerDrawnComboBox.
|
||||||
@@ -1021,6 +1026,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
void ResetColours();
|
void ResetColours();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets column sizes and splitter positions, based on proportions.
|
||||||
|
|
||||||
|
@param enableAutoResizing
|
||||||
|
If @true, automatic column resizing is enabled (only applicapple
|
||||||
|
if window style wxPG_SPLITTER_AUTO_CENTER is used).
|
||||||
|
|
||||||
|
@see wxPropertyGridInterface::SetColumnProportion()
|
||||||
|
*/
|
||||||
|
void ResetColumnSizes( bool enableAutoResizing = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Selects a property.
|
Selects a property.
|
||||||
Editor widget is automatically created, but not focused unless focus is
|
Editor widget is automatically created, but not focused unless focus is
|
||||||
|
@@ -554,6 +554,8 @@ public:
|
|||||||
return m_columnProportions[column];
|
return m_columnProportions[column];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResetColumnSizes( int setSplitterFlags );
|
||||||
|
|
||||||
wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
|
wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
|
||||||
|
|
||||||
wxPGProperty* GetPropertyByLabel( const wxString& name,
|
wxPGProperty* GetPropertyByLabel( const wxString& name,
|
||||||
|
@@ -503,11 +503,13 @@ public:
|
|||||||
bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
|
bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Centers the splitter. If argument is true, automatic splitter centering
|
Centers the splitter.
|
||||||
is enabled (only applicable if style wxPG_SPLITTER_AUTO_CENTER was
|
|
||||||
defined).
|
@param enableAutoResizing
|
||||||
|
If @true, automatic column resizing is enabled (only applicapple
|
||||||
|
if window style wxPG_SPLITTER_AUTO_CENTER is used).
|
||||||
*/
|
*/
|
||||||
void CenterSplitter( bool enable_auto_centering = false );
|
void CenterSplitter( bool enableAutoResizing = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Deletes all properties.
|
Deletes all properties.
|
||||||
@@ -735,7 +737,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Returns current splitter x position.
|
Returns current splitter x position.
|
||||||
*/
|
*/
|
||||||
int GetSplitterPosition() const;
|
int GetSplitterPosition( unsigned int splitterIndex = 0 ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns wxTextCtrl active in currently selected property, if any. Takes
|
Returns wxTextCtrl active in currently selected property, if any. Takes
|
||||||
@@ -839,6 +841,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
void ResetColours();
|
void ResetColours();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets column sizes and splitter positions, based on proportions.
|
||||||
|
|
||||||
|
@param enableAutoResizing
|
||||||
|
If @true, automatic column resizing is enabled (only applicapple
|
||||||
|
if window style wxPG_SPLITTER_AUTO_CENTER is used).
|
||||||
|
|
||||||
|
@see wxPropertyGridInterface::SetColumnProportion()
|
||||||
|
*/
|
||||||
|
void ResetColumnSizes( bool enableAutoResizing = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes given property from selection. If property is not selected,
|
Removes given property from selection. If property is not selected,
|
||||||
an assertion failure will occur.
|
an assertion failure will occur.
|
||||||
|
@@ -2812,10 +2812,22 @@ void wxPropertyGrid::DoSetSplitterPosition( int newxpos,
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxPropertyGrid::CenterSplitter( bool enableAutoCentering )
|
void wxPropertyGrid::ResetColumnSizes( bool enableAutoResizing )
|
||||||
|
{
|
||||||
|
wxPropertyGridPageState* state = m_pState;
|
||||||
|
if ( state )
|
||||||
|
state->ResetColumnSizes(0);
|
||||||
|
|
||||||
|
if ( enableAutoResizing && HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
|
||||||
|
m_pState->m_dontCenterSplitter = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxPropertyGrid::CenterSplitter( bool enableAutoResizing )
|
||||||
{
|
{
|
||||||
SetSplitterPosition( m_width/2 );
|
SetSplitterPosition( m_width/2 );
|
||||||
if ( enableAutoCentering && HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
|
if ( enableAutoResizing && HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
|
||||||
m_pState->m_dontCenterSplitter = false;
|
m_pState->m_dontCenterSplitter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4626,7 +4638,7 @@ bool wxPropertyGrid::HandleMouseClick( int x, unsigned int y, wxMouseEvent &even
|
|||||||
// Double-clicking the splitter causes auto-centering
|
// Double-clicking the splitter causes auto-centering
|
||||||
if ( m_pState->GetColumnCount() <= 2 )
|
if ( m_pState->GetColumnCount() <= 2 )
|
||||||
{
|
{
|
||||||
CenterSplitter( true );
|
ResetColumnSizes( true );
|
||||||
|
|
||||||
SendEvent(wxEVT_PG_COL_DRAGGING,
|
SendEvent(wxEVT_PG_COL_DRAGGING,
|
||||||
m_propHover,
|
m_propHover,
|
||||||
@@ -5040,8 +5052,14 @@ bool wxPropertyGrid::HandleMouseUp( int x, unsigned int WXUNUSED(y),
|
|||||||
wxPG_SEL_NOVALIDATE,
|
wxPG_SEL_NOVALIDATE,
|
||||||
(unsigned int)m_draggedSplitter);
|
(unsigned int)m_draggedSplitter);
|
||||||
|
|
||||||
// Disable splitter auto-centering
|
// Disable splitter auto-centering (but only if moved any -
|
||||||
state->m_dontCenterSplitter = true;
|
// otherwise we end up disabling auto-center even after a
|
||||||
|
// recentering double-click).
|
||||||
|
int posDiff = abs(m_startingSplitterX -
|
||||||
|
GetSplitterPosition(m_draggedSplitter));
|
||||||
|
|
||||||
|
if ( posDiff > 1 )
|
||||||
|
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 )
|
||||||
|
@@ -1106,25 +1106,31 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange )
|
|||||||
//
|
//
|
||||||
// Generic re-center code
|
// Generic re-center code
|
||||||
//
|
//
|
||||||
|
ResetColumnSizes(wxPG_SPLITTER_FROM_AUTO_CENTER);
|
||||||
// Calculate sum of proportions
|
|
||||||
int psum = 0;
|
|
||||||
for ( i=0; i<m_colWidths.size(); i++ )
|
|
||||||
psum += m_columnProportions[i];
|
|
||||||
int puwid = (pg->m_width*256) / psum;
|
|
||||||
int cpos = 0;
|
|
||||||
|
|
||||||
for ( i=0; i<(m_colWidths.size() - 1); i++ )
|
|
||||||
{
|
|
||||||
int cwid = (puwid*m_columnProportions[i]) / 256;
|
|
||||||
cpos += cwid;
|
|
||||||
DoSetSplitterPosition(cpos, i,
|
|
||||||
wxPG_SPLITTER_FROM_AUTO_CENTER);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxPropertyGridPageState::ResetColumnSizes( int setSplitterFlags )
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
// Calculate sum of proportions
|
||||||
|
int psum = 0;
|
||||||
|
for ( i=0; i<m_colWidths.size(); i++ )
|
||||||
|
psum += m_columnProportions[i];
|
||||||
|
int puwid = (m_pPropGrid->m_width*256) / psum;
|
||||||
|
int cpos = 0;
|
||||||
|
|
||||||
|
// Convert proportion to splitter positions
|
||||||
|
for ( i=0; i<(m_colWidths.size() - 1); i++ )
|
||||||
|
{
|
||||||
|
int cwid = (puwid*m_columnProportions[i]) / 256;
|
||||||
|
cpos += cwid;
|
||||||
|
DoSetSplitterPosition(cpos, i,
|
||||||
|
setSplitterFlags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxPropertyGridPageState::SetColumnCount( int colCount )
|
void wxPropertyGridPageState::SetColumnCount( int colCount )
|
||||||
{
|
{
|
||||||
wxASSERT( colCount >= 2 );
|
wxASSERT( colCount >= 2 );
|
||||||
|
Reference in New Issue
Block a user