1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/props.h
3 // Purpose: wxPropertyGrid Property Classes
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PROPGRID_PROPS_H_
13 #define _WX_PROPGRID_PROPS_H_
19 // -----------------------------------------------------------------------
21 class wxPGArrayEditorDialog
;
23 #include "wx/propgrid/editors.h"
25 #include "wx/filename.h"
26 #include "wx/dialog.h"
27 #include "wx/textctrl.h"
28 #include "wx/button.h"
29 #include "wx/listbox.h"
31 // -----------------------------------------------------------------------
34 // Property class implementation helper macros.
37 #define WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME, UPCLASS, T, T_AS_ARG, EDITOR) \
38 IMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS) \
39 WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME, T, EDITOR)
41 // -----------------------------------------------------------------------
44 // These macros help creating DoGetValidator
45 #define WX_PG_DOGETVALIDATOR_ENTRY() \
46 static wxValidator* s_ptr = NULL; \
47 if ( s_ptr ) return s_ptr;
49 // Common function exit
50 #define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
52 wxPGGlobalVars->m_arrValidators.push_back( VALIDATOR ); \
55 // -----------------------------------------------------------------------
57 /** @class wxPGInDialogValidator
59 Creates and manages a temporary wxTextCtrl for validation purposes.
60 Uses wxPropertyGrid's current editor, if available.
62 class WXDLLIMPEXP_PROPGRID wxPGInDialogValidator
65 wxPGInDialogValidator()
70 ~wxPGInDialogValidator()
73 m_textCtrl
->Destroy();
76 bool DoValidate( wxPropertyGrid
* propGrid
,
77 wxValidator
* validator
,
78 const wxString
& value
);
81 wxTextCtrl
* m_textCtrl
;
85 // -----------------------------------------------------------------------
87 // -----------------------------------------------------------------------
89 #define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
91 /** @class wxStringProperty
93 Basic property with string value.
95 <b>Supported special attributes:</b>
96 - "Password": set to 1 inorder to enable wxTE_PASSWORD on the editor.
99 - If value "<composed>" is set, then actual value is formed (or composed)
100 from values of child properties.
102 class WXDLLIMPEXP_PROPGRID wxStringProperty
: public wxPGProperty
104 WX_PG_DECLARE_PROPERTY_CLASS(wxStringProperty
)
106 wxStringProperty( const wxString
& label
= wxPG_LABEL
,
107 const wxString
& name
= wxPG_LABEL
,
108 const wxString
& value
= wxEmptyString
);
109 virtual ~wxStringProperty();
111 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
112 virtual bool StringToValue( wxVariant
& variant
,
113 const wxString
& text
,
114 int argFlags
= 0 ) const;
116 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
118 /** This is updated so "<composed>" special value can be handled.
120 virtual void OnSetValue();
125 // -----------------------------------------------------------------------
127 /** Constants used with NumericValidation<>().
129 enum wxPGNumericValidationConstants
131 /** Instead of modifying the value, show an error message.
133 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
= 0,
135 /** Modify value, but stick with the limitations.
137 wxPG_PROPERTY_VALIDATION_SATURATE
= 1,
139 /** Modify value, wrap around on overflow.
141 wxPG_PROPERTY_VALIDATION_WRAP
= 2
144 // -----------------------------------------------------------------------
146 /** @class wxIntProperty
148 Basic property with integer value.
150 Seamlessly supports 64-bit integer (wxLongLong) on overflow.
152 <b>Example how to use seamless 64-bit integer support</b>
157 wxLongLong_t value = pg->GetPropertyValueAsLongLong();
164 wxVariant variant = property->GetValue();
165 if ( variant.GetType() == "wxLongLong" )
166 value = wxLongLongFromVariant(variant);
168 value = variant.GetLong();
174 pg->SetPropertyValue(longLongVal);
180 property->SetValue(WXVARIANT(longLongVal));
184 <b>Supported special attributes:</b>
185 - "Min", "Max": Specify acceptable value range.
187 class WXDLLIMPEXP_PROPGRID wxIntProperty
: public wxPGProperty
189 WX_PG_DECLARE_PROPERTY_CLASS(wxIntProperty
)
191 wxIntProperty( const wxString
& label
= wxPG_LABEL
,
192 const wxString
& name
= wxPG_LABEL
,
194 virtual ~wxIntProperty();
196 wxIntProperty( const wxString
& label
,
197 const wxString
& name
,
198 const wxLongLong
& value
);
199 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
200 virtual bool StringToValue( wxVariant
& variant
,
201 const wxString
& text
,
202 int argFlags
= 0 ) const;
203 virtual bool ValidateValue( wxVariant
& value
,
204 wxPGValidationInfo
& validationInfo
) const;
205 virtual bool IntToValue( wxVariant
& variant
,
207 int argFlags
= 0 ) const;
208 static wxValidator
* GetClassValidator();
209 virtual wxValidator
* DoGetValidator() const;
211 /** Validation helper.
213 static bool DoValidation( const wxPGProperty
* property
,
215 wxPGValidationInfo
* pValidationInfo
,
217 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
);
222 // -----------------------------------------------------------------------
224 /** @class wxUIntProperty
226 Basic property with unsigned integer value.
227 Seamlessly supports 64-bit integer (wxULongLong) on overflow.
229 <b>Supported special attributes:</b>
230 - "Min", "Max": Specify acceptable value range.
231 - "Base": Define base. Valid constants are wxPG_BASE_OCT, wxPG_BASE_DEC,
232 wxPG_BASE_HEX and wxPG_BASE_HEXL (lowercase characters). Arbitrary bases
233 are <b>not</b> supported.
234 - "Prefix": Possible values are wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and
235 wxPG_PREFIX_DOLLAR_SIGN. Only wxPG_PREFIX_NONE works with Decimal and Octal
239 - For example how to use seamless 64-bit integer support, see wxIntProperty
240 documentation (just use wxULongLong instead of wxLongLong).
242 class WXDLLIMPEXP_PROPGRID wxUIntProperty
: public wxPGProperty
244 WX_PG_DECLARE_PROPERTY_CLASS(wxUIntProperty
)
246 wxUIntProperty( const wxString
& label
= wxPG_LABEL
,
247 const wxString
& name
= wxPG_LABEL
,
248 unsigned long value
= 0 );
249 virtual ~wxUIntProperty();
250 wxUIntProperty( const wxString
& label
,
251 const wxString
& name
,
252 const wxULongLong
& value
);
253 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
254 virtual bool StringToValue( wxVariant
& variant
,
255 const wxString
& text
,
256 int argFlags
= 0 ) const;
257 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
258 virtual bool ValidateValue( wxVariant
& value
,
259 wxPGValidationInfo
& validationInfo
) const;
260 virtual bool IntToValue( wxVariant
& variant
,
262 int argFlags
= 0 ) const;
265 wxByte m_realBase
; // translated to 8,16,etc.
271 // -----------------------------------------------------------------------
273 /** @class wxFloatProperty
275 Basic property with double-precision floating point value.
277 <b>Supported special attributes:</b>
278 - "Precision": Sets the (max) precision used when floating point value is
279 rendered as text. The default -1 means infinite precision.
281 class WXDLLIMPEXP_PROPGRID wxFloatProperty
: public wxPGProperty
283 WX_PG_DECLARE_PROPERTY_CLASS(wxFloatProperty
)
285 wxFloatProperty( const wxString
& label
= wxPG_LABEL
,
286 const wxString
& name
= wxPG_LABEL
,
287 double value
= 0.0 );
288 virtual ~wxFloatProperty();
290 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
291 virtual bool StringToValue( wxVariant
& variant
,
292 const wxString
& text
,
293 int argFlags
= 0 ) const;
294 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
295 virtual bool ValidateValue( wxVariant
& value
,
296 wxPGValidationInfo
& validationInfo
) const;
298 /** Validation helper.
300 static bool DoValidation( const wxPGProperty
* property
,
302 wxPGValidationInfo
* pValidationInfo
,
304 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
);
305 virtual wxValidator
* DoGetValidator () const;
311 // -----------------------------------------------------------------------
313 /** @class wxBoolProperty
315 Basic property with boolean value.
317 <b>Supported special attributes:</b>
318 - "UseCheckbox": Set to 1 to use check box editor instead of combo box.
319 - "UseDClickCycling": Set to 1 to cycle combo box instead showing the list.
321 class WXDLLIMPEXP_PROPGRID wxBoolProperty
: public wxPGProperty
323 WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty
)
325 wxBoolProperty( const wxString
& label
= wxPG_LABEL
,
326 const wxString
& name
= wxPG_LABEL
,
327 bool value
= false );
328 virtual ~wxBoolProperty();
330 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
331 virtual bool StringToValue( wxVariant
& variant
,
332 const wxString
& text
,
333 int argFlags
= 0 ) const;
334 virtual bool IntToValue( wxVariant
& variant
,
335 int number
, int argFlags
= 0 ) const;
336 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
339 // -----------------------------------------------------------------------
341 // If set, then selection of choices is static and should not be
342 // changed (i.e. returns NULL in GetPropertyChoices).
343 #define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
345 /** @class wxEnumProperty
347 You can derive custom properties with choices from this class. See
348 wxBaseEnumProperty for remarks.
351 - Updating private index is important. You can do this either by calling
352 SetIndex() in IntToValue, and then letting wxBaseEnumProperty::OnSetValue
353 be called (by not implementing it, or by calling super class function in
354 it) -OR- you can just call SetIndex in OnSetValue.
356 class WXDLLIMPEXP_PROPGRID wxEnumProperty
: public wxPGProperty
358 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty
)
362 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
363 const wxString
& name
= wxPG_LABEL
,
364 const wxChar
* const* labels
= NULL
,
365 const long* values
= NULL
,
367 wxEnumProperty( const wxString
& label
,
368 const wxString
& name
,
369 wxPGChoices
& choices
,
372 // Special constructor for caching choices (used by derived class)
373 wxEnumProperty( const wxString
& label
,
374 const wxString
& name
,
375 const wxChar
* const* labels
,
377 wxPGChoices
* choicesCache
,
380 wxEnumProperty( const wxString
& label
,
381 const wxString
& name
,
382 const wxArrayString
& labels
,
383 const wxArrayInt
& values
= wxArrayInt(),
386 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
387 const wxString
& name
= wxPG_LABEL
,
388 const wxArrayString
& labels
= wxArrayString(),
389 const wxArrayInt
& values
= wxArrayInt(),
393 virtual ~wxEnumProperty();
395 size_t GetItemCount() const { return m_choices
.GetCount(); }
397 virtual void OnSetValue();
398 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
399 virtual bool StringToValue( wxVariant
& variant
,
400 const wxString
& text
,
401 int argFlags
= 0 ) const;
402 virtual bool ValidateValue( wxVariant
& value
,
403 wxPGValidationInfo
& validationInfo
) const;
405 // If wxPG_FULL_VALUE is not set in flags, then the value is interpreted
406 // as index to choices list. Otherwise, it is actual value.
407 virtual bool IntToValue( wxVariant
& variant
,
409 int argFlags
= 0 ) const;
412 // Additional virtuals
414 // This must be overridden to have non-index based value
415 virtual int GetIndexForValue( int value
) const;
417 // GetChoiceSelection needs to overridden since m_index is
418 // the true index, and various property classes derived from
419 // this take advantage of it.
420 virtual int GetChoiceSelection() const { return m_index
; }
422 virtual void OnValidationFailure( wxVariant
& pendingValue
);
426 int GetIndex() const;
427 void SetIndex( int index
);
429 bool ValueFromString_( wxVariant
& value
,
430 const wxString
& text
,
431 int argFlags
) const;
432 bool ValueFromInt_( wxVariant
& value
, int intVal
, int argFlags
) const;
434 static void ResetNextIndex() { ms_nextIndex
= -2; }
437 // This is private so that classes are guaranteed to use GetIndex
438 // for up-to-date index value.
441 // Relies on ValidateValue being called always before OnSetValue
442 static int ms_nextIndex
;
445 // -----------------------------------------------------------------------
447 /** @class wxEditEnumProperty
449 wxEnumProperty with wxString value and writable combo box editor.
452 Uses int value, similar to wxEnumProperty, unless text entered by user is
453 is not in choices (in which case string value is used).
455 class WXDLLIMPEXP_PROPGRID wxEditEnumProperty
: public wxEnumProperty
457 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty
)
460 wxEditEnumProperty( const wxString
& label
,
461 const wxString
& name
,
462 const wxChar
* const* labels
,
464 const wxString
& value
);
465 wxEditEnumProperty( const wxString
& label
= wxPG_LABEL
,
466 const wxString
& name
= wxPG_LABEL
,
467 const wxArrayString
& labels
= wxArrayString(),
468 const wxArrayInt
& values
= wxArrayInt(),
469 const wxString
& value
= wxEmptyString
);
470 wxEditEnumProperty( const wxString
& label
,
471 const wxString
& name
,
472 wxPGChoices
& choices
,
473 const wxString
& value
= wxEmptyString
);
475 // Special constructor for caching choices (used by derived class)
476 wxEditEnumProperty( const wxString
& label
,
477 const wxString
& name
,
478 const wxChar
* const* labels
,
480 wxPGChoices
* choicesCache
,
481 const wxString
& value
);
483 virtual ~wxEditEnumProperty();
488 // -----------------------------------------------------------------------
490 /** @class wxFlagsProperty
492 Represents a bit set that fits in a long integer. wxBoolProperty
493 sub-properties are created for editing individual bits. Textctrl is created
494 to manually edit the flags as a text; a continous sequence of spaces,
495 commas and semicolons is considered as a flag id separator.
496 <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
497 you will need to use SetPropertyChoices - otherwise they will not get
500 class WXDLLIMPEXP_PROPGRID wxFlagsProperty
: public wxPGProperty
502 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty
)
506 wxFlagsProperty( const wxString
& label
,
507 const wxString
& name
,
508 const wxChar
* const* labels
,
509 const long* values
= NULL
,
511 wxFlagsProperty( const wxString
& label
,
512 const wxString
& name
,
513 wxPGChoices
& choices
,
516 wxFlagsProperty( const wxString
& label
= wxPG_LABEL
,
517 const wxString
& name
= wxPG_LABEL
,
518 const wxArrayString
& labels
= wxArrayString(),
519 const wxArrayInt
& values
= wxArrayInt(),
521 virtual ~wxFlagsProperty ();
523 virtual void OnSetValue();
524 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
525 virtual bool StringToValue( wxVariant
& variant
,
526 const wxString
& text
,
528 virtual wxVariant
ChildChanged( wxVariant
& thisValue
,
530 wxVariant
& childValue
) const;
531 virtual void RefreshChildren();
532 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
534 // GetChoiceSelection needs to overridden since m_choices is
535 // used and value is integer, but it is not index.
536 virtual int GetChoiceSelection() const { return wxNOT_FOUND
; }
539 size_t GetItemCount() const { return m_choices
.GetCount(); }
540 const wxString
& GetLabel( size_t ind
) const
541 { return m_choices
.GetLabel(ind
); }
544 // Used to detect if choices have been changed
545 wxPGChoicesData
* m_oldChoicesData
;
547 // Needed to properly mark changed sub-properties
550 // Converts string id to a relevant bit.
551 long IdToBit( const wxString
& id
) const;
553 // Creates children and sets value.
557 // -----------------------------------------------------------------------
559 /** @class wxPGFileDialogAdapter
562 class WXDLLIMPEXP_PROPGRID
563 wxPGFileDialogAdapter
: public wxPGEditorDialogAdapter
566 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
567 wxPGProperty
* property
);
570 // -----------------------------------------------------------------------
572 // Indicates first bit useable by derived properties.
573 #define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
575 /** @class wxFileProperty
577 Like wxLongStringProperty, but the button triggers file selector instead.
579 <b>Supported special attributes:</b>
580 - "Wildcard": Sets wildcard (see wxFileDialog for format details), "All
581 files..." is default.
582 - "ShowFullPath": Default 1. When 0, only the file name is shown (i.e. drive
583 and directory are hidden).
584 - "ShowRelativePath": If set, then the filename is shown relative to the
586 - "InitialPath": Sets the initial path of where to look for files.
587 - "DialogTitle": Sets a specific title for the dir dialog.
589 class WXDLLIMPEXP_PROPGRID wxFileProperty
: public wxPGProperty
591 friend class wxPGFileDialogAdapter
;
592 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty
)
595 wxFileProperty( const wxString
& label
= wxPG_LABEL
,
596 const wxString
& name
= wxPG_LABEL
,
597 const wxString
& value
= wxEmptyString
);
598 virtual ~wxFileProperty ();
600 virtual void OnSetValue();
601 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
602 virtual bool StringToValue( wxVariant
& variant
,
603 const wxString
& text
,
604 int argFlags
= 0 ) const;
605 virtual wxPGEditorDialogAdapter
* GetEditorDialog() const;
606 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
608 static wxValidator
* GetClassValidator();
609 virtual wxValidator
* DoGetValidator() const;
612 Returns filename to file represented by current value.
614 wxFileName
GetFileName() const;
618 wxString m_basePath
; // If set, then show path relative to it
619 wxString m_initialPath
; // If set, start the file dialog here
620 wxString m_dlgTitle
; // If set, used as title for file dialog
621 int m_indFilter
; // index to the selected filter
624 // -----------------------------------------------------------------------
626 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
629 /** @class wxPGLongStringDialogAdapter
632 class WXDLLIMPEXP_PROPGRID
633 wxPGLongStringDialogAdapter
: public wxPGEditorDialogAdapter
636 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
637 wxPGProperty
* property
);
641 /** @class wxLongStringProperty
643 Like wxStringProperty, but has a button that triggers a small text
646 class WXDLLIMPEXP_PROPGRID wxLongStringProperty
: public wxPGProperty
648 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty
)
651 wxLongStringProperty( const wxString
& label
= wxPG_LABEL
,
652 const wxString
& name
= wxPG_LABEL
,
653 const wxString
& value
= wxEmptyString
);
654 virtual ~wxLongStringProperty();
656 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
657 virtual bool StringToValue( wxVariant
& variant
,
658 const wxString
& text
,
659 int argFlags
= 0 ) const;
660 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
661 wxWindow
* primary
, wxEvent
& event
);
663 // Shows string editor dialog. Value to be edited should be read from
664 // value, and if dialog is not cancelled, it should be stored back and true
665 // should be returned if that was the case.
666 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
, wxString
& value
);
668 static bool DisplayEditorDialog( wxPGProperty
* prop
,
669 wxPropertyGrid
* propGrid
,
675 // -----------------------------------------------------------------------
678 /** @class wxDirProperty
680 Like wxLongStringProperty, but the button triggers dir selector instead.
682 <b>Supported special attributes:</b>
683 - "DialogMessage": Sets specific message in the dir selector.
685 class WXDLLIMPEXP_PROPGRID wxDirProperty
: public wxLongStringProperty
687 DECLARE_DYNAMIC_CLASS(wxDirProperty
)
689 wxDirProperty( const wxString
& name
= wxPG_LABEL
,
690 const wxString
& label
= wxPG_LABEL
,
691 const wxString
& value
= wxEmptyString
);
692 virtual ~wxDirProperty();
694 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
695 virtual wxValidator
* DoGetValidator() const;
697 virtual bool OnButtonClick ( wxPropertyGrid
* propGrid
, wxString
& value
);
700 wxString m_dlgMessage
;
703 // -----------------------------------------------------------------------
705 // wxBoolProperty specific flags
706 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
707 // DCC = Double Click Cycles
708 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
711 // -----------------------------------------------------------------------
713 /** @class wxArrayStringProperty
715 Property that manages a list of strings.
717 class WXDLLIMPEXP_PROPGRID wxArrayStringProperty
: public wxPGProperty
719 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty
)
721 wxArrayStringProperty( const wxString
& label
= wxPG_LABEL
,
722 const wxString
& name
= wxPG_LABEL
,
723 const wxArrayString
& value
= wxArrayString() );
724 virtual ~wxArrayStringProperty();
726 virtual void OnSetValue();
727 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
728 virtual bool StringToValue( wxVariant
& variant
,
729 const wxString
& text
,
730 int argFlags
= 0 ) const;
731 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
732 wxWindow
* primary
, wxEvent
& event
);
733 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
735 // Implement in derived class for custom array-to-string conversion.
736 virtual void ConvertArrayToString(const wxArrayString
& arr
,
738 const wxUniChar
& delimiter
) const;
740 // Shows string editor dialog. Value to be edited should be read from
741 // value, and if dialog is not cancelled, it should be stored back and true
742 // should be returned if that was the case.
743 virtual bool OnCustomStringEdit( wxWindow
* parent
, wxString
& value
);
746 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
,
750 // Creates wxPGArrayEditorDialog for string editing. Called in OnButtonClick.
751 virtual wxPGArrayEditorDialog
* CreateEditorDialog();
760 Generates contents for string dst based on the contents of
763 static void ArrayStringToString( wxString
& dst
, const wxArrayString
& src
,
764 wxUniChar delimiter
, int flags
);
767 // Previously this was to be implemented in derived class for array-to-
768 // string conversion. Now you should implement ConvertValueToString()
770 virtual void GenerateValueAsString();
772 wxString m_display
; // Cache for displayed text.
773 wxUniChar m_delimiter
;
776 // -----------------------------------------------------------------------
778 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
780 DECL PROPNAME : public wxArrayStringProperty \
782 WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
784 PROPNAME( const wxString& label = wxPG_LABEL, \
785 const wxString& name = wxPG_LABEL, \
786 const wxArrayString& value = wxArrayString() ); \
788 virtual bool OnEvent( wxPropertyGrid* propgrid, \
789 wxWindow* primary, wxEvent& event ); \
790 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
791 virtual wxValidator* DoGetValidator() const; \
794 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
795 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
797 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
800 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
801 wxArrayString, const wxArrayString&, \
803 PROPNAME::PROPNAME( const wxString& label, \
804 const wxString& name, \
805 const wxArrayString& value ) \
806 : wxArrayStringProperty(label,name,value) \
808 PROPNAME::GenerateValueAsString(); \
809 m_delimiter = DELIMCHAR; \
811 PROPNAME::~PROPNAME() { } \
812 bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
813 wxWindow* primary, wxEvent& event ) \
815 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
816 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
820 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
821 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
823 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
824 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
826 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
827 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
830 wxValidator* PROPNAME::DoGetValidator () const \
834 // -----------------------------------------------------------------------
835 // wxPGArrayEditorDialog
836 // -----------------------------------------------------------------------
838 #if wxUSE_EDITABLELISTBOX
840 class WXDLLIMPEXP_FWD_ADV wxEditableListBox
;
841 class WXDLLIMPEXP_FWD_CORE wxListEvent
;
843 #define wxAEDIALOG_STYLE \
844 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
846 class WXDLLIMPEXP_PROPGRID wxPGArrayEditorDialog
: public wxDialog
849 wxPGArrayEditorDialog();
850 virtual ~wxPGArrayEditorDialog() { }
854 wxPGArrayEditorDialog( wxWindow
*parent
,
855 const wxString
& message
,
856 const wxString
& caption
,
857 long style
= wxAEDIALOG_STYLE
,
858 const wxPoint
& pos
= wxDefaultPosition
,
859 const wxSize
& sz
= wxDefaultSize
);
861 bool Create( wxWindow
*parent
,
862 const wxString
& message
,
863 const wxString
& caption
,
864 long style
= wxAEDIALOG_STYLE
,
865 const wxPoint
& pos
= wxDefaultPosition
,
866 const wxSize
& sz
= wxDefaultSize
);
868 void EnableCustomNewAction()
870 m_hasCustomNewAction
= true;
873 /** Set value modified by dialog.
875 virtual void SetDialogValue( const wxVariant
& WXUNUSED(value
) )
877 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
880 /** Return value modified by dialog.
882 virtual wxVariant
GetDialogValue() const
884 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
888 /** Override to return wxValidator to be used with the wxTextCtrl
889 in dialog. Note that the validator is used in the standard
890 wx way, ie. it immediately prevents user from entering invalid
894 Dialog frees the validator.
896 virtual wxValidator
* GetTextCtrlValidator() const
901 // Returns true if array was actually modified
902 bool IsModified() const { return m_modified
; }
904 // wxEditableListBox utilities
905 int GetSelection() const;
907 // implementation from now on
908 void OnAddClick(wxCommandEvent
& event
);
909 void OnDeleteClick(wxCommandEvent
& event
);
910 void OnUpClick(wxCommandEvent
& event
);
911 void OnDownClick(wxCommandEvent
& event
);
912 void OnEndLabelEdit(wxListEvent
& event
);
913 void OnIdle(wxIdleEvent
& event
);
916 wxEditableListBox
* m_elb
;
918 // These are used for focus repair
919 wxWindow
* m_elbSubPanel
;
920 wxWindow
* m_lastFocused
;
922 // A new item, edited by user, is pending at this index.
923 // It will be committed once list ctrl item editing is done.
924 int m_itemPendingAtIndex
;
927 bool m_hasCustomNewAction
;
929 // These must be overridden - must return true on success.
930 virtual wxString
ArrayGet( size_t index
) = 0;
931 virtual size_t ArrayGetCount() = 0;
932 virtual bool ArrayInsert( const wxString
& str
, int index
) = 0;
933 virtual bool ArraySet( size_t index
, const wxString
& str
) = 0;
934 virtual void ArrayRemoveAt( int index
) = 0;
935 virtual void ArraySwap( size_t first
, size_t second
) = 0;
936 virtual bool OnCustomNewAction(wxString
* WXUNUSED(resString
))
942 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayEditorDialog
)
943 DECLARE_EVENT_TABLE()
946 #endif // wxUSE_EDITABLELISTBOX
948 // -----------------------------------------------------------------------
949 // wxPGArrayStringEditorDialog
950 // -----------------------------------------------------------------------
952 class WXDLLIMPEXP_PROPGRID
953 wxPGArrayStringEditorDialog
: public wxPGArrayEditorDialog
956 wxPGArrayStringEditorDialog();
957 virtual ~wxPGArrayStringEditorDialog() { }
961 virtual void SetDialogValue( const wxVariant
& value
)
963 m_array
= value
.GetArrayString();
966 virtual wxVariant
GetDialogValue() const
971 void SetCustomButton( const wxString
& custBtText
,
972 wxArrayStringProperty
* pcc
)
974 if ( custBtText
.length() )
976 EnableCustomNewAction();
977 m_pCallingClass
= pcc
;
981 virtual bool OnCustomNewAction(wxString
* resString
);
984 wxArrayString m_array
;
986 wxArrayStringProperty
* m_pCallingClass
;
988 virtual wxString
ArrayGet( size_t index
);
989 virtual size_t ArrayGetCount();
990 virtual bool ArrayInsert( const wxString
& str
, int index
);
991 virtual bool ArraySet( size_t index
, const wxString
& str
);
992 virtual void ArrayRemoveAt( int index
);
993 virtual void ArraySwap( size_t first
, size_t second
);
996 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog
)
997 DECLARE_EVENT_TABLE()
1000 // -----------------------------------------------------------------------
1002 #endif // wxUSE_PROPGRID
1004 #endif // _WX_PROPGRID_PROPS_H_