// Created: 2008-08-24
// RCS-ID: $Id$
// Copyright: (c) Jaakko Salli
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
if ( parent->IsCategory() || parent->IsRoot() )
{
- if ( p->GetBaseName().length() )
+ if ( !p->GetBaseName().empty() )
m_dictName.erase( p->GetBaseName() );
- if ( newName.length() )
+ if ( !newName.empty() )
m_dictName[newName] = (void*) p;
}
bool wxPropertyGridPageState::DoIsPropertySelected( wxPGProperty* prop ) const
{
- const wxArrayPGProperty& selection = m_selection;
-
- for ( unsigned int i=0; i<selection.size(); i++ )
- {
- if ( selection[i] == prop )
- return true;
- }
+ if ( wxPGFindInVector(m_selection, prop) != wxNOT_FOUND )
+ return true;
return false;
}
bool wxPropertyGridPageState::DoHideProperty( wxPGProperty* p, bool hide, int flags )
{
- if ( !hide )
- p->ClearFlag( wxPG_PROP_HIDDEN );
- else
- p->SetFlag( wxPG_PROP_HIDDEN );
-
- if ( flags & wxPG_RECURSE )
- {
- unsigned int i;
- for ( i = 0; i < p->GetChildCount(); i++ )
- DoHideProperty(p->Item(i), hide, flags | wxPG_RECURSE_STARTS);
- }
-
+ p->DoHide(hide, flags);
VirtualHeightChanged();
return true;
}
-// -----------------------------------------------------------------------
-
-bool wxPropertyGridPageState::DoEnableProperty( wxPGProperty* p, bool enable )
-{
- if ( p )
- {
- if ( enable )
- {
- if ( !(p->m_flags & wxPG_PROP_DISABLED) )
- return false;
-
- // Enabling
-
- p->m_flags &= ~(wxPG_PROP_DISABLED);
- }
- else
- {
- if ( p->m_flags & wxPG_PROP_DISABLED )
- return false;
-
- // Disabling
-
- p->m_flags |= wxPG_PROP_DISABLED;
-
- }
-
- // Apply same to sub-properties as well
- unsigned int i;
- for ( i = 0; i < p->GetChildCount(); i++ )
- DoEnableProperty( p->Item(i), enable );
-
- return true;
- }
- return false;
-}
-
// -----------------------------------------------------------------------
// wxPropertyGridPageState wxVariant related routines
// -----------------------------------------------------------------------
wxASSERT( wxStrcmp(current->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
const wxString& name = current->GetName();
- if ( name.length() > 0 )
+ if ( !name.empty() )
{
//
// '@' signified a special entry
wxVariant *current = (wxVariant*)*node;
const wxString& name = current->GetName();
- if ( name.length() > 0 )
+ if ( !name.empty() )
{
//
// '@' signified a special entry
{
wxPropertyGrid* propGrid = m_pPropGrid;
- // This will allow better behavior.
+ // This will allow better behaviour.
if ( scheduledParent == m_properties )
scheduledParent = NULL;
bool res = PrepareToAddItem( property, (wxPropertyCategory*)parent );
- // PrepareToAddItem() may just decide to use use current category
+ // PrepareToAddItem() may just decide to use current category
// instead of adding new one.
if ( !res )
return m_currentCategory;
}
// Only add name to hashmap if parent is root or category
- if ( property->m_name.length() &&
+ if ( !property->m_name.empty() &&
(parentIsCategory || parentIsRoot) )
m_dictName[property->m_name] = (void*) property;
pg->m_deletedProperties.push_back(item);
else
pg->m_removedProperties.push_back(item);
+
+ // Rename the property so it won't remain in the way
+ // of the user code.
+
+ // Let's trust that no sane property uses prefix like
+ // this. It would be anyway fairly inconvenient (in
+ // current code) to check whether a new name is used
+ // by another property with parent (due to the child
+ // name notation).
+ wxString newName = wxS("_&/_%$") + item->GetBaseName();
+ DoSetPropertyName(item, newName);
+
return;
}
}
}
- if ( item->GetBaseName().length() &&
+ if ( !item->GetBaseName().empty() &&
(parent->IsCategory() || parent->IsRoot()) )
m_dictName.erase(item->GetBaseName());
if ( pg && pg->m_propHover == item )
pg->m_propHover = NULL;
+ // Mark the property as 'unattached'
+ item->m_parentState = NULL;
+ item->m_parent = NULL;
+
// We can actually delete it now
if ( doDelete )
delete item;
+ else
+ item->OnDetached(this, pg);
m_itemsAdded = 1; // Not a logical assignment (but required nonetheless).