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
GetValueAsString( 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
GetValueAsString( 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
GetValueAsString( 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
GetValueAsString( 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
GetValueAsString( 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 /** @class wxBaseEnumProperty
348 Derive dynamic custom properties with choices from this class.
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 wxBaseEnumProperty
: public wxPGProperty
359 wxBaseEnumProperty( const wxString
& label
= wxPG_LABEL
,
360 const wxString
& name
= wxPG_LABEL
);
362 virtual void OnSetValue();
363 virtual wxString
GetValueAsString( int argFlags
) const;
364 virtual bool StringToValue( wxVariant
& variant
,
365 const wxString
& text
,
366 int argFlags
= 0 ) const;
367 virtual bool ValidateValue( wxVariant
& value
,
368 wxPGValidationInfo
& validationInfo
) const;
370 // If wxPG_FULL_VALUE is not set in flags, then the value is interpreted
371 // as index to choices list. Otherwise, it is actual value.
372 virtual bool IntToValue( wxVariant
& variant
,
374 int argFlags
= 0 ) const;
377 // Additional virtuals
379 // This must be overridden to have non-index based value
380 virtual int GetIndexForValue( int value
) const;
382 // This returns string and value for index
383 // Returns NULL if beyond last item
384 // pvalue is never NULL - always set it.
385 virtual const wxString
* GetEntry( size_t index
, int* pvalue
) const = 0;
387 // GetChoiceSelection needs to overridden since m_index is
388 // the true index, and various property classes derived from
389 // this take advantage of it.
390 virtual int GetChoiceSelection() const { return m_index
; }
392 int GetValueForIndex( size_t index
) const
395 GetEntry( index
, &v
);
401 int GetIndex() const;
402 void SetIndex( int index
);
404 bool ValueFromString_( wxVariant
& value
,
405 const wxString
& text
,
406 int argFlags
) const;
407 bool ValueFromInt_( wxVariant
& value
, int intVal
, int argFlags
) const;
409 static void ResetNextIndex() { ms_nextIndex
= -2; }
412 // This is private so that classes are guaranteed to use GetIndex
413 // for up-to-date index value.
416 // Relies on ValidateValue being called always before OnSetValue
417 static int ms_nextIndex
;
420 // -----------------------------------------------------------------------
422 // If set, then selection of choices is static and should not be
423 // changed (i.e. returns NULL in GetPropertyChoices).
424 #define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
426 /** @class wxEnumProperty
428 You can derive custom properties with choices from this class. See
429 wxBaseEnumProperty for remarks.
431 class WXDLLIMPEXP_PROPGRID wxEnumProperty
: public wxBaseEnumProperty
433 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty
)
437 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
438 const wxString
& name
= wxPG_LABEL
,
439 const wxChar
** labels
= NULL
,
440 const long* values
= NULL
,
442 wxEnumProperty( const wxString
& label
,
443 const wxString
& name
,
444 wxPGChoices
& choices
,
447 // Special constructor for caching choices (used by derived class)
448 wxEnumProperty( const wxString
& label
,
449 const wxString
& name
,
450 const wxChar
** labels
,
452 wxPGChoices
* choicesCache
,
455 wxEnumProperty( const wxString
& label
,
456 const wxString
& name
,
457 const wxArrayString
& labels
,
458 const wxArrayInt
& values
= wxArrayInt(),
461 wxEnumProperty( const wxString
& label
= wxPG_LABEL
,
462 const wxString
& name
= wxPG_LABEL
,
463 const wxArrayString
& labels
= wxArrayString(),
464 const wxArrayInt
& values
= wxArrayInt(),
468 virtual ~wxEnumProperty();
470 virtual int GetIndexForValue( int value
) const;
471 virtual const wxString
* GetEntry( size_t index
, int* pvalue
) const;
473 size_t GetItemCount() const { return m_choices
.GetCount(); }
474 const wxPGChoices
& GetChoices() const { return m_choices
; }
477 // -----------------------------------------------------------------------
479 /** @class wxEditEnumProperty
481 wxEnumProperty with wxString value and writable combo box editor.
484 Uses int value, similar to wxEnumProperty, unless text entered by user is
485 is not in choices (in which case string value is used).
487 class WXDLLIMPEXP_PROPGRID wxEditEnumProperty
: public wxEnumProperty
489 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty
)
492 wxEditEnumProperty( const wxString
& label
,
493 const wxString
& name
,
494 const wxChar
** labels
,
496 const wxString
& value
);
497 wxEditEnumProperty( const wxString
& label
= wxPG_LABEL
,
498 const wxString
& name
= wxPG_LABEL
,
499 const wxArrayString
& labels
= wxArrayString(),
500 const wxArrayInt
& values
= wxArrayInt(),
501 const wxString
& value
= wxEmptyString
);
502 wxEditEnumProperty( const wxString
& label
,
503 const wxString
& name
,
504 wxPGChoices
& choices
,
505 const wxString
& value
= wxEmptyString
);
507 // Special constructor for caching choices (used by derived class)
508 wxEditEnumProperty( const wxString
& label
,
509 const wxString
& name
,
510 const wxChar
** labels
,
512 wxPGChoices
* choicesCache
,
513 const wxString
& value
);
515 virtual ~wxEditEnumProperty();
520 // -----------------------------------------------------------------------
522 /** @class wxFlagsProperty
524 Represents a bit set that fits in a long integer. wxBoolProperty
525 sub-properties are created for editing individual bits. Textctrl is created
526 to manually edit the flags as a text; a continous sequence of spaces,
527 commas and semicolons is considered as a flag id separator.
528 <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
529 you will need to use SetPropertyChoices - otherwise they will not get
532 class WXDLLIMPEXP_PROPGRID wxFlagsProperty
: public wxPGProperty
534 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty
)
538 wxFlagsProperty( const wxString
& label
,
539 const wxString
& name
,
540 const wxChar
** labels
,
541 const long* values
= NULL
,
543 wxFlagsProperty( const wxString
& label
,
544 const wxString
& name
,
545 wxPGChoices
& choices
,
548 wxFlagsProperty( const wxString
& label
= wxPG_LABEL
,
549 const wxString
& name
= wxPG_LABEL
,
550 const wxArrayString
& labels
= wxArrayString(),
551 const wxArrayInt
& values
= wxArrayInt(),
553 virtual ~wxFlagsProperty ();
555 virtual void OnSetValue();
556 virtual wxString
GetValueAsString( int argFlags
) const;
557 virtual bool StringToValue( wxVariant
& variant
,
558 const wxString
& text
,
560 virtual void ChildChanged( wxVariant
& thisValue
,
562 wxVariant
& childValue
) const;
563 virtual void RefreshChildren();
565 // GetChoiceSelection needs to overridden since m_choices is
566 // used and value is integer, but it is not index.
567 virtual int GetChoiceSelection() const { return wxNOT_FOUND
; }
570 size_t GetItemCount() const { return m_choices
.GetCount(); }
571 const wxString
& GetLabel( size_t ind
) const
572 { return m_choices
.GetLabel(ind
); }
575 // Used to detect if choices have been changed
576 wxPGChoicesData
* m_oldChoicesData
;
578 // Needed to properly mark changed sub-properties
581 // Converts string id to a relevant bit.
582 long IdToBit( const wxString
& id
) const;
584 // Creates children and sets value.
588 // -----------------------------------------------------------------------
590 /** @class wxPGFileDialogAdapter
593 class WXDLLIMPEXP_PROPGRID
594 wxPGFileDialogAdapter
: public wxPGEditorDialogAdapter
597 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
598 wxPGProperty
* property
);
601 // -----------------------------------------------------------------------
603 #include "wx/filename.h"
605 // Indicates first bit useable by derived properties.
606 #define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
608 /** @class wxFileProperty
610 Like wxLongStringProperty, but the button triggers file selector instead.
612 <b>Supported special attributes:</b>
613 - "Wildcard": Sets wildcard (see wxFileDialog for format details), "All
614 files..." is default.
615 - "ShowFullPath": Default 1. When 0, only the file name is shown (i.e. drive
616 and directory are hidden).
617 - "ShowRelativePath": If set, then the filename is shown relative to the
619 - "InitialPath": Sets the initial path of where to look for files.
620 - "DialogTitle": Sets a specific title for the dir dialog.
622 class WXDLLIMPEXP_PROPGRID wxFileProperty
: public wxPGProperty
624 friend class wxPGFileDialogAdapter
;
625 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty
)
628 wxFileProperty( const wxString
& label
= wxPG_LABEL
,
629 const wxString
& name
= wxPG_LABEL
,
630 const wxString
& value
= wxEmptyString
);
631 virtual ~wxFileProperty ();
633 virtual void OnSetValue();
634 virtual wxString
GetValueAsString( int argFlags
) const;
635 virtual bool StringToValue( wxVariant
& variant
,
636 const wxString
& text
,
637 int argFlags
= 0 ) const;
638 virtual wxPGEditorDialogAdapter
* GetEditorDialog() const;
639 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
641 static wxValidator
* GetClassValidator();
642 virtual wxValidator
* DoGetValidator() const;
646 wxString m_basePath
; // If set, then show path relative to it
647 wxString m_initialPath
; // If set, start the file dialog here
648 wxString m_dlgTitle
; // If set, used as title for file dialog
649 wxFileName m_filename
; // used as primary storage
650 int m_indFilter
; // index to the selected filter
653 // -----------------------------------------------------------------------
655 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
658 /** @class wxPGLongStringDialogAdapter
661 class WXDLLIMPEXP_PROPGRID
662 wxPGLongStringDialogAdapter
: public wxPGEditorDialogAdapter
665 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
666 wxPGProperty
* property
);
670 /** @class wxLongStringProperty
672 Like wxStringProperty, but has a button that triggers a small text
675 class WXDLLIMPEXP_PROPGRID wxLongStringProperty
: public wxPGProperty
677 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty
)
680 wxLongStringProperty( const wxString
& label
= wxPG_LABEL
,
681 const wxString
& name
= wxPG_LABEL
,
682 const wxString
& value
= wxEmptyString
);
683 virtual ~wxLongStringProperty();
685 virtual wxString
GetValueAsString( int argFlags
= 0 ) const;
686 virtual bool StringToValue( wxVariant
& variant
,
687 const wxString
& text
,
688 int argFlags
= 0 ) const;
689 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
690 wxWindow
* primary
, wxEvent
& event
);
692 // Shows string editor dialog. Value to be edited should be read from
693 // value, and if dialog is not cancelled, it should be stored back and true
694 // should be returned if that was the case.
695 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
, wxString
& value
);
697 static bool DisplayEditorDialog( wxPGProperty
* prop
,
698 wxPropertyGrid
* propGrid
,
704 // -----------------------------------------------------------------------
707 // Exclude class from wxPython bindings
710 /** @class wxDirProperty
712 Like wxLongStringProperty, but the button triggers dir selector instead.
714 <b>Supported special attributes:</b>
715 - "DialogMessage": Sets specific message in the dir selector.
717 class WXDLLIMPEXP_PROPGRID wxDirProperty
: public wxLongStringProperty
720 DECLARE_DYNAMIC_CLASS(wxDirProperty
)
723 wxDirProperty( const wxString
& name
= wxPG_LABEL
,
724 const wxString
& label
= wxPG_LABEL
,
725 const wxString
& value
= wxEmptyString
);
726 virtual ~wxDirProperty();
728 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
729 virtual wxValidator
* DoGetValidator() const;
731 virtual bool OnButtonClick ( wxPropertyGrid
* propGrid
, wxString
& value
);
734 wxString m_dlgMessage
;
739 // -----------------------------------------------------------------------
741 // wxBoolProperty specific flags
742 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
743 // DCC = Double Click Cycles
744 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
747 // -----------------------------------------------------------------------
749 /** @class wxArrayStringProperty
751 Property that manages a list of strings.
753 class WXDLLIMPEXP_PROPGRID wxArrayStringProperty
: public wxPGProperty
755 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty
)
758 wxArrayStringProperty( const wxString
& label
= wxPG_LABEL
,
759 const wxString
& name
= wxPG_LABEL
,
760 const wxArrayString
& value
= wxArrayString() );
761 virtual ~wxArrayStringProperty();
763 virtual void OnSetValue();
764 virtual wxString
GetValueAsString( int argFlags
= 0 ) const;
765 virtual bool StringToValue( wxVariant
& variant
,
766 const wxString
& text
,
767 int argFlags
= 0 ) const;
768 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
769 wxWindow
* primary
, wxEvent
& event
);
771 virtual void GenerateValueAsString();
773 // Shows string editor dialog. Value to be edited should be read from
774 // value, and if dialog is not cancelled, it should be stored back and true
775 // should be returned if that was the case.
776 virtual bool OnCustomStringEdit( wxWindow
* parent
, wxString
& value
);
779 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
,
784 // Creates wxArrayEditorDialog for string editing. Called in OnButtonClick.
785 virtual wxArrayEditorDialog
* CreateEditorDialog();
789 wxString m_display
; // Cache for displayed text.
792 // -----------------------------------------------------------------------
794 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
796 DECL PROPNAME : public wxArrayStringProperty \
798 WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
800 PROPNAME( const wxString& label = wxPG_LABEL, \
801 const wxString& name = wxPG_LABEL, \
802 const wxArrayString& value = wxArrayString() ); \
804 virtual void GenerateValueAsString(); \
805 virtual bool StringToValue( wxVariant& value, \
806 const wxString& text, int = 0 ) const; \
807 virtual bool OnEvent( wxPropertyGrid* propgrid, \
808 wxWindow* primary, wxEvent& event ); \
809 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
810 virtual wxValidator* DoGetValidator() const; \
813 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
814 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
816 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
819 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
820 wxArrayString, const wxArrayString&, \
822 PROPNAME::PROPNAME( const wxString& label, \
823 const wxString& name, \
824 const wxArrayString& value ) \
825 : wxArrayStringProperty(label,name,value) \
827 PROPNAME::GenerateValueAsString(); \
829 PROPNAME::~PROPNAME() { } \
830 void PROPNAME::GenerateValueAsString() \
832 wxChar delimChar = DELIMCHAR; \
833 if ( delimChar == wxS('"') ) \
834 wxArrayStringProperty::GenerateValueAsString(); \
836 wxPropertyGrid::ArrayStringToString(m_display, \
837 m_value.GetArrayString(), \
840 bool PROPNAME::StringToValue( wxVariant& variant, \
841 const wxString& text, int ) const \
843 wxChar delimChar = DELIMCHAR; \
844 if ( delimChar == wxS('"') ) \
845 return wxArrayStringProperty::StringToValue(variant, text, 0); \
848 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
850 WX_PG_TOKENIZER1_END() \
854 bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
855 wxWindow* primary, wxEvent& event ) \
857 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
858 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
862 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
863 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
865 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
866 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
868 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
869 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
872 wxValidator* PROPNAME::DoGetValidator () const \
873 { return (wxValidator*) NULL; }
876 // -----------------------------------------------------------------------
877 // wxArrayEditorDialog
878 // -----------------------------------------------------------------------
880 #include "wx/button.h"
881 #include "wx/dialog.h"
882 #include "wx/listbox.h"
884 #define wxAEDIALOG_STYLE \
885 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
887 class WXDLLIMPEXP_PROPGRID wxArrayEditorDialog
: public wxDialog
890 wxArrayEditorDialog();
891 virtual ~wxArrayEditorDialog() { }
895 wxArrayEditorDialog( wxWindow
*parent
,
896 const wxString
& message
,
897 const wxString
& caption
,
898 long style
= wxAEDIALOG_STYLE
,
899 const wxPoint
& pos
= wxDefaultPosition
,
900 const wxSize
& sz
= wxDefaultSize
);
902 bool Create( wxWindow
*parent
,
903 const wxString
& message
,
904 const wxString
& caption
,
905 long style
= wxAEDIALOG_STYLE
,
906 const wxPoint
& pos
= wxDefaultPosition
,
907 const wxSize
& sz
= wxDefaultSize
);
909 /** Set value modified by dialog.
911 virtual void SetDialogValue( const wxVariant
& WXUNUSED(value
) )
913 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
916 /** Return value modified by dialog.
918 virtual wxVariant
GetDialogValue() const
920 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
924 /** Override to return wxValidator to be used with the wxTextCtrl
925 in dialog. Note that the validator is used in the standard
926 wx way, ie. it immediately prevents user from entering invalid
930 Dialog frees the validator.
932 virtual wxValidator
* GetTextCtrlValidator() const
934 return (wxValidator
*) NULL
;
937 // Returns true if array was actually modified
938 bool IsModified() const { return m_modified
; }
940 //const wxArrayString& GetStrings() const { return m_array; }
942 // implementation from now on
943 void OnUpdateClick(wxCommandEvent
& event
);
944 void OnAddClick(wxCommandEvent
& event
);
945 void OnDeleteClick(wxCommandEvent
& event
);
946 void OnListBoxClick(wxCommandEvent
& event
);
947 void OnUpClick(wxCommandEvent
& event
);
948 void OnDownClick(wxCommandEvent
& event
);
949 //void OnCustomEditClick(wxCommandEvent& event);
950 void OnIdle(wxIdleEvent
& event
);
953 wxTextCtrl
* m_edValue
;
954 wxListBox
* m_lbStrings
;
956 wxButton
* m_butAdd
; // Button pointers
957 wxButton
* m_butCustom
; // required for disabling/enabling changing.
958 wxButton
* m_butUpdate
;
959 wxButton
* m_butRemove
;
963 //wxArrayString m_array;
965 const wxChar
* m_custBtText
;
966 //wxArrayStringPropertyClass* m_pCallingClass;
970 unsigned char m_curFocus
;
972 // These must be overridden - must return true on success.
973 virtual wxString
ArrayGet( size_t index
) = 0;
974 virtual size_t ArrayGetCount() = 0;
975 virtual bool ArrayInsert( const wxString
& str
, int index
) = 0;
976 virtual bool ArraySet( size_t index
, const wxString
& str
) = 0;
977 virtual void ArrayRemoveAt( int index
) = 0;
978 virtual void ArraySwap( size_t first
, size_t second
) = 0;
982 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog
)
983 DECLARE_EVENT_TABLE()
987 // -----------------------------------------------------------------------
988 // wxPGArrayStringEditorDialog
989 // -----------------------------------------------------------------------
991 class WXDLLIMPEXP_PROPGRID
992 wxPGArrayStringEditorDialog
: public wxArrayEditorDialog
995 wxPGArrayStringEditorDialog();
996 virtual ~wxPGArrayStringEditorDialog() { }
1000 virtual void SetDialogValue( const wxVariant
& value
)
1002 m_array
= value
.GetArrayString();
1005 virtual wxVariant
GetDialogValue() const
1010 void SetCustomButton( const wxChar
* custBtText
, wxArrayStringProperty
* pcc
)
1012 m_custBtText
= custBtText
;
1013 m_pCallingClass
= pcc
;
1016 void OnCustomEditClick(wxCommandEvent
& event
);
1019 wxArrayString m_array
;
1021 wxArrayStringProperty
* m_pCallingClass
;
1023 virtual wxString
ArrayGet( size_t index
);
1024 virtual size_t ArrayGetCount();
1025 virtual bool ArrayInsert( const wxString
& str
, int index
);
1026 virtual bool ArraySet( size_t index
, const wxString
& str
);
1027 virtual void ArrayRemoveAt( int index
);
1028 virtual void ArraySwap( size_t first
, size_t second
);
1032 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog
)
1033 DECLARE_EVENT_TABLE()
1037 // -----------------------------------------------------------------------
1039 #endif // wxUSE_PROPGRID
1041 #endif // _WX_PROPGRID_PROPS_H_