Use wxVariant::IsType() function to check the type of variant values in wxPG.
Since there is a dedicated function to check the type of variant then there is not necessary to call wxVariant::GetType() function and perform explicit comparisons of returned strings.
This commit is contained in:
@@ -537,7 +537,7 @@ public:
|
|||||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
|
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
|
||||||
wxString typeName(wxS(TYPENAME)); \
|
wxString typeName(wxS(TYPENAME)); \
|
||||||
wxVariant value = p->GetValue(); \
|
wxVariant value = p->GetValue(); \
|
||||||
if ( value.GetType() != typeName ) \
|
if ( !value.IsType(typeName) ) \
|
||||||
{ \
|
{ \
|
||||||
wxPGGetFailed(p, typeName); \
|
wxPGGetFailed(p, typeName); \
|
||||||
return DEFVAL; \
|
return DEFVAL; \
|
||||||
@@ -546,7 +546,7 @@ public:
|
|||||||
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
|
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
|
||||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
|
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
|
||||||
wxVariant value = p->GetValue(); \
|
wxVariant value = p->GetValue(); \
|
||||||
if ( value.GetType() != wxS(TYPENAME) ) \
|
if ( !value.IsType(wxS(TYPENAME)) ) \
|
||||||
return DEFVAL; \
|
return DEFVAL; \
|
||||||
|
|
||||||
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
|
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
|
||||||
|
@@ -483,7 +483,7 @@ wxPGWindowList wxPGDatePickerCtrlEditor::CreateControls( wxPropertyGrid* propgri
|
|||||||
wxDateTime dateValue(wxInvalidDateTime);
|
wxDateTime dateValue(wxInvalidDateTime);
|
||||||
|
|
||||||
wxVariant value = prop->GetValue();
|
wxVariant value = prop->GetValue();
|
||||||
if ( value.GetType() == wxT("datetime") )
|
if ( value.IsType(wxT("datetime")) )
|
||||||
dateValue = value.GetDateTime();
|
dateValue = value.GetDateTime();
|
||||||
|
|
||||||
ctrl->Create(propgrid->GetPanel(),
|
ctrl->Create(propgrid->GetPanel(),
|
||||||
@@ -509,7 +509,7 @@ void wxPGDatePickerCtrlEditor::UpdateControl( wxPGProperty* property,
|
|||||||
|
|
||||||
wxDateTime dateValue(wxInvalidDateTime);
|
wxDateTime dateValue(wxInvalidDateTime);
|
||||||
wxVariant v(property->GetValue());
|
wxVariant v(property->GetValue());
|
||||||
if ( v.GetType() == wxT("datetime") )
|
if ( v.IsType(wxT("datetime")) )
|
||||||
dateValue = v.GetDateTime();
|
dateValue = v.GetDateTime();
|
||||||
|
|
||||||
ctrl->SetValue( dateValue );
|
ctrl->SetValue( dateValue );
|
||||||
@@ -697,7 +697,7 @@ bool wxFontProperty::OnEvent( wxPropertyGrid* propgrid, wxWindow* WXUNUSED(prima
|
|||||||
wxFontData data;
|
wxFontData data;
|
||||||
wxFont font;
|
wxFont font;
|
||||||
|
|
||||||
if ( useValue.GetType() == wxS("wxFont") )
|
if ( useValue.IsType(wxS("wxFont")) )
|
||||||
font << useValue;
|
font << useValue;
|
||||||
|
|
||||||
data.SetInitialFont( font );
|
data.SetInitialFont( font );
|
||||||
@@ -1069,7 +1069,7 @@ int wxSystemColourProperty::ColToInd( const wxColour& colour ) const
|
|||||||
void wxSystemColourProperty::OnSetValue()
|
void wxSystemColourProperty::OnSetValue()
|
||||||
{
|
{
|
||||||
// Convert from generic wxobject ptr to wxPGVariantDataColour
|
// Convert from generic wxobject ptr to wxPGVariantDataColour
|
||||||
if ( m_value.GetType() == wxS("wxColour*") )
|
if ( m_value.IsType(wxS("wxColour*")) )
|
||||||
{
|
{
|
||||||
wxColour* pCol = wxStaticCast(m_value.GetWxObjectPtr(), wxColour);
|
wxColour* pCol = wxStaticCast(m_value.GetWxObjectPtr(), wxColour);
|
||||||
m_value << *pCol;
|
m_value << *pCol;
|
||||||
@@ -1093,7 +1093,7 @@ void wxSystemColourProperty::OnSetValue()
|
|||||||
|
|
||||||
int ind = wxNOT_FOUND;
|
int ind = wxNOT_FOUND;
|
||||||
|
|
||||||
if ( m_value.GetType() == wxS("wxColourPropertyValue") )
|
if ( m_value.IsType(wxS("wxColourPropertyValue")) )
|
||||||
{
|
{
|
||||||
wxColourPropertyValue cpv;
|
wxColourPropertyValue cpv;
|
||||||
cpv << m_value;
|
cpv << m_value;
|
||||||
@@ -1218,7 +1218,7 @@ int wxSystemColourProperty::GetCustomColourIndex() const
|
|||||||
|
|
||||||
bool wxSystemColourProperty::QueryColourFromUser( wxVariant& variant ) const
|
bool wxSystemColourProperty::QueryColourFromUser( wxVariant& variant ) const
|
||||||
{
|
{
|
||||||
wxASSERT( m_value.GetType() != wxPG_VARIANT_TYPE_STRING );
|
wxASSERT( !m_value.IsType(wxPG_VARIANT_TYPE_STRING) );
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
wxPropertyGrid* propgrid = GetGrid();
|
wxPropertyGrid* propgrid = GetGrid();
|
||||||
@@ -2018,7 +2018,7 @@ void wxMultiChoiceProperty::GenerateValueAsString( wxVariant& value,
|
|||||||
{
|
{
|
||||||
wxArrayString strings;
|
wxArrayString strings;
|
||||||
|
|
||||||
if ( value.GetType() == wxPG_VARIANT_TYPE_ARRSTRING )
|
if ( value.IsType(wxPG_VARIANT_TYPE_ARRSTRING) )
|
||||||
strings = value.GetArrayString();
|
strings = value.GetArrayString();
|
||||||
|
|
||||||
wxString& tempStr = *target;
|
wxString& tempStr = *target;
|
||||||
@@ -2204,7 +2204,7 @@ void wxDateProperty::OnSetValue()
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Convert invalid dates to unspecified value
|
// Convert invalid dates to unspecified value
|
||||||
if ( m_value.GetType() == wxT("datetime") )
|
if ( m_value.IsType(wxT("datetime")) )
|
||||||
{
|
{
|
||||||
if ( !m_value.GetDateTime().IsValid() )
|
if ( !m_value.GetDateTime().IsValid() )
|
||||||
m_value.MakeNull();
|
m_value.MakeNull();
|
||||||
|
@@ -1984,7 +1984,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
|
|||||||
wxVariant attrVal = prop->GetAttribute(wxPG_ATTR_AUTOCOMPLETE);
|
wxVariant attrVal = prop->GetAttribute(wxPG_ATTR_AUTOCOMPLETE);
|
||||||
if ( !attrVal.IsNull() )
|
if ( !attrVal.IsNull() )
|
||||||
{
|
{
|
||||||
wxASSERT(attrVal.GetType() == wxS("arrstring"));
|
wxASSERT(attrVal.IsType(wxS("arrstring")));
|
||||||
tc->AutoComplete(attrVal.GetArrayString());
|
tc->AutoComplete(attrVal.GetArrayString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -936,7 +936,7 @@ void wxPGProperty::DoGenerateComposedValue( wxString& text,
|
|||||||
{
|
{
|
||||||
if ( overridesLeft &&
|
if ( overridesLeft &&
|
||||||
curChild->HasFlag(wxPG_PROP_COMPOSED_VALUE) &&
|
curChild->HasFlag(wxPG_PROP_COMPOSED_VALUE) &&
|
||||||
childValue.GetType() == wxPG_VARIANT_TYPE_LIST )
|
childValue.IsType(wxPG_VARIANT_TYPE_LIST) )
|
||||||
{
|
{
|
||||||
wxVariantList& childList = childValue.GetList();
|
wxVariantList& childList = childValue.GetList();
|
||||||
DoGenerateComposedValue(s, argFlags|wxPG_COMPOSITE_FRAGMENT,
|
DoGenerateComposedValue(s, argFlags|wxPG_COMPOSITE_FRAGMENT,
|
||||||
@@ -1368,7 +1368,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
// List variants are reserved a special purpose
|
// List variants are reserved a special purpose
|
||||||
// as intermediate containers for child values
|
// as intermediate containers for child values
|
||||||
// of properties with children.
|
// of properties with children.
|
||||||
if ( value.GetType() == wxPG_VARIANT_TYPE_LIST )
|
if ( value.IsType(wxPG_VARIANT_TYPE_LIST) )
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// However, situation is different for composed string properties
|
// However, situation is different for composed string properties
|
||||||
@@ -1389,7 +1389,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
|
|
||||||
if ( pList && !pList->IsNull() )
|
if ( pList && !pList->IsNull() )
|
||||||
{
|
{
|
||||||
wxASSERT( pList->GetType() == wxPG_VARIANT_TYPE_LIST );
|
wxASSERT( pList->IsType(wxPG_VARIANT_TYPE_LIST) );
|
||||||
wxASSERT( GetChildCount() );
|
wxASSERT( GetChildCount() );
|
||||||
wxASSERT( !IsCategory() );
|
wxASSERT( !IsCategory() );
|
||||||
|
|
||||||
@@ -1408,7 +1408,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
if ( child )
|
if ( child )
|
||||||
{
|
{
|
||||||
//wxLogDebug(wxT("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName().c_str(),childValue.GetType().c_str());
|
//wxLogDebug(wxT("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName().c_str(),childValue.GetType().c_str());
|
||||||
if ( childValue.GetType() == wxPG_VARIANT_TYPE_LIST )
|
if ( childValue.IsType(wxPG_VARIANT_TYPE_LIST) )
|
||||||
{
|
{
|
||||||
if ( child->HasFlag(wxPG_PROP_AGGREGATE) && !(flags & wxPG_SETVAL_AGGREGATED) )
|
if ( child->HasFlag(wxPG_PROP_AGGREGATE) && !(flags & wxPG_SETVAL_AGGREGATED) )
|
||||||
{
|
{
|
||||||
@@ -2409,7 +2409,7 @@ void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const
|
|||||||
{
|
{
|
||||||
//wxLogDebug(wxT(" %s(n=%i), %s"),childValue.GetName().c_str(),n,childValue.GetType().c_str());
|
//wxLogDebug(wxT(" %s(n=%i), %s"),childValue.GetName().c_str(),n,childValue.GetType().c_str());
|
||||||
|
|
||||||
if ( childValue.GetType() == wxPG_VARIANT_TYPE_LIST )
|
if ( childValue.IsType(wxPG_VARIANT_TYPE_LIST) )
|
||||||
{
|
{
|
||||||
wxVariant cv2(child->GetValue());
|
wxVariant cv2(child->GetValue());
|
||||||
child->AdaptListToValue(childValue, &cv2);
|
child->AdaptListToValue(childValue, &cv2);
|
||||||
@@ -2712,7 +2712,7 @@ bool wxPGProperty::AreAllChildrenSpecified( wxVariant* pendingList ) const
|
|||||||
{
|
{
|
||||||
const wxVariant* childList = NULL;
|
const wxVariant* childList = NULL;
|
||||||
|
|
||||||
if ( listValue && listValue->GetType() == wxPG_VARIANT_TYPE_LIST )
|
if ( listValue && listValue->IsType(wxPG_VARIANT_TYPE_LIST) )
|
||||||
childList = listValue;
|
childList = listValue;
|
||||||
|
|
||||||
if ( !child->AreAllChildrenSpecified((wxVariant*)childList) )
|
if ( !child->AreAllChildrenSpecified((wxVariant*)childList) )
|
||||||
@@ -2843,7 +2843,7 @@ wxPropertyCategory::~wxPropertyCategory()
|
|||||||
wxString wxPropertyCategory::ValueToString( wxVariant& WXUNUSED(value),
|
wxString wxPropertyCategory::ValueToString( wxVariant& WXUNUSED(value),
|
||||||
int WXUNUSED(argFlags) ) const
|
int WXUNUSED(argFlags) ) const
|
||||||
{
|
{
|
||||||
if ( m_value.GetType() == wxPG_VARIANT_TYPE_STRING )
|
if ( m_value.IsType(wxPG_VARIANT_TYPE_STRING) )
|
||||||
return m_value.GetString();
|
return m_value.GetString();
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
@@ -2999,7 +2999,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
|
|||||||
//
|
//
|
||||||
// Variant list a special value that cannot be validated
|
// Variant list a special value that cannot be validated
|
||||||
// by normal means.
|
// by normal means.
|
||||||
if ( pendingValue.GetType() != wxPG_VARIANT_TYPE_LIST )
|
if ( !pendingValue.IsType(wxPG_VARIANT_TYPE_LIST) )
|
||||||
{
|
{
|
||||||
if ( !p->ValidateValue(pendingValue, m_validationInfo) )
|
if ( !p->ValidateValue(pendingValue, m_validationInfo) )
|
||||||
return false;
|
return false;
|
||||||
@@ -3045,7 +3045,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
|
|||||||
wxVariant value;
|
wxVariant value;
|
||||||
wxPGProperty* evtChangingProperty = changedProperty;
|
wxPGProperty* evtChangingProperty = changedProperty;
|
||||||
|
|
||||||
if ( pPendingValue->GetType() != wxPG_VARIANT_TYPE_LIST )
|
if ( !pPendingValue->IsType(wxPG_VARIANT_TYPE_LIST) )
|
||||||
{
|
{
|
||||||
value = *pPendingValue;
|
value = *pPendingValue;
|
||||||
}
|
}
|
||||||
@@ -3104,7 +3104,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
|
|||||||
|
|
||||||
// If changedProperty is not property which value was edited,
|
// If changedProperty is not property which value was edited,
|
||||||
// then call wxPGProperty::ValidateValue() for that as well.
|
// then call wxPGProperty::ValidateValue() for that as well.
|
||||||
if ( p != changedProperty && value.GetType() != wxPG_VARIANT_TYPE_LIST )
|
if ( p != changedProperty && !value.IsType(wxPG_VARIANT_TYPE_LIST) )
|
||||||
{
|
{
|
||||||
if ( !changedProperty->ValidateValue(value, m_validationInfo) )
|
if ( !changedProperty->ValidateValue(value, m_validationInfo) )
|
||||||
return false;
|
return false;
|
||||||
|
@@ -1595,7 +1595,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Is it list?
|
// Is it list?
|
||||||
if ( current->GetType() != wxS("list") )
|
if ( !current->IsType(wxS("list")) )
|
||||||
{
|
{
|
||||||
// Not.
|
// Not.
|
||||||
}
|
}
|
||||||
@@ -1638,7 +1638,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
|
|||||||
wxPGProperty* foundProp = BaseGetPropertyByName(propName);
|
wxPGProperty* foundProp = BaseGetPropertyByName(propName);
|
||||||
if ( foundProp )
|
if ( foundProp )
|
||||||
{
|
{
|
||||||
wxASSERT( current->GetType() == wxPG_VARIANT_TYPE_LIST );
|
wxASSERT( current->IsType(wxPG_VARIANT_TYPE_LIST) );
|
||||||
|
|
||||||
wxVariantList& list2 = current->GetList();
|
wxVariantList& list2 = current->GetList();
|
||||||
wxVariantList::const_iterator node2;
|
wxVariantList::const_iterator node2;
|
||||||
|
@@ -327,7 +327,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
|||||||
|
|
||||||
bool wxIntProperty::IntToValue( wxVariant& variant, int value, int WXUNUSED(argFlags) ) const
|
bool wxIntProperty::IntToValue( wxVariant& variant, int value, int WXUNUSED(argFlags) ) const
|
||||||
{
|
{
|
||||||
if ( variant.GetType() != wxPG_VARIANT_TYPE_LONG || variant != (long)value )
|
if ( !variant.IsType(wxPG_VARIANT_TYPE_LONG) || variant != (long)value )
|
||||||
{
|
{
|
||||||
variant = (long)value;
|
variant = (long)value;
|
||||||
return true;
|
return true;
|
||||||
@@ -640,7 +640,7 @@ wxString wxUIntProperty::ValueToString( wxVariant& value,
|
|||||||
if ( index >= wxPG_UINT_TEMPLATE_MAX )
|
if ( index >= wxPG_UINT_TEMPLATE_MAX )
|
||||||
index = wxPG_UINT_DEC;
|
index = wxPG_UINT_DEC;
|
||||||
|
|
||||||
if ( value.GetType() == wxPG_VARIANT_TYPE_LONG )
|
if (value.IsType(wxPG_VARIANT_TYPE_LONG))
|
||||||
{
|
{
|
||||||
return wxString::Format(gs_uintTemplates32[index],
|
return wxString::Format(gs_uintTemplates32[index],
|
||||||
(unsigned long)value.GetLong());
|
(unsigned long)value.GetLong());
|
||||||
@@ -1223,7 +1223,7 @@ bool wxEnumProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& WXUNUS
|
|||||||
// Make sure string value is in the list,
|
// Make sure string value is in the list,
|
||||||
// unless property has string as preferred value type
|
// unless property has string as preferred value type
|
||||||
// To reduce code size, use conversion here as well
|
// To reduce code size, use conversion here as well
|
||||||
if ( value.GetType() == wxPG_VARIANT_TYPE_STRING )
|
if ( value.IsType(wxPG_VARIANT_TYPE_STRING) )
|
||||||
return ValueFromString_(value, NULL, value.GetString(), wxPG_PROPERTY_SPECIFIC);
|
return ValueFromString_(value, NULL, value.GetString(), wxPG_PROPERTY_SPECIFIC);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1232,7 +1232,7 @@ bool wxEnumProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& WXUNUS
|
|||||||
wxString wxEnumProperty::ValueToString( wxVariant& value,
|
wxString wxEnumProperty::ValueToString( wxVariant& value,
|
||||||
int WXUNUSED(argFlags) ) const
|
int WXUNUSED(argFlags) ) const
|
||||||
{
|
{
|
||||||
if ( value.GetType() == wxPG_VARIANT_TYPE_STRING )
|
if ( value.IsType(wxPG_VARIANT_TYPE_STRING) )
|
||||||
return value.GetString();
|
return value.GetString();
|
||||||
|
|
||||||
int index = m_choices.Index(value.GetLong());
|
int index = m_choices.Index(value.GetLong());
|
||||||
|
Reference in New Issue
Block a user