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 // -----------------------------------------------------------------------
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
;
87 // -----------------------------------------------------------------------
89 // -----------------------------------------------------------------------
91 #define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
93 /** @class wxStringProperty
95 Basic property with string value.
97 <b>Supported special attributes:</b>
98 - "Password": set to 1 inorder to enable wxTE_PASSWORD on the editor.
101 - If value "<composed>" is set, then actual value is formed (or composed)
102 from values of child properties.
104 class WXDLLIMPEXP_PROPGRID wxStringProperty
: public wxPGProperty
106 WX_PG_DECLARE_PROPERTY_CLASS(wxStringProperty
)
108 wxStringProperty( const wxString
& label
= wxPG_LABEL
,
109 const wxString
& name
= wxPG_LABEL
,
110 const wxString
& value
= wxEmptyString
);
111 virtual ~wxStringProperty();
113 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
114 virtual bool StringToValue( wxVariant
& variant
,
115 const wxString
& text
,
116 int argFlags
= 0 ) const;
118 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
120 /** This is updated so "<composed>" special value can be handled.
122 virtual void OnSetValue();
127 // -----------------------------------------------------------------------
130 /** Constants used with DoValidation() methods.
134 /** Instead of modifying the value, show an error message.
136 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
= 0,
138 /** Modify value, but stick with the limitations.
140 wxPG_PROPERTY_VALIDATION_SATURATE
= 1,
142 /** Modify value, wrap around on overflow.
144 wxPG_PROPERTY_VALIDATION_WRAP
= 2
148 // -----------------------------------------------------------------------
150 /** @class wxIntProperty
152 Basic property with integer value.
154 Seamlessly supports 64-bit integer (wxLongLong) on overflow.
156 <b>Example how to use seamless 64-bit integer support</b>
161 wxLongLong_t value = pg->GetPropertyValueAsLongLong();
168 wxVariant variant = property->GetValue();
169 if ( variant.GetType() == "wxLongLong" )
170 value = wxLongLongFromVariant(variant);
172 value = variant.GetLong();
178 pg->SetPropertyValue(longLongVal);
184 property->SetValue(WXVARIANT(longLongVal));
188 <b>Supported special attributes:</b>
189 - "Min", "Max": Specify acceptable value range.
191 class WXDLLIMPEXP_PROPGRID wxIntProperty
: public wxPGProperty
193 WX_PG_DECLARE_PROPERTY_CLASS(wxIntProperty
)
195 wxIntProperty( const wxString
& label
= wxPG_LABEL
,
196 const wxString
& name
= wxPG_LABEL
,
198 virtual ~wxIntProperty();
200 wxIntProperty( const wxString
& label
,
201 const wxString
& name
,
202 const wxLongLong
& value
);
203 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
204 virtual bool StringToValue( wxVariant
& variant
,
205 const wxString
& text
,
206 int argFlags
= 0 ) const;
207 virtual bool ValidateValue( wxVariant
& value
,
208 wxPGValidationInfo
& validationInfo
) const;
209 virtual bool IntToValue( wxVariant
& variant
,
211 int argFlags
= 0 ) const;
212 static wxValidator
* GetClassValidator();
213 virtual wxValidator
* DoGetValidator() const;
215 /** Validation helper.
217 static bool DoValidation( const wxPGProperty
* property
,
219 wxPGValidationInfo
* pValidationInfo
,
221 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
);
226 // -----------------------------------------------------------------------
228 /** @class wxUIntProperty
230 Basic property with unsigned integer value.
231 Seamlessly supports 64-bit integer (wxULongLong) on overflow.
233 <b>Supported special attributes:</b>
234 - "Min", "Max": Specify acceptable value range.
235 - "Base": Define base. Valid constants are wxPG_BASE_OCT, wxPG_BASE_DEC,
236 wxPG_BASE_HEX and wxPG_BASE_HEXL (lowercase characters). Arbitrary bases
237 are <b>not</b> supported.
238 - "Prefix": Possible values are wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and
239 wxPG_PREFIX_DOLLAR_SIGN. Only wxPG_PREFIX_NONE works with Decimal and Octal
243 - For example how to use seamless 64-bit integer support, see wxIntProperty
244 documentation (just use wxULongLong instead of wxLongLong).
246 class WXDLLIMPEXP_PROPGRID wxUIntProperty
: public wxPGProperty
248 WX_PG_DECLARE_PROPERTY_CLASS(wxUIntProperty
)
250 wxUIntProperty( const wxString
& label
= wxPG_LABEL
,
251 const wxString
& name
= wxPG_LABEL
,
252 unsigned long value
= 0 );
253 virtual ~wxUIntProperty();
254 wxUIntProperty( const wxString
& label
,
255 const wxString
& name
,
256 const wxULongLong
& value
);
257 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
258 virtual bool StringToValue( wxVariant
& variant
,
259 const wxString
& text
,
260 int argFlags
= 0 ) const;
261 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
262 virtual bool ValidateValue( wxVariant
& value
,
263 wxPGValidationInfo
& validationInfo
) const;
264 virtual bool IntToValue( wxVariant
& variant
,
266 int argFlags
= 0 ) const;
269 wxByte m_realBase
; // translated to 8,16,etc.
275 // -----------------------------------------------------------------------
277 /** @class wxFloatProperty
279 Basic property with double-precision floating point value.
281 <b>Supported special attributes:</b>
282 - "Precision": Sets the (max) precision used when floating point value is
283 rendered as text. The default -1 means infinite precision.
285 class WXDLLIMPEXP_PROPGRID wxFloatProperty
: public wxPGProperty
287 WX_PG_DECLARE_PROPERTY_CLASS(wxFloatProperty
)
289 wxFloatProperty( const wxString
& label
= wxPG_LABEL
,
290 const wxString
& name
= wxPG_LABEL
,
291 double value
= 0.0 );
292 virtual ~wxFloatProperty();
294 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
295 virtual bool StringToValue( wxVariant
& variant
,
296 const wxString
& text
,
297 int argFlags
= 0 ) const;
298 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
299 virtual bool ValidateValue( wxVariant
& value
,
300 wxPGValidationInfo
& validationInfo
) const;
302 /** Validation helper.
304 static bool DoValidation( const wxPGProperty
* property
,
306 wxPGValidationInfo
* pValidationInfo
,
308 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
);
309 virtual wxValidator
* DoGetValidator () const;
315 // -----------------------------------------------------------------------
317 // Exclude class from wxPython bindings
320 /** @class wxBoolProperty
322 Basic property with boolean value.
324 <b>Supported special attributes:</b>
325 - "UseCheckbox": Set to 1 to use check box editor instead of combo box.
326 - "UseDClickCycling": Set to 1 to cycle combo box instead showing the list.
328 class WXDLLIMPEXP_PROPGRID wxBoolProperty
: public wxPGProperty
330 WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty
)
332 wxBoolProperty( const wxString
& label
= wxPG_LABEL
,
333 const wxString
& name
= wxPG_LABEL
,
334 bool value
= false );
335 virtual ~wxBoolProperty();
337 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
338 virtual bool StringToValue( wxVariant
& variant
,
339 const wxString
& text
,
340 int argFlags
= 0 ) const;
341 virtual bool IntToValue( wxVariant
& variant
,
342 int number
, int argFlags
= 0 ) const;
343 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
348 // -----------------------------------------------------------------------
350 // If set, then selection of choices is static and should not be
351 // changed (i.e. returns NULL in GetPropertyChoices).
352 #define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
354 /** @class wxEnumProperty
356 You can derive custom properties with choices from this class. See
357 wxBaseEnumProperty for remarks.
360 - Updating private index is important. You can do this either by calling
361 SetIndex() in IntToValue, and then letting wxBaseEnumProperty::OnSetValue
362 be called (by not implementing it, or by calling super class function in
363 it) -OR- you can just call SetIndex in OnSetValue.
365 class WXDLLIMPEXP_PROPGRID wxEnumProperty
: public wxPGProperty
367 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty
)
371 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
372 const wxString
& name
= wxPG_LABEL
,
373 const wxChar
** labels
= NULL
,
374 const long* values
= NULL
,
376 wxEnumProperty( const wxString
& label
,
377 const wxString
& name
,
378 wxPGChoices
& choices
,
381 // Special constructor for caching choices (used by derived class)
382 wxEnumProperty( const wxString
& label
,
383 const wxString
& name
,
384 const wxChar
** labels
,
386 wxPGChoices
* choicesCache
,
389 wxEnumProperty( const wxString
& label
,
390 const wxString
& name
,
391 const wxArrayString
& labels
,
392 const wxArrayInt
& values
= wxArrayInt(),
395 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
396 const wxString
& name
= wxPG_LABEL
,
397 const wxArrayString
& labels
= wxArrayString(),
398 const wxArrayInt
& values
= wxArrayInt(),
402 virtual ~wxEnumProperty();
404 size_t GetItemCount() const { return m_choices
.GetCount(); }
406 virtual void OnSetValue();
407 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
408 virtual bool StringToValue( wxVariant
& variant
,
409 const wxString
& text
,
410 int argFlags
= 0 ) const;
411 virtual bool ValidateValue( wxVariant
& value
,
412 wxPGValidationInfo
& validationInfo
) const;
414 // If wxPG_FULL_VALUE is not set in flags, then the value is interpreted
415 // as index to choices list. Otherwise, it is actual value.
416 virtual bool IntToValue( wxVariant
& variant
,
418 int argFlags
= 0 ) const;
421 // Additional virtuals
423 // This must be overridden to have non-index based value
424 virtual int GetIndexForValue( int value
) const;
426 // GetChoiceSelection needs to overridden since m_index is
427 // the true index, and various property classes derived from
428 // this take advantage of it.
429 virtual int GetChoiceSelection() const { return m_index
; }
431 virtual void OnValidationFailure( wxVariant
& pendingValue
);
435 int GetIndex() const;
436 void SetIndex( int index
);
438 bool ValueFromString_( wxVariant
& value
,
439 const wxString
& text
,
440 int argFlags
) const;
441 bool ValueFromInt_( wxVariant
& value
, int intVal
, int argFlags
) const;
443 static void ResetNextIndex() { ms_nextIndex
= -2; }
446 // This is private so that classes are guaranteed to use GetIndex
447 // for up-to-date index value.
450 // Relies on ValidateValue being called always before OnSetValue
451 static int ms_nextIndex
;
454 // -----------------------------------------------------------------------
456 /** @class wxEditEnumProperty
458 wxEnumProperty with wxString value and writable combo box editor.
461 Uses int value, similar to wxEnumProperty, unless text entered by user is
462 is not in choices (in which case string value is used).
464 class WXDLLIMPEXP_PROPGRID wxEditEnumProperty
: public wxEnumProperty
466 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty
)
469 wxEditEnumProperty( const wxString
& label
,
470 const wxString
& name
,
471 const wxChar
** labels
,
473 const wxString
& value
);
474 wxEditEnumProperty( const wxString
& label
= wxPG_LABEL
,
475 const wxString
& name
= wxPG_LABEL
,
476 const wxArrayString
& labels
= wxArrayString(),
477 const wxArrayInt
& values
= wxArrayInt(),
478 const wxString
& value
= wxEmptyString
);
479 wxEditEnumProperty( const wxString
& label
,
480 const wxString
& name
,
481 wxPGChoices
& choices
,
482 const wxString
& value
= wxEmptyString
);
484 // Special constructor for caching choices (used by derived class)
485 wxEditEnumProperty( const wxString
& label
,
486 const wxString
& name
,
487 const wxChar
** labels
,
489 wxPGChoices
* choicesCache
,
490 const wxString
& value
);
492 virtual ~wxEditEnumProperty();
497 // -----------------------------------------------------------------------
499 /** @class wxFlagsProperty
501 Represents a bit set that fits in a long integer. wxBoolProperty
502 sub-properties are created for editing individual bits. Textctrl is created
503 to manually edit the flags as a text; a continous sequence of spaces,
504 commas and semicolons is considered as a flag id separator.
505 <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
506 you will need to use SetPropertyChoices - otherwise they will not get
509 class WXDLLIMPEXP_PROPGRID wxFlagsProperty
: public wxPGProperty
511 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty
)
515 wxFlagsProperty( const wxString
& label
,
516 const wxString
& name
,
517 const wxChar
** labels
,
518 const long* values
= NULL
,
520 wxFlagsProperty( const wxString
& label
,
521 const wxString
& name
,
522 wxPGChoices
& choices
,
525 wxFlagsProperty( const wxString
& label
= wxPG_LABEL
,
526 const wxString
& name
= wxPG_LABEL
,
527 const wxArrayString
& labels
= wxArrayString(),
528 const wxArrayInt
& values
= wxArrayInt(),
530 virtual ~wxFlagsProperty ();
532 virtual void OnSetValue();
533 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
534 virtual bool StringToValue( wxVariant
& variant
,
535 const wxString
& text
,
537 virtual void ChildChanged( wxVariant
& thisValue
,
539 wxVariant
& childValue
) const;
540 virtual void RefreshChildren();
541 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
543 // GetChoiceSelection needs to overridden since m_choices is
544 // used and value is integer, but it is not index.
545 virtual int GetChoiceSelection() const { return wxNOT_FOUND
; }
548 size_t GetItemCount() const { return m_choices
.GetCount(); }
549 const wxString
& GetLabel( size_t ind
) const
550 { return m_choices
.GetLabel(ind
); }
553 // Used to detect if choices have been changed
554 wxPGChoicesData
* m_oldChoicesData
;
556 // Needed to properly mark changed sub-properties
559 // Converts string id to a relevant bit.
560 long IdToBit( const wxString
& id
) const;
562 // Creates children and sets value.
566 // -----------------------------------------------------------------------
568 /** @class wxPGFileDialogAdapter
571 class WXDLLIMPEXP_PROPGRID
572 wxPGFileDialogAdapter
: public wxPGEditorDialogAdapter
575 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
576 wxPGProperty
* property
);
579 // -----------------------------------------------------------------------
581 // Indicates first bit useable by derived properties.
582 #define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
584 /** @class wxFileProperty
586 Like wxLongStringProperty, but the button triggers file selector instead.
588 <b>Supported special attributes:</b>
589 - "Wildcard": Sets wildcard (see wxFileDialog for format details), "All
590 files..." is default.
591 - "ShowFullPath": Default 1. When 0, only the file name is shown (i.e. drive
592 and directory are hidden).
593 - "ShowRelativePath": If set, then the filename is shown relative to the
595 - "InitialPath": Sets the initial path of where to look for files.
596 - "DialogTitle": Sets a specific title for the dir dialog.
598 class WXDLLIMPEXP_PROPGRID wxFileProperty
: public wxPGProperty
600 friend class wxPGFileDialogAdapter
;
601 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty
)
604 wxFileProperty( const wxString
& label
= wxPG_LABEL
,
605 const wxString
& name
= wxPG_LABEL
,
606 const wxString
& value
= wxEmptyString
);
607 virtual ~wxFileProperty ();
609 virtual void OnSetValue();
610 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
611 virtual bool StringToValue( wxVariant
& variant
,
612 const wxString
& text
,
613 int argFlags
= 0 ) const;
614 virtual wxPGEditorDialogAdapter
* GetEditorDialog() const;
615 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
617 static wxValidator
* GetClassValidator();
618 virtual wxValidator
* DoGetValidator() const;
621 Returns filename to file represented by current value.
623 wxFileName
GetFileName() const;
627 wxString m_basePath
; // If set, then show path relative to it
628 wxString m_initialPath
; // If set, start the file dialog here
629 wxString m_dlgTitle
; // If set, used as title for file dialog
630 int m_indFilter
; // index to the selected filter
633 // -----------------------------------------------------------------------
635 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
638 /** @class wxPGLongStringDialogAdapter
641 class WXDLLIMPEXP_PROPGRID
642 wxPGLongStringDialogAdapter
: public wxPGEditorDialogAdapter
645 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
646 wxPGProperty
* property
);
650 /** @class wxLongStringProperty
652 Like wxStringProperty, but has a button that triggers a small text
655 class WXDLLIMPEXP_PROPGRID wxLongStringProperty
: public wxPGProperty
657 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty
)
660 wxLongStringProperty( const wxString
& label
= wxPG_LABEL
,
661 const wxString
& name
= wxPG_LABEL
,
662 const wxString
& value
= wxEmptyString
);
663 virtual ~wxLongStringProperty();
665 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
666 virtual bool StringToValue( wxVariant
& variant
,
667 const wxString
& text
,
668 int argFlags
= 0 ) const;
669 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
670 wxWindow
* primary
, wxEvent
& event
);
672 // Shows string editor dialog. Value to be edited should be read from
673 // value, and if dialog is not cancelled, it should be stored back and true
674 // should be returned if that was the case.
675 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
, wxString
& value
);
677 static bool DisplayEditorDialog( wxPGProperty
* prop
,
678 wxPropertyGrid
* propGrid
,
684 // -----------------------------------------------------------------------
687 // Exclude class from wxPython bindings
690 /** @class wxDirProperty
692 Like wxLongStringProperty, but the button triggers dir selector instead.
694 <b>Supported special attributes:</b>
695 - "DialogMessage": Sets specific message in the dir selector.
697 class WXDLLIMPEXP_PROPGRID wxDirProperty
: public wxLongStringProperty
700 DECLARE_DYNAMIC_CLASS(wxDirProperty
)
703 wxDirProperty( const wxString
& name
= wxPG_LABEL
,
704 const wxString
& label
= wxPG_LABEL
,
705 const wxString
& value
= wxEmptyString
);
706 virtual ~wxDirProperty();
708 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
709 virtual wxValidator
* DoGetValidator() const;
711 virtual bool OnButtonClick ( wxPropertyGrid
* propGrid
, wxString
& value
);
714 wxString m_dlgMessage
;
719 // -----------------------------------------------------------------------
721 // wxBoolProperty specific flags
722 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
723 // DCC = Double Click Cycles
724 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
727 // -----------------------------------------------------------------------
729 /** @class wxArrayStringProperty
731 Property that manages a list of strings.
733 class WXDLLIMPEXP_PROPGRID wxArrayStringProperty
: public wxPGProperty
735 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty
)
738 wxArrayStringProperty( const wxString
& label
= wxPG_LABEL
,
739 const wxString
& name
= wxPG_LABEL
,
740 const wxArrayString
& value
= wxArrayString() );
741 virtual ~wxArrayStringProperty();
743 virtual void OnSetValue();
744 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
745 virtual bool StringToValue( wxVariant
& variant
,
746 const wxString
& text
,
747 int argFlags
= 0 ) const;
748 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
749 wxWindow
* primary
, wxEvent
& event
);
751 virtual void GenerateValueAsString();
753 // Shows string editor dialog. Value to be edited should be read from
754 // value, and if dialog is not cancelled, it should be stored back and true
755 // should be returned if that was the case.
756 virtual bool OnCustomStringEdit( wxWindow
* parent
, wxString
& value
);
759 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
,
764 // Creates wxArrayEditorDialog for string editing. Called in OnButtonClick.
765 virtual wxArrayEditorDialog
* CreateEditorDialog();
769 wxString m_display
; // Cache for displayed text.
772 // -----------------------------------------------------------------------
774 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
776 DECL PROPNAME : public wxArrayStringProperty \
778 WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
780 PROPNAME( const wxString& label = wxPG_LABEL, \
781 const wxString& name = wxPG_LABEL, \
782 const wxArrayString& value = wxArrayString() ); \
784 virtual void GenerateValueAsString(); \
785 virtual bool StringToValue( wxVariant& value, \
786 const wxString& text, int = 0 ) const; \
787 virtual bool OnEvent( wxPropertyGrid* propgrid, \
788 wxWindow* primary, wxEvent& event ); \
789 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
790 virtual wxValidator* DoGetValidator() const; \
793 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
794 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
796 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
799 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
800 wxArrayString, const wxArrayString&, \
802 PROPNAME::PROPNAME( const wxString& label, \
803 const wxString& name, \
804 const wxArrayString& value ) \
805 : wxArrayStringProperty(label,name,value) \
807 PROPNAME::GenerateValueAsString(); \
809 PROPNAME::~PROPNAME() { } \
810 void PROPNAME::GenerateValueAsString() \
812 wxChar delimChar = DELIMCHAR; \
813 if ( delimChar == wxS('"') ) \
814 wxArrayStringProperty::GenerateValueAsString(); \
816 wxPropertyGrid::ArrayStringToString(m_display, \
817 m_value.GetArrayString(), \
820 bool PROPNAME::StringToValue( wxVariant& variant, \
821 const wxString& text, int ) const \
823 wxChar delimChar = DELIMCHAR; \
824 if ( delimChar == wxS('"') ) \
825 return wxArrayStringProperty::StringToValue(variant, text, 0); \
828 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
830 WX_PG_TOKENIZER1_END() \
834 bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
835 wxWindow* primary, wxEvent& event ) \
837 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
838 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
842 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
843 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
845 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
846 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
848 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
849 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
852 wxValidator* PROPNAME::DoGetValidator () const \
856 // -----------------------------------------------------------------------
857 // wxArrayEditorDialog
858 // -----------------------------------------------------------------------
860 #define wxAEDIALOG_STYLE \
861 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
863 class WXDLLIMPEXP_PROPGRID wxArrayEditorDialog
: public wxDialog
866 wxArrayEditorDialog();
867 virtual ~wxArrayEditorDialog() { }
871 wxArrayEditorDialog( wxWindow
*parent
,
872 const wxString
& message
,
873 const wxString
& caption
,
874 long style
= wxAEDIALOG_STYLE
,
875 const wxPoint
& pos
= wxDefaultPosition
,
876 const wxSize
& sz
= wxDefaultSize
);
878 bool Create( wxWindow
*parent
,
879 const wxString
& message
,
880 const wxString
& caption
,
881 long style
= wxAEDIALOG_STYLE
,
882 const wxPoint
& pos
= wxDefaultPosition
,
883 const wxSize
& sz
= wxDefaultSize
);
885 /** Set value modified by dialog.
887 virtual void SetDialogValue( const wxVariant
& WXUNUSED(value
) )
889 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
892 /** Return value modified by dialog.
894 virtual wxVariant
GetDialogValue() const
896 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
900 /** Override to return wxValidator to be used with the wxTextCtrl
901 in dialog. Note that the validator is used in the standard
902 wx way, ie. it immediately prevents user from entering invalid
906 Dialog frees the validator.
908 virtual wxValidator
* GetTextCtrlValidator() const
913 // Returns true if array was actually modified
914 bool IsModified() const { return m_modified
; }
916 //const wxArrayString& GetStrings() const { return m_array; }
918 // implementation from now on
919 void OnUpdateClick(wxCommandEvent
& event
);
920 void OnAddClick(wxCommandEvent
& event
);
921 void OnDeleteClick(wxCommandEvent
& event
);
922 void OnListBoxClick(wxCommandEvent
& event
);
923 void OnUpClick(wxCommandEvent
& event
);
924 void OnDownClick(wxCommandEvent
& event
);
925 //void OnCustomEditClick(wxCommandEvent& event);
926 void OnIdle(wxIdleEvent
& event
);
929 wxTextCtrl
* m_edValue
;
930 wxListBox
* m_lbStrings
;
932 wxButton
* m_butAdd
; // Button pointers
933 wxButton
* m_butCustom
; // required for disabling/enabling changing.
934 wxButton
* m_butUpdate
;
935 wxButton
* m_butRemove
;
939 //wxArrayString m_array;
941 const wxChar
* m_custBtText
;
942 //wxArrayStringPropertyClass* m_pCallingClass;
946 unsigned char m_curFocus
;
948 // These must be overridden - must return true on success.
949 virtual wxString
ArrayGet( size_t index
) = 0;
950 virtual size_t ArrayGetCount() = 0;
951 virtual bool ArrayInsert( const wxString
& str
, int index
) = 0;
952 virtual bool ArraySet( size_t index
, const wxString
& str
) = 0;
953 virtual void ArrayRemoveAt( int index
) = 0;
954 virtual void ArraySwap( size_t first
, size_t second
) = 0;
958 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog
)
959 DECLARE_EVENT_TABLE()
963 // -----------------------------------------------------------------------
964 // wxPGArrayStringEditorDialog
965 // -----------------------------------------------------------------------
967 class WXDLLIMPEXP_PROPGRID
968 wxPGArrayStringEditorDialog
: public wxArrayEditorDialog
971 wxPGArrayStringEditorDialog();
972 virtual ~wxPGArrayStringEditorDialog() { }
976 virtual void SetDialogValue( const wxVariant
& value
)
978 m_array
= value
.GetArrayString();
981 virtual wxVariant
GetDialogValue() const
986 void SetCustomButton( const wxChar
* custBtText
, wxArrayStringProperty
* pcc
)
988 m_custBtText
= custBtText
;
989 m_pCallingClass
= pcc
;
992 void OnCustomEditClick(wxCommandEvent
& event
);
995 wxArrayString m_array
;
997 wxArrayStringProperty
* m_pCallingClass
;
999 virtual wxString
ArrayGet( size_t index
);
1000 virtual size_t ArrayGetCount();
1001 virtual bool ArrayInsert( const wxString
& str
, int index
);
1002 virtual bool ArraySet( size_t index
, const wxString
& str
);
1003 virtual void ArrayRemoveAt( int index
);
1004 virtual void ArraySwap( size_t first
, size_t second
);
1008 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog
)
1009 DECLARE_EVENT_TABLE()
1013 // -----------------------------------------------------------------------
1015 #endif // wxUSE_PROPGRID
1017 #endif // _WX_PROPGRID_PROPS_H_