Make wxPGPropertyFlags a bitmask
To improve type safety of flags.
This commit is contained in:
parent
1b5a43599a
commit
c8552aec0c
19 changed files with 763 additions and 615 deletions
|
|
@ -507,7 +507,7 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
wxPGProperty* p = it.GetProperty();
|
||||
if ( p->IsCategory() )
|
||||
FAIL_CHECK(wxString::Format("'%s' is a category (non-private child property expected)", p->GetLabel()).c_str());
|
||||
else if ( p->GetParent()->HasFlag(wxPG_PROP_AGGREGATE) )
|
||||
else if ( p->GetParent()->HasFlag(wxPGPropertyFlags::Aggregate) )
|
||||
FAIL_CHECK(wxString::Format("'%s' is a private child (non-private child property expected)", p->GetLabel()).c_str());
|
||||
count++;
|
||||
}
|
||||
|
|
@ -527,7 +527,7 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
for ( auto it = pgManager->GetVIterator(wxPG_ITERATE_PROPERTIES | wxPG_ITERATE_CATEGORIES); !it.AtEnd(); it.Next() )
|
||||
{
|
||||
wxPGProperty* p = it.GetProperty();
|
||||
if ( p->GetParent()->HasFlag(wxPG_PROP_AGGREGATE) )
|
||||
if ( p->GetParent()->HasFlag(wxPGPropertyFlags::Aggregate) )
|
||||
FAIL_CHECK(wxString::Format("'%s' is a private child (non-private child property or category expected)", p->GetLabel()).c_str());
|
||||
count++;
|
||||
}
|
||||
|
|
@ -539,7 +539,7 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
wxPGProperty* p = it.GetProperty();
|
||||
if ( (p->GetParent() != p->GetGrid()->GetRoot() && !p->GetParent()->IsExpanded()) )
|
||||
FAIL_CHECK(wxString::Format("'%s' had collapsed parent (only visible properties expected)", p->GetLabel()).c_str());
|
||||
else if ( p->HasFlag(wxPG_PROP_HIDDEN) )
|
||||
else if ( p->HasFlag(wxPGPropertyFlags::Hidden) )
|
||||
FAIL_CHECK(wxString::Format("'%s' was hidden (only visible properties expected)", p->GetLabel()).c_str());
|
||||
count++;
|
||||
}
|
||||
|
|
@ -697,7 +697,7 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
// Delete everything in reverse order
|
||||
|
||||
std::vector<wxPGProperty*> array;
|
||||
for ( auto it = pgManager->GetVIterator(wxPG_ITERATE_ALL & ~(wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE))); !it.AtEnd(); it.Next() )
|
||||
for ( auto it = pgManager->GetVIterator(wxPG_ITERATE_ALL & ~(wxPG_IT_CHILDREN(wxPGPropertyFlags::Aggregate))); !it.AtEnd(); it.Next() )
|
||||
{
|
||||
array.push_back(it.GetProperty());
|
||||
}
|
||||
|
|
@ -710,7 +710,7 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
|
||||
// Check if grid is empty.
|
||||
auto it = pgManager->GetVIterator(wxPG_ITERATE_ALL & ~(wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)));
|
||||
auto it = pgManager->GetVIterator(wxPG_ITERATE_ALL & ~(wxPG_IT_CHILDREN(wxPGPropertyFlags::Aggregate)));
|
||||
if ( !it.AtEnd() )
|
||||
{
|
||||
FAIL_CHECK("Not all properties are deleted");
|
||||
|
|
@ -1597,22 +1597,22 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
wxPGProperty* p = *it;
|
||||
|
||||
// Save initial flags
|
||||
wxPGProperty::FlagType oldFlags = 0;
|
||||
if ( p->HasFlag(wxPG_PROP_COLLAPSED) )
|
||||
wxPGPropertyFlags oldFlags = wxPGPropertyFlags::Null;
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Collapsed) )
|
||||
{
|
||||
oldFlags |= wxPG_PROP_COLLAPSED;
|
||||
oldFlags |= wxPGPropertyFlags::Collapsed;
|
||||
}
|
||||
if ( p->HasFlag(wxPG_PROP_DISABLED) )
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Disabled) )
|
||||
{
|
||||
oldFlags |= wxPG_PROP_DISABLED;
|
||||
oldFlags |= wxPGPropertyFlags::Disabled;
|
||||
}
|
||||
if ( p->HasFlag(wxPG_PROP_HIDDEN) )
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Hidden) )
|
||||
{
|
||||
oldFlags |= wxPG_PROP_HIDDEN;
|
||||
oldFlags |= wxPGPropertyFlags::Hidden;
|
||||
}
|
||||
if ( p->HasFlag(wxPG_PROP_NOEDITOR) )
|
||||
if ( p->HasFlag(wxPGPropertyFlags::NoEditor) )
|
||||
{
|
||||
oldFlags |= wxPG_PROP_NOEDITOR;
|
||||
oldFlags |= wxPGPropertyFlags::NoEditor;
|
||||
}
|
||||
|
||||
wxString flags;
|
||||
|
|
@ -1652,37 +1652,37 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
|
||||
// Verify if flags have been properly set
|
||||
if ( flags.Find("COLLAPSED") != wxNOT_FOUND &&
|
||||
!p->HasFlag(wxPG_PROP_COLLAPSED) )
|
||||
!p->HasFlag(wxPGPropertyFlags::Collapsed) )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Error setting flag from string 'COLLAPSED' for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
if ( flags.Find("COLLAPSED") == wxNOT_FOUND &&
|
||||
p->HasFlag(wxPG_PROP_COLLAPSED) )
|
||||
p->HasFlag(wxPGPropertyFlags::Collapsed) )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Error resetting flag from string 'COLLAPSED'for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
if ( flags.Find("DISABLED") != wxNOT_FOUND &&
|
||||
!p->HasFlag(wxPG_PROP_DISABLED) )
|
||||
!p->HasFlag(wxPGPropertyFlags::Disabled) )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Error setting flag from string 'DISABLED' for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
if ( flags.Find("DISABLED") == wxNOT_FOUND &&
|
||||
p->HasFlag(wxPG_PROP_DISABLED) )
|
||||
p->HasFlag(wxPGPropertyFlags::Disabled) )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Error resetting flag from string 'DISABLED' for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
if ( flags.Find("HIDDEN") != wxNOT_FOUND &&
|
||||
!p->HasFlag(wxPG_PROP_HIDDEN) )
|
||||
!p->HasFlag(wxPGPropertyFlags::Hidden) )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Error setting flag from string 'HIDDEN' for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
if ( flags.Find("HIDDEN") == wxNOT_FOUND &&
|
||||
p->HasFlag(wxPG_PROP_HIDDEN) )
|
||||
p->HasFlag(wxPGPropertyFlags::Hidden) )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Error resetting flag from string 'HIDDEN' for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
|
|
@ -1691,8 +1691,8 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
// Get individual flags
|
||||
bool ok;
|
||||
|
||||
flags = p->GetFlagsAsString(wxPG_PROP_COLLAPSED);
|
||||
if ( p->HasFlag(wxPG_PROP_COLLAPSED) )
|
||||
flags = p->GetFlagsAsString(wxPGPropertyFlags::Collapsed);
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Collapsed) )
|
||||
{
|
||||
ok = (flags == "COLLAPSED");
|
||||
}
|
||||
|
|
@ -1702,12 +1702,12 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
if ( !ok )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPG_PROP_COLLAPSED flag for property '%s'",
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPGPropertyFlags::Collapsed flag for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
|
||||
flags = p->GetFlagsAsString(wxPG_PROP_DISABLED);
|
||||
if ( p->HasFlag(wxPG_PROP_DISABLED) )
|
||||
flags = p->GetFlagsAsString(wxPGPropertyFlags::Disabled);
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Disabled) )
|
||||
{
|
||||
ok = (flags == "DISABLED");
|
||||
}
|
||||
|
|
@ -1717,12 +1717,12 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
if ( !ok )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPG_PROP_DISABLED flag for property '%s'",
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPGPropertyFlags::Disabled flag for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
|
||||
flags = p->GetFlagsAsString(wxPG_PROP_HIDDEN);
|
||||
if ( p->HasFlag(wxPG_PROP_HIDDEN) )
|
||||
flags = p->GetFlagsAsString(wxPGPropertyFlags::Hidden);
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Hidden) )
|
||||
{
|
||||
ok = (flags == "HIDDEN");
|
||||
}
|
||||
|
|
@ -1732,12 +1732,12 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
if ( !ok )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPG_PROP_HIDDEN flag for property '%s'",
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPGPropertyFlags::Hidden flag for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
|
||||
flags = p->GetFlagsAsString(wxPG_PROP_NOEDITOR);
|
||||
if ( p->HasFlag(wxPG_PROP_NOEDITOR) )
|
||||
flags = p->GetFlagsAsString(wxPGPropertyFlags::NoEditor);
|
||||
if ( p->HasFlag(wxPGPropertyFlags::NoEditor) )
|
||||
{
|
||||
ok = (flags == "NOEDITOR");
|
||||
}
|
||||
|
|
@ -1747,13 +1747,13 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
if ( !ok )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPG_PROP_NOEDITOR flag for property '%s'",
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPGPropertyFlags::NoEditor flag for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
|
||||
// Get all flags
|
||||
flags = p->GetFlagsAsString(wxPG_STRING_STORED_FLAGS);
|
||||
if ( p->HasFlag(wxPG_PROP_COLLAPSED) )
|
||||
flags = p->GetFlagsAsString(wxPGPropertyFlags::StringStoredFlags);
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Collapsed) )
|
||||
{
|
||||
ok = (flags.Find("COLLAPSED") != wxNOT_FOUND);
|
||||
}
|
||||
|
|
@ -1763,11 +1763,11 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
if ( !ok )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPG_PROP_COLLAPSED flag for property '%s'",
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPGPropertyFlags::Collapsed flag for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
|
||||
if ( p->HasFlag(wxPG_PROP_DISABLED) )
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Disabled) )
|
||||
{
|
||||
ok = (flags.Find("DISABLED") != wxNOT_FOUND);
|
||||
}
|
||||
|
|
@ -1777,11 +1777,11 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
if ( !ok )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPG_PROP_DISBALED flag for property '%s'",
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPGPropertyFlags::Disabled flag for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
|
||||
if ( p->HasFlag(wxPG_PROP_HIDDEN) )
|
||||
if ( p->HasFlag(wxPGPropertyFlags::Hidden) )
|
||||
{
|
||||
ok = (flags.Find("HIDDEN") != wxNOT_FOUND);
|
||||
}
|
||||
|
|
@ -1791,11 +1791,11 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
if ( !ok )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPG_PROP_HIDDEN flag for property '%s'",
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPGPropertyFlags::Hidden flag for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
|
||||
if ( p->HasFlag(wxPG_PROP_NOEDITOR) )
|
||||
if ( p->HasFlag(wxPGPropertyFlags::NoEditor) )
|
||||
{
|
||||
ok = (flags.Find("NOEDITOR") != wxNOT_FOUND);
|
||||
}
|
||||
|
|
@ -1805,15 +1805,15 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]")
|
|||
}
|
||||
if ( !ok )
|
||||
{
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPG_PROP_NOEDITOR flag for property '%s'",
|
||||
FAIL_CHECK(wxString::Format("Invalid string for wxPGPropertyFlags::NoEditor flag for property '%s'",
|
||||
p->GetName()).c_str());
|
||||
}
|
||||
|
||||
// Restore original flags
|
||||
p->ChangeFlag(wxPG_PROP_COLLAPSED, (oldFlags & wxPG_PROP_COLLAPSED) != 0);
|
||||
p->ChangeFlag(wxPG_PROP_DISABLED, (oldFlags & wxPG_PROP_DISABLED) != 0);
|
||||
p->ChangeFlag(wxPG_PROP_HIDDEN, (oldFlags & wxPG_PROP_HIDDEN) != 0);
|
||||
p->ChangeFlag(wxPG_PROP_NOEDITOR, (oldFlags & wxPG_PROP_NOEDITOR) != 0);
|
||||
p->ChangeFlag(wxPGPropertyFlags::Collapsed, !!(oldFlags & wxPGPropertyFlags::Collapsed));
|
||||
p->ChangeFlag(wxPGPropertyFlags::Disabled, !!(oldFlags & wxPGPropertyFlags::Disabled));
|
||||
p->ChangeFlag(wxPGPropertyFlags::Hidden, !!(oldFlags & wxPGPropertyFlags::Hidden));
|
||||
p->ChangeFlag(wxPGPropertyFlags::NoEditor, !!(oldFlags & wxPGPropertyFlags::NoEditor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue