]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/propgrid/property.h
use renderer for drawing the item background on ports other than GTK2 and Mac too...
[wxWidgets.git] / include / wx / propgrid / property.h
index 1c209463c824b8c0100f5d2e64df288311e55f5e..8a087be51e7c88ebd6dbc0c5f1e6a871abc91781 100644 (file)
@@ -389,9 +389,6 @@ wxPG_PROP_CLASS_SPECIFIC_2          = 0x00100000
 /** @}
 */
 
-// Amalgam of flags that should be inherited by sub-properties
-#define wxPG_INHERITED_PROPFLAGS        (wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR)
-
 // Combination of flags that can be stored by GetFlagsAsString
 #define wxPG_STRING_STORED_FLAGS \
     (wxPG_PROP_DISABLED|wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR|wxPG_PROP_COLLAPSED)
@@ -974,7 +971,11 @@ public:
             variant << value;
             SetValue(variant);
 
-            // If has private child properties then create them here, e.g.:
+            // If has private child properties then create them here. Also
+            // set flag that indicates presence of private children. E.g.:
+            //
+            //     SetParentalType(wxPG_PROP_AGGREGATE);
+            //
             //     AddChild( new wxStringProperty( "Subprop 1",
             //                                     wxPG_LABEL,
             //                                     value.GetSubProp1() ) );
@@ -1032,7 +1033,7 @@ public:
             If wxPG_FULL_VALUE is set, returns complete, storable value instead
             of displayable one (they may be different).
             If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of
-            composite property string value (as generated by GetValueAsString()
+            composite property string value (as generated by ValueToString()
             called with this same flag).
 
         @return Returns @true if resulting wxVariant value was different.
@@ -1080,22 +1081,24 @@ public:
                              int number,
                              int argFlags = 0 ) const;
 #endif  // !defined(SWIG) || defined(CREATE_VCW)
+    /**
+        Converts property value into a text representation.
 
-public:
-    /** Returns text representation of property's value.
+        @param value
+            Value to be converted.
 
         @param argFlags
+            If 0 (default value), then displayed string is returned.
             If wxPG_FULL_VALUE is set, returns complete, storable string value
             instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
             string value that must be editable in textctrl. If
             wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
-            display as a part of composite property string value.
+            display as a part of string property's composite text
+            representation.
 
-        @remarks
-        Default implementation returns string composed from text
-        representations of child properties.
+        @remarks Default implementation calls GenerateComposedValue().
     */
-    virtual wxString GetValueAsString( int argFlags = 0 ) const;
+    virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
 
     /** Converts string to a value, and if successful, calls SetValue() on it.
         Default behavior is to do nothing.
@@ -1278,7 +1281,7 @@ public:
               colour) pen for drawing framing rectangle. It can be changed as
               well.
 
-        @see GetValueAsString()
+        @see ValueToString()
     */
     virtual void OnCustomPaint( wxDC& dc,
                                 const wxRect& rect,
@@ -1386,8 +1389,15 @@ public:
         else ClearFlag( wxPG_PROP_USES_COMMON_VALUE );
     }
 
-    /** Composes text from values of child properties. */
-    void GenerateComposedValue( wxString& text, int argFlags = 0 ) const;
+    /**
+        Composes text from values of child properties.
+    */
+    wxString GenerateComposedValue() const
+    {
+        wxString s;
+        DoGenerateComposedValue(s);
+        return s;
+    }
 
     /** Returns property's label. */
     const wxString& GetLabel() const { return m_label; }
@@ -1434,11 +1444,31 @@ public:
     }
 #endif
 
-    /** To acquire property's value as string, you should use this
-         function (instead of GetValueAsString()), as it may produce
-         more accurate value in future versions.
+    /** Returns text representation of property's value.
+
+        @param argFlags
+            If 0 (default value), then displayed string is returned.
+            If wxPG_FULL_VALUE is set, returns complete, storable string value
+            instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
+            string value that must be editable in textctrl. If
+            wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
+            display as a part of string property's composite text
+            representation.
+
+        @remarks In older versions, this function used to be overridden to convert
+                 property's value into a string representation. This function is
+                 now handled by ValueToString(), and overriding this function now
+                 will result in run-time assertion failure.
+    */
+    virtual wxString GetValueAsString( int argFlags = 0 ) const;
+
+    /** Synonymous to GetValueAsString().
+
+        @deprecated Use GetValueAsString() instead.
+
+        @see GetValueAsString()
     */
