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:
Jaakko Salli
2009-01-07 18:53:09 +00:00
parent 5f8704a6e3
commit 433969811e
10 changed files with 286 additions and 63 deletions

View File

@@ -306,6 +306,15 @@ wxArrayPGProperty GetPropertiesInRandomOrder( wxPropertyGridInterface* props, in
return arr;
}
// Callback for testing property sorting
int MyPropertySortFunction(wxPropertyGrid* WXUNUSED(propGrid),
wxPGProperty* p1,
wxPGProperty* p2)
{
// Reverse alphabetical order
return p2->GetLabel().CmpNoCase( p1->GetBaseName() );
}
bool FormMain::RunTests( bool fullTest, bool interactive )
{
wxString t;
@@ -935,6 +944,51 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
pgman->Update();
}
{
RT_START_TEST(SortFunction)
wxPGProperty* p;
// Make sure indexes are as supposed
p = pgman->GetProperty(wxT("User Name"));
if ( p->GetIndexInParent() != 3 )
RT_FAILURE();
p = pgman->GetProperty(wxT("User Id"));
if ( p->GetIndexInParent() != 2 )
RT_FAILURE();
p = pgman->GetProperty(wxT("User Home"));
if ( p->GetIndexInParent() != 1 )
RT_FAILURE();
p = pgman->GetProperty(wxT("Operating System"));
if ( p->GetIndexInParent() != 0 )
RT_FAILURE();
pgman->GetGrid()->SetSortFunction(MyPropertySortFunction);
pgman->GetGrid()->SortChildren(wxT("Environment"));
// Make sure indexes have been reversed
p = pgman->GetProperty(wxT("User Name"));
if ( p->GetIndexInParent() != 0 )
RT_FAILURE();
p = pgman->GetProperty(wxT("User Id"));
if ( p->GetIndexInParent() != 1 )
RT_FAILURE();
p = pgman->GetProperty(wxT("User Home"));
if ( p->GetIndexInParent() != 2 )
RT_FAILURE();
p = pgman->GetProperty(wxT("Operating System"));
if ( p->GetIndexInParent() != 3 )
RT_FAILURE();
}
{
RT_START_TEST(SetPropertyBackgroundColour)
wxCommandEvent evt;