// Author: Jaakko Salli
// Modified by:
// Created: 2008-08-23
-// RCS-ID: $Id:
+// RCS-ID: $Id$
// Copyright: (c) Jaakko Salli
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
~wxPGAttributeStorage();
void Set( const wxString& name, const wxVariant& value );
- size_t GetCount() const { return m_map.size(); }
+ unsigned int GetCount() const { return (unsigned int) m_map.size(); }
wxVariant FindValue( const wxString& name ) const
{
wxPGHashMapS2P::const_iterator it = m_map.find(name);
/** @}
*/
-// 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)
if ( index == -1 )
{
it = m_items.end();
- index = m_items.size();
+ index = (int) m_items.size();
}
else
{
// Delete all entries
void Clear();
- size_t GetCount() const { return m_items.size(); }
+ unsigned int GetCount() const
+ {
+ return (unsigned int) m_items.size();
+ }
wxPGChoiceEntry* Item( unsigned int i ) const
{
/** Gets a unsigned number identifying this list. */
wxPGChoicesId GetId() const { return (wxPGChoicesId) m_data; };
- const wxString& GetLabel( size_t ind ) const
+ const wxString& GetLabel( unsigned int ind ) const
{
return Item(ind).GetText();
}
- size_t GetCount () const
+ unsigned int GetCount () const
{
if ( !m_data )
return 0;
return m_data->GetCount();
}
- int GetValue( size_t ind ) const { return Item(ind).GetValue(); }
+ int GetValue( unsigned int ind ) const { return Item(ind).GetValue(); }
/** Returns array of values matching the given strings. Unmatching strings
result in wxPG_INVALID_VALUE entry in array.
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() ) );
wxPGValidationInfo& validationInfo ) const;
/**
- Converts 'text' into proper value 'variant'.
- Returns true if new (different than m_value) value could be interpreted
- from the text.
+ Converts text into wxVariant value appropriate for this property.
+
+ @param variant
+ On function entry this is the old value (should not be wxNullVariant
+ in normal cases). Translated value must be assigned back to it.
+
+ @param text
+ Text to be translated into variant.
+
@param argFlags
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).
- @remarks
- Default implementation converts semicolon delimited tokens into child
- values. Only works for properties with children.
+ @return Returns @true if resulting wxVariant value was different.
+
+ @remarks Default implementation converts semicolon delimited tokens into
+ child values. Only works for properties with children.
+
+ You might want to take into account that m_value is Null variant
+ if property value is unspecified (which is usually only case if
+ you explicitly enabled that sort behavior).
*/
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
/**
- Converts 'number' (including choice selection) into proper value
- 'variant'.
+ Converts integer (possibly a choice selection) into wxVariant value
+ appropriate for this property.
+
+ @param variant
+ On function entry this is the old value (should not be wxNullVariant
+ in normal cases). Translated value must be assigned back to it.
- Returns true if new (different than m_value) value could be interpreted
- from the integer.
+ @param number
+ Integer to be translated into variant.
@param argFlags
If wxPG_FULL_VALUE is set, returns complete, storable value instead
of displayable one.
+ @return Returns @true if resulting wxVariant value was different.
+
@remarks
- If property is not supposed to use choice or spinctrl or other editor
with int-based value, it is not necessary to implement this method.
- If property uses choice control, and displays a dialog on some choice
items, then it is preferred to display that dialog in IntToValue
instead of OnEvent.
+ - You might want to take into account that m_value is Null variant if
+ property value is unspecified (which is usually only case if you
+ explicitly enabled that sort behavior).
*/
virtual bool IntToValue( wxVariant& value,
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.
colour) pen for drawing framing rectangle. It can be changed as
well.
- @see GetValueAsString()
+ @see ValueToString()
*/
virtual void OnCustomPaint( wxDC& dc,
const wxRect& rect,
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; }
}
#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 );
wxString GetDisplayedString() const
{
- return GetValueString(0);
+ return GetValueAsString(0);
}
/** Returns property grid where property lies. */
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
}
#endif // #if wxUSE_VALIDATORS
- /** 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
- True if value changed.
- */
- bool PrepareValueForDialogEditing( wxPropertyGrid* propgrid );
-
#ifndef SWIG
/** Returns client data (void*) of a property.
*/
*/
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
int GetChildrenHeight( int lh, int iMax = -1 ) const;
/** Returns number of child properties */
- unsigned int GetChildCount() const { return m_children.size(); }
+ unsigned int GetChildCount() const
+ {
+ return (unsigned int) m_children.size();
+ }
/** Returns sub-property at index i. */
- wxPGProperty* Item( size_t i ) const
+ wxPGProperty* Item( unsigned int i ) const
{ return m_children[i]; }
/** Returns last sub-property.
void Empty();
// Puts correct indexes to children
- void FixIndexesOfChildren( size_t starthere = 0 );
+ void FixIndicesOfChildren( unsigned int starthere = 0 );
#ifndef SWIG
// Returns wxPropertyGridPageState in which this property resides.
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 );
- void SetParentalType( int flag )
- {
- m_flags &= ~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS);
- m_flags |= flag;
- }
+ // Removes child property with given pointer. Does not delete it.
+ void RemoveChild( wxPGProperty* p );
void SetParentState( wxPropertyGridPageState* pstate )
{ m_parentState = pstate; }
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; }