From 9ff8e5534b281554d0afeed38eebaab81c4aa0ef Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Feb 2014 23:55:05 +0000 Subject: [PATCH] Use symbolic constants in wxPropertyGrid wxUIntProperty code. No real changes, just use symbolic constants instead of hard coded magical constants. The code is still difficult to understand but slightly better than before. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75911 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/props.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index c79faae159..710b8a03ec 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -469,8 +469,18 @@ wxValidator* wxIntProperty::DoGetValidator() const // wxUIntProperty // ----------------------------------------------------------------------- - -#define wxPG_UINT_TEMPLATE_MAX 8 +enum +{ + wxPG_UINT_HEX_LOWER, + wxPG_UINT_HEX_LOWER_PREFIX, + wxPG_UINT_HEX_LOWER_DOLLAR, + wxPG_UINT_HEX_UPPER, + wxPG_UINT_HEX_UPPER_PREFIX, + wxPG_UINT_HEX_UPPER_DOLLAR, + wxPG_UINT_DEC, + wxPG_UINT_OCT, + wxPG_UINT_TEMPLATE_MAX +}; static const wxChar* const gs_uintTemplates32[wxPG_UINT_TEMPLATE_MAX] = { wxT("%lx"),wxT("0x%lx"),wxT("$%lx"), @@ -494,7 +504,7 @@ WX_PG_IMPLEMENT_PROPERTY_CLASS(wxUIntProperty,wxPGProperty, void wxUIntProperty::Init() { - m_base = 6; // This is magic number for dec base (must be same as in setattribute) + m_base = wxPG_UINT_DEC; m_realBase = 10; m_prefix = wxPG_PREFIX_NONE; } @@ -632,13 +642,13 @@ bool wxUIntProperty::DoSetAttribute( const wxString& name, wxVariant& value ) // // Translate logical base to a template array index - m_base = 7; // oct + m_base = wxPG_UINT_OCT; if ( val == wxPG_BASE_HEX ) - m_base = 3; + m_base = wxPG_UINT_HEX_UPPER; else if ( val == wxPG_BASE_DEC ) - m_base = 6; + m_base = wxPG_UINT_DEC; else if ( val == wxPG_BASE_HEXL ) - m_base = 0; + m_base = wxPG_UINT_HEX_LOWER_DOLLAR; return true; } else if ( name == wxPG_UINT_PREFIX )