From d00c184ec82e8dae27389108482fb2af4f76de8b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 30 Mar 2015 23:57:51 +0200 Subject: [PATCH] Simplify declaration and definition of some wxPropertyGridInterface::GetPropertyValueAsXXX methods. For IMPLEMENT_GET_VALUE macro which is used to implement specialized methods (for bool and double types) define additional parameter to provide explicitly corresponding wxPG type name. With this additional parameter it is not necessary to maintain a separate list of constants containing wxPG type names only for the purposes of this macro and globally defined literals can be used instead. --- src/propgrid/propgridiface.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index c12ecca767..bb0954b276 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -39,15 +39,6 @@ #include "wx/propgrid/property.h" #include "wx/propgrid/propgrid.h" - -const wxChar *wxPGTypeName_long = wxT("long"); -const wxChar *wxPGTypeName_bool = wxT("bool"); -const wxChar *wxPGTypeName_double = wxT("double"); -const wxChar *wxPGTypeName_wxString = wxT("string"); -const wxChar *wxPGTypeName_void = wxT("void*"); -const wxChar *wxPGTypeName_wxArrayString = wxT("arrstring"); - - // ---------------------------------------------------------------------------- // VariantDatas // ---------------------------------------------------------------------------- @@ -727,14 +718,14 @@ void wxPropertyGridInterface::SetPropertyCell( wxPGPropArg id, // ----------------------------------------------------------------------- // GetPropertyValueAsXXX methods -#define IMPLEMENT_GET_VALUE(T,TRET,BIGNAME,DEFRETVAL) \ +#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(wxPGTypeName_##T) ) \ + if ( !value.IsType(PGTypeName) ) \ { \ - wxPGGetFailed(p,wxPGTypeName_##T); \ + wxPGGetFailed(p, PGTypeName); \ return (TRET)DEFRETVAL; \ } \ return (TRET)value.Get##BIGNAME(); \ @@ -763,8 +754,8 @@ bool wxPropertyGridInterface::GetPropertyValueAsBool( wxPGPropArg id ) const return false; } -IMPLEMENT_GET_VALUE(long,long,Long,0) -IMPLEMENT_GET_VALUE(double,double,Double,0.0) +IMPLEMENT_GET_VALUE(long,wxPG_VARIANT_TYPE_LONG,Long,0) +IMPLEMENT_GET_VALUE(double,wxPG_VARIANT_TYPE_DOUBLE,Double,0.0) bool wxPropertyGridInterface::IsPropertyExpanded( wxPGPropArg id ) const {