From 78be29a447993967780bbadf8c9df1354fcc9f73 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Feb 2014 23:52:53 +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/trunk@75901 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 8aba9bd222..d0508afa70 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -470,8 +470,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"), @@ -495,7 +505,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; } @@ -633,13 +643,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 )