-    wxString GetValueString( int argFlags = 0 ) const;
+    wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const );
 
     void UpdateControl( wxWindow* primary );
 
@@ -1459,7 +1489,7 @@ public:
 
     wxString GetDisplayedString() const
     {
-        return GetValueString(0);
+        return GetValueAsString(0);
     }
 
     /** Returns property grid where property lies. */
@@ -1795,6 +1825,27 @@ public:
 
     inline void SetName( const wxString& newName );
 
+    /**
+        Changes what sort of parent this property is for its children.
+
+        @param flag
+            Use one of the following values: wxPG_PROP_MISC_PARENT (for generic
+            parents), wxPG_PROP_CATEGORY (for categories), or
+            wxPG_PROP_AGGREGATE (for derived property classes with private
+            children).
+
+        @remarks You only need to call this if you use AddChild() to add
+                 child properties. Adding properties with
+                 wxPropertyGridInterface::Insert() or
+                 wxPropertyGridInterface::AppendIn() will automatically set
+                 property to use wxPG_PROP_MISC_PARENT style.
+    */
+    void SetParentalType( int flag )
+    {
+        m_flags &= ~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS);
+        m_flags |= flag;
+    }
+
     void SetValueToUnspecified()
     {
         wxVariant val;  // Create NULL variant
@@ -1883,7 +1934,23 @@ public:
     */
     void AdaptListToValue( wxVariant& list, wxVariant* value ) const;
 
-    /** This is used by properties that have fixed sub-properties. */
+    /**
+        Adds a child property. If you use this instead of
+        wxPropertyGridInterface::Insert() or
+        wxPropertyGridInterface::AppendIn(), then you must set up
+        property's parental type before making the call. To do this,
+        call property's SetParentalType() function with either
+        wxPG_PROP_MISC_PARENT (normal, public children) or with
+        wxPG_PROP_AGGREGATE (private children for subclassed property).
+        For instance:
+
+        @code
+            wxPGProperty* prop = new wxStringProperty(wxS("Property"));
+            prop->SetParentalType(wxPG_PROP_MISC_PARENT);
+            wxPGProperty* prop2 = new wxStringProperty(wxS("Property2"));
+            prop->AddChild(prop2);
+        @endcode
+    */
     void AddChild( wxPGProperty* prop );
 
     /** Returns height of children, recursively, and
@@ -1914,7 +1981,7 @@ public:
     void Empty();
 
     // Puts correct indexes to children
-    void FixIndexesOfChildren( unsigned int starthere = 0 );
+    void FixIndicesOfChildren( unsigned int starthere = 0 );
 
 #ifndef SWIG
     // Returns wxPropertyGridPageState in which this property resides.
@@ -1988,20 +2055,19 @@ protected:
                     int index = -1,
                     bool correct_mode = true );
 
+    void DoGenerateComposedValue( wxString& text,
+                                  int argFlags = wxPG_VALUE_IS_CURRENT,
+                                  const wxVariantList* valueOverrides = NULL,
+                                  wxPGHashMapS2S* childResults = NULL ) const;
+
     void DoSetName(const wxString& str) { m_name = str; }
 
-    // Call for after sub-properties added with AddChild
-    void PrepareSubProperties();
+    void InitAfterAdded( wxPropertyGridPageState* pageState,
+                         wxPropertyGrid* propgrid );
 
     // Removes child property with given pointer. Does not delete it.
     void RemoveChild( wxPGProperty* p );
 
-    void SetParentalType( int flag )
-    {
-        m_flags &= ~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS);
-        m_flags |= flag;
-    }
-
     void SetParentState( wxPropertyGridPageState* pstate )
         { m_parentState = pstate; }
 
@@ -2151,7 +2217,7 @@ public:
     int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const;
 
 protected:
-    virtual wxString GetValueAsString( int argFlags ) const;
+    virtual wxString ValueToString( wxVariant& value, int argFlags ) const;
 
     void SetTextColIndex( unsigned int colInd )
         { m_capFgColIndex = (wxByte) colInd; }