- 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);
- }
-}
-
-// -----------------------------------------------------------------------
-// wxPropertyGrid property adding and removal
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::PrepareAfterItemsAdded()
-{
- if ( !m_pState || !m_pState->m_itemsAdded ) return;
-
- m_pState->m_itemsAdded = 0;
-
- if ( m_windowStyle & wxPG_AUTO_SORT )
- Sort();
-
- RecalculateVirtualSize();
-}
-
-// -----------------------------------------------------------------------
-// wxPropertyGrid property value setting and getting
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::DoSetPropertyValueUnspecified( wxPGProperty* p )
-{
- m_pState->DoSetPropertyValueUnspecified(p);
- DrawItemAndChildren(p);
-
- wxPGProperty* parent = p->GetParent();
- while ( (parent->GetFlags() & wxPG_PROP_PARENTAL_FLAGS) == wxPG_PROP_MISC_PARENT )
- {
- DrawItem(parent);
- parent = parent->GetParent();
- }
-}
-
-// -----------------------------------------------------------------------
-// wxPropertyGrid property operations
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::DoSetPropertyName( wxPGProperty* p, const wxString& newname )
-{
- wxCHECK_RET( p, wxT("invalid property id") );
-
- if ( p->GetBaseName().Len() ) m_pState->m_dictName.erase( p->GetBaseName() );
- if ( newname.Len() ) m_pState->m_dictName[newname] = (void*) p;
-
- p->DoSetName(newname);
-}
-
-// -----------------------------------------------------------------------
-
-bool wxPropertyGrid::EnsureVisible( wxPGPropArg id )
-{
- wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
-
- Update();
-
- bool changed = false;
-
- // Is it inside collapsed section?
- if ( !p->IsVisible() )
- {
- // expand parents
- wxPGProperty* parent = p->GetParent();
- wxPGProperty* grandparent = parent->GetParent();
-
- if ( grandparent && grandparent != m_pState->m_properties )
- Expand( grandparent );
-
- Expand( parent );
- changed = true;
- }
-
- // Need to scroll?
- int vx, vy;
- GetViewStart(&vx,&vy);
- vy*=wxPG_PIXELS_PER_UNIT;
-
- int y = p->GetY();
-
- if ( y < vy )
- {
- Scroll(vx, y/wxPG_PIXELS_PER_UNIT );
- m_iFlags |= wxPG_FL_SCROLLED;
- changed = true;
- }
- else if ( (y+m_lineHeight) > (vy+m_height) )
- {
- Scroll(vx, (y-m_height+(m_lineHeight*2))/wxPG_PIXELS_PER_UNIT );
- m_iFlags |= wxPG_FL_SCROLLED;
- changed = true;
- }
-
- if ( changed )
- DrawItems( p, p );
-
- return changed;
-}
-
-// -----------------------------------------------------------------------
-// wxPropertyGrid helper methods called by properties
-// -----------------------------------------------------------------------
-
-// Control font changer helper.
-void wxPropertyGrid::SetCurControlBoldFont()
-{
- wxASSERT( m_wndEditor );
- m_wndEditor->SetFont( m_captionFont );
-}
-
-// -----------------------------------------------------------------------
-
-wxPoint wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty* p,
- const wxSize& sz )
-{
-#if wxPG_SMALL_SCREEN
- // On small-screen devices, always show dialogs with default position and size.
- return wxDefaultPosition;
-#else
- int splitterX = GetSplitterPosition();
- int x = splitterX;
- int y = p->GetY();
-
- wxCHECK_MSG( y >= 0, wxPoint(-1,-1), wxT("invalid y?") );