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.
This commit is contained in:
Artur Wieczorek
2019-05-26 01:13:08 +02:00
parent d8f04a7bb1
commit 908342e3ad
5 changed files with 63 additions and 68 deletions

View File

@@ -1355,7 +1355,7 @@ public:
} }
// Returns property's hint text (shown in empty value cell). // Returns property's hint text (shown in empty value cell).
inline wxString GetHintText() const; wxString GetHintText() const;
// Returns property grid where property lies. // Returns property grid where property lies.
wxPropertyGrid* GetGrid() const; wxPropertyGrid* GetGrid() const;
@@ -1629,7 +1629,7 @@ public:
} }
// Sets editor for a property, , by editor name. // 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. // Sets cell information for given column.
void SetCell( int column, const wxPGCell& cell ); void SetCell( int column, const wxPGCell& cell );
@@ -1787,7 +1787,7 @@ public:
bool SetChoices( const wxPGChoices& choices ); bool SetChoices( const wxPGChoices& choices );
// Set max length of text in text editor. // 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 // Call with 'false' in OnSetValue to cancel value changes after all
// (i.e. cancel 'true' returned by StringToValue() or IntToValue()). // (i.e. cancel 'true' returned by StringToValue() or IntToValue()).

View File

@@ -1947,69 +1947,6 @@ private:
wxDECLARE_EVENT_TABLE(); 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 #define wxPG_BASE_EVT_PRE_ID 1775

View File

@@ -420,7 +420,7 @@ public:
// Returns actual height of contained visible properties. // Returns actual height of contained visible properties.
// Mostly used for internal diagnostic purposes. // Mostly used for internal diagnostic purposes.
inline unsigned int GetActualVirtualHeight() const; unsigned int GetActualVirtualHeight() const;
unsigned int GetColumnCount() const unsigned int GetColumnCount() const
{ {
@@ -512,7 +512,7 @@ public:
wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const; wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
// Returns true if page is visibly displayed. // Returns true if page is visibly displayed.
inline bool IsDisplayed() const; bool IsDisplayed() const;
bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); } bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); }

View File

@@ -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 // wxPGRootProperty
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

View File

@@ -2105,6 +2105,16 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
VirtualHeightChanged(); VirtualHeightChanged();
} }
bool wxPropertyGridPageState::IsDisplayed() const
{
return (this == m_pPropGrid->GetState());
}
unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
{
return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
#endif // wxUSE_PROPGRID #endif // wxUSE_PROPGRID