]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/propgrid/property.h
interface revisions
[wxWidgets.git] / interface / wx / propgrid / property.h
index 229a8ede3ca506abb301c585a277da237c163790..4538172cc2f36ac7ce1e3125ee5d8fa13959fade 100644 (file)
     @code
         virtual bool OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
         {
-            // Update property value from editor, if necessary
-            PrepareValueForDialogEditing(propGrid);
-
             wxSize dialogSize(...size of your dialog...);
 
             wxPoint dlgPos = propGrid->GetGoodEditorDialogPosition(this,
                 return wxPGEditor_TextCtrl;
             }
 
-            virtual wxString GetValueAsString( int argFlags ) const
+            virtual wxString ValueToString( wxVariant& value,
+                                            int argFlags ) const
             {
-                // TODO: Return property value in string format
+                // TODO: Convert given property value to a string
             }
 
             virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags )
@@ -545,7 +543,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.
@@ -590,19 +588,23 @@ public:
     virtual bool IntToValue( wxVariant& value, int number, int argFlags = 0 ) const;
 
     /**
-        Returns text representation of property's value.
+        Converts property value into a text representation.
+
+        @param value
+            Value to be converted.
 
         @param argFlags
-        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.
+            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
-        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.
@@ -788,7 +790,7 @@ public:
             - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper colour) pen for
               drawing framing rectangle. It can be changed as well.
 
-        @see GetValueAsString()
+        @see ValueToString()
     */
     virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata );
 
@@ -871,8 +873,21 @@ public:
     int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE );
 
     /**
-        Properties which have private child properties should add them
-        with this function, called in their constructor.
+        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* property );
 
@@ -913,8 +928,10 @@ public:
     /** Deletes all child properties. */
     void Empty();
 
-    /** 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;
 
     /**
         Returns property attribute value, null variant if not found.
@@ -1089,14 +1106,31 @@ public:
     */
     wxBitmap* GetValueImage() const;
 
-    /**
-        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 );
 
     /**
         Returns value type used by this property.
@@ -1197,25 +1231,7 @@ public:
     /**
         Returns child property at index i.
     */
-    wxPGProperty* Item( size_t i ) const;
-
-    /**
-        Updates property value in case there were last minute
-        changes. If value was unspecified, it will be set to default.
-        Use only for properties that have TextCtrl-based editor.
-
-        @remarks If you have code similar to
-                @code
-                // Update the value in case of last minute changes
-                if ( primary && propgrid->IsEditorsValueModified() )
-                     GetEditorClass()->CopyValueFromControl( this, primary );
-                @endcode
-                in wxPGProperty::OnEvent wxEVT_COMMAND_BUTTON_CLICKED handler,
-                then replace it with call to this method.
-
-        @return Returns @true if value changed.
-    */
-    bool PrepareValueForDialogEditing( wxPropertyGrid* propgrid );
+    wxPGProperty* Item( unsigned int i ) const;
 
     /**
         If property's editor is active, then update it's value.
@@ -1320,6 +1336,23 @@ public:
     */
     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 );
+
     /** Sets wxValidator for a property */
     void SetValidator( const wxValidator& validator );
 
@@ -1469,17 +1502,17 @@ public:
     /**
         Returns labe of item.
     */
-    const wxString& GetLabel( size_t ind ) const;
+    const wxString& GetLabel( unsigned int ind ) const;
 
     /**
         Returns number of items.
     */
-    size_t GetCount () const;
+    unsigned int GetCount() const;
 
     /**
         Returns value of item;
     */
-    int GetValue( size_t ind ) const;
+    int GetValue( unsigned int ind ) const;
 
     /**
         Returns array of values matching the given strings. Unmatching strings