diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 19e16d8843..fb302adb6a 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -2013,6 +2013,16 @@ public: void SetTextColour( const wxColour& colour, 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 @code @@ -2397,6 +2407,14 @@ protected: FlagType ignoreWithFlags, 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). */ diff --git a/include/wx/propgrid/propgridiface.h b/include/wx/propgrid/propgridiface.h index d1c0ec8661..7ddea4e35d 100644 --- a/include/wx/propgrid/propgridiface.h +++ b/include/wx/propgrid/propgridiface.h @@ -953,8 +953,19 @@ public: int flags = wxPG_RECURSE ); /** 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). */ - void SetPropertyColoursToDefault( wxPGPropArg id ); +#if WXWIN_COMPATIBILITY_3_0 + 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. diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 7fe26594eb..77607c67ae 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -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 { if ( m_cells.size() > column ) @@ -1774,6 +1790,27 @@ void wxPGProperty::SetTextColour( const wxColour& colour, 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 { return NULL; diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index 96ecefcd19..9394649a84 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -685,11 +685,18 @@ void wxPropertyGridInterface::SetPropertyTextColour( wxPGPropArg id, // ----------------------------------------------------------------------- -void wxPropertyGridInterface::SetPropertyColoursToDefault( wxPGPropArg id ) +#if WXWIN_COMPATIBILITY_3_0 +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() - p->m_cells.clear(); + p->SetDefaultColours(flags); } // -----------------------------------------------------------------------