]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxPGProperty::Enable() for conveniency. Refactored related code and improved...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 8 Aug 2010 11:41:20 +0000 (11:41 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 8 Aug 2010 11:41:20 +0000 (11:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65216 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/property.h
include/wx/propgrid/propgridiface.h
include/wx/propgrid/propgridpagestate.h
interface/wx/propgrid/property.h
interface/wx/propgrid/propgridiface.h
src/propgrid/property.cpp
src/propgrid/propgridiface.cpp
src/propgrid/propgridpagestate.cpp

index 14eca1252b3ee07b40877927a4aee2bc7f8a4ed0..dc1f2c2426fdf1906eea2996641d3af538a8aab6 100644 (file)
@@ -1523,6 +1523,17 @@ public:
     */
     void DeleteChoice( int index );
 
+    /**
+        Enables or disables the property. Disabled property usually appears
+        as having grey text.
+
+        @param enable
+            If @false, property is disabled instead.
+
+        @see wxPropertyGridInterface::EnableProperty()
+    */
+    void Enable( bool enable = true );
+
     /**
         Call to enable or disable usage of common value (integer value that can
         be selected for properties instead of their normal values) for this
@@ -2357,6 +2368,8 @@ protected:
     // Removes child property with given pointer. Does not delete it.
     void RemoveChild( wxPGProperty* p );
 
+    void DoEnable( bool enable );
+
     void DoPreAddChild( int index, wxPGProperty* prop );
 
     void SetParentState( wxPropertyGridPageState* pstate )
index 839ade4774859f30c6434b731152822d28b79506..8aa26d070e3e8b3141040ca01278df07920e1570 100644 (file)
@@ -267,7 +267,11 @@ public:
     */
     wxPGProperty* RemoveProperty( wxPGPropArg id );
 
-    /** Disables property. */
+    /**
+        Disables a property.
+
+        @see EnableProperty(), wxPGProperty::Enable()
+    */
     bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
 
     /**
@@ -280,7 +284,14 @@ public:
 
     /**
         Enables or disables property, depending on whether enable is true or
-        false.
+        false. Disabled property usually appears as having grey text.
+
+        @param id
+            Name or pointer to a property.
+        @param enable
+            If @false, property is disabled instead.
+
+        @see wxPGProperty::Enable()
      */
     bool EnableProperty( wxPGPropArg id, bool enable = true );
 
index faf12fdce850eaade540a5ada9717f58f2db0baf..3f72dc92d45b9f89e4eedcd2c2e21bba2f9baaee 100644 (file)
@@ -473,9 +473,6 @@ public:
         }
     }
 
-    /** Enables or disables given property and its subproperties. */
-    bool DoEnableProperty( wxPGProperty* p, bool enable );
-
     /** Returns (precalculated) height of contained visible properties.
     */
     unsigned int GetVirtualHeight() const
index 0e314680f181b5af104a998e4629376a8ccfb300..23102687cb892282d7d5f9500d6496fe51e45030 100644 (file)
@@ -1161,6 +1161,17 @@ public:
     /** Deletes all child properties. */
     void Empty();
 
+    /**
+        Enables or disables the property. Disabled property usually appears
+        as having grey text.
+
+        @param enable
+            If @false, property is disabled instead.
+
+        @see wxPropertyGridInterface::EnableProperty()
+    */
+    void Enable( bool enable = true );
+
     /**
         Composes text from values of child properties.
     */
index 7309f907fdda3f7653a12353edbde9966d3d90a7..bdf95761719637f7b34f58ef2b7602d446e86753 100644 (file)
@@ -153,6 +153,8 @@ public:
 
     /**
         Disables a property.
+
+        @see EnableProperty(), wxPGProperty::Enable()
     */
     bool DisableProperty( wxPGPropArg id );
 
@@ -164,12 +166,15 @@ public:
     bool EditorValidate();
 
     /**
-        Enables or disables property.
+        Enables or disables property. Disabled property usually appears as
+        having grey text.
 
         @param id
             Name or pointer to a property.
         @param enable
             If @false, property is disabled instead.
+
+        @see wxPGProperty::Enable()
     */
     bool EnableProperty( wxPGPropArg id, bool enable = true );
 
index 333a27d0c8a7e8c673900d428b80559471095092..e759aa5d7288e5373eb80296d1c0543da8d598e4 100644 (file)
@@ -1492,6 +1492,31 @@ wxVariant wxPGProperty::GetDefaultValue() const
     return wxVariant();
 }
 
+void wxPGProperty::Enable( bool enable )
+{
+    wxPropertyGrid* pg = GetGrid();
+
+    // Preferably call the version in the owning wxPropertyGrid,
+    // since it handles the editor de-activation.
+    if ( pg )
+        pg->EnableProperty(this, enable);
+    else
+        DoEnable(enable);
+}
+
+void wxPGProperty::DoEnable( bool enable )
+{
+    if ( enable )
+        ClearFlag(wxPG_PROP_DISABLED);
+    else
+        SetFlag(wxPG_PROP_DISABLED);
+
+    // Apply same to sub-properties as well
+    unsigned int i;
+    for ( i = 0; i < GetChildCount(); i++ )
+        Item(i)->DoEnable( enable );
+}
+
 void wxPGProperty::EnsureCells( unsigned int column )
 {
     if ( column >= m_cells.size() )
index 66dcd9e67c05f5cd93eda37c76f0ca659497a5ee..f8aab4650791af392cb821e9da632ae89c421e24 100644 (file)
@@ -277,7 +277,7 @@ bool wxPropertyGridInterface::EnableProperty( wxPGPropArg id, bool enable )
             grid->DoSelectProperty( p, wxPG_SEL_FORCE );
     }
 
-    state->DoEnableProperty(p, enable);
+    p->DoEnable(enable);
 
     RefreshProperty( p );
 
index 74b1adbe1f39011e38b39ebddf25bd3e891e90c1..1ae7c025d247d5cfd2188c3351b6a4cbc91ff38f 100644 (file)
@@ -1398,42 +1398,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
 // -----------------------------------------------------------------------