1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/props.h
3 // Purpose: wxPropertyGrid Property Classes
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PROPGRID_PROPS_H_
13 #define _WX_PROPGRID_PROPS_H_
17 // -----------------------------------------------------------------------
19 class wxArrayEditorDialog
;
21 #include "wx/propgrid/editors.h"
23 #include "wx/filename.h"
24 #include "wx/dialog.h"
25 #include "wx/textctrl.h"
26 #include "wx/button.h"
27 #include "wx/listbox.h"
29 // -----------------------------------------------------------------------
32 // Property class implementation helper macros.
35 #define WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME, UPCLASS, T, T_AS_ARG, EDITOR) \
36 IMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS) \
37 WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME, T, EDITOR)
39 // -----------------------------------------------------------------------
42 // These macros help creating DoGetValidator
43 #define WX_PG_DOGETVALIDATOR_ENTRY() \
44 static wxValidator* s_ptr = NULL; \
45 if ( s_ptr ) return s_ptr;
47 // Common function exit
48 #define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
50 wxPGGlobalVars->m_arrValidators.push_back( VALIDATOR ); \
53 // -----------------------------------------------------------------------
55 /** @class wxPGInDialogValidator
57 Creates and manages a temporary wxTextCtrl for validation purposes.
58 Uses wxPropertyGrid's current editor, if available.
60 class WXDLLIMPEXP_PROPGRID wxPGInDialogValidator
63 wxPGInDialogValidator()
68 ~wxPGInDialogValidator()
71 m_textCtrl
->Destroy();
74 bool DoValidate( wxPropertyGrid
* propGrid
,
75 wxValidator
* validator
,
76 const wxString
& value
);
79 wxTextCtrl
* m_textCtrl
;
83 // -----------------------------------------------------------------------
85 // -----------------------------------------------------------------------
87 #define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
89 /** @class wxStringProperty
91 Basic property with string value.
93 <b>Supported special attributes:</b>
94 - "Password": set to 1 inorder to enable wxTE_PASSWORD on the editor.
97 - If value "<composed>" is set, then actual value is formed (or composed)
98 from values of child properties.
100 class WXDLLIMPEXP_PROPGRID wxStringProperty
: public wxPGProperty
102 WX_PG_DECLARE_PROPERTY_CLASS(wxStringProperty
)
104 wxStringProperty( const wxString
& label
= wxPG_LABEL
,
105 const wxString
& name
= wxPG_LABEL
,
106 const wxString
& value
= wxEmptyString
);
107 virtual ~wxStringProperty();
109 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
110 virtual bool StringToValue( wxVariant
& variant
,
111 const wxString
& text
,
112 int argFlags
= 0 ) const;
114 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
116 /** This is updated so "<composed>" special value can be handled.
118 virtual void OnSetValue();
123 // -----------------------------------------------------------------------
125 /** Constants used with DoValidation() methods.
127 enum wxPGDoValidationConstants
129 /** Instead of modifying the value, show an error message.
131 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
= 0,
133 /** Modify value, but stick with the limitations.
135 wxPG_PROPERTY_VALIDATION_SATURATE
= 1,
137 /** Modify value, wrap around on overflow.
139 wxPG_PROPERTY_VALIDATION_WRAP
= 2
142 // -----------------------------------------------------------------------
144 /** @class wxIntProperty
146 Basic property with integer value.
148 Seamlessly supports 64-bit integer (wxLongLong) on overflow.
150 <b>Example how to use seamless 64-bit integer support</b>
155 wxLongLong_t value = pg->GetPropertyValueAsLongLong();
162 wxVariant variant = property->GetValue();
163 if ( variant.GetType() == "wxLongLong" )
164 value = wxLongLongFromVariant(variant);
166 value = variant.GetLong();
172 pg->SetPropertyValue(longLongVal);
178 property->SetValue(WXVARIANT(longLongVal));
182 <b>Supported special attributes:</b>
183 - "Min", "Max": Specify acceptable value range.
185 class WXDLLIMPEXP_PROPGRID wxIntProperty
: public wxPGProperty
187 WX_PG_DECLARE_PROPERTY_CLASS(wxIntProperty
)
189 wxIntProperty( const wxString
& label
= wxPG_LABEL
,
190 const wxString
& name
= wxPG_LABEL
,
192 virtual ~wxIntProperty();
194 wxIntProperty( const wxString
& label
,
195 const wxString
& name
,
196 const wxLongLong
& value
);
197 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
198 virtual bool StringToValue( wxVariant
& variant
,
199 const wxString
& text
,
200 int argFlags
= 0 ) const;
201 virtual bool ValidateValue( wxVariant
& value
,
202 wxPGValidationInfo
& validationInfo
) const;
203 virtual bool IntToValue( wxVariant
& variant
,
205 int argFlags
= 0 ) const;
206 static wxValidator
* GetClassValidator();
207 virtual wxValidator
* DoGetValidator() const;
209 /** Validation helper.
211 static bool DoValidation( const wxPGProperty
* property
,
213 wxPGValidationInfo
* pValidationInfo
,
215 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
);
220 // -----------------------------------------------------------------------
222 /** @class wxUIntProperty
224 Basic property with unsigned integer value.
225 Seamlessly supports 64-bit integer (wxULongLong) on overflow.
227 <b>Supported special attributes:</b>
228 - "Min", "Max": Specify acceptable value range.
229 - "Base": Define base. Valid constants are wxPG_BASE_OCT, wxPG_BASE_DEC,
230 wxPG_BASE_HEX and wxPG_BASE_HEXL (lowercase characters). Arbitrary bases
231 are <b>not</b> supported.
232 - "Prefix": Possible values are wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and
233 wxPG_PREFIX_DOLLAR_SIGN. Only wxPG_PREFIX_NONE works with Decimal and Octal
237 - For example how to use seamless 64-bit integer support, see wxIntProperty
238 documentation (just use wxULongLong instead of wxLongLong).
240 class WXDLLIMPEXP_PROPGRID wxUIntProperty
: public wxPGProperty
242 WX_PG_DECLARE_PROPERTY_CLASS(wxUIntProperty
)
244 wxUIntProperty( const wxString
& label
= wxPG_LABEL
,
245 const wxString
& name
= wxPG_LABEL
,
246 unsigned long value
= 0 );
247 virtual ~wxUIntProperty();
248 wxUIntProperty( const wxString
& label
,
249 const wxString
& name
,
250 const wxULongLong
& value
);
251 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
252 virtual bool StringToValue( wxVariant
& variant
,
253 const wxString
& text
,
254 int argFlags
= 0 ) const;
255 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
256 virtual bool ValidateValue( wxVariant
& value
,
257 wxPGValidationInfo
& validationInfo
) const;
258 virtual bool IntToValue( wxVariant
& variant
,
260 int argFlags
= 0 ) const;
263 wxByte m_realBase
; // translated to 8,16,etc.
269 // -----------------------------------------------------------------------
271 /** @class wxFloatProperty
273 Basic property with double-precision floating point value.
275 <b>Supported special attributes:</b>
276 - "Precision": Sets the (max) precision used when floating point value is
277 rendered as text. The default -1 means infinite precision.
279 class WXDLLIMPEXP_PROPGRID wxFloatProperty
: public wxPGProperty
281 WX_PG_DECLARE_PROPERTY_CLASS(wxFloatProperty
)
283 wxFloatProperty( const wxString
& label
= wxPG_LABEL
,
284 const wxString
& name
= wxPG_LABEL
,
285 double value
= 0.0 );
286 virtual ~wxFloatProperty();
288 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
289 virtual bool StringToValue( wxVariant
& variant
,
290 const wxString
& text
,
291 int argFlags
= 0 ) const;
292 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
293 virtual bool ValidateValue( wxVariant
& value
,
294 wxPGValidationInfo
& validationInfo
) const;
296 /** Validation helper.
298 static bool DoValidation( const wxPGProperty
* property
,
300 wxPGValidationInfo
* pValidationInfo
,
302 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
);
303 virtual wxValidator
* DoGetValidator () const;
309 // -----------------------------------------------------------------------
311 /** @class wxBoolProperty
313 Basic property with boolean value.
315 <b>Supported special attributes:</b>
316 - "UseCheckbox": Set to 1 to use check box editor instead of combo box.
317 - "UseDClickCycling": Set to 1 to cycle combo box instead showing the list.
319 class WXDLLIMPEXP_PROPGRID wxBoolProperty
: public wxPGProperty
321 WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty
)
323 wxBoolProperty( const wxString
& label
= wxPG_LABEL
,
324 const wxString
& name
= wxPG_LABEL
,
325 bool value
= false );
326 virtual ~wxBoolProperty();
328 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
329 virtual bool StringToValue( wxVariant
& variant
,
330 const wxString
& text
,
331 int argFlags
= 0 ) const;
332 virtual bool IntToValue( wxVariant
& variant
,
333 int number
, int argFlags
= 0 ) const;
334 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
337 // -----------------------------------------------------------------------
339 // If set, then selection of choices is static and should not be
340 // changed (i.e. returns NULL in GetPropertyChoices).
341 #define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
343 /** @class wxEnumProperty
345 You can derive custom properties with choices from this class. See
346 wxBaseEnumProperty for remarks.
349 - Updating private index is important. You can do this either by calling
350 SetIndex() in IntToValue, and then letting wxBaseEnumProperty::OnSetValue
351 be called (by not implementing it, or by calling super class function in
352 it) -OR- you can just call SetIndex in OnSetValue.
354 class WXDLLIMPEXP_PROPGRID wxEnumProperty
: public wxPGProperty
356 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty
)
360 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
361 const wxString
& name
= wxPG_LABEL
,
362 const wxChar
* const* labels
= NULL
,
363 const long* values
= NULL
,
365 wxEnumProperty( const wxString
& label
,
366 const wxString
& name
,
367 wxPGChoices
& choices
,
370 // Special constructor for caching choices (used by derived class)
371 wxEnumProperty( const wxString
& label
,
372 const wxString
& name
,
373 const wxChar
* const* labels
,
375 wxPGChoices
* choicesCache
,
378 wxEnumProperty( const wxString
& label
,
379 const wxString
& name
,
380 const wxArrayString
& labels
,
381 const wxArrayInt
& values
= wxArrayInt(),
384 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
385 const wxString
& name
= wxPG_LABEL
,
386 const wxArrayString
& labels
= wxArrayString(),
387 const wxArrayInt
& values
= wxArrayInt(),
391 virtual ~wxEnumProperty();
393 size_t GetItemCount() const { return m_choices
.GetCount(); }
395 virtual void OnSetValue();
396 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
397 virtual bool StringToValue( wxVariant
& variant
,
398 const wxString
& text
,
399 int argFlags
= 0 ) const;
400 virtual bool ValidateValue( wxVariant
& value
,
401 wxPGValidationInfo
& validationInfo
) const;
403 // If wxPG_FULL_VALUE is not set in flags, then the value is interpreted
404 // as index to choices list. Otherwise, it is actual value.
405 virtual bool IntToValue( wxVariant
& variant
,
407 int argFlags
= 0 ) const;
410 // Additional virtuals
412 // This must be overridden to have non-index based value
413 virtual int GetIndexForValue( int value
) const;
415 // GetChoiceSelection needs to overridden since m_index is
416 // the true index, and various property classes derived from
417 // this take advantage of it.
418 virtual int GetChoiceSelection() const { return m_index
; }
420 virtual void OnValidationFailure( wxVariant
& pendingValue
);
424 int GetIndex() const;
425 void SetIndex( int index
);
427 bool ValueFromString_( wxVariant
& value
,
428 const wxString
& text
,
429 int argFlags
) const;
430 bool ValueFromInt_( wxVariant
& value
, int intVal
, int argFlags
) const;
432 static void ResetNextIndex() { ms_nextIndex
= -2; }
435 // This is private so that classes are guaranteed to use GetIndex
436 // for up-to-date index value.
439 // Relies on ValidateValue being called always before OnSetValue
440 static int ms_nextIndex
;
443 // -----------------------------------------------------------------------
445 /** @class wxEditEnumProperty
447 wxEnumProperty with wxString value and writable combo box editor.
450 Uses int value, similar to wxEnumProperty, unless text entered by user is
451 is not in choices (in which case string value is used).
453 class WXDLLIMPEXP_PROPGRID wxEditEnumProperty
: public wxEnumProperty
455 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty
)
458 wxEditEnumProperty( const wxString
& label
,
459 const wxString
& name
,
460 const wxChar
* const* labels
,
462 const wxString
& value
);
463 wxEditEnumProperty( const wxString
& label
= wxPG_LABEL
,
464 const wxString
& name
= wxPG_LABEL
,
465 const wxArrayString
& labels
= wxArrayString(),
466 const wxArrayInt
& values
= wxArrayInt(),
467 const wxString
& value
= wxEmptyString
);
468 wxEditEnumProperty( const wxString
& label
,
469 const wxString
& name
,
470 wxPGChoices
& choices
,
471 const wxString
& value
= wxEmptyString
);
473 // Special constructor for caching choices (used by derived class)
474 wxEditEnumProperty( const wxString
& label
,
475 const wxString
& name
,
476 const wxChar
* const* labels
,
478 wxPGChoices
* choicesCache
,
479 const wxString
& value
);
481 virtual ~wxEditEnumProperty();
486 // -----------------------------------------------------------------------
488 /** @class wxFlagsProperty
490 Represents a bit set that fits in a long integer. wxBoolProperty
491 sub-properties are created for editing individual bits. Textctrl is created
492 to manually edit the flags as a text; a continous sequence of spaces,
493 commas and semicolons is considered as a flag id separator.
494 <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
495 you will need to use SetPropertyChoices - otherwise they will not get
498 class WXDLLIMPEXP_PROPGRID wxFlagsProperty
: public wxPGProperty
500 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty
)
504 wxFlagsProperty( const wxString
& label
,
505 const wxString
& name
,
506 const wxChar
* const* labels
,
507 const long* values
= NULL
,
509 wxFlagsProperty( const wxString
& label
,
510 const wxString
& name
,
511 wxPGChoices
& choices
,
514 wxFlagsProperty( const wxString
& label
= wxPG_LABEL
,
515 const wxString
& name
= wxPG_LABEL
,
516 const wxArrayString
& labels
= wxArrayString(),
517 const wxArrayInt
& values
= wxArrayInt(),
519 virtual ~wxFlagsProperty ();
521 virtual void OnSetValue();
522 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
523 virtual bool StringToValue( wxVariant
& variant
,
524 const wxString
& text
,
526 virtual wxVariant
ChildChanged( wxVariant
& thisValue
,
528 wxVariant
& childValue
) const;
529 virtual void RefreshChildren();
530 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
532 // GetChoiceSelection needs to overridden since m_choices is
533 // used and value is integer, but it is not index.
534 virtual int GetChoiceSelection() const { return wxNOT_FOUND
; }
537 size_t GetItemCount() const { return m_choices
.GetCount(); }
538 const wxString
& GetLabel( size_t ind
) const
539 { return m_choices
.GetLabel(ind
); }
542 // Used to detect if choices have been changed
543 wxPGChoicesData
* m_oldChoicesData
;
545 // Needed to properly mark changed sub-properties
548 // Converts string id to a relevant bit.
549 long IdToBit( const wxString
& id
) const;
551 // Creates children and sets value.
555 // -----------------------------------------------------------------------
557 /** @class wxPGFileDialogAdapter
560 class WXDLLIMPEXP_PROPGRID
561 wxPGFileDialogAdapter
: public wxPGEditorDialogAdapter
564 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
565 wxPGProperty
* property
);
568 // -----------------------------------------------------------------------
570 // Indicates first bit useable by derived properties.
571 #define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
573 /** @class wxFileProperty
575 Like wxLongStringProperty, but the button triggers file selector instead.
577 <b>Supported special attributes:</b>
578 - "Wildcard": Sets wildcard (see wxFileDialog for format details), "All
579 files..." is default.
580 - "ShowFullPath": Default 1. When 0, only the file name is shown (i.e. drive
581 and directory are hidden).
582 - "ShowRelativePath": If set, then the filename is shown relative to the
584 - "InitialPath": Sets the initial path of where to look for files.
585 - "DialogTitle": Sets a specific title for the dir dialog.
587 class WXDLLIMPEXP_PROPGRID wxFileProperty
: public wxPGProperty
589 friend class wxPGFileDialogAdapter
;
590 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty
)
593 wxFileProperty( const wxString
& label
= wxPG_LABEL
,
594 const wxString
& name
= wxPG_LABEL
,
595 const wxString
& value
= wxEmptyString
);
596 virtual ~wxFileProperty ();
598 virtual void OnSetValue();
599 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
600 virtual bool StringToValue( wxVariant
& variant
,
601 const wxString
& text
,
602 int argFlags
= 0 ) const;
603 virtual wxPGEditorDialogAdapter
* GetEditorDialog() const;
604 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
606 static wxValidator
* GetClassValidator();
607 virtual wxValidator
* DoGetValidator() const;
610 Returns filename to file represented by current value.
612 wxFileName
GetFileName() const;
616 wxString m_basePath
; // If set, then show path relative to it
617 wxString m_initialPath
; // If set, start the file dialog here
618 wxString m_dlgTitle
; // If set, used as title for file dialog
619 int m_indFilter
; // index to the selected filter
622 // -----------------------------------------------------------------------
624 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
627 /** @class wxPGLongStringDialogAdapter
630 class WXDLLIMPEXP_PROPGRID
631 wxPGLongStringDialogAdapter
: public wxPGEditorDialogAdapter
634 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
635 wxPGProperty
* property
);
639 /** @class wxLongStringProperty
641 Like wxStringProperty, but has a button that triggers a small text
644 class WXDLLIMPEXP_PROPGRID wxLongStringProperty
: public wxPGProperty
646 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty
)
649 wxLongStringProperty( const wxString
& label
= wxPG_LABEL
,
650 const wxString
& name
= wxPG_LABEL
,
651 const wxString
& value
= wxEmptyString
);
652 virtual ~wxLongStringProperty();
654 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
655 virtual bool StringToValue( wxVariant
& variant
,
656 const wxString
& text
,
657 int argFlags
= 0 ) const;
658 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
659 wxWindow
* primary
, wxEvent
& event
);
661 // Shows string editor dialog. Value to be edited should be read from
662 // value, and if dialog is not cancelled, it should be stored back and true
663 // should be returned if that was the case.
664 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
, wxString
& value
);
666 static bool DisplayEditorDialog( wxPGProperty
* prop
,
667 wxPropertyGrid
* propGrid
,
673 // -----------------------------------------------------------------------
676 /** @class wxDirProperty
678 Like wxLongStringProperty, but the button triggers dir selector instead.
680 <b>Supported special attributes:</b>
681 - "DialogMessage": Sets specific message in the dir selector.
683 class WXDLLIMPEXP_PROPGRID wxDirProperty
: public wxLongStringProperty
685 DECLARE_DYNAMIC_CLASS(wxDirProperty
)
687 wxDirProperty( const wxString
& name
= wxPG_LABEL
,
688 const wxString
& label
= wxPG_LABEL
,
689 const wxString
& value
= wxEmptyString
);
690 virtual ~wxDirProperty();
692 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
693 virtual wxValidator
* DoGetValidator() const;
695 virtual bool OnButtonClick ( wxPropertyGrid
* propGrid
, wxString
& value
);
698 wxString m_dlgMessage
;
701 // -----------------------------------------------------------------------
703 // wxBoolProperty specific flags
704 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
705 // DCC = Double Click Cycles
706 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
709 // -----------------------------------------------------------------------
711 /** @class wxArrayStringProperty
713 Property that manages a list of strings.
715 class WXDLLIMPEXP_PROPGRID wxArrayStringProperty
: public wxPGProperty
717 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty
)
720 wxArrayStringProperty( const wxString
& label
= wxPG_LABEL
,
721 const wxString
& name
= wxPG_LABEL
,
722 const wxArrayString
& value
= wxArrayString() );
723 virtual ~wxArrayStringProperty();
725 virtual void OnSetValue();
726 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
727 virtual bool StringToValue( wxVariant
& variant
,
728 const wxString
& text
,
729 int argFlags
= 0 ) const;
730 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
731 wxWindow
* primary
, wxEvent
& event
);
733 virtual void GenerateValueAsString();
735 // Shows string editor dialog. Value to be edited should be read from
736 // value, and if dialog is not cancelled, it should be stored back and true
737 // should be returned if that was the case.
738 virtual bool OnCustomStringEdit( wxWindow
* parent
, wxString
& value
);
741 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
,
745 // Creates wxArrayEditorDialog for string editing. Called in OnButtonClick.
746 virtual wxArrayEditorDialog
* CreateEditorDialog();
749 wxString m_display
; // Cache for displayed text.
752 // -----------------------------------------------------------------------
754 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
756 DECL PROPNAME : public wxArrayStringProperty \
758 WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
760 PROPNAME( const wxString& label = wxPG_LABEL, \
761 const wxString& name = wxPG_LABEL, \
762 const wxArrayString& value = wxArrayString() ); \
764 virtual void GenerateValueAsString(); \
765 virtual bool StringToValue( wxVariant& value, \
766 const wxString& text, int = 0 ) const; \
767 virtual bool OnEvent( wxPropertyGrid* propgrid, \
768 wxWindow* primary, wxEvent& event ); \
769 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
770 virtual wxValidator* DoGetValidator() const; \
773 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
774 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
776 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
779 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
780 wxArrayString, const wxArrayString&, \
782 PROPNAME::PROPNAME( const wxString& label, \
783 const wxString& name, \
784 const wxArrayString& value ) \
785 : wxArrayStringProperty(label,name,value) \
787 PROPNAME::GenerateValueAsString(); \
789 PROPNAME::~PROPNAME() { } \
790 void PROPNAME::GenerateValueAsString() \
792 wxChar delimChar = DELIMCHAR; \
793 if ( delimChar == wxS('"') ) \
794 wxArrayStringProperty::GenerateValueAsString(); \
796 wxPropertyGrid::ArrayStringToString(m_display, \
797 m_value.GetArrayString(), \
800 bool PROPNAME::StringToValue( wxVariant& variant, \
801 const wxString& text, int ) const \
803 wxChar delimChar = DELIMCHAR; \
804 if ( delimChar == wxS('"') ) \
805 return wxArrayStringProperty::StringToValue(variant, text, 0); \
808 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
810 WX_PG_TOKENIZER1_END() \
814 bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
815 wxWindow* primary, wxEvent& event ) \
817 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
818 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
822 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
823 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
825 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
826 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
828 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
829 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
832 wxValidator* PROPNAME::DoGetValidator () const \
836 // -----------------------------------------------------------------------
837 // wxArrayEditorDialog
838 // -----------------------------------------------------------------------
840 #define wxAEDIALOG_STYLE \
841 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
843 class WXDLLIMPEXP_PROPGRID wxArrayEditorDialog
: public wxDialog
846 wxArrayEditorDialog();
847 virtual ~wxArrayEditorDialog() { }
851 wxArrayEditorDialog( wxWindow
*parent
,
852 const wxString
& message
,
853 const wxString
& caption
,
854 long style
= wxAEDIALOG_STYLE
,
855 const wxPoint
& pos
= wxDefaultPosition
,
856 const wxSize
& sz
= wxDefaultSize
);
858 bool Create( wxWindow
*parent
,
859 const wxString
& message
,
860 const wxString
& caption
,
861 long style
= wxAEDIALOG_STYLE
,
862 const wxPoint
& pos
= wxDefaultPosition
,
863 const wxSize
& sz
= wxDefaultSize
);
865 /** Set value modified by dialog.
867 virtual void SetDialogValue( const wxVariant
& WXUNUSED(value
) )
869 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
872 /** Return value modified by dialog.
874 virtual wxVariant
GetDialogValue() const
876 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
880 /** Override to return wxValidator to be used with the wxTextCtrl
881 in dialog. Note that the validator is used in the standard
882 wx way, ie. it immediately prevents user from entering invalid
886 Dialog frees the validator.
888 virtual wxValidator
* GetTextCtrlValidator() const
893 // Returns true if array was actually modified
894 bool IsModified() const { return m_modified
; }
896 //const wxArrayString& GetStrings() const { return m_array; }
898 // implementation from now on
899 void OnUpdateClick(wxCommandEvent
& event
);
900 void OnAddClick(wxCommandEvent
& event
);
901 void OnDeleteClick(wxCommandEvent
& event
);
902 void OnListBoxClick(wxCommandEvent
& event
);
903 void OnUpClick(wxCommandEvent
& event
);
904 void OnDownClick(wxCommandEvent
& event
);
905 //void OnCustomEditClick(wxCommandEvent& event);
906 void OnIdle(wxIdleEvent
& event
);
909 wxTextCtrl
* m_edValue
;
910 wxListBox
* m_lbStrings
;
912 wxButton
* m_butAdd
; // Button pointers
913 wxButton
* m_butCustom
; // required for disabling/enabling changing.
914 wxButton
* m_butUpdate
;
915 wxButton
* m_butRemove
;
919 //wxArrayString m_array;
921 const wxChar
* m_custBtText
;
922 //wxArrayStringPropertyClass* m_pCallingClass;
926 unsigned char m_curFocus
;
928 // These must be overridden - must return true on success.
929 virtual wxString
ArrayGet( size_t index
) = 0;
930 virtual size_t ArrayGetCount() = 0;
931 virtual bool ArrayInsert( const wxString
& str
, int index
) = 0;
932 virtual bool ArraySet( size_t index
, const wxString
& str
) = 0;
933 virtual void ArrayRemoveAt( int index
) = 0;
934 virtual void ArraySwap( size_t first
, size_t second
) = 0;
937 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog
)
938 DECLARE_EVENT_TABLE()
941 // -----------------------------------------------------------------------
942 // wxPGArrayStringEditorDialog
943 // -----------------------------------------------------------------------
945 class WXDLLIMPEXP_PROPGRID
946 wxPGArrayStringEditorDialog
: public wxArrayEditorDialog
949 wxPGArrayStringEditorDialog();
950 virtual ~wxPGArrayStringEditorDialog() { }
954 virtual void SetDialogValue( const wxVariant
& value
)
956 m_array
= value
.GetArrayString();
959 virtual wxVariant
GetDialogValue() const
964 void SetCustomButton( const wxChar
* custBtText
, wxArrayStringProperty
* pcc
)
966 m_custBtText
= custBtText
;
967 m_pCallingClass
= pcc
;
970 void OnCustomEditClick(wxCommandEvent
& event
);
973 wxArrayString m_array
;
975 wxArrayStringProperty
* m_pCallingClass
;
977 virtual wxString
ArrayGet( size_t index
);
978 virtual size_t ArrayGetCount();
979 virtual bool ArrayInsert( const wxString
& str
, int index
);
980 virtual bool ArraySet( size_t index
, const wxString
& str
);
981 virtual void ArrayRemoveAt( int index
);
982 virtual void ArraySwap( size_t first
, size_t second
);
985 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog
)
986 DECLARE_EVENT_TABLE()
989 // -----------------------------------------------------------------------
991 #endif // wxUSE_PROPGRID
993 #endif // _WX_PROPGRID_PROPS_H_