X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ce8e27f685bf14f9e37130b3ee9ac9b8b7d692a..86ac84b8ce086e6bbda58f422d41f84268606e35:/include/wx/propgrid/property.h?ds=sidebyside diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 864227349d..a4e3fbddc4 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -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; }; @@ -697,7 +681,7 @@ protected: typedef void* wxPGChoicesId; -class WXDLLIMPEXP_PROPGRID wxPGChoicesData +class WXDLLIMPEXP_PROPGRID wxPGChoicesData : public wxObjectRefData { friend class wxPGChoices; public: @@ -728,20 +712,9 @@ public: return m_items[i]; } - void DecRef() - { - m_refCount--; - wxASSERT( m_refCount >= 0 ); - if ( m_refCount == 0 ) - delete this; - } - private: wxVector m_items; - // So that multiple properties can use the same set - int m_refCount; - virtual ~wxPGChoicesData(); }; @@ -785,7 +758,7 @@ public: if ( a.m_data != wxPGChoicesEmptyData ) { m_data = a.m_data; - m_data->m_refCount++; + m_data->IncRef(); } } @@ -825,7 +798,7 @@ public: { wxASSERT(data); m_data = data; - data->m_refCount++; + data->IncRef(); } /** Destructor. */ @@ -998,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; } @@ -1274,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 @@ -1302,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. */ @@ -1541,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. @@ -1555,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. @@ -2010,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 )