// 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".
//
// Generic re-center code
//
+ ResetColumnSizes(wxPG_SPLITTER_FROM_AUTO_CENTER);
+ }
+ }
+}
- // Calculate sum of proportions
- int psum = 0;
- for ( i=0; i<m_colWidths.size(); i++ )
- psum += m_columnProportions[i];
- int puwid = (pg->m_width*256) / psum;
- int cpos = 0;
+void wxPropertyGridPageState::ResetColumnSizes( int setSplitterFlags )
+{
+ unsigned int i;
+ // Calculate sum of proportions
+ int psum = 0;
+ for ( i=0; i<m_colWidths.size(); i++ )
+ psum += m_columnProportions[i];
+ int puwid = (m_pPropGrid->m_width*256) / psum;
+ int cpos = 0;
- for ( i=0; i<(m_colWidths.size() - 1); i++ )
- {
- int cwid = (puwid*m_columnProportions[i]) / 256;
- cpos += cwid;
- DoSetSplitterPosition(cpos, i,
- wxPG_SPLITTER_FROM_AUTO_CENTER);
- }
- }
+ // Convert proportion to splitter positions
+ for ( i=0; i<(m_colWidths.size() - 1); i++ )
+ {
+ int cwid = (puwid*m_columnProportions[i]) / 256;
+ cpos += cwid;
+ DoSetSplitterPosition(cpos, i,
+ setSplitterFlags);
}
}
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
// -----------------------------------------------------------------------
wxCHECK_RET( item != &m_regularArray && item != m_abcArray,
wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
+ wxPropertyGrid* pg = GetGrid();
+
+ // Must defer deletion? Yes, if handling a wxPG event.
+ if ( pg && pg->m_processedEvent )
+ {
+ if ( doDelete )
+ 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;
+ }
+
unsigned int indinparent = item->GetIndexInParent();
wxPGProperty* pwc = (wxPGProperty*)item;
wxASSERT( item->GetParentState() == this );
- wxPropertyGrid* pg = GetGrid();
-
if ( DoIsPropertySelected(item) )
{
if ( pg && pg->GetState() == this )
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;