Added wxPropertyGrid::SetSortFunction(); moved Sort() and SortChildren() to wxPropertyGridInterface; default sorting is now case-insensitive
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1008,6 +1008,45 @@ public:
|
||||
m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
Sets the property sorting function.
|
||||
|
||||
@param sortFunction
|
||||
The sorting function to be used. It should return a value greater
|
||||
than 0 if position of p1 is after p2. So, for instance, when
|
||||
comparing property names, you can use following implementation:
|
||||
|
||||
@code
|
||||
int MyPropertySortFunction(wxPropertyGrid* propGrid,
|
||||
wxPGProperty* p1,
|
||||
wxPGProperty* p2)
|
||||
{
|
||||
return p1->GetBaseName().compare( p2->GetBaseName() );
|
||||
}
|
||||
@endcode
|
||||
|
||||
@remarks
|
||||
Default property sort function sorts properties by their labels
|
||||
(case-insensitively).
|
||||
|
||||
@see GetSortFunction, wxPropertyGridInterface::Sort,
|
||||
wxPropertyGridInterface::SortChildren
|
||||
*/
|
||||
void SetSortFunction( wxPGSortCallback sortFunction )
|
||||
{
|
||||
m_sortFunction = sortFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the property sort function (default is @NULL).
|
||||
|
||||
@see SetSortFunction
|
||||
*/
|
||||
wxPGSortCallback GetSortFunction() const
|
||||
{
|
||||
return m_sortFunction;
|
||||
}
|
||||
|
||||
/** Set virtual width for this particular page. Width -1 indicates that the
|
||||
virtual width should be disabled. */
|
||||
void SetVirtualWidth( int width );
|
||||
@@ -1041,13 +1080,6 @@ public:
|
||||
DoShowPropertyError(p, msg);
|
||||
}
|
||||
|
||||
/** Sorts all items at all levels (except sub-properties). */
|
||||
void Sort();
|
||||
|
||||
/** Sorts children of a category.
|
||||
*/
|
||||
void SortChildren( wxPGPropArg id );
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Following methods do not need to be (currently) documented
|
||||
@@ -1577,6 +1609,9 @@ protected:
|
||||
// Top level parent
|
||||
wxWindow* m_tlp;
|
||||
|
||||
// Sort function
|
||||
wxPGSortCallback m_sortFunction;
|
||||
|
||||
// y coordinate of property that mouse hovering
|
||||
int m_propHoverY;
|
||||
// Which column's editor is selected (usually 1)?
|
||||
|
@@ -301,6 +301,29 @@ class wxPGValidationInfo;
|
||||
#define wxPG_DEFAULT_IMAGE_SIZE wxSize(-1, -1)
|
||||
|
||||
|
||||
/** This callback function is used for sorting properties.
|
||||
|
||||
Call wxPropertyGrid::SetSortFunction() to set it.
|
||||
|
||||
Sort function should return a value greater than 0 if position of p1 is
|
||||
after p2. So, for instance, when comparing property names, you can use
|
||||
following implementation:
|
||||
|
||||
@code
|
||||
int MyPropertySortFunction(wxPropertyGrid* propGrid,
|
||||
wxPGProperty* p1,
|
||||
wxPGProperty* p2)
|
||||
{
|
||||
return p1->GetBaseName().compare( p2->GetBaseName() );
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
typedef int (*wxPGSortCallback)(wxPropertyGrid* propGrid,
|
||||
wxPGProperty* p1,
|
||||
wxPGProperty* p2);
|
||||
|
||||
|
||||
|
||||
typedef wxString wxPGCachedString;
|
||||
|
||||
/** @}
|
||||
|
@@ -1226,6 +1226,30 @@ public:
|
||||
*/
|
||||
void SetValidationFailureBehavior( int vfbFlags );
|
||||
|
||||
/**
|
||||
Sorts all properties.
|
||||
|
||||
@see SortChildren, wxPropertyGrid::SetSortFunction
|
||||
*/
|
||||
void Sort();
|
||||
|
||||
/**
|
||||
Sorts children of a property.
|
||||
|
||||
@param id
|
||||
Name or pointer to a property.
|
||||
|
||||
@param recursively
|
||||
If @true, then children are sorted recursively.
|
||||
|
||||
@see Sort, wxPropertyGrid::SetSortFunction
|
||||
*/
|
||||
void SortChildren( wxPGPropArg id, bool recursively = false )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
m_pState->DoSortChildren(p, recursively);
|
||||
}
|
||||
|
||||
#ifdef SWIG
|
||||
%pythoncode {
|
||||
def MapType(class_,factory):
|
||||
|
@@ -613,8 +613,8 @@ public:
|
||||
/** Set virtual width for this particular page. */
|
||||
void SetVirtualWidth( int width );
|
||||
|
||||
void SortChildren( wxPGProperty* p );
|
||||
void Sort();
|
||||
void DoSortChildren( wxPGProperty* p, bool recursively = false );
|
||||
void DoSort();
|
||||
|
||||
void SetSelection( wxPGProperty* p ) { m_selected = p; }
|
||||
|
||||
|
Reference in New Issue
Block a user