git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57975
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxPG_RECURSE_STARTS = 0x00000080,
/** Force value change. */
wxPG_RECURSE_STARTS = 0x00000080,
/** Force value change. */
+wxPG_FORCE = 0x00000100,
+
+/** Only sort categories and their immediate children.
+ Sorting done by wxPG_AUTO_SORT option uses this.
+*/
+wxPG_SORT_TOP_LEVEL_ONLY = 0x00000200
void SetValidationFailureBehavior( int vfbFlags );
/**
void SetValidationFailureBehavior( int vfbFlags );
/**
+ Sorts all properties recursively.
+
+ @param flags
+ This can contain any of the following options:
+ wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their
+ immediate children. Sorting done by wxPG_AUTO_SORT option
+ uses this.
@see SortChildren, wxPropertyGrid::SetSortFunction
*/
@see SortChildren, wxPropertyGrid::SetSortFunction
*/
+ void Sort( int flags = 0 );
/**
Sorts children of a property.
/**
Sorts children of a property.
@param id
Name or pointer to a property.
@param id
Name or pointer to a property.
- @param recursively
- If @true, then children are sorted recursively.
+ @param flags
+ This can contain any of the following options:
+ wxPG_RECURSE: Sorts recursively.
@see Sort, wxPropertyGrid::SetSortFunction
*/
@see Sort, wxPropertyGrid::SetSortFunction
*/
- void SortChildren( wxPGPropArg id, bool recursively = false )
+ void SortChildren( wxPGPropArg id, int flags = 0 )
{
wxPG_PROP_ARG_CALL_PROLOG()
{
wxPG_PROP_ARG_CALL_PROLOG()
- m_pState->DoSortChildren(p, recursively);
+ m_pState->DoSortChildren(p, flags);
/** Set virtual width for this particular page. */
void SetVirtualWidth( int width );
/** Set virtual width for this particular page. */
void SetVirtualWidth( int width );
- void DoSortChildren( wxPGProperty* p, bool recursively = false );
- void DoSort();
+ void DoSortChildren( wxPGProperty* p, int flags = 0 );
+ void DoSort( int flags = 0 );
+
+ bool PrepareAfterItemsAdded();
void SetSelection( wxPGProperty* p ) { m_selected = p; }
void SetSelection( wxPGProperty* p ) { m_selected = p; }
void SetValidationFailureBehavior( int vfbFlags );
/**
void SetValidationFailureBehavior( int vfbFlags );
/**
+ Sorts all properties recursively.
+
+ @param flags
+ This can contain any of the following options:
+ wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their
+ immediate children. Sorting done by wxPG_AUTO_SORT option
+ uses this.
@see SortChildren, wxPropertyGrid::SetSortFunction
*/
@see SortChildren, wxPropertyGrid::SetSortFunction
*/
+ void Sort( int flags = 0 );
/**
Sorts children of a property.
/**
Sorts children of a property.
@param id
Name or pointer to a property.
@param id
Name or pointer to a property.
- @param recursively
- If @true, then children are sorted recursively.
+ @param flags
+ This can contain any of the following options:
+ wxPG_RECURSE: Sorts recursively.
@see Sort, wxPropertyGrid::SetSortFunction
*/
@see Sort, wxPropertyGrid::SetSortFunction
*/
- void SortChildren( wxPGPropArg id, bool recursively = false );
+ void SortChildren( wxPGPropArg id, int flags = 0 );
/**
Returns editor pointer of editor with given name;
/**
Returns editor pointer of editor with given name;
m_pState->m_itemsAdded = 0;
if ( m_windowStyle & wxPG_AUTO_SORT )
m_pState->m_itemsAdded = 0;
if ( m_windowStyle & wxPG_AUTO_SORT )
+ Sort(wxPG_SORT_TOP_LEVEL_ONLY);
RecalculateVirtualSize();
}
RecalculateVirtualSize();
}
else if ( !m_frozen )
{
// Refresh, if not frozen.
else if ( !m_frozen )
{
// Refresh, if not frozen.
- if ( m_pState->m_itemsAdded )
- PrepareAfterItemsAdded();
+ m_pState->PrepareAfterItemsAdded();
// Reselect
if ( m_pState->m_selected )
// Reselect
if ( m_pState->m_selected )
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
-void wxPropertyGridInterface::Sort()
+void wxPropertyGridInterface::Sort( int flags )
{
wxPropertyGrid* pg = GetPropertyGrid();
{
wxPropertyGrid* pg = GetPropertyGrid();
{
wxPropertyGridPageState* page = GetPageState(pageIndex);
if ( !page ) break;
{
wxPropertyGridPageState* page = GetPageState(pageIndex);
if ( !page ) break;
#endif
void wxPropertyGridPageState::DoSortChildren( wxPGProperty* p,
#endif
void wxPropertyGridPageState::DoSortChildren( wxPGProperty* p,
{
if ( !p )
p = m_properties;
{
if ( !p )
p = m_properties;
+ // Can only sort items with children
if ( !p->GetChildCount() )
return;
if ( !p->GetChildCount() )
return;
- // Can only sort items with children
- if ( p->GetChildCount() < 1 )
+ // Never sort children of aggregate properties
+ if ( p->HasFlag(wxPG_PROP_AGGREGATE) )
+ return;
+
+ if ( (flags & wxPG_SORT_TOP_LEVEL_ONLY)
+ && !p->IsCategory() && !p->IsRoot() )
p->m_children.Sort( wxPG_SortFunc_ByLabel );
#endif
p->m_children.Sort( wxPG_SortFunc_ByLabel );
#endif
p->FixIndicesOfChildren();
p->FixIndicesOfChildren();
- if ( recursively && !p->HasFlag(wxPG_PROP_AGGREGATE) )
+ if ( flags & wxPG_RECURSE )
+ // Apply sort recursively
for ( unsigned int i=0; i<p->GetChildCount(); i++ )
for ( unsigned int i=0; i<p->GetChildCount(); i++ )
- DoSortChildren(p->Item(i));
+ DoSortChildren(p->Item(i), flags);
}
}
// -----------------------------------------------------------------------
}
}
// -----------------------------------------------------------------------
-void wxPropertyGridPageState::DoSort()
+void wxPropertyGridPageState::DoSort( int flags )
- DoSortChildren( m_properties, true );
+ DoSortChildren( m_properties, flags | wxPG_RECURSE );
// Sort categories as well (but we need not do it recursively)
// Sort categories as well (but we need not do it recursively)
- if ( !IsInNonCatMode() )
+ if ( IsInNonCatMode() )
- for ( i=0;i<m_properties->GetChildCount();i++)
+ for ( i=0;i<m_regularArray.GetChildCount();i++)
- wxPGProperty* p = m_properties->Item(i);
+ wxPGProperty* p = m_regularArray.Item(i);
+ DoSortChildren( p, 0 );
+// -----------------------------------------------------------------------
+
+bool wxPropertyGridPageState::PrepareAfterItemsAdded()
+{
+ if ( !m_itemsAdded ) return false;
+
+ wxPropertyGrid* pg = GetGrid();
+
+ m_itemsAdded = 0;
+
+ if ( pg->HasFlag(wxPG_AUTO_SORT) )
+ DoSort(wxPG_SORT_TOP_LEVEL_ONLY);
+
+ return true;
+}
+
// -----------------------------------------------------------------------
// wxPropertyGridPageState splitter, column and hittest functions
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// wxPropertyGridPageState splitter, column and hittest functions
// -----------------------------------------------------------------------