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,
*/
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;
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;
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;
protected:
- void GenerateValueAsString();
+ void GenerateValueAsString( wxString* target ) const;
// Returns translation of values into string indices.
wxArrayInt GetValueAsIndices() const;
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;
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.
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. 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; }
}
#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. */
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; }
// (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
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);
// 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
};
// -----------------------------------------------------------------------
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;
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;
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;
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;
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;
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;
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;
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;
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
};
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;
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;
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 )
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.
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.
- 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 );
/** Deletes all child properties. */
void Empty();
- /** Composes text from values of child properties. */
+ /**
+ 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 = 0 ) const;
/**
*/
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.
if ( imagename.length() )
{
+ wxFileName filename = GetFileName();
size_t prevCount = g_myImageArray.GetCount();
int index = ms_choices.Index(imagename);
if ( index == wxNOT_FOUND )
{
ms_choices.Add( imagename );
- g_myImageArray.Add( new wxMyImageInfo( m_filename.GetFullPath() ) );
+ g_myImageArray.Add( new wxMyImageInfo( filename.GetFullPath() ) );
index = g_myImageArray.GetCount() - 1;
}
if ( !g_myImageArray[index].m_pThumbnail2 )
{
// Load if file exists.
- if ( m_filename.FileExists() )
- m_pImage = new wxImage( m_filename.GetFullPath() );
+ if ( filename.FileExists() )
+ m_pImage = new wxImage( filename.GetFullPath() );
}
m_index = index;
if ( !mii.m_pThumbnail2 )
{
+ wxFileName filename = GetFileName();
if ( !m_pImage || !m_pImage->Ok() ||
- m_filename != mii.m_path
+ filename != mii.m_path
)
{
if ( m_pImage )
void wxArrayDoubleProperty::OnSetValue()
{
+ // Generate cached display string, to optimize grid drawing
GenerateValueAsString( m_display, m_precision, true );
}
-wxString wxArrayDoubleProperty::GetValueAsString( int arg_flags ) const
+wxString wxArrayDoubleProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
{
- if ( !(arg_flags & wxPG_FULL_VALUE ))
- return m_display;
-
wxString s;
- GenerateValueAsString(s,-1,false);
+
+ if ( argFlags & wxPG_FULL_VALUE )
+ {
+ GenerateValueAsString(s,-1,false);
+ }
+ else
+ {
+ //
+ // Display cached string only if value truly matches m_value
+ if ( value.GetData() == m_value.GetData() )
+ return m_display;
+ else
+ GenerateValueAsString( s, m_precision, true );
+ }
+
return s;
}
virtual ~wxArrayDoubleProperty ();
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;
}
}
-wxString wxFontProperty::GetValueAsString( int argFlags ) const
+wxString wxFontProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
{
- return wxPGProperty::GetValueAsString(argFlags);
+ return wxPGProperty::ValueToString(value, argFlags);
}
bool wxFontProperty::OnEvent( wxPropertyGrid* propgrid, wxWindow* WXUNUSED(primary),
return m_choices.GetLabel(index);
}
-wxString wxSystemColourProperty::GetValueAsString( int argFlags ) const
+wxString wxSystemColourProperty::ValueToString( wxVariant& value,
+ int WXUNUSED(argFlags) ) const
{
- wxColourPropertyValue val = GetVal();
-
- int ind = GetIndex();
-
- // Always show custom colour for textctrl-editor
- if ( val.m_type == wxPG_COLOUR_CUSTOM ||
- ind == GetCustomColourIndex() ||
- (argFlags & wxPG_PROPERTY_SPECIFIC) )
- {
- return ColourToString(val.m_colour, wxNOT_FOUND);
- }
-
- if ( ind == -1 )
- return wxEmptyString;
+ wxColourPropertyValue val = GetVal(&value);
- return ColourToString(val.m_colour, ind);
+ return ColourToString(val.m_colour, m_choices.Index(val.m_type));
}
SetIndex( ind );
}
-wxString wxColourProperty::GetValueAsString( int argFlags ) const
+wxString wxColourProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
{
const wxPGEditor* editor = GetEditorClass();
if ( editor != wxPGEditor_Choice &&
editor != wxPGEditor_ComboBox )
argFlags |= wxPG_PROPERTY_SPECIFIC;
- return wxSystemColourProperty::GetValueAsString(argFlags);
+ return wxSystemColourProperty::ValueToString(value, argFlags);
}
wxColour wxColourProperty::GetColour( int index ) const
m_pBitmap = NULL;
}
+ wxFileName filename = GetFileName();
+
// Create the image thumbnail
- if ( m_filename.FileExists() )
+ if ( filename.FileExists() )
{
- m_pImage = new wxImage( m_filename.GetFullPath() );
+ m_pImage = new wxImage( filename.GetFullPath() );
}
}
void wxMultiChoiceProperty::OnSetValue()
{
- GenerateValueAsString();
+ GenerateValueAsString(&m_display);
}
-wxString wxMultiChoiceProperty::GetValueAsString( int ) const
+wxString wxMultiChoiceProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
{
- return m_display;
+ // If possible, use cached string
+ if ( argFlags & wxPG_VALUE_IS_CURRENT )
+ return m_display;
+
+ wxString s;
+ GenerateValueAsString(&s);
+ return s;
}
-void wxMultiChoiceProperty::GenerateValueAsString()
+void wxMultiChoiceProperty::GenerateValueAsString( wxString* target ) const
{
wxArrayString strings;
if ( m_value.GetType() == wxPG_VARIANT_TYPE_ARRSTRING )
strings = m_value.GetArrayString();
- wxString& tempStr = m_display;
+ wxString& tempStr = *target;
unsigned int i;
unsigned int itemCount = strings.size();
return false;
}
-wxString wxDateProperty::GetValueAsString( int argFlags ) const
+wxString wxDateProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
{
const wxChar* format = (const wxChar*) NULL;
- wxDateTime dateTime = m_value.GetDateTime();
+ wxDateTime dateTime = value.GetDateTime();
if ( !dateTime.IsValid() )
return wxT("Invalid");
return (wxWindow*) NULL;
if ( !property->IsValueUnspecified() )
- text = property->GetValueString(property->HasFlag(wxPG_PROP_READONLY)?0:wxPG_EDITABLE_VALUE);
+ text = property->GetValueAsString(property->HasFlag(wxPG_PROP_READONLY) ?
+ 0 : wxPG_EDITABLE_VALUE);
int flags = 0;
if ( (property->GetFlags() & wxPG_PROP_PASSWORD) &&
else
{
if ( !p->IsValueUnspecified() )
- text = p->GetValueString(0);
+ text = p->GetValueAsString(0);
}
}
void wxPGComboBoxEditor::UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const
{
wxOwnerDrawnComboBox* cb = (wxOwnerDrawnComboBox*)ctrl;
- cb->SetValue(property->GetValueString(wxPG_EDITABLE_VALUE));
+ cb->SetValue(property->GetValueAsString(wxPG_EDITABLE_VALUE));
// TODO: If string matches any selection, then select that.
}
wxString text;
if ( !property->IsValueUnspecified() )
- text = property->GetValueString(property->HasFlag(wxPG_PROP_READONLY)?0:wxPG_EDITABLE_VALUE);
+ text = property->GetValueAsString(property->HasFlag(wxPG_PROP_READONLY)?0:wxPG_EDITABLE_VALUE);
return GenerateEditorTextCtrl(pos,sz,text,but,property->m_maxLen);
}
#define PWC_CHILD_SUMMARY_CHAR_LIMIT 64 // Character limit of summary field when not editing
+#if wxPG_COMPATIBILITY_1_4
+
+// Used to establish backwards compatiblity
+const char* g_invalidStringContent = "@__TOTALLY_INVALID_STRING__@";
+
+#endif
// -----------------------------------------------------------------------
if ( column == 0 )
text = property->GetLabel();
else if ( column == 1 )
- text = property->GetValueString();
+ text = property->GetValueAsString();
else
text = wxEmptyString;
}
imageOffset = paintdata.m_drawnWidth;
}
- text = property->GetValueString();
+ text = property->GetValueAsString();
// Add units string?
if ( propertyGrid->GetColumnCount() <= 2 )
m_parentState = pageState;
+#if wxPG_COMPATIBILITY_1_4
+ // Make sure deprecated virtual functions are not implemented
+ wxString s = GetValueAsString( 0xFFFF );
+ wxASSERT_MSG( s == g_invalidStringContent,
+ "Implement ValueToString() instead of GetValueAsString()" );
+#endif
+
if ( !parentIsRoot )
{
m_bgColIndex = parent->m_bgColIndex;
return wxEmptyString;
}
-void wxPGProperty::GenerateComposedValue( wxString& text, int argFlags ) const
+void wxPGProperty::GenerateComposedValue( wxString& text,
+ int argFlags,
+ const wxVariantList* valueOverrides,
+ wxPGHashMapS2S* childResults ) const
{
int i;
int iMax = m_children.size();
wxPGProperty* curChild = m_children[0];
+ bool overridesLeft = false;
+ wxVariant overrideValue;
+ wxVariantList::const_iterator node;
+
+ if ( valueOverrides )
+ {
+ node = valueOverrides->begin();
+ if ( node != valueOverrides->end() )
+ {
+ overrideValue = *node;
+ overridesLeft = true;
+ }
+ }
+
for ( i = 0; i < iMax; i++ )
{
+ wxVariant childValue;
+
+ wxString childLabel = curChild->GetLabel();
+
+ // Check for value override
+ if ( overridesLeft && overrideValue.GetName() == childLabel )
+ {
+ if ( !overrideValue.IsNull() )
+ childValue = overrideValue;
+ else
+ childValue = curChild->GetValue();
+ node++;
+ if ( node != valueOverrides->end() )
+ overrideValue = *node;
+ else
+ overridesLeft = false;
+ }
+ else
+ {
+ childValue = curChild->GetValue();
+ }
+
wxString s;
- if ( !curChild->IsValueUnspecified() )
- s = curChild->GetValueString(argFlags|wxPG_COMPOSITE_FRAGMENT);
+ if ( !childValue.IsNull() )
+ {
+ if ( overridesLeft &&
+ curChild->HasFlag(wxPG_PROP_COMPOSED_VALUE) &&
+ childValue.GetType() == wxPG_VARIANT_TYPE_LIST )
+ {
+ wxVariantList& childList = childValue.GetList();
+ GenerateComposedValue(s, argFlags|wxPG_COMPOSITE_FRAGMENT,
+ &childList, childResults);
+ }
+ else
+ {
+ s = curChild->ValueToString(childValue,
+ argFlags|wxPG_COMPOSITE_FRAGMENT);
+ }
+ }
+
+ if ( childResults && curChild->GetChildCount() )
+ (*childResults)[curChild->GetName()] = s;
bool skip = false;
if ( (argFlags & wxPG_UNEDITABLE_COMPOSITE_FRAGMENT) && !s.length() )
text += wxS("; ...");
}
-wxString wxPGProperty::GetValueAsString( int argFlags ) const
+wxString wxPGProperty::ValueToString( wxVariant& WXUNUSED(value),
+ int argFlags ) const
{
wxCHECK_MSG( GetChildCount() > 0,
wxString(),
- wxT("If user property does not have any children, it must override GetValueAsString") );
+ "If user property does not have any children, it must "
+ "override GetValueAsString" );
+
+ // FIXME: Currently code below only works if value is actually m_value
+ wxASSERT_MSG( argFlags & wxPG_VALUE_IS_CURRENT,
+ "Sorry, currently default wxPGProperty::ValueToString() "
+ "implementation only works if value is m_value." );
wxString text;
GenerateComposedValue(text, argFlags);
return text;
}
-wxString wxPGProperty::GetValueString( int argFlags ) const
+wxString wxPGProperty::GetValueAsString( int argFlags ) const
{
+#if wxPG_COMPATIBILITY_1_4
+ // This is backwards compatibility test
+ // That is, to make sure this function is not overridden
+ // (instead, ValueToString() should be).
+ if ( argFlags == 0xFFFF )
+ {
+ // Do not override! (for backwards compliancy)
+ return g_invalidStringContent;
+ }
+#endif
+
if ( IsValueUnspecified() )
return wxEmptyString;
if ( m_commonValue == -1 )
- return GetValueAsString(argFlags);
+ {
+ wxVariant value(GetValue());
+ return ValueToString(value, argFlags|wxPG_VALUE_IS_CURRENT);
+ }
//
// Return common value's string representation
}
}
+wxString wxPGProperty::GetValueString( int argFlags ) const
+{
+ return GetValueAsString(argFlags);
+}
+
bool wxPGProperty::IntToValue( wxVariant& variant, int number, int WXUNUSED(argFlags) ) const
{
variant = (long)number;
!parent->IsCategory() && !parent->IsRoot() )
{
wxString s;
- parent->GenerateComposedValue(s, 0);
+ parent->GenerateComposedValue(s);
parent->m_value = s;
return parent->UpdateParentValues();
}
}
-wxString wxPropertyCategory::GetValueAsString( int ) const
+wxString wxPropertyCategory::ValueToString( wxVariant& WXUNUSED(value),
+ int WXUNUSED(argFlags) ) const
{
return wxEmptyString;
}
if ( HasFlag(wxPG_PROP_COMPOSED_VALUE) )
{
wxString s;
- GenerateComposedValue(s, 0);
+ GenerateComposedValue(s);
m_value = s;
}
}
wxStringProperty::~wxStringProperty() { }
-wxString wxStringProperty::GetValueAsString( int argFlags ) const
+wxString wxStringProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
{
- wxString s = m_value.GetString();
+ wxString s = value.GetString();
if ( GetChildCount() && HasFlag(wxPG_PROP_COMPOSED_VALUE) )
{
// Value stored in m_value is non-editable, non-full value
if ( (argFlags & wxPG_FULL_VALUE) || (argFlags & wxPG_EDITABLE_VALUE) )
+ {
+ // Calling this under incorrect conditions will fail
+ wxASSERT_MSG( argFlags & wxPG_VALUE_IS_CURRENT,
+ "Sorry, currently default wxPGProperty::ValueToString() "
+ "implementation only works if value is m_value." );
+
GenerateComposedValue(s, argFlags);
+ }
return s;
}
wxIntProperty::~wxIntProperty() { }
-wxString wxIntProperty::GetValueAsString( int ) const
+wxString wxIntProperty::ValueToString( wxVariant& value,
+ int WXUNUSED(argFlags) ) const
{
- if ( m_value.GetType() == wxPG_VARIANT_TYPE_LONG )
+ if ( value.GetType() == wxPG_VARIANT_TYPE_LONG )
{
- return wxString::Format(wxS("%li"),m_value.GetLong());
+ return wxString::Format(wxS("%li"),value.GetLong());
}
- else if ( m_value.GetType() == wxLongLong_VariantType )
+ else if ( value.GetType() == wxLongLong_VariantType )
{
wxLongLong ll;
- ll << m_value;
+ ll << value;
return ll.ToString();
}
wxUIntProperty::~wxUIntProperty() { }
-wxString wxUIntProperty::GetValueAsString( int ) const
+wxString wxUIntProperty::ValueToString( wxVariant& value,
+ int WXUNUSED(argFlags) ) const
{
size_t index = m_base + m_prefix;
if ( index >= wxPG_UINT_TEMPLATE_MAX )
index = wxPG_BASE_DEC;
- if ( m_value.GetType() == wxPG_VARIANT_TYPE_LONG )
+ if ( value.GetType() == wxPG_VARIANT_TYPE_LONG )
{
- return wxString::Format(gs_uintTemplates32[index], (unsigned long)m_value.GetLong());
+ return wxString::Format(gs_uintTemplates32[index], (unsigned long)value.GetLong());
}
wxULongLong ull;
- ull << m_value;
+ ull << value;
return wxString::Format(gs_uintTemplates64[index], ull.GetValue());
}
}
}
-wxString wxFloatProperty::GetValueAsString( int argFlags ) const
+wxString wxFloatProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
{
wxString text;
- if ( !m_value.IsNull() )
+ if ( !value.IsNull() )
{
wxPropertyGrid::DoubleToString(text,
- m_value,
+ value,
m_precision,
!(argFlags & wxPG_FULL_VALUE),
(wxString*) NULL);
wxBoolProperty::~wxBoolProperty() { }
-wxString wxBoolProperty::GetValueAsString( int argFlags ) const
+wxString wxBoolProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
{
- bool value = m_value.GetBool();
+ bool boolValue = value.GetBool();
// As a fragment of composite string value,
// make it a little more readable.
if ( argFlags & wxPG_COMPOSITE_FRAGMENT )
{
- if ( value )
+ if ( boolValue )
{
return m_label;
}
if ( !(argFlags & wxPG_FULL_VALUE) )
{
- return wxPGGlobalVars->m_boolChoices[value?1:0].GetText();
+ return wxPGGlobalVars->m_boolChoices[boolValue?1:0].GetText();
}
wxString text;
- if (value) text = wxS("true");
+ if ( boolValue ) text = wxS("true");
else text = wxS("false");
return text;
return true;
}
-wxString wxBaseEnumProperty::GetValueAsString( int ) const
+wxString wxBaseEnumProperty::ValueToString( wxVariant& value,
+ int WXUNUSED(argFlags) ) const
{
- if ( m_value.GetType() == wxPG_VARIANT_TYPE_STRING )
- return m_value.GetString();
+ if ( value.GetType() == wxPG_VARIANT_TYPE_STRING )
+ return value.GetString();
- if ( m_index >= 0 )
- {
- int unusedVal;
- const wxString* pstr = GetEntry( m_index, &unusedVal );
+ int index = m_choices.Index(value.GetLong());
+ if ( index < 0 )
+ return wxEmptyString;
- if ( pstr )
- return *pstr;
- }
- return wxEmptyString;
+ return m_choices.GetLabel(index);
}
bool wxBaseEnumProperty::StringToValue( wxVariant& variant, const wxString& text, int argFlags ) const
}
}
-wxString wxFlagsProperty::GetValueAsString( int ) const
+wxString wxFlagsProperty::ValueToString( wxVariant& value,
+ int WXUNUSED(argFlags) ) const
{
wxString text;
if ( !m_choices.IsOk() )
return text;
- long flags = m_value;
+ long flags = value;
unsigned int i;
const wxPGChoices& choices = m_choices;
if ( property->IsKindOf(CLASSINFO(wxFileProperty)) )
{
fileProp = ((wxFileProperty*)property);
- path = fileProp->m_filename.GetPath();
+ wxFileName filename = fileProp->GetValue().GetString();
+ path = filename.GetPath();
indFilter = fileProp->m_indFilter;
if ( !path.length() && fileProp->m_basePath.length() )
{
const wxString& fnstr = m_value.GetString();
- m_filename = fnstr;
+ wxFileName filename = fnstr;
- if ( !m_filename.HasName() )
+ if ( !filename.HasName() )
{
m_value = wxPGVariant_EmptyString;
- m_filename.Clear();
}
// Find index for extension.
if ( m_indFilter < 0 && fnstr.length() )
{
- wxString ext = m_filename.GetExt();
+ wxString ext = filename.GetExt();
int curind = 0;
size_t pos = 0;
size_t len = m_wildcard.length();
}
}
-wxString wxFileProperty::GetValueAsString( int argFlags ) const
+wxFileName wxFileProperty::GetFileName() const
{
- // Always return empty string when name component is empty
- wxString fullName = m_filename.GetFullName();
+ wxFileName filename;
+
+ if ( !m_value.IsNull() )
+ filename = m_value.GetString();
+
+ return filename;
+}
+
+wxString wxFileProperty::ValueToString( wxVariant& value,
+ int argFlags ) const
+{
+ wxFileName filename = value.GetString();
+
+ if ( !filename.HasName() )
+ return wxEmptyString;
+
+ wxString fullName = filename.GetFullName();
if ( !fullName.length() )
- return fullName;
+ return wxEmptyString;
if ( argFlags & wxPG_FULL_VALUE )
{
- return m_filename.GetFullPath();
+ return filename.GetFullPath();
}
else if ( m_flags & wxPG_PROP_SHOW_FULL_FILENAME )
{
if ( m_basePath.Length() )
{
- wxFileName fn2(m_filename);
+ wxFileName fn2(filename);
fn2.MakeRelativeTo(m_basePath);
return fn2.GetFullPath();
}
- return m_filename.GetFullPath();
+ return filename.GetFullPath();
}
- return m_filename.GetFullName();
+ return filename.GetFullName();
}
wxPGEditorDialogAdapter* wxFileProperty::GetEditorDialog() const
bool wxFileProperty::StringToValue( wxVariant& variant, const wxString& text, int argFlags ) const
{
+ wxFileName filename = variant.GetString();
+
if ( (m_flags & wxPG_PROP_SHOW_FULL_FILENAME) || (argFlags & wxPG_FULL_VALUE) )
{
- if ( m_filename != text )
+ if ( filename != text )
{
variant = text;
return true;
}
else
{
- if ( m_filename.GetFullName() != text )
+ if ( filename.GetFullName() != text )
{
- wxFileName fn = m_filename;
+ wxFileName fn = filename;
fn.SetFullName(text);
variant = fn.GetFullPath();
return true;
wxLongStringProperty::~wxLongStringProperty() {}
-wxString wxLongStringProperty::GetValueAsString( int ) const
+wxString wxLongStringProperty::ValueToString( wxVariant& value,
+ int WXUNUSED(argFlags) ) const
{
- return m_value;
+ return value;
}
bool wxLongStringProperty::OnEvent( wxPropertyGrid* propGrid, wxWindow* WXUNUSED(primary),
GenerateValueAsString();
}
-wxString wxArrayStringProperty::GetValueAsString( int WXUNUSED(argFlags) ) const
+#define ARRSTRPROP_ARRAY_TO_STRING(STRING,ARRAY) \
+ wxPropertyGrid::ArrayStringToString(STRING,ARRAY,wxS('"'),wxS('"'),1)
+
+wxString wxArrayStringProperty::ValueToString( wxVariant& WXUNUSED(value),
+ int argFlags ) const
{
- return m_display;
+ //
+ // If this is called from GetValueAsString(), return cached string
+ if ( argFlags & wxPG_VALUE_IS_CURRENT )
+ {
+ return m_display;
+ }
+
+ wxArrayString arr = m_value.GetArrayString();
+ wxString s;
+ ARRSTRPROP_ARRAY_TO_STRING(s, arr);
+ return s;
}
// Converts wxArrayString to a string separated by delimeters and spaces.
}
}
-#define ARRSTRPROP_ARRAY_TO_STRING(STRING,ARRAY) \
- wxPropertyGrid::ArrayStringToString(STRING,ARRAY,wxS('"'),wxS('"'),1);
-
void wxArrayStringProperty::GenerateValueAsString()
{
wxArrayString arr = m_value.GetArrayString();
- ARRSTRPROP_ARRAY_TO_STRING(m_display, arr)
+ ARRSTRPROP_ARRAY_TO_STRING(m_display, arr);
}
// Default implementation doesn't do anything.
{
wxArrayString actualValue = value.GetArrayString();
wxString tempStr;
- ARRSTRPROP_ARRAY_TO_STRING(tempStr, actualValue)
+ ARRSTRPROP_ARRAY_TO_STRING(tempStr, actualValue);
#if wxUSE_VALIDATORS
if ( dialogValidator.DoValidate( propGrid, validator, tempStr ) )
#endif