From 908342e3ad607833ec491017cca62dbeebd7c8bf Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 26 May 2019 01:13:08 +0200 Subject: [PATCH] Code cleanup: Define wxPGProperty and wxPropertyGridPageState functions in their own class files Having definitions of several wxPGProperty and wxPropertyGridPageState functions in wxPropertyGrid header is misleading so they should be moved to the files with their own classes definitions for the sake of clarity. --- include/wx/propgrid/property.h | 6 +-- include/wx/propgrid/propgrid.h | 63 ------------------------- include/wx/propgrid/propgridpagestate.h | 4 +- src/propgrid/property.cpp | 48 +++++++++++++++++++ src/propgrid/propgridpagestate.cpp | 10 ++++ 5 files changed, 63 insertions(+), 68 deletions(-) diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 095563ec4e..e7f0e7e48e 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -1355,7 +1355,7 @@ public: } // Returns property's hint text (shown in empty value cell). - inline wxString GetHintText() const; + wxString GetHintText() const; // Returns property grid where property lies. wxPropertyGrid* GetGrid() const; @@ -1629,7 +1629,7 @@ public: } // Sets editor for a property, , by editor name. - inline void SetEditor( const wxString& editorName ); + void SetEditor( const wxString& editorName ); // Sets cell information for given column. void SetCell( int column, const wxPGCell& cell ); @@ -1787,7 +1787,7 @@ public: bool SetChoices( const wxPGChoices& choices ); // Set max length of text in text editor. - inline bool SetMaxLength( int maxLen ); + bool SetMaxLength( int maxLen ); // Call with 'false' in OnSetValue to cancel value changes after all // (i.e. cancel 'true' returned by StringToValue() or IntToValue()). diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 901da641e7..6e061dce36 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1947,69 +1947,6 @@ private: wxDECLARE_EVENT_TABLE(); }; -// ----------------------------------------------------------------------- -// -// Bunch of inlines that need to resolved after all classes have been defined. -// - -inline bool wxPropertyGridPageState::IsDisplayed() const -{ - return ( this == m_pPropGrid->GetState() ); -} - -inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const -{ - return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight()); -} - -inline wxString wxPGProperty::GetHintText() const -{ - wxVariant vHintText = GetAttribute(wxPG_ATTR_HINT); - -#if wxPG_COMPATIBILITY_1_4 - // Try the old, deprecated "InlineHelp" - if ( vHintText.IsNull() ) - vHintText = GetAttribute(wxPG_ATTR_INLINE_HELP); -#endif - - if ( !vHintText.IsNull() ) - return vHintText.GetString(); - - return wxEmptyString; -} - -inline int wxPGProperty::GetDisplayedCommonValueCount() const -{ - if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE) ) - { - wxPropertyGrid* pg = GetGrid(); - if ( pg ) - return (int) pg->GetCommonValueCount(); - } - return 0; -} - -inline void wxPGProperty::SetDefaultValue( wxVariant& value ) -{ - SetAttribute(wxPG_ATTR_DEFAULT_VALUE, value); -} - -inline void wxPGProperty::SetEditor( const wxString& editorName ) -{ - m_customEditor = wxPropertyGridInterface::GetEditorByName(editorName); -} - -inline bool wxPGProperty::SetMaxLength( int maxLen ) -{ - const wxPGEditor* editorClass = GetEditorClass(); - if ( editorClass != wxPGEditor_TextCtrl && - editorClass != wxPGEditor_TextCtrlAndButton ) - return false; - - m_maxLen = wxMax(maxLen, 0); // shouldn't be a nagative value - return true; -} - // ----------------------------------------------------------------------- #define wxPG_BASE_EVT_PRE_ID 1775 diff --git a/include/wx/propgrid/propgridpagestate.h b/include/wx/propgrid/propgridpagestate.h index 8c596048d1..4285352d94 100644 --- a/include/wx/propgrid/propgridpagestate.h +++ b/include/wx/propgrid/propgridpagestate.h @@ -420,7 +420,7 @@ public: // Returns actual height of contained visible properties. // Mostly used for internal diagnostic purposes. - inline unsigned int GetActualVirtualHeight() const; + unsigned int GetActualVirtualHeight() const; unsigned int GetColumnCount() const { @@ -512,7 +512,7 @@ public: wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const; // Returns true if page is visibly displayed. - inline bool IsDisplayed() const; + bool IsDisplayed() const; bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); } diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index b49b3bc475..8d0a9720fd 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -2824,6 +2824,54 @@ void wxPGProperty::SubPropsChanged( int oldSelInd ) } } +wxString wxPGProperty::GetHintText() const +{ + wxVariant vHintText = GetAttribute(wxPG_ATTR_HINT); + +#if wxPG_COMPATIBILITY_1_4 + // Try the old, deprecated "InlineHelp" + if ( vHintText.IsNull() ) + vHintText = GetAttribute(wxPG_ATTR_INLINE_HELP); +#endif + + if ( !vHintText.IsNull() ) + return vHintText.GetString(); + + return wxEmptyString; +} + +int wxPGProperty::GetDisplayedCommonValueCount() const +{ + if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE) ) + { + wxPropertyGrid* pg = GetGrid(); + if ( pg ) + return (int)pg->GetCommonValueCount(); + } + return 0; +} + +void wxPGProperty::SetDefaultValue(wxVariant& value) +{ + SetAttribute(wxPG_ATTR_DEFAULT_VALUE, value); +} + +void wxPGProperty::SetEditor(const wxString& editorName) +{ + m_customEditor = wxPropertyGridInterface::GetEditorByName(editorName); +} + +bool wxPGProperty::SetMaxLength(int maxLen) +{ + const wxPGEditor* editorClass = GetEditorClass(); + if ( editorClass != wxPGEditor_TextCtrl && + editorClass != wxPGEditor_TextCtrlAndButton ) + return false; + + m_maxLen = wxMax(maxLen, 0); // shouldn't be a nagative value + return true; +} + // ----------------------------------------------------------------------- // wxPGRootProperty // ----------------------------------------------------------------------- diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index 4bc4f4eb1c..a5b6fb583b 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -2105,6 +2105,16 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete ) VirtualHeightChanged(); } +bool wxPropertyGridPageState::IsDisplayed() const +{ + return (this == m_pPropGrid->GetState()); +} + +unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const +{ + return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight()); +} + // ----------------------------------------------------------------------- #endif // wxUSE_PROPGRID