Cleanup wxPropertyGridInterface declarations

Move definitions of GetPropertyValueAs*() functions away from class
declaration to avoid polluting the header.
This commit is contained in:
Artur Wieczorek 2022-04-10 13:40:08 +02:00
parent ef20164efb
commit 1a31eef189
2 changed files with 66 additions and 63 deletions

View File

@ -433,11 +433,7 @@ public:
// Returns value as wxVariant. To get wxObject pointer from it,
// you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
// If property value is unspecified, wxNullVariant is returned.
wxVariant GetPropertyValue( wxPGPropArg id )
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
return p->GetValue();
}
wxVariant GetPropertyValue(wxPGPropArg id);
wxString GetPropertyValueAsString( wxPGPropArg id ) const;
long GetPropertyValueAsLong( wxPGPropArg id ) const;
@ -450,58 +446,18 @@ public:
bool GetPropertyValueAsBool( wxPGPropArg id ) const;
double GetPropertyValueAsDouble( wxPGPropArg id ) const;
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(PGTypeName, DEFVAL) \
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
wxVariant value = p->GetValue(); \
if ( !value.IsType(PGTypeName) ) \
{ \
wxPGGetFailed(p, PGTypeName); \
return DEFVAL; \
}
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(PGTypeName, DEFVAL) \
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
wxVariant value = p->GetValue(); \
if ( !value.IsType(PGTypeName) ) \
return DEFVAL; \
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxPG_VARIANT_TYPE_ARRSTRING,
wxArrayString())
return value.GetArrayString();
}
wxArrayString GetPropertyValueAsArrayString(wxPGPropArg id) const;
#if defined(wxLongLong_t) && wxUSE_LONGLONG
wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
return p->GetValue().GetLongLong().GetValue();
}
wxLongLong_t GetPropertyValueAsLongLong(wxPGPropArg id) const;
wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
return p->GetValue().GetULongLong().GetValue();
}
wxULongLong_t GetPropertyValueAsULongLong(wxPGPropArg id) const;
#endif
wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxArrayInt_VariantType,
wxArrayInt())
wxArrayInt arr;
arr << value;
return arr;
}
wxArrayInt GetPropertyValueAsArrayInt(wxPGPropArg id) const;
#if wxUSE_DATETIME
wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxPG_VARIANT_TYPE_DATETIME,
wxDateTime())
return value.GetDateTime();
}
wxDateTime GetPropertyValueAsDateTime(wxPGPropArg id) const;
#endif
// Returns a wxVariant list containing wxVariant versions of all

View File

@ -759,17 +759,10 @@ void wxPropertyGridInterface::SetPropertyCell( wxPGPropArg id,
// -----------------------------------------------------------------------
// GetPropertyValueAsXXX methods
#define IMPLEMENT_GET_VALUE(TRET,PGTypeName,BIGNAME,DEFRETVAL) \
TRET wxPropertyGridInterface::GetPropertyValueAs##BIGNAME( wxPGPropArg id ) const \
{ \
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFRETVAL) \
wxVariant value = p->GetValue(); \
if ( !value.IsType(PGTypeName) ) \
{ \
wxPGGetFailed(p, PGTypeName); \
return (TRET)DEFRETVAL; \
} \
return (TRET)value.Get##BIGNAME(); \
wxVariant wxPropertyGridInterface::GetPropertyValue(wxPGPropArg id)
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
return p->GetValue();
}
// String is different from others.
@ -795,8 +788,62 @@ bool wxPropertyGridInterface::GetPropertyValueAsBool( wxPGPropArg id ) const
return false;
}
IMPLEMENT_GET_VALUE(long,wxPG_VARIANT_TYPE_LONG,Long,0)
IMPLEMENT_GET_VALUE(double,wxPG_VARIANT_TYPE_DOUBLE,Double,0.0)
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(PGTypeName, DEFVAL) \
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
wxVariant value = p->GetValue(); \
if ( !value.IsType(PGTypeName) ) \
{ \
wxPGGetFailed(p, PGTypeName); \
return DEFVAL; \
}
long wxPropertyGridInterface::GetPropertyValueAsLong(wxPGPropArg id) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxPG_VARIANT_TYPE_LONG, 0L)
return value.GetLong();
}
double wxPropertyGridInterface::GetPropertyValueAsDouble(wxPGPropArg id) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxPG_VARIANT_TYPE_DOUBLE, 0.0)
return value.GetDouble();
}
wxArrayString wxPropertyGridInterface::GetPropertyValueAsArrayString(wxPGPropArg id) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxPG_VARIANT_TYPE_ARRSTRING, wxArrayString())
return value.GetArrayString();
}
#if defined(wxLongLong_t) && wxUSE_LONGLONG
wxLongLong_t wxPropertyGridInterface::GetPropertyValueAsLongLong(wxPGPropArg id) const
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
return p->GetValue().GetLongLong().GetValue();
}
wxULongLong_t wxPropertyGridInterface::GetPropertyValueAsULongLong(wxPGPropArg id) const
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
return p->GetValue().GetULongLong().GetValue();
}
#endif
wxArrayInt wxPropertyGridInterface::GetPropertyValueAsArrayInt(wxPGPropArg id) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxArrayInt_VariantType, wxArrayInt())
wxArrayInt arr;
arr << value;
return arr;
}
#if wxUSE_DATETIME
wxDateTime wxPropertyGridInterface::GetPropertyValueAsDateTime(wxPGPropArg id) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxPG_VARIANT_TYPE_DATETIME, wxDateTime())
return value.GetDateTime();
}
#endif
bool wxPropertyGridInterface::IsPropertyExpanded( wxPGPropArg id ) const
{