Use predefined constants to represent common wxPG variant types (cont.).

Instead of using individual string literals use globally defined constants representing wxPG variant types (wxLongLong, wxULongLong, wxArrayInt, etc.).
This commit is contained in:
Artur Wieczorek 2015-04-03 21:09:13 +02:00
parent d89d730900
commit 6a7b95f419
3 changed files with 15 additions and 16 deletions

View File

@ -533,25 +533,24 @@ public:
bool GetPropertyValueAsBool( wxPGPropArg id ) const;
double GetPropertyValueAsDouble( wxPGPropArg id ) const;
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(PGTypeName, DEFVAL) \
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
wxString typeName(wxS(TYPENAME)); \
wxVariant value = p->GetValue(); \
if ( !value.IsType(typeName) ) \
if ( !value.IsType(PGTypeName) ) \
{ \
wxPGGetFailed(p, typeName); \
wxPGGetFailed(p, PGTypeName); \
return DEFVAL; \
}
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, 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(wxS(TYPENAME)) ) \
if ( !value.IsType(PGTypeName) ) \
return DEFVAL; \
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring",
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxPG_VARIANT_TYPE_ARRSTRING,
wxArrayString())
return value.GetArrayString();
}
@ -572,7 +571,7 @@ public:
wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt",
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxArrayInt_VariantType,
wxArrayInt())
wxArrayInt arr;
arr << value;
@ -582,7 +581,7 @@ public:
#if wxUSE_DATETIME
wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
{
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime",
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxPG_VARIANT_TYPE_DATETIME,
wxDateTime())
return value.GetDateTime();
}

View File

@ -190,10 +190,10 @@ public:
or
@code
wxLongLong_t value;
wxLongLong value;
wxVariant variant = property->GetValue();
if ( variant.GetType() == "wxLongLong" )
value = wxLongLongFromVariant(variant);
if ( variant.GetType() == "longlong" )
value = variant.GetLongLong();
else
value = variant.GetLong();
@endcode

View File

@ -1547,9 +1547,9 @@ wxVariant wxPGProperty::GetDefaultValue() const
return wxVariant(0.0);
if ( valueType == wxPG_VARIANT_TYPE_ARRSTRING )
return wxVariant(wxArrayString());
if ( valueType == wxS("wxLongLong") )
if ( valueType == wxPG_VARIANT_TYPE_LONGLONG )
return WXVARIANT(wxLongLong(0));
if ( valueType == wxS("wxULongLong") )
if ( valueType == wxPG_VARIANT_TYPE_ULONGLONG )
return WXVARIANT(wxULongLong(0));
if ( valueType == wxS("wxColour") )
return WXVARIANT(*wxBLACK);
@ -1559,9 +1559,9 @@ wxVariant wxPGProperty::GetDefaultValue() const
#endif
if ( valueType == wxS("wxFont") )
return WXVARIANT(*wxNORMAL_FONT);
if ( valueType == wxS("wxPoint") )
if ( valueType == wxPoint_VariantType )
return WXVARIANT(wxPoint(0, 0));
if ( valueType == wxS("wxSize") )
if ( valueType == wxSize_VariantType )
return WXVARIANT(wxSize(0, 0));
}