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 // -----------------------------------------------------------------------
26 // Property class implementation helper macros.
29 #define WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME, UPCLASS, T, T_AS_ARG, EDITOR) \
30 IMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS) \
31 WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME, T, EDITOR)
33 // -----------------------------------------------------------------------
36 // These macros help creating DoGetValidator
37 #define WX_PG_DOGETVALIDATOR_ENTRY() \
38 static wxValidator* s_ptr = (wxValidator*) NULL; \
39 if ( s_ptr ) return s_ptr;
41 // Common function exit
42 #define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
44 wxPGGlobalVars->m_arrValidators.push_back( VALIDATOR ); \
47 // -----------------------------------------------------------------------
51 #include "wx/textctrl.h"
53 /** @class wxPGInDialogValidator
55 Creates and manages a temporary wxTextCtrl for validation purposes.
56 Uses wxPropertyGrid's current editor, if available.
58 class WXDLLIMPEXP_PROPGRID wxPGInDialogValidator
61 wxPGInDialogValidator()
66 ~wxPGInDialogValidator()
69 m_textCtrl
->Destroy();
72 bool DoValidate( wxPropertyGrid
* propGrid
,
73 wxValidator
* validator
,
74 const wxString
& value
);
77 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 // -----------------------------------------------------------------------
126 /** Constants used with DoValidation() methods.
130 /** Instead of modifying the value, show an error message.
132 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE
= 0,
134 /** Modify value, but stick with the limitations.
136 wxPG_PROPERTY_VALIDATION_SATURATE
= 1,
138 /** Modify value, wrap around on overflow.
140 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
);
308 virtual wxValidator
* DoGetValidator () const;
311 // -----------------------------------------------------------------------
313 // Exclude class from wxPython bindings
316 /** @class wxBoolProperty
318 Basic property with boolean value.
320 <b>Supported special attributes:</b>
321 - "UseCheckbox": Set to 1 to use check box editor instead of combo box.
322 - "UseDClickCycling": Set to 1 to cycle combo box instead showing the list.
324 class WXDLLIMPEXP_PROPGRID wxBoolProperty
: public wxPGProperty
326 WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty
)
328 wxBoolProperty( const wxString
& label
= wxPG_LABEL
,
329 const wxString
& name
= wxPG_LABEL
,
330 bool value
= false );
331 virtual ~wxBoolProperty();
333 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
334 virtual bool StringToValue( wxVariant
& variant
,
335 const wxString
& text
,
336 int argFlags
= 0 ) const;
337 virtual bool IntToValue( wxVariant
& variant
,
338 int number
, int argFlags
= 0 ) const;
339 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
344 // -----------------------------------------------------------------------
346 // If set, then selection of choices is static and should not be
347 // changed (i.e. returns NULL in GetPropertyChoices).
348 #define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
350 /** @class wxEnumProperty
352 You can derive custom properties with choices from this class. See
353 wxBaseEnumProperty for remarks.
356 - Updating private index is important. You can do this either by calling
357 SetIndex() in IntToValue, and then letting wxBaseEnumProperty::OnSetValue
358 be called (by not implementing it, or by calling super class function in
359 it) -OR- you can just call SetIndex in OnSetValue.
361 class WXDLLIMPEXP_PROPGRID wxEnumProperty
: public wxPGProperty
363 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty
)
367 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
368 const wxString
& name
= wxPG_LABEL
,
369 const wxChar
** labels
= NULL
,
370 const long* values
= NULL
,
372 wxEnumProperty( const wxString
& label
,
373 const wxString
& name
,
374 wxPGChoices
& choices
,
377 // Special constructor for caching choices (used by derived class)
378 wxEnumProperty( const wxString
& label
,
379 const wxString
& name
,
380 const wxChar
** labels
,
382 wxPGChoices
* choicesCache
,
385 wxEnumProperty( const wxString
& label
,
386 const wxString
& name
,
387 const wxArrayString
& labels
,
388 const wxArrayInt
& values
= wxArrayInt(),
391 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
392 const wxString
& name
= wxPG_LABEL
,
393 const wxArrayString
& labels
= wxArrayString(),
394 const wxArrayInt
& values
= wxArrayInt(),
398 virtual ~wxEnumProperty();
400 size_t GetItemCount() const { return m_choices
.GetCount(); }
402 virtual void OnSetValue();
403 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
404 virtual bool StringToValue( wxVariant
& variant
,
405 const wxString
& text
,
406 int argFlags
= 0 ) const;
407 virtual bool ValidateValue( wxVariant
& value
,
408 wxPGValidationInfo
& validationInfo
) const;
410 // If wxPG_FULL_VALUE is not set in flags, then the value is interpreted
411 // as index to choices list. Otherwise, it is actual value.
412 virtual bool IntToValue( wxVariant
& variant
,
414 int argFlags
= 0 ) const;
417 // Additional virtuals
419 // This must be overridden to have non-index based value
420 virtual int GetIndexForValue( int value
) const;
422 // GetChoiceSelection needs to overridden since m_index is
423 // the true index, and various property classes derived from
424 // this take advantage of it.
425 virtual int GetChoiceSelection() const { return m_index
; }
429 int GetIndex() const;
430 void SetIndex( int index
);
432 bool ValueFromString_( wxVariant
& value
,
433 const wxString
& text
,
434 int argFlags
) const;
435 bool ValueFromInt_( wxVariant
& value
, int intVal
, int argFlags
) const;
437 static void ResetNextIndex() { ms_nextIndex
= -2; }
440 // This is private so that classes are guaranteed to use GetIndex
441 // for up-to-date index value.
444 // Relies on ValidateValue being called always before OnSetValue
445 static int ms_nextIndex
;
448 // -----------------------------------------------------------------------
450 /** @class wxEditEnumProperty
452 wxEnumProperty with wxString value and writable combo box editor.
455 Uses int value, similar to wxEnumProperty, unless text entered by user is
456 is not in choices (in which case string value is used).
458 class WXDLLIMPEXP_PROPGRID wxEditEnumProperty
: public wxEnumProperty
460 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty
)
463 wxEditEnumProperty( const wxString
& label
,
464 const wxString
& name
,
465 const wxChar
** labels
,
467 const wxString
& value
);
468 wxEditEnumProperty( const wxString
& label
= wxPG_LABEL
,
469 const wxString
& name
= wxPG_LABEL
,
470 const wxArrayString
& labels
= wxArrayString(),
471 const wxArrayInt
& values
= wxArrayInt(),
472 const wxString
& value
= wxEmptyString
);
473 wxEditEnumProperty( const wxString
& label
,
474 const wxString
& name
,
475 wxPGChoices
& choices
,
476 const wxString
& value
= wxEmptyString
);
478 // Special constructor for caching choices (used by derived class)
479 wxEditEnumProperty( const wxString
& label
,
480 const wxString
& name
,
481 const wxChar
** labels
,
483 wxPGChoices
* choicesCache
,
484 const wxString
& value
);
486 virtual ~wxEditEnumProperty();
491 // -----------------------------------------------------------------------
493 /** @class wxFlagsProperty
495 Represents a bit set that fits in a long integer. wxBoolProperty
496 sub-properties are created for editing individual bits. Textctrl is created
497 to manually edit the flags as a text; a continous sequence of spaces,
498 commas and semicolons is considered as a flag id separator.
499 <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
500 you will need to use SetPropertyChoices - otherwise they will not get
503 class WXDLLIMPEXP_PROPGRID wxFlagsProperty
: public wxPGProperty
505 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty
)
509 wxFlagsProperty( const wxString
& label
,
510 const wxString
& name
,
511 const wxChar
** labels
,
512 const long* values
= NULL
,
514 wxFlagsProperty( const wxString
& label
,
515 const wxString
& name
,
516 wxPGChoices
& choices
,
519 wxFlagsProperty( const wxString
& label
= wxPG_LABEL
,
520 const wxString
& name
= wxPG_LABEL
,
521 const wxArrayString
& labels
= wxArrayString(),
522 const wxArrayInt
& values
= wxArrayInt(),
524 virtual ~wxFlagsProperty ();
526 virtual void OnSetValue();
527 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
528 virtual bool StringToValue( wxVariant
& variant
,
529 const wxString
& text
,
531 virtual void ChildChanged( wxVariant
& thisValue
,
533 wxVariant
& childValue
) const;
534 virtual void RefreshChildren();
536 // GetChoiceSelection needs to overridden since m_choices is
537 // used and value is integer, but it is not index.
538 virtual int GetChoiceSelection() const { return wxNOT_FOUND
; }
541 size_t GetItemCount() const { return m_choices
.GetCount(); }
542 const wxString
& GetLabel( size_t ind
) const
543 { return m_choices
.GetLabel(ind
); }
546 // Used to detect if choices have been changed
547 wxPGChoicesData
* m_oldChoicesData
;
549 // Needed to properly mark changed sub-properties
552 // Converts string id to a relevant bit.
553 long IdToBit( const wxString
& id
) const;
555 // Creates children and sets value.
559 // -----------------------------------------------------------------------
561 /** @class wxPGFileDialogAdapter
564 class WXDLLIMPEXP_PROPGRID
565 wxPGFileDialogAdapter
: public wxPGEditorDialogAdapter
568 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
569 wxPGProperty
* property
);
572 // -----------------------------------------------------------------------
574 #include "wx/filename.h"
576 // Indicates first bit useable by derived properties.
577 #define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
579 /** @class wxFileProperty
581 Like wxLongStringProperty, but the button triggers file selector instead.
583 <b>Supported special attributes:</b>
584 - "Wildcard": Sets wildcard (see wxFileDialog for format details), "All
585 files..." is default.
586 - "ShowFullPath": Default 1. When 0, only the file name is shown (i.e. drive
587 and directory are hidden).
588 - "ShowRelativePath": If set, then the filename is shown relative to the
590 - "InitialPath": Sets the initial path of where to look for files.
591 - "DialogTitle": Sets a specific title for the dir dialog.
593 class WXDLLIMPEXP_PROPGRID wxFileProperty
: public wxPGProperty
595 friend class wxPGFileDialogAdapter
;
596 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty
)
599 wxFileProperty( const wxString
& label
= wxPG_LABEL
,
600 const wxString
& name
= wxPG_LABEL
,
601 const wxString
& value
= wxEmptyString
);
602 virtual ~wxFileProperty ();
604 virtual void OnSetValue();
605 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
606 virtual bool StringToValue( wxVariant
& variant
,
607 const wxString
& text
,
608 int argFlags
= 0 ) const;
609 virtual wxPGEditorDialogAdapter
* GetEditorDialog() const;
610 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
612 static wxValidator
* GetClassValidator();
613 virtual wxValidator
* DoGetValidator() const;
616 Returns filename to file represented by current value.
618 wxFileName
GetFileName() const;
622 wxString m_basePath
; // If set, then show path relative to it
623 wxString m_initialPath
; // If set, start the file dialog here
624 wxString m_dlgTitle
; // If set, used as title for file dialog
625 int m_indFilter
; // index to the selected filter
628 // -----------------------------------------------------------------------
630 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
633 /** @class wxPGLongStringDialogAdapter
636 class WXDLLIMPEXP_PROPGRID
637 wxPGLongStringDialogAdapter
: public wxPGEditorDialogAdapter
640 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
641 wxPGProperty
* property
);
645 /** @class wxLongStringProperty
647 Like wxStringProperty, but has a button that triggers a small text
650 class WXDLLIMPEXP_PROPGRID wxLongStringProperty
: public wxPGProperty
652 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty
)
655 wxLongStringProperty( const wxString
& label
= wxPG_LABEL
,
656 const wxString
& name
= wxPG_LABEL
,
657 const wxString
& value
= wxEmptyString
);
658 virtual ~wxLongStringProperty();
660 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
661 virtual bool StringToValue( wxVariant
& variant
,
662 const wxString
& text
,
663 int argFlags
= 0 ) const;
664 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
665 wxWindow
* primary
, wxEvent
& event
);
667 // Shows string editor dialog. Value to be edited should be read from
668 // value, and if dialog is not cancelled, it should be stored back and true
669 // should be returned if that was the case.
670 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
, wxString
& value
);
672 static bool DisplayEditorDialog( wxPGProperty
* prop
,
673 wxPropertyGrid
* propGrid
,
679 // -----------------------------------------------------------------------
682 // Exclude class from wxPython bindings
685 /** @class wxDirProperty
687 Like wxLongStringProperty, but the button triggers dir selector instead.
689 <b>Supported special attributes:</b>
690 - "DialogMessage": Sets specific message in the dir selector.
692 class WXDLLIMPEXP_PROPGRID wxDirProperty
: public wxLongStringProperty
695 DECLARE_DYNAMIC_CLASS(wxDirProperty
)
698 wxDirProperty( const wxString
& name
= wxPG_LABEL
,
699 const wxString
& label
= wxPG_LABEL
,
700 const wxString
& value
= wxEmptyString
);
701 virtual ~wxDirProperty();
703 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
704 virtual wxValidator
* DoGetValidator() const;
706 virtual bool OnButtonClick ( wxPropertyGrid
* propGrid
, wxString
& value
);
709 wxString m_dlgMessage
;
714 // -----------------------------------------------------------------------
716 // wxBoolProperty specific flags
717 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
718 // DCC = Double Click Cycles
719 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
722 // -----------------------------------------------------------------------
724 /** @class wxArrayStringProperty
726 Property that manages a list of strings.
728 class WXDLLIMPEXP_PROPGRID wxArrayStringProperty
: public wxPGProperty
730 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty
)
733 wxArrayStringProperty( const wxString
& label
= wxPG_LABEL
,
734 const wxString
& name
= wxPG_LABEL
,
735 const wxArrayString
& value
= wxArrayString() );
736 virtual ~wxArrayStringProperty();
738 virtual void OnSetValue();
739 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
740 virtual bool StringToValue( wxVariant
& variant
,
741 const wxString
& text
,
742 int argFlags
= 0 ) const;
743 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
744 wxWindow
* primary
, wxEvent
& event
);
746 virtual void GenerateValueAsString();
748 // Shows string editor dialog. Value to be edited should be read from
749 // value, and if dialog is not cancelled, it should be stored back and true
750 // should be returned if that was the case.
751 virtual bool OnCustomStringEdit( wxWindow
* parent
, wxString
& value
);
754 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
,
759 // Creates wxArrayEditorDialog for string editing. Called in OnButtonClick.
760 virtual wxArrayEditorDialog
* CreateEditorDialog();
764 wxString m_display
; // Cache for displayed text.
767 // -----------------------------------------------------------------------
769 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
771 DECL PROPNAME : public wxArrayStringProperty \
773 WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
775 PROPNAME( const wxString& label = wxPG_LABEL, \
776 const wxString& name = wxPG_LABEL, \
777 const wxArrayString& value = wxArrayString() ); \
779 virtual void GenerateValueAsString(); \
780 virtual bool StringToValue( wxVariant& value, \
781 const wxString& text, int = 0 ) const; \
782 virtual bool OnEvent( wxPropertyGrid* propgrid, \
783 wxWindow* primary, wxEvent& event ); \
784 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
785 virtual wxValidator* DoGetValidator() const; \
788 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
789 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
791 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
794 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
795 wxArrayString, const wxArrayString&, \
797 PROPNAME::PROPNAME( const wxString& label, \
798 const wxString& name, \
799 const wxArrayString& value ) \
800 : wxArrayStringProperty(label,name,value) \
802 PROPNAME::GenerateValueAsString(); \
804 PROPNAME::~PROPNAME() { } \
805 void PROPNAME::GenerateValueAsString() \
807 wxChar delimChar = DELIMCHAR; \
808 if ( delimChar == wxS('"') ) \
809 wxArrayStringProperty::GenerateValueAsString(); \
811 wxPropertyGrid::ArrayStringToString(m_display, \
812 m_value.GetArrayString(), \
815 bool PROPNAME::StringToValue( wxVariant& variant, \
816 const wxString& text, int ) const \
818 wxChar delimChar = DELIMCHAR; \
819 if ( delimChar == wxS('"') ) \
820 return wxArrayStringProperty::StringToValue(variant, text, 0); \
823 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
825 WX_PG_TOKENIZER1_END() \
829 bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
830 wxWindow* primary, wxEvent& event ) \
832 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
833 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
837 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
838 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
840 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
841 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
843 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
844 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
847 wxValidator* PROPNAME::DoGetValidator () const \
848 { return (wxValidator*) NULL; }
851 // -----------------------------------------------------------------------
852 // wxArrayEditorDialog
853 // -----------------------------------------------------------------------
855 #include "wx/button.h"
856 #include "wx/dialog.h"
857 #include "wx/listbox.h"
859 #define wxAEDIALOG_STYLE \
860 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
862 class WXDLLIMPEXP_PROPGRID wxArrayEditorDialog
: public wxDialog
865 wxArrayEditorDialog();
866 virtual ~wxArrayEditorDialog() { }
870 wxArrayEditorDialog( wxWindow
*parent
,
871 const wxString
& message
,
872 const wxString
& caption
,
873 long style
= wxAEDIALOG_STYLE
,
874 const wxPoint
& pos
= wxDefaultPosition
,
875 const wxSize
& sz
= wxDefaultSize
);
877 bool Create( wxWindow
*parent
,
878 const wxString
& message
,
879 const wxString
& caption
,
880 long style
= wxAEDIALOG_STYLE
,
881 const wxPoint
& pos
= wxDefaultPosition
,
882 const wxSize
& sz
= wxDefaultSize
);
884 /** Set value modified by dialog.
886 virtual void SetDialogValue( const wxVariant
& WXUNUSED(value
) )
888 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
891 /** Return value modified by dialog.
893 virtual wxVariant
GetDialogValue() const
895 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
899 /** Override to return wxValidator to be used with the wxTextCtrl
900 in dialog. Note that the validator is used in the standard
901 wx way, ie. it immediately prevents user from entering invalid
905 Dialog frees the validator.
907 virtual wxValidator
* GetTextCtrlValidator() const
909 return (wxValidator
*) NULL
;
912 // Returns true if array was actually modified
913 bool IsModified() const { return m_modified
; }
915 //const wxArrayString& GetStrings() const { return m_array; }
917 // implementation from now on
918 void OnUpdateClick(wxCommandEvent
& event
);
919 void OnAddClick(wxCommandEvent
& event
);
920 void OnDeleteClick(wxCommandEvent
& event
);
921 void OnListBoxClick(wxCommandEvent
& event
);
922 void OnUpClick(wxCommandEvent
& event
);
923 void OnDownClick(wxCommandEvent
& event
);
924 //void OnCustomEditClick(wxCommandEvent& event);
925 void OnIdle(wxIdleEvent
& event
);
928 wxTextCtrl
* m_edValue
;
929 wxListBox
* m_lbStrings
;
931 wxButton
* m_butAdd
; // Button pointers
932 wxButton
* m_butCustom
; // required for disabling/enabling changing.
933 wxButton
* m_butUpdate
;
934 wxButton
* m_butRemove
;
938 //wxArrayString m_array;
940 const wxChar
* m_custBtText
;
941 //wxArrayStringPropertyClass* m_pCallingClass;
945 unsigned char m_curFocus
;
947 // These must be overridden - must return true on success.
948 virtual wxString
ArrayGet( size_t index
) = 0;
949 virtual size_t ArrayGetCount() = 0;
950 virtual bool ArrayInsert( const wxString
& str
, int index
) = 0;
951 virtual bool ArraySet( size_t index
, const wxString
& str
) = 0;
952 virtual void ArrayRemoveAt( int index
) = 0;
953 virtual void ArraySwap( size_t first
, size_t second
) = 0;
957 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog
)
958 DECLARE_EVENT_TABLE()
962 // -----------------------------------------------------------------------
963 // wxPGArrayStringEditorDialog
964 // -----------------------------------------------------------------------
966 class WXDLLIMPEXP_PROPGRID
967 wxPGArrayStringEditorDialog
: public wxArrayEditorDialog
970 wxPGArrayStringEditorDialog();
971 virtual ~wxPGArrayStringEditorDialog() { }
975 virtual void SetDialogValue( const wxVariant
& value
)
977 m_array
= value
.GetArrayString();
980 virtual wxVariant
GetDialogValue() const
985 void SetCustomButton( const wxChar
* custBtText
, wxArrayStringProperty
* pcc
)
987 m_custBtText
= custBtText
;
988 m_pCallingClass
= pcc
;
991 void OnCustomEditClick(wxCommandEvent
& event
);
994 wxArrayString m_array
;
996 wxArrayStringProperty
* m_pCallingClass
;
998 virtual wxString
ArrayGet( size_t index
);
999 virtual size_t ArrayGetCount();
1000 virtual bool ArrayInsert( const wxString
& str
, int index
);
1001 virtual bool ArraySet( size_t index
, const wxString
& str
);
1002 virtual void ArrayRemoveAt( int index
);
1003 virtual void ArraySwap( size_t first
, size_t second
);
1007 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog
)
1008 DECLARE_EVENT_TABLE()
1012 // -----------------------------------------------------------------------
1014 #endif // wxUSE_PROPGRID
1016 #endif // _WX_PROPGRID_PROPS_H_