From 1ee97383f71c9eb8094b614a74fd9cbcf943eabd Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 21 Apr 2019 00:14:13 +0200 Subject: [PATCH] Make wxPG_COLOUR_HAS_ALPHA a built-in attribute wxPG_COLOUR_HAS_ALPHA attribute is used only in wxSystemColourProperty (and derived properties) to set respective internal flag so it doesn't have to be stored in the property's attribute store. --- interface/wx/propgrid/property.h | 3 ++- src/propgrid/advprops.cpp | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index adada0ce19..f0ee54ab61 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -201,7 +201,8 @@ struct wxPGPaintData #define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom") /** - wxColourProperty and its kind: Set to True in order to support editing + Built-in attribute of wxColourProperty and its kind, @bool type. Default + value is @false. Set this attribute to @true in order to support editing alpha colour component. */ #define wxPG_COLOUR_HAS_ALPHA wxS("HasAlpha") diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 8d95388738..ef87b33060 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -873,6 +873,7 @@ void wxFontProperty::OnCustomPaint(wxDC& dc, // wxEnumProperty based classes cannot use wxPG_PROP_CLASS_SPECIFIC_1 #define wxPG_PROP_HIDE_CUSTOM_COLOUR wxPG_PROP_CLASS_SPECIFIC_2 +#define wxPG_PROP_COLOUR_HAS_ALPHA wxPG_PROP_CLASS_SPECIFIC_3 #include "wx/colordlg.h" @@ -1182,8 +1183,7 @@ wxString wxSystemColourProperty::ColourToString( const wxColour& col, if ( index == wxNOT_FOUND ) { - if ( (argFlags & wxPG_FULL_VALUE) || - GetAttributeAsLong(wxPG_COLOUR_HAS_ALPHA, 0) ) + if ( (argFlags & wxPG_FULL_VALUE) || (m_flags & wxPG_PROP_COLOUR_HAS_ALPHA) ) { return wxString::Format(wxS("(%i,%i,%i,%i)"), (int)col.Red(), @@ -1263,7 +1263,7 @@ bool wxSystemColourProperty::QueryColourFromUser( wxVariant& variant ) const wxColourData data; data.SetChooseFull(true); - data.SetChooseAlpha(GetAttributeAsLong(wxPG_COLOUR_HAS_ALPHA, 0) != 0); + data.SetChooseAlpha((m_flags & wxPG_PROP_COLOUR_HAS_ALPHA) != 0); data.SetColour(val.m_colour); for ( int i = 0; i < wxColourData::NUM_CUSTOM; i++ ) { @@ -1591,6 +1591,16 @@ bool wxSystemColourProperty::DoSetAttribute( const wxString& name, wxVariant& va } return true; } + else if ( name == wxPG_COLOUR_HAS_ALPHA ) + { + if ( value.GetBool() ) + m_flags |= wxPG_PROP_COLOUR_HAS_ALPHA; + else + m_flags &= ~(wxPG_PROP_COLOUR_HAS_ALPHA); + + return true; + } + return false; }