new flags: wxPG_VFB_SHOW_MESSAGEBOX and wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR.
- wxPropertyGrid: Added wxPropertyGrid::DedicateKey().
- wxPropertyGrid: wxArrayStringProperty now uses wxEditableListBox.
+- wxPropertyGrid: Added "Delimiter" attribute for wxArrayStringProperty.
- wxPropertyGridManager: added wxPG_NO_INTERNAL_BORDER,
wxPG_EX_NO_TOOLBAR_DIVIDER and wxPG_EX_TOOLBAR_SEPARATOR styles for finer
control over borders. Borders around property grid are now native for
*/
#define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage")
+/**
+ wxArrayStringProperty's string delimiter character. If this is aquotation
+ mark or hyphen, then strings will be quoted instead (with given
+ character).
+
+ Default delimiter is quotation mark.
+*/
+#define wxPG_ARRAY_DELIMITER wxS("Delimiter")
+
/** Sets displayed date format for wxDateProperty.
*/
#define wxPG_DATE_FORMAT wxS("DateFormat")
// Events from editor controls are forward to this function
void HandleCustomEditorEvent( wxEvent &event );
- /**
- Generates contents for string dst based on the contents of
- wxArrayString src.
-
- Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
- so on. Set flags to 1 inorder to convert backslashes to double-back-
- slashes and "(preDelims)"'s to "(preDelims)".
- */
- static void ArrayStringToString( wxString& dst, const wxArrayString& src,
- wxChar preDelim, wxChar postDelim,
- int flags );
-
// Mostly useful for page switching.
void SwitchState( wxPropertyGridPageState* pNewState );
{
WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty)
public:
-
wxArrayStringProperty( const wxString& label = wxPG_LABEL,
const wxString& name = wxPG_LABEL,
const wxArrayString& value = wxArrayString() );
int argFlags = 0 ) const;
virtual bool OnEvent( wxPropertyGrid* propgrid,
wxWindow* primary, wxEvent& event );
+ virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
- virtual void GenerateValueAsString();
+ // Implement in derived class for custom array-to-string conversion.
+ virtual void ConvertArrayToString(const wxArrayString& arr,
+ wxString* pString,
+ const wxUniChar& delimiter) const;
// Shows string editor dialog. Value to be edited should be read from
// value, and if dialog is not cancelled, it should be stored back and true
// Creates wxPGArrayEditorDialog for string editing. Called in OnButtonClick.
virtual wxPGArrayEditorDialog* CreateEditorDialog();
+ enum ConversionFlags
+ {
+ Escape = 0x01,
+ QuoteStrings = 0x02
+ };
+
+ /**
+ Generates contents for string dst based on the contents of
+ wxArrayString src.
+ */
+ static void ArrayStringToString( wxString& dst, const wxArrayString& src,
+ wxUniChar delimiter, int flags );
+
protected:
+ // Previously this was to be implemented in derived class for array-to-
+ // string conversion. Now you should implement ConvertValueToString()
+ // instead.
+ virtual void GenerateValueAsString();
+
wxString m_display; // Cache for displayed text.
+ wxUniChar m_delimiter;
};
// -----------------------------------------------------------------------
const wxString& name = wxPG_LABEL, \
const wxArrayString& value = wxArrayString() ); \
~PROPNAME(); \
- virtual void GenerateValueAsString(); \
- virtual bool StringToValue( wxVariant& value, \
- const wxString& text, int = 0 ) const; \
virtual bool OnEvent( wxPropertyGrid* propgrid, \
wxWindow* primary, wxEvent& event ); \
virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
: wxArrayStringProperty(label,name,value) \
{ \
PROPNAME::GenerateValueAsString(); \
+ m_delimiter = DELIMCHAR; \
} \
PROPNAME::~PROPNAME() { } \
-void PROPNAME::GenerateValueAsString() \
-{ \
- wxChar delimChar = DELIMCHAR; \
- if ( delimChar == wxS('"') ) \
- wxArrayStringProperty::GenerateValueAsString(); \
- else \
- wxPropertyGrid::ArrayStringToString(m_display, \
- m_value.GetArrayString(), \
- 0,DELIMCHAR,0); \
-} \
-bool PROPNAME::StringToValue( wxVariant& variant, \
- const wxString& text, int ) const \
-{ \
- wxChar delimChar = DELIMCHAR; \
- if ( delimChar == wxS('"') ) \
- return wxArrayStringProperty::StringToValue(variant, text, 0); \
- \
- wxArrayString arr; \
- WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
- arr.Add( token ); \
- WX_PG_TOKENIZER1_END() \
- variant = arr; \
- return true; \
-} \
bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
wxWindow* primary, wxEvent& event ) \
{ \
*/
#define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage")
+/**
+ wxArrayStringProperty's string delimiter character. If this is aquotation
+ mark or hyphen, then strings will be quoted instead (with given
+ character).
+
+ Default delimiter is quotation mark.
+*/
+#define wxPG_ARRAY_DELIMITER wxS("Delimiter")
+
/** Sets displayed date format for wxDateProperty.
*/
#define wxPG_DATE_FORMAT wxS("DateFormat")
// Dirs Property
// -----------------------------------------------------------------------
-WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(wxDirsProperty,wxT(','),wxT("Browse"))
+WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(wxDirsProperty, ',',
+ "Browse")
#if wxUSE_VALIDATORS
GenerateValueAsString();
}
-#define ARRSTRPROP_ARRAY_TO_STRING(STRING,ARRAY) \
- wxPropertyGrid::ArrayStringToString(STRING,ARRAY,wxS('"'),wxS('"'),1)
+void
+wxArrayStringProperty::ConvertArrayToString(const wxArrayString& arr,
+ wxString* pString,
+ const wxUniChar& delimiter) const
+{
+ if ( delimiter == '"' || delimiter == '\'' )
+ {
+ // Quoted strings
+ ArrayStringToString(*pString,
+ arr,
+ delimiter,
+ Escape | QuoteStrings);
+ }
+ else
+ {
+ // Regular delimiter
+ ArrayStringToString(*pString,
+ arr,
+ delimiter,
+ 0);
+ }
+}
wxString wxArrayStringProperty::ValueToString( wxVariant& WXUNUSED(value),
int argFlags ) const
wxArrayString arr = m_value.GetArrayString();
wxString s;
- ARRSTRPROP_ARRAY_TO_STRING(s, arr);
+ ConvertArrayToString(arr, &s, m_delimiter);
return s;
}
// Converts wxArrayString to a string separated by delimeters and spaces.
// preDelim is useful for "str1" "str2" style. Set flags to 1 to do slash
// conversion.
-void wxPropertyGrid::ArrayStringToString( wxString& dst, const wxArrayString& src,
- wxChar preDelim, wxChar postDelim,
- int flags )
+void
+wxArrayStringProperty::ArrayStringToString( wxString& dst,
+ const wxArrayString& src,
+ wxUniChar delimiter, int flags )
{
wxString pdr;
+ wxString preas;
unsigned int i;
unsigned int itemCount = src.size();
- wxChar preas[2] = { 0, 0 };
-
dst.Empty();
- if ( flags & 1 )
+ if ( flags & Escape )
{
- preas[0] = preDelim;
+ preas[0] = delimiter;
pdr = wxS("\\");
- pdr += preDelim;
+ pdr += delimiter;
}
if ( itemCount )
dst.append( preas );
- wxASSERT( postDelim );
- wxString postDelimStr(postDelim);
- //wxString preDelimStr(preDelim);
+ wxString delimStr(delimiter);
for ( i = 0; i < itemCount; i++ )
{
wxString str( src.Item(i) );
// Do some character conversion.
- // Convertes \ to \\ and <preDelim> to \<preDelim>
- // Useful when preDelim and postDelim are "\"".
- if ( flags & 1 )
+ // Converts \ to \\ and $delimiter to \$delimiter
+ // Useful when quoting.
+ if ( flags & Escape )
{
str.Replace( wxS("\\"), wxS("\\\\"), true );
if ( pdr.length() )
if ( i < (itemCount-1) )
{
- dst.append( postDelimStr );
+ dst.append( delimStr );
dst.append( wxS(" ") );
dst.append( preas );
}
- else if ( preDelim )
- dst.append( postDelimStr );
+ else if ( flags & QuoteStrings )
+ dst.append( delimStr );
}
}
void wxArrayStringProperty::GenerateValueAsString()
{
wxArrayString arr = m_value.GetArrayString();
- ARRSTRPROP_ARRAY_TO_STRING(m_display, arr);
+ ConvertArrayToString(arr, &m_display, m_delimiter);
}
// Default implementation doesn't do anything.
{
wxArrayString actualValue = value.GetArrayString();
wxString tempStr;
- ARRSTRPROP_ARRAY_TO_STRING(tempStr, actualValue);
+ ConvertArrayToString(actualValue, &tempStr, m_delimiter);
#if wxUSE_VALIDATORS
- if ( dialogValidator.DoValidate( propGrid, validator, tempStr ) )
+ if ( dialogValidator.DoValidate(propGrid, validator,
+ tempStr) )
#endif
{
SetValueInEvent( actualValue );
return false;
}
-bool wxArrayStringProperty::StringToValue( wxVariant& variant, const wxString& text, int ) const
+bool wxArrayStringProperty::StringToValue( wxVariant& variant,
+ const wxString& text, int ) const
{
wxArrayString arr;
- WX_PG_TOKENIZER2_BEGIN(text,wxS('"'))
+ if ( m_delimiter == '"' || m_delimiter == '\'' )
+ {
+ // Quoted strings
+ WX_PG_TOKENIZER2_BEGIN(text, m_delimiter)
- // Need to replace backslashes with empty characters
- // (opposite what is done in GenerateValueString).
- token.Replace ( wxS("\\\\"), wxS("\\"), true );
+ // Need to replace backslashes with empty characters
+ // (opposite what is done in ConvertArrayToString()).
+ token.Replace ( wxS("\\\\"), wxS("\\"), true );
- arr.Add( token );
+ arr.Add( token );
- WX_PG_TOKENIZER2_END()
+ WX_PG_TOKENIZER2_END()
+ }
+ else
+ {
+ // Regular delimiter
+ WX_PG_TOKENIZER1_BEGIN(text, m_delimiter)
+ arr.Add( token );
+ WX_PG_TOKENIZER1_END()
+ }
variant = arr;
return true;
}
+bool wxArrayStringProperty::DoSetAttribute( const wxString& name, wxVariant& value )
+{
+ if ( name == wxPG_ARRAY_DELIMITER )
+ {
+ m_delimiter = value.GetChar();
+ GenerateValueAsString();
+ return false;
+ }
+ return true;
+}
+
// -----------------------------------------------------------------------
// wxPGInDialogValidator
// -----------------------------------------------------------------------