]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/propgrid/property.h
Export public wxDelegateTheme class.
[wxWidgets.git] / include / wx / propgrid / property.h
index 8f2da0c73022c5f9477137429d7d024cb1db959a..a4e3fbddc4871a171c6d0f37ddd1325755a64a65 100644 (file)
@@ -64,12 +64,12 @@ struct wxPGPaintData
 
     Base class for wxPropertyGrid cell renderers.
 */
-class WXDLLIMPEXP_PROPGRID wxPGCellRenderer
+class WXDLLIMPEXP_PROPGRID wxPGCellRenderer : public wxObjectRefData
 {
 public:
 
-    wxPGCellRenderer( unsigned int refCount = 1 )
-        : m_refCount(refCount) { }
+    wxPGCellRenderer()
+        : wxObjectRefData() { }
     virtual ~wxPGCellRenderer() { }
 
     // Render flags
@@ -145,22 +145,6 @@ public:
                      const wxRect& rect,
                      const wxPGCell& cell,
                      int flags ) const;
-
-    void IncRef()
-    {
-        m_refCount++;
-    }
-
-    void DecRef()
-    {
-        m_refCount--;
-        if ( !m_refCount )
-            delete this;
-    }
-protected:
-
-private:
-    unsigned int    m_refCount;
 };
 
 
@@ -639,6 +623,8 @@ wxPG_PROP_CLASS_SPECIFIC_2          = 0x00100000
 */
 
 // Redefine attribute macros to use cached strings
+#undef wxPG_ATTR_DEFAULT_VALUE
+#define wxPG_ATTR_DEFAULT_VALUE           wxPGGlobalVars->m_strDefaultValue
 #undef wxPG_ATTR_MIN
 #define wxPG_ATTR_MIN                     wxPGGlobalVars->m_strMin
 #undef wxPG_ATTR_MAX
@@ -695,7 +681,7 @@ protected:
 
 typedef void* wxPGChoicesId;
 
-class WXDLLIMPEXP_PROPGRID wxPGChoicesData
+class WXDLLIMPEXP_PROPGRID wxPGChoicesData : public wxObjectRefData
 {
     friend class wxPGChoices;
 public:
@@ -726,20 +712,9 @@ public:
         return m_items[i];
     }
 
-    void DecRef()
-    {
-        m_refCount--;
-        wxASSERT( m_refCount >= 0 );
-        if ( m_refCount == 0 )
-            delete this;
-    }
-
 private:
     wxVector<wxPGChoiceEntry>   m_items;
 
-    // So that multiple properties can use the same set
-    int             m_refCount;
-
     virtual ~wxPGChoicesData();
 };
 
@@ -783,7 +758,7 @@ public:
         if ( a.m_data != wxPGChoicesEmptyData )
         {
             m_data = a.m_data;
-            m_data->m_refCount++;
+            m_data->IncRef();
         }
     }
 
@@ -823,7 +798,7 @@ public:
     {
         wxASSERT(data);
         m_data = data;
-        data->m_refCount++;
+        data->IncRef();
     }
 
     /** Destructor. */
@@ -996,8 +971,8 @@ public:
     // Returns data, increases refcount.
     wxPGChoicesData* GetData()
     {
-        wxASSERT( m_data->m_refCount != 0xFFFFFFF );
-        m_data->m_refCount++;
+        wxASSERT( m_data->GetRefCount() != -1 );
+        m_data->IncRef();
         return m_data;
     }
 
@@ -1272,17 +1247,21 @@ public:
                           wxEvent& event );
 
     /**
-        Called after value of a child property has been altered.
+        Called after value of a child property has been altered. Must return
+        new value of the whole property (after any alterations warrented by
+        child's new value).
 
         Note that this function is usually called at the time that value of
-        this property, or given child property, is still pending for change.
+        this property, or given child property, is still pending for change,
+        and as such, result of GetValue() or m_value should not be relied
+        on.
 
         Sample pseudo-code implementation:
 
         @code
-        void MyProperty::ChildChanged( wxVariant& thisValue,
-                                       int childIndex,
-                                       wxVariant& childValue ) const
+        wxVariant MyProperty::ChildChanged( wxVariant& thisValue,
+                                            int childIndex,
+                                            wxVariant& childValue ) const
         {
             // Acquire reference to actual type of data stored in variant
             // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros
@@ -1300,19 +1279,28 @@ public:
                     break;
                 ...
             }
+
+            // Return altered data
+            return data;
         }
         @endcode
 
         @param thisValue
-            Value of this property, that should be altered.
+            Value of this property. Changed value should be returned (in
+            previous versions of wxPropertyGrid it was only necessary to
+            write value back to this argument).
         @param childIndex
-            Index of child changed (you can use Item(childIndex) to get).
+            Index of child changed (you can use Item(childIndex) to get
+            child property).
         @param childValue
-            Value of the child property.
+            (Pending) value of the child property.
+
+        @return
+            Modified value of the whole property.
     */
-    virtual void ChildChanged( wxVariant& thisValue,
-                               int childIndex,
-                               wxVariant& childValue ) const;
+    virtual wxVariant ChildChanged( wxVariant& thisValue,
+                                    int childIndex,
+                                    wxVariant& childValue ) const;
 
     /** Returns pointer to an instance of used editor.
     */
@@ -1539,7 +1527,6 @@ public:
         return DoGetValue();
     }
 
-#ifndef SWIG
     /** Returns reference to the internal stored value. GetValue is preferred
         way to get the actual value, since GetValueRef ignores DoGetValue,
         which may override stored value.
@@ -1553,7 +1540,13 @@ public:
     {
         return m_value;
     }
-#endif
+
+    // Helper function (for wxPython bindings and such) for settings protected
+    // m_value.
+    wxVariant GetValuePlain() const
+    {
+        return m_value;
+    }
 
     /** Returns text representation of property's value.
 
@@ -1854,6 +1847,14 @@ public:
     void SetTextColour( const wxColour& colour,
                         bool recursively = false );
 
+    /** Set default value of a property. Synonymous to
+
+        @code
+            SetAttribute("DefaultValue", value);
+        @endcode
+    */
+    void SetDefaultValue( wxVariant& value );
+
 #ifndef SWIG
     /** Sets editor for a property.
 
@@ -2000,6 +2001,13 @@ public:
         SetValue(val);
     }
 
+    // Helper function (for wxPython bindings and such) for settings protected
+    // m_value.
+    void SetValuePlain( wxVariant value )
+    {
+        m_value = value;
+    }
+
 #if wxUSE_VALIDATORS
     /** Sets wxValidator for a property*/
     void SetValidator( const wxValidator& validator )