Added virtual wxPGProperty::ValueToString(). In derived property classes, now it must be implemented instead of GetValueAsString (assertion failure is raised at run-time if you fail to do so). This change is needed to properly support wxEVT_PG_CHANGING for nested composite string properties. wxPGProperty::GenerateComposedValue() partially updated to support this.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56363 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli
2008-10-16 17:19:50 +00:00
parent f7ca1dd416
commit 1425eca550
12 changed files with 388 additions and 167 deletions

View File

@@ -180,7 +180,7 @@ public:
const wxFont& value = wxFont());
virtual ~wxFontProperty();
virtual void OnSetValue();
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool OnEvent( wxPropertyGrid* propgrid,
wxWindow* primary, wxEvent& event );
virtual void ChildChanged( wxVariant& thisValue,
@@ -231,7 +231,7 @@ public:
*/
virtual int GetCustomColourIndex() const;
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -292,7 +292,7 @@ public:
virtual ~wxColourProperty();
protected:
virtual wxString GetValueAsString( int argFlags ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual wxColour GetColour( int index ) const;
virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const;
@@ -392,7 +392,7 @@ public:
virtual ~wxMultiChoiceProperty();
virtual void OnSetValue();
virtual wxString GetValueAsString( int flags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue(wxVariant& variant,
const wxString& text,
int argFlags = 0) const;
@@ -406,7 +406,7 @@ public:
protected:
void GenerateValueAsString();
void GenerateValueAsString( wxString* target ) const;
// Returns translation of values into string indices.
wxArrayInt GetValueAsIndices() const;
@@ -442,7 +442,7 @@ public:
const wxDateTime& value = wxDateTime() );
virtual ~wxDateProperty();
virtual wxString GetValueAsString( int flags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue(wxVariant& variant,
const wxString& text,
int argFlags = 0) const;

View File

@@ -1033,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.
@@ -1081,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.
@@ -1279,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,
@@ -1387,8 +1389,14 @@ 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. You usually do not have
to care about arguments other than 'text'.
*/
void GenerateComposedValue( wxString& text,
int argFlags = wxPG_VALUE_IS_CURRENT,
const wxVariantList* valueOverrides = NULL,
wxPGHashMapS2S* childResults = NULL ) const;
/** Returns property's label. */
const wxString& GetLabel() const { return m_label; }
@@ -1435,11 +1443,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.
*/
wxString GetValueString( int argFlags = 0 ) const;
virtual wxString GetValueAsString( int argFlags = 0 ) const;
/** Synonymous to GetValueAsString().
@deprecated Use GetValueAsString() instead.
@see GetValueAsString()
*/
wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const );
void UpdateControl( wxWindow* primary );
@@ -1460,7 +1488,7 @@ public:
wxString GetDisplayedString() const
{
return GetValueString(0);
return GetValueAsString(0);
}
/** Returns property grid where property lies. */
@@ -2183,7 +2211,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; }

View File

@@ -229,6 +229,12 @@
// (for tree buttons)
//#undef wxPG_ICON_WIDTH
#if WXWIN_COMPATIBILITY_2_6 || WXWIN_COMPATIBILITY_2_8
#define wxPG_COMPATIBILITY_1_4 1
#else
#define wxPG_COMPATIBILITY_1_4 0
#endif
// Need to force disable tooltips?
#if !wxUSE_TOOLTIPS
#undef wxPG_SUPPORT_TOOLTIPS
@@ -332,7 +338,10 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
wxPGHashMapS2P,
class WXDLLIMPEXP_PROPGRID);
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxString,
wxPGHashMapS2S,
class WXDLLIMPEXP_PROPGRID);
WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(void*,
wxPGHashMapP2P,
class WXDLLIMPEXP_PROPGRID);
@@ -392,7 +401,11 @@ enum wxPG_MISC_ARG_FLAGS
// Means property for which final string value is for can not really be
// edited.
wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020
wxPG_UNEDITABLE_COMPOSITE_FRAGMENT = 0x00000020,
// ValueToString() called from GetValueAsString()
// (guarantees that input wxVariant value is current own value)
wxPG_VALUE_IS_CURRENT = 0x00000040
};
// -----------------------------------------------------------------------

View File

@@ -106,7 +106,7 @@ public:
const wxString& value = wxEmptyString );
virtual ~wxStringProperty();
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -196,7 +196,7 @@ public:
wxIntProperty( const wxString& label,
const wxString& name,
const wxLongLong& value );
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -250,7 +250,7 @@ public:
wxUIntProperty( const wxString& label,
const wxString& name,
const wxULongLong& value );
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -287,7 +287,7 @@ public:
double value = 0.0 );
virtual ~wxFloatProperty();
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -330,7 +330,7 @@ public:
bool value = false );
virtual ~wxBoolProperty();
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -360,7 +360,7 @@ public:
const wxString& name = wxPG_LABEL );
virtual void OnSetValue();
virtual wxString GetValueAsString( int argFlags ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -553,7 +553,7 @@ public:
virtual ~wxFlagsProperty ();
virtual void OnSetValue();
virtual wxString GetValueAsString( int argFlags ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int flags ) const;
@@ -631,7 +631,7 @@ public:
virtual ~wxFileProperty ();
virtual void OnSetValue();
virtual wxString GetValueAsString( int argFlags ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -641,12 +641,16 @@ public:
static wxValidator* GetClassValidator();
virtual wxValidator* DoGetValidator() const;
/**
Returns filename to file represented by current value.
*/
wxFileName GetFileName() const;
protected:
wxString m_wildcard;
wxString m_basePath; // If set, then show path relative to it
wxString m_initialPath; // If set, start the file dialog here
wxString m_dlgTitle; // If set, used as title for file dialog
wxFileName m_filename; // used as primary storage
int m_indFilter; // index to the selected filter
};
@@ -682,7 +686,7 @@ public:
const wxString& value = wxEmptyString );
virtual ~wxLongStringProperty();
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;
@@ -761,7 +765,7 @@ public:
virtual ~wxArrayStringProperty();
virtual void OnSetValue();
virtual wxString GetValueAsString( int argFlags = 0 ) const;
virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
virtual bool StringToValue( wxVariant& variant,
const wxString& text,
int argFlags = 0 ) const;