From b6ab81584f49a1997e6d6236fcb65d1b5c58a5bd Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 16 May 2015 17:16:30 +0200 Subject: [PATCH] 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. --- include/wx/propgrid/property.h | 20 +++++++++++++++++++- include/wx/propgrid/propgridpagestate.h | 6 +++--- src/propgrid/propgridiface.cpp | 4 ++-- src/propgrid/propgridpagestate.cpp | 10 +++++----- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index e0e6050315..542fa35342 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -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 ) { diff --git a/include/wx/propgrid/propgridpagestate.h b/include/wx/propgrid/propgridpagestate.h index 03f7ea2aef..e1a64cc221 100644 --- a/include/wx/propgrid/propgridpagestate.h +++ b/include/wx/propgrid/propgridpagestate.h @@ -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; }; diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index bb0954b276..9f368b629d 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -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); } } diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index 88fac75877..7f1a1ac16b 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -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() )