/**
Centers the splitter.
-
- If argument is true, automatic splitter centering is enabled (only
- applicapple 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.
*/
/** Returns current selection text colour. */
wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
- /** Returns current splitter x position. */
- int GetSplitterPosition() const
- { return m_pState->DoGetSplitterPosition(0); }
+ /**
+ Returns current splitter x position.
+ */
+ int GetSplitterPosition( unsigned int splitterIndex = 0 ) const
+ {
+ return m_pState->DoGetSplitterPosition(splitterIndex);
+ }
/** Returns wxTextCtrl active in currently selected property, if any. Takes
into account wxOwnerDrawnComboBox.
*/
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.
Editor widget is automatically created, but not focused unless focus is
return m_columnProportions[column];
}
+ void ResetColumnSizes( int setSplitterFlags );
+
wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
wxPGProperty* GetPropertyByLabel( const wxString& name,
bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
/**
- Centers the splitter. If argument is true, automatic splitter centering
- is enabled (only applicable if style wxPG_SPLITTER_AUTO_CENTER was
- defined).
+ Centers the splitter.
+
+ @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.
/**
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
*/
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,
an assertion failure will occur.
// -----------------------------------------------------------------------
-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 );
- if ( enableAutoCentering && HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
+ if ( enableAutoResizing && HasFlag(wxPG_SPLITTER_AUTO_CENTER) )
m_pState->m_dontCenterSplitter = false;
}
// Double-clicking the splitter causes auto-centering
if ( m_pState->GetColumnCount() <= 2 )
{
- CenterSplitter( true );
+ ResetColumnSizes( true );
SendEvent(wxEVT_PG_COL_DRAGGING,
m_propHover,
wxPG_SEL_NOVALIDATE,
(unsigned int)m_draggedSplitter);
- // Disable splitter auto-centering
- state->m_dontCenterSplitter = true;
+ // Disable splitter auto-centering (but only if moved any -
+ // 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
if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED )
//
// 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;
+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;
- 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);
- }
- }
+ // 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);
}
}