From c904964610dd6e4e3863f3c55e5e8b586e9a5c6a Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Sun, 19 Oct 2008 11:16:29 +0000 Subject: [PATCH] Fixed wxSystemColourProperty::ValueToString(). It now once again properly formats custom colour selection as (R, G, B) when displayed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/advprops.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 7a58087922..4a18197dc4 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -1001,11 +1001,29 @@ wxString wxSystemColourProperty::ColourToString( const wxColour& col, int index } wxString wxSystemColourProperty::ValueToString( wxVariant& value, - int WXUNUSED(argFlags) ) const + int argFlags ) const { wxColourPropertyValue val = GetVal(&value); - return ColourToString(val.m_colour, m_choices.Index(val.m_type)); + int index; + + if ( argFlags & wxPG_VALUE_IS_CURRENT ) + { + // GetIndex() only works reliably if wxPG_VALUE_IS_CURRENT flag is set, + // but we should use it whenever possible. + index = GetIndex(); + + // If custom colour was selected, use invalid index, so that + // ColourToString() will return properly formatted colour text. + if ( index == GetCustomColourIndex() ) + index = wxNOT_FOUND; + } + else + { + index = m_choices.Index(val.m_type); + } + + return ColourToString(val.m_colour, index); } -- 2.45.2