]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/propgridpagestate.cpp
Misc validity fixes to samples/xrc/rc/*.xrc.
[wxWidgets.git] / src / propgrid / propgridpagestate.cpp
index 74b1adbe1f39011e38b39ebddf25bd3e891e90c1..b178b1b46ce139fe726b5e15a8b5637fa68ebd8f 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Jaakko Salli
 // Modified by:
 // Created:     2008-08-24
-// RCS-ID:      $Id$
 // Copyright:   (c) Jaakko Salli
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -477,9 +476,9 @@ void wxPropertyGridPageState::DoSetPropertyName( wxPGProperty* p,
 
     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;
     }
 
@@ -803,6 +802,27 @@ int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC& dc,
     return maxW;
 }
 
+int wxPropertyGridPageState::GetColumnFullWidth( wxClientDC &dc, wxPGProperty *p, unsigned int col )
+{
+    if ( p->IsCategory() )
+        return 0;
+
+    const wxPGCell* cell = NULL;
+    wxString text;
+    p->GetDisplayInfo(col, -1, 0, &text, &cell);
+    int w = dc.GetTextExtent(text).x;
+
+    if ( col == 0 )
+        w += (int)p->m_depth * m_pPropGrid->m_subgroup_extramargin;
+
+    // account for the bitmap
+    if ( col == 1 )
+        w += p->GetImageOffset(m_pPropGrid->GetImageRect(p, -1).GetWidth());
+
+    w += (wxPG_XBEFORETEXT*2);
+    return w;
+}
+
 int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn ) const
 {
     int n = GetGrid()->m_marginWidth;
@@ -1398,42 +1418,6 @@ bool wxPropertyGridPageState::DoHideProperty( wxPGProperty* p, bool hide, int fl
     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
 // -----------------------------------------------------------------------
@@ -1534,7 +1518,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
         wxASSERT( wxStrcmp(current->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
 
         const wxString& name = current->GetName();
-        if ( name.length() > 0 )
+        if ( !name.empty() )
         {
             //
             // '@' signified a special entry
@@ -1593,7 +1577,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
             wxVariant *current = (wxVariant*)*node;
 
             const wxString& name = current->GetName();
-            if ( name.length() > 0 )
+            if ( !name.empty() )
             {
                 //
                 // '@' signified a special entry
@@ -1662,7 +1646,7 @@ bool wxPropertyGridPageState::PrepareToAddItem( wxPGProperty* property,
 {
     wxPropertyGrid* propGrid = m_pPropGrid;
 
-    // This will allow better behavior.
+    // This will allow better behaviour.
     if ( scheduledParent == m_properties )
         scheduledParent = NULL;
 
@@ -1758,7 +1742,7 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index
 
     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;
@@ -1818,7 +1802,7 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index
     }
 
     // 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;
 
@@ -1955,7 +1939,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
         }
     }
 
-    if ( item->GetBaseName().length() &&
+    if ( !item->GetBaseName().empty() &&
          (parent->IsCategory() || parent->IsRoot()) )
         m_dictName.erase(item->GetBaseName());
 
@@ -1970,6 +1954,8 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
     // 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).