Extend functionality of wxPropertyGridInterface::SetPropertyColoursToDefault method.
SetPropertyTextColour, SetPropertyBackgroundColour methods are able to set colours recursively for sub-properties but SetPropertyColoursToDefault method is not. For the sake of consistency, SetPropertyColoursToDefault method is extended to have the same capabilities as SetPropertyTextColour and SetPropertyBackgroundColour. Behaviour and signature in default case (no recursion) is preserved. For internal purposes there were also implemented helper methods in wxPGProperty class: SetDefaultColours, ClearCells.
This commit is contained in:
@@ -2013,6 +2013,16 @@ public:
|
|||||||
void SetTextColour( const wxColour& colour,
|
void SetTextColour( const wxColour& colour,
|
||||||
int flags = wxPG_RECURSE );
|
int flags = wxPG_RECURSE );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets property's default text and background colours.
|
||||||
|
|
||||||
|
@param flags
|
||||||
|
Default is wxPG_RECURSE which causes colours to be set recursively.
|
||||||
|
Omit this flag to only set colours for the property in question
|
||||||
|
and not any of its children.
|
||||||
|
*/
|
||||||
|
void SetDefaultColours(int flags = wxPG_RECURSE);
|
||||||
|
|
||||||
/** Set default value of a property. Synonymous to
|
/** Set default value of a property. Synonymous to
|
||||||
|
|
||||||
@code
|
@code
|
||||||
@@ -2397,6 +2407,14 @@ protected:
|
|||||||
FlagType ignoreWithFlags,
|
FlagType ignoreWithFlags,
|
||||||
bool recursively );
|
bool recursively );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Clear cells associated with property.
|
||||||
|
|
||||||
|
@param recursively
|
||||||
|
If @true, apply this operation recursively in child properties.
|
||||||
|
*/
|
||||||
|
void ClearCells(FlagType ignoreWithFlags, bool recursively);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Makes sure m_cells has size of column+1 (or more).
|
Makes sure m_cells has size of column+1 (or more).
|
||||||
*/
|
*/
|
||||||
|
@@ -953,8 +953,19 @@ public:
|
|||||||
int flags = wxPG_RECURSE );
|
int flags = wxPG_RECURSE );
|
||||||
|
|
||||||
/** Resets text and background colours of given property.
|
/** Resets text and background colours of given property.
|
||||||
|
@param id
|
||||||
|
Property name or pointer.
|
||||||
|
|
||||||
|
@param flags
|
||||||
|
Default is wxPG_DONT_RECURSE which causes colour to be reset
|
||||||
|
only for the property in question (for backward compatibility).
|
||||||
*/
|
*/
|
||||||
|
#if WXWIN_COMPATIBILITY_3_0
|
||||||
void SetPropertyColoursToDefault(wxPGPropArg id);
|
void SetPropertyColoursToDefault(wxPGPropArg id);
|
||||||
|
void SetPropertyColoursToDefault(wxPGPropArg id, int flags);
|
||||||
|
#else
|
||||||
|
void SetPropertyColoursToDefault(wxPGPropArg id, int flags = wxPG_DONT_RECURSE);
|
||||||
|
#endif // WXWIN_COMPATIBILITY_3_0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets text colour of a property.
|
Sets text colour of a property.
|
||||||
|
@@ -1681,6 +1681,22 @@ void wxPGProperty::AdaptiveSetCell( unsigned int firstCol,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxPGProperty::ClearCells(FlagType ignoreWithFlags, bool recursively)
|
||||||
|
{
|
||||||
|
if ( !(m_flags & ignoreWithFlags) && !IsRoot() )
|
||||||
|
{
|
||||||
|
m_cells.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( recursively )
|
||||||
|
{
|
||||||
|
for ( unsigned int i = 0; i < GetChildCount(); i++ )
|
||||||
|
{
|
||||||
|
Item(i)->ClearCells(ignoreWithFlags, recursively);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const wxPGCell& wxPGProperty::GetCell( unsigned int column ) const
|
const wxPGCell& wxPGProperty::GetCell( unsigned int column ) const
|
||||||
{
|
{
|
||||||
if ( m_cells.size() > column )
|
if ( m_cells.size() > column )
|
||||||
@@ -1774,6 +1790,27 @@ void wxPGProperty::SetTextColour( const wxColour& colour,
|
|||||||
recursively );
|
recursively );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxPGProperty::SetDefaultColours(int flags)
|
||||||
|
{
|
||||||
|
wxPGProperty* firstProp = this;
|
||||||
|
bool recursively = flags & wxPG_RECURSE ? true : false;
|
||||||
|
|
||||||
|
// If category is tried to set recursively, skip it and only
|
||||||
|
// affect the children.
|
||||||
|
if ( recursively )
|
||||||
|
{
|
||||||
|
while ( firstProp->IsCategory() )
|
||||||
|
{
|
||||||
|
if ( !firstProp->GetChildCount() )
|
||||||
|
return;
|
||||||
|
firstProp = firstProp->Item(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearCells(recursively ? wxPG_PROP_CATEGORY : 0,
|
||||||
|
recursively);
|
||||||
|
}
|
||||||
|
|
||||||
wxPGEditorDialogAdapter* wxPGProperty::GetEditorDialog() const
|
wxPGEditorDialogAdapter* wxPGProperty::GetEditorDialog() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -685,11 +685,18 @@ void wxPropertyGridInterface::SetPropertyTextColour( wxPGPropArg id,
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_3_0
|
||||||
void wxPropertyGridInterface::SetPropertyColoursToDefault(wxPGPropArg id)
|
void wxPropertyGridInterface::SetPropertyColoursToDefault(wxPGPropArg id)
|
||||||
|
{
|
||||||
|
SetPropertyColoursToDefault(id, wxPG_DONT_RECURSE);
|
||||||
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY_3_0
|
||||||
|
|
||||||
|
void wxPropertyGridInterface::SetPropertyColoursToDefault(wxPGPropArg id, int flags)
|
||||||
{
|
{
|
||||||
wxPG_PROP_ARG_CALL_PROLOG()
|
wxPG_PROP_ARG_CALL_PROLOG()
|
||||||
|
|
||||||
p->m_cells.clear();
|
p->SetDefaultColours(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user