Make wxPG_COLOUR_ALLOW_CUSTOM a Boolean property
So far it was implemented as property which could take int values 0/1 so it was acting essentially as a Boolean property. Implementing it explicitly as a Boolean one will make it more intuitive. Legacy code setting 0/1 int values shouldn't be affected because conversion from int to bool is implicit.
This commit is contained in:
@@ -95,6 +95,9 @@ public:
|
|||||||
@ingroup classes
|
@ingroup classes
|
||||||
Has dropdown list of wxWidgets system colours. Value used is
|
Has dropdown list of wxWidgets system colours. Value used is
|
||||||
of wxColourPropertyValue type.
|
of wxColourPropertyValue type.
|
||||||
|
|
||||||
|
<b>Supported special attributes:</b>
|
||||||
|
::wxPG_COLOUR_ALLOW_CUSTOM, ::wxPG_COLOUR_HAS_ALPHA
|
||||||
*/
|
*/
|
||||||
class wxSystemColourProperty : public wxEnumProperty
|
class wxSystemColourProperty : public wxEnumProperty
|
||||||
{
|
{
|
||||||
@@ -168,6 +171,14 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** @class wxColourProperty
|
||||||
|
@ingroup classes
|
||||||
|
Allows to select a colour from the list or with colour dialog. Value used
|
||||||
|
is of wxColourPropertyValue type.
|
||||||
|
|
||||||
|
<b>Supported special attributes:</b>
|
||||||
|
::wxPG_COLOUR_ALLOW_CUSTOM, ::wxPG_COLOUR_HAS_ALPHA
|
||||||
|
*/
|
||||||
class wxColourProperty : public wxSystemColourProperty
|
class wxColourProperty : public wxSystemColourProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -206,9 +206,9 @@ struct wxPGPaintData
|
|||||||
*/
|
*/
|
||||||
#define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode")
|
#define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode")
|
||||||
|
|
||||||
/** Built-in attribute of wxColourProperty and its kind, type of @c int,
|
/** Built-in attribute of wxColourProperty and its kind, type of @c bool,
|
||||||
default value is 1. Setting this attribute to 0 hides custom colour
|
default value is @true. Setting this attribute to @false hides custom
|
||||||
from property's list of choices.
|
colour from property's list of choices.
|
||||||
*/
|
*/
|
||||||
#define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom")
|
#define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom")
|
||||||
|
|
||||||
|
@@ -1571,16 +1571,16 @@ bool wxSystemColourProperty::DoSetAttribute( const wxString& name, wxVariant& va
|
|||||||
{
|
{
|
||||||
if ( name == wxPG_COLOUR_ALLOW_CUSTOM )
|
if ( name == wxPG_COLOUR_ALLOW_CUSTOM )
|
||||||
{
|
{
|
||||||
int ival = value.GetLong();
|
bool allow = value.GetBool();
|
||||||
|
|
||||||
if ( ival && (m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
|
if ( allow && (m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
|
||||||
{
|
{
|
||||||
// Show custom choice
|
// Show custom choice
|
||||||
/* TRANSLATORS: Custom colour choice entry */
|
/* TRANSLATORS: Custom colour choice entry */
|
||||||
m_choices.Add(_("Custom"), wxPG_COLOUR_CUSTOM);
|
m_choices.Add(_("Custom"), wxPG_COLOUR_CUSTOM);
|
||||||
m_flags &= ~(wxPG_PROP_HIDE_CUSTOM_COLOUR);
|
m_flags &= ~(wxPG_PROP_HIDE_CUSTOM_COLOUR);
|
||||||
}
|
}
|
||||||
else if ( !ival && !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
|
else if ( !allow && !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
|
||||||
{
|
{
|
||||||
// Hide custom choice
|
// Hide custom choice
|
||||||
m_choices.RemoveAt(GetCustomColourIndex());
|
m_choices.RemoveAt(GetCustomColourIndex());
|
||||||
|
Reference in New Issue
Block a user