-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::SetBackgroundColourIndex( wxPGProperty* p, int index )
-{
- unsigned char ind = index;
-
- p->m_bgColIndex = ind;
-
- unsigned int i;
- for ( i=0; i<p->GetChildCount(); i++ )
- SetBackgroundColourIndex(p->Item(i),index);
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::SetPropertyBackgroundColour( wxPGPropArg id, const wxColour& colour )
-{
- wxPG_PROP_ARG_CALL_PROLOG()
-
- size_t i;
- int colInd = -1;
-
- long colAsLong = wxPG_COLOUR(colour.Red(),colour.Green(),colour.Blue());
-
- // As it is most likely that the previous colour is used, start comparison
- // from the end.
- for ( i=(m_arrBgBrushes.size()-1); i>0; i-- )
- {
- if ( ((wxPGBrush*)m_arrBgBrushes.Item(i))->GetColourAsLong() == colAsLong )
- {
- colInd = i;
- break;
- }
- }
-
- if ( colInd < 0 )
- {
- colInd = m_arrBgBrushes.size();
- wxCHECK_RET( colInd < 256, wxT("wxPropertyGrid: Warning - Only 255 different property background colours allowed.") );
- m_arrBgBrushes.Add( (void*)new wxPGBrush(colour) );
- }
-
- // Set indexes
- SetBackgroundColourIndex(p,colInd);
-
- // If this was on a visible grid, then draw it.
- DrawItemAndChildren(p);
-}
-
-// -----------------------------------------------------------------------
-
-wxColour wxPropertyGrid::GetPropertyBackgroundColour( wxPGPropArg id ) const
-{
- wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
-
- return ((wxPGBrush*)m_arrBgBrushes.Item(p->m_bgColIndex))->GetColour();
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::SetTextColourIndex( wxPGProperty* p, int index, int flags )
-{
- unsigned char ind = index;
-
- p->m_fgColIndex = ind;
-
- if ( p->GetChildCount() && (flags & wxPG_RECURSE) )
- {
- unsigned int i;
- for ( i=0; i<p->GetChildCount(); i++ )
- SetTextColourIndex( p->Item(i), index, flags );
- }
-}
-
-// -----------------------------------------------------------------------
-
-int wxPropertyGrid::CacheColour( const wxColour& colour )
-{
- unsigned int i;
- int colInd = -1;
-
- long colAsLong = wxPG_COLOUR(colour.Red(),colour.Green(),colour.Blue());
-
- // As it is most likely that the previous colour is used, start comparison
- // from the end.
- for ( i=(m_arrFgCols.size()-1); i>0; i-- )
- {
- if ( ((wxPGColour*)m_arrFgCols.Item(i))->GetColourAsLong() == colAsLong )
- {
- colInd = i;
- break;
- }
- }
-
- if ( colInd < 0 )
- {
- colInd = m_arrFgCols.size();
- wxCHECK_MSG( colInd < 256, 0, wxT("wxPropertyGrid: Warning - Only 255 different property foreground colours allowed.") );
- m_arrFgCols.Add( (void*)new wxPGColour(colour) );
- }
-
- return colInd;
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::SetPropertyTextColour( wxPGPropArg id, const wxColour& colour,
- bool recursively )
-{
- wxPG_PROP_ARG_CALL_PROLOG()
-
- if ( p->IsCategory() )
- {
- wxPropertyCategory* cat = (wxPropertyCategory*) p;
- cat->SetTextColIndex(CacheColour(colour));
- }
-
- // Set indexes
- int flags = 0;
- if ( recursively )
- flags |= wxPG_RECURSE;
- SetTextColourIndex(p, CacheColour(colour), flags);
-
- DrawItemAndChildren(p);
-}
-
-// -----------------------------------------------------------------------
-
-wxColour wxPropertyGrid::GetPropertyTextColour( wxPGPropArg id ) const
-{
- wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
-
- return wxColour(*((wxPGColour*)m_arrFgCols.Item(p->m_fgColIndex)));
-}
-
-void wxPropertyGrid::SetPropertyColoursToDefault( wxPGPropArg id )
-{
- wxPG_PROP_ARG_CALL_PROLOG()
-
- SetBackgroundColourIndex( p, 0 );
- SetTextColourIndex( p, 0, wxPG_RECURSE );
-
- if ( p->IsCategory() )
- {
- wxPropertyCategory* cat = (wxPropertyCategory*) p;
- cat->SetTextColIndex(1);
- }
-}
-