Deprecate wxPGProperty::GetFlags() getter method.

Instead of using pass-trough getter just to check the bits of internal field there are implemented dedicated HasFlag() and HasFlagsExact() methods to do so.
This commit is contained in:
Artur Wieczorek
2015-05-16 17:16:30 +02:00
parent 08f9e27351
commit b6ab81584f
4 changed files with 29 additions and 11 deletions

View File

@@ -1754,6 +1754,21 @@ public:
return (m_flags & flag) != 0;
}
#endif
/**
Returns true if property has given flag set.
*/
bool HasFlag(FlagType flag) const
{
return (m_flags & flag) != 0;
}
/**
Returns true if property has all given flags set.
*/
bool HasFlagsExact(FlagType flags) const
{
return (m_flags & flags) == flags;
}
/** Returns comma-delimited string of property attributes.
*/
@@ -1766,13 +1781,16 @@ public:
*/
wxVariant GetAttributesAsList() const;
#if WXWIN_COMPATIBILITY_3_0
/**
Returns property flags.
*/
wxDEPRECATED_MSG("Use HasFlag or HasFlagsExact functions instead.")
FlagType GetFlags() const
{
return m_flags;
}
#endif
const wxPGEditor* GetEditorClass() const;
@@ -2105,7 +2123,7 @@ public:
example, if you want to disable a property, call
Enable(false) instead of setting wxPG_PROP_DISABLED flag.
@see HasFlag(), GetFlags()
@see HasFlag(), HasFlagsExact()
*/
void ChangeFlag( wxPGPropertyFlags flag, bool set )
{

View File

@@ -183,7 +183,7 @@ wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
// Macro to test if children of PWC should be iterated through
#define wxPG_ITERATOR_PARENTEXMASK_TEST(PWC, PARENTMASK) \
( \
!(PWC->GetFlags() & PARENTMASK) && \
!PWC->HasFlag(PARENTMASK) && \
PWC->GetChildCount() \
)
@@ -240,8 +240,8 @@ private:
wxPGProperty* m_baseParent;
// Masks are used to quickly exclude items
int m_itemExMask;
int m_parentExMask;
wxPGProperty::FlagType m_itemExMask;
wxPGProperty::FlagType m_parentExMask;
};

View File

@@ -494,12 +494,12 @@ void wxPropertyGridInterface::GetPropertiesWithFlag( wxArrayPGProperty* targetAr
if ( !inverse )
{
if ( (property->GetFlags() & flags) == flags )
if ( property->HasFlagsExact(flags) )
targetArr->push_back((wxPGProperty*)property);
}
else
{
if ( (property->GetFlags() & flags) != flags )
if ( !property->HasFlagsExact(flags) )
targetArr->push_back((wxPGProperty*)property);
}
}

View File

@@ -62,7 +62,7 @@ void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState* state, int flags
wxPG_ITERATOR_CREATE_MASKS(flags, m_itemExMask, m_parentExMask)
// Need to skip first?
if ( property && (property->GetFlags() & m_itemExMask) )
if ( property && property->HasFlag(m_itemExMask) )
{
if ( dir == 1 )
Next();
@@ -145,7 +145,7 @@ void wxPropertyGridIteratorBase::Prev()
m_property = property;
// If property does not match our criteria, skip it
if ( property->GetFlags() & m_itemExMask )
if ( property->HasFlag(m_itemExMask) )
Prev();
}
@@ -192,7 +192,7 @@ void wxPropertyGridIteratorBase::Next( bool iterateChildren )
m_property = property;
// If property does not match our criteria, skip it
if ( property->GetFlags() & m_itemExMask )
if ( property->HasFlag(m_itemExMask) )
Next();
}
@@ -420,7 +420,7 @@ wxPGProperty* wxPropertyGridPageState::GetLastItem( int flags )
if ( !m_properties->GetChildCount() )
return NULL;
wxPG_ITERATOR_CREATE_MASKS(flags, int itemExMask, int parentExMask)
wxPG_ITERATOR_CREATE_MASKS(flags, wxPGProperty::FlagType itemExMask, wxPGProperty::FlagType parentExMask)
// First, get last child of last parent
wxPGProperty* pwc = (wxPGProperty*)m_properties->Last();
@@ -429,7 +429,7 @@ wxPGProperty* wxPropertyGridPageState::GetLastItem( int flags )
pwc = (wxPGProperty*) pwc->Last();
// Then, if it doesn't fit our criteria, back up until we find something that does
if ( pwc->GetFlags() & itemExMask )
if ( pwc->HasFlag(itemExMask) )
{
wxPropertyGridIterator it( this, flags, pwc );
for ( ; !it.AtEnd(); it.Prev() )