From 0ce8e27f685bf14f9e37130b3ee9ac9b8b7d692a Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Sun, 31 May 2009 08:58:38 +0000 Subject: [PATCH] Added wxPGProperty::SetDefaultValue(v), as a shortcut for SetAttribute(DefaultValue, v) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60828 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/property.h | 10 ++++++++++ include/wx/propgrid/propgrid.h | 6 ++++++ interface/wx/propgrid/property.h | 8 ++++++++ src/propgrid/property.cpp | 2 +- src/propgrid/propgrid.cpp | 1 + 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 8f2da0c730..864227349d 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -639,6 +639,8 @@ wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000 */ // Redefine attribute macros to use cached strings +#undef wxPG_ATTR_DEFAULT_VALUE +#define wxPG_ATTR_DEFAULT_VALUE wxPGGlobalVars->m_strDefaultValue #undef wxPG_ATTR_MIN #define wxPG_ATTR_MIN wxPGGlobalVars->m_strMin #undef wxPG_ATTR_MAX @@ -1854,6 +1856,14 @@ public: void SetTextColour( const wxColour& colour, bool recursively = false ); + /** Set default value of a property. Synonymous to + + @code + SetAttribute("DefaultValue", value); + @endcode + */ + void SetDefaultValue( wxVariant& value ); + #ifndef SWIG /** Sets editor for a property. diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 3c6c604055..b69292b00a 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -74,6 +74,7 @@ public: wxPGCachedString m_strbool; wxPGCachedString m_strlist; + wxPGCachedString m_strDefaultValue; wxPGCachedString m_strMin; wxPGCachedString m_strMax; wxPGCachedString m_strUnits; @@ -1849,6 +1850,11 @@ inline int wxPGProperty::GetDisplayedCommonValueCount() const 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); diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index f55d892088..9bf9531fb8 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -1341,6 +1341,14 @@ public: */ void SetChoiceSelection( int newValue ); + /** Set default value of a property. Synonymous to + + @code + SetAttribute("DefaultValue", value); + @endcode + */ + void SetDefaultValue( wxVariant& value ); + /** Sets property's help string, which is shown, for example, in wxPropertyGridManager's description text box. diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 913c554e52..94c98b5f9d 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -1372,7 +1372,7 @@ void wxPGProperty::RefreshEditor() wxVariant wxPGProperty::GetDefaultValue() const { - wxVariant defVal = GetAttribute(wxS("DefaultValue")); + wxVariant defVal = GetAttribute(wxPG_ATTR_DEFAULT_VALUE); if ( !defVal.IsNull() ) return defVal; diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 5a18f55513..8da3ca884c 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -195,6 +195,7 @@ wxPGGlobalVarsClass::wxPGGlobalVarsClass() m_strlong = wxS("long"); m_strbool = wxS("bool"); m_strlist = wxS("list"); + m_strDefaultValue = wxS("DefaultValue"); m_strMin = wxS("Min"); m_strMax = wxS("Max"); m_strUnits = wxS("Units");