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 /** @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
ValueToString( wxVariant
& value
, int argFlags
= 0 ) 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
ValueToString( wxVariant
& value
, int argFlags
= 0 ) 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
ValueToString( wxVariant
& value
, int argFlags
= 0 ) 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;
645 Returns filename to file represented by current value.
647 wxFileName
GetFileName() const;
651 wxString m_basePath
; // If set, then show path relative to it
652 wxString m_initialPath
; // If set, start the file dialog here
653 wxString m_dlgTitle
; // If set, used as title for file dialog
654 int m_indFilter
; // index to the selected filter
657 // -----------------------------------------------------------------------
659 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
662 /** @class wxPGLongStringDialogAdapter
665 class WXDLLIMPEXP_PROPGRID
666 wxPGLongStringDialogAdapter
: public wxPGEditorDialogAdapter
669 virtual bool DoShowDialog( wxPropertyGrid
* propGrid
,
670 wxPGProperty
* property
);
674 /** @class wxLongStringProperty
676 Like wxStringProperty, but has a button that triggers a small text
679 class WXDLLIMPEXP_PROPGRID wxLongStringProperty
: public wxPGProperty
681 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty
)
684 wxLongStringProperty( const wxString
& label
= wxPG_LABEL
,
685 const wxString
& name
= wxPG_LABEL
,
686 const wxString
& value
= wxEmptyString
);
687 virtual ~wxLongStringProperty();
689 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
690 virtual bool StringToValue( wxVariant
& variant
,
691 const wxString
& text
,
692 int argFlags
= 0 ) const;
693 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
694 wxWindow
* primary
, wxEvent
& event
);
696 // Shows string editor dialog. Value to be edited should be read from
697 // value, and if dialog is not cancelled, it should be stored back and true
698 // should be returned if that was the case.
699 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
, wxString
& value
);
701 static bool DisplayEditorDialog( wxPGProperty
* prop
,
702 wxPropertyGrid
* propGrid
,
708 // -----------------------------------------------------------------------
711 // Exclude class from wxPython bindings
714 /** @class wxDirProperty
716 Like wxLongStringProperty, but the button triggers dir selector instead.
718 <b>Supported special attributes:</b>
719 - "DialogMessage": Sets specific message in the dir selector.
721 class WXDLLIMPEXP_PROPGRID wxDirProperty
: public wxLongStringProperty
724 DECLARE_DYNAMIC_CLASS(wxDirProperty
)
727 wxDirProperty( const wxString
& name
= wxPG_LABEL
,
728 const wxString
& label
= wxPG_LABEL
,
729 const wxString
& value
= wxEmptyString
);
730 virtual ~wxDirProperty();
732 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
733 virtual wxValidator
* DoGetValidator() const;
735 virtual bool OnButtonClick ( wxPropertyGrid
* propGrid
, wxString
& value
);
738 wxString m_dlgMessage
;
743 // -----------------------------------------------------------------------
745 // wxBoolProperty specific flags
746 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
747 // DCC = Double Click Cycles
748 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
751 // -----------------------------------------------------------------------
753 /** @class wxArrayStringProperty
755 Property that manages a list of strings.
757 class WXDLLIMPEXP_PROPGRID wxArrayStringProperty
: public wxPGProperty
759 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty
)
762 wxArrayStringProperty( const wxString
& label
= wxPG_LABEL
,
763 const wxString
& name
= wxPG_LABEL
,
764 const wxArrayString
& value
= wxArrayString() );
765 virtual ~wxArrayStringProperty();
767 virtual void OnSetValue();
768 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
769 virtual bool StringToValue( wxVariant
& variant
,
770 const wxString
& text
,
771 int argFlags
= 0 ) const;
772 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
773 wxWindow
* primary
, wxEvent
& event
);
775 virtual void GenerateValueAsString();
777 // Shows string editor dialog. Value to be edited should be read from
778 // value, and if dialog is not cancelled, it should be stored back and true
779 // should be returned if that was the case.
780 virtual bool OnCustomStringEdit( wxWindow
* parent
, wxString
& value
);
783 virtual bool OnButtonClick( wxPropertyGrid
* propgrid
,
788 // Creates wxArrayEditorDialog for string editing. Called in OnButtonClick.
789 virtual wxArrayEditorDialog
* CreateEditorDialog();
793 wxString m_display
; // Cache for displayed text.
796 // -----------------------------------------------------------------------
798 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
800 DECL PROPNAME : public wxArrayStringProperty \
802 WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
804 PROPNAME( const wxString& label = wxPG_LABEL, \
805 const wxString& name = wxPG_LABEL, \
806 const wxArrayString& value = wxArrayString() ); \
808 virtual void GenerateValueAsString(); \
809 virtual bool StringToValue( wxVariant& value, \
810 const wxString& text, int = 0 ) const; \
811 virtual bool OnEvent( wxPropertyGrid* propgrid, \
812 wxWindow* primary, wxEvent& event ); \
813 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
814 virtual wxValidator* DoGetValidator() const; \
817 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
818 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
820 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
823 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
824 wxArrayString, const wxArrayString&, \
826 PROPNAME::PROPNAME( const wxString& label, \
827 const wxString& name, \
828 const wxArrayString& value ) \
829 : wxArrayStringProperty(label,name,value) \
831 PROPNAME::GenerateValueAsString(); \
833 PROPNAME::~PROPNAME() { } \
834 void PROPNAME::GenerateValueAsString() \
836 wxChar delimChar = DELIMCHAR; \
837 if ( delimChar == wxS('"') ) \
838 wxArrayStringProperty::GenerateValueAsString(); \
840 wxPropertyGrid::ArrayStringToString(m_display, \
841 m_value.GetArrayString(), \
844 bool PROPNAME::StringToValue( wxVariant& variant, \
845 const wxString& text, int ) const \
847 wxChar delimChar = DELIMCHAR; \
848 if ( delimChar == wxS('"') ) \
849 return wxArrayStringProperty::StringToValue(variant, text, 0); \
852 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
854 WX_PG_TOKENIZER1_END() \
858 bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
859 wxWindow* primary, wxEvent& event ) \
861 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
862 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
866 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
867 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
869 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
870 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
872 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
873 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
876 wxValidator* PROPNAME::DoGetValidator () const \
877 { return (wxValidator*) NULL; }
880 // -----------------------------------------------------------------------
881 // wxArrayEditorDialog
882 // -----------------------------------------------------------------------
884 #include "wx/button.h"
885 #include "wx/dialog.h"
886 #include "wx/listbox.h"
888 #define wxAEDIALOG_STYLE \
889 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
891 class WXDLLIMPEXP_PROPGRID wxArrayEditorDialog
: public wxDialog
894 wxArrayEditorDialog();
895 virtual ~wxArrayEditorDialog() { }
899 wxArrayEditorDialog( wxWindow
*parent
,
900 const wxString
& message
,
901 const wxString
& caption
,
902 long style
= wxAEDIALOG_STYLE
,
903 const wxPoint
& pos
= wxDefaultPosition
,
904 const wxSize
& sz
= wxDefaultSize
);
906 bool Create( wxWindow
*parent
,
907 const wxString
& message
,
908 const wxString
& caption
,
909 long style
= wxAEDIALOG_STYLE
,
910 const wxPoint
& pos
= wxDefaultPosition
,
911 const wxSize
& sz
= wxDefaultSize
);
913 /** Set value modified by dialog.
915 virtual void SetDialogValue( const wxVariant
& WXUNUSED(value
) )
917 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
920 /** Return value modified by dialog.
922 virtual wxVariant
GetDialogValue() const
924 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
928 /** Override to return wxValidator to be used with the wxTextCtrl
929 in dialog. Note that the validator is used in the standard
930 wx way, ie. it immediately prevents user from entering invalid
934 Dialog frees the validator.
936 virtual wxValidator
* GetTextCtrlValidator() const
938 return (wxValidator
*) NULL
;
941 // Returns true if array was actually modified
942 bool IsModified() const { return m_modified
; }
944 //const wxArrayString& GetStrings() const { return m_array; }
946 // implementation from now on
947 void OnUpdateClick(wxCommandEvent
& event
);
948 void OnAddClick(wxCommandEvent
& event
);
949 void OnDeleteClick(wxCommandEvent
& event
);
950 void OnListBoxClick(wxCommandEvent
& event
);
951 void OnUpClick(wxCommandEvent
& event
);
952 void OnDownClick(wxCommandEvent
& event
);
953 //void OnCustomEditClick(wxCommandEvent& event);
954 void OnIdle(wxIdleEvent
& event
);
957 wxTextCtrl
* m_edValue
;
958 wxListBox
* m_lbStrings
;
960 wxButton
* m_butAdd
; // Button pointers
961 wxButton
* m_butCustom
; // required for disabling/enabling changing.
962 wxButton
* m_butUpdate
;
963 wxButton
* m_butRemove
;
967 //wxArrayString m_array;
969 const wxChar
* m_custBtText
;
970 //wxArrayStringPropertyClass* m_pCallingClass;
974 unsigned char m_curFocus
;
976 // These must be overridden - must return true on success.
977 virtual wxString
ArrayGet( size_t index
) = 0;
978 virtual size_t ArrayGetCount() = 0;
979 virtual bool ArrayInsert( const wxString
& str
, int index
) = 0;
980 virtual bool ArraySet( size_t index
, const wxString
& str
) = 0;
981 virtual void ArrayRemoveAt( int index
) = 0;
982 virtual void ArraySwap( size_t first
, size_t second
) = 0;
986 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog
)
987 DECLARE_EVENT_TABLE()
991 // -----------------------------------------------------------------------
992 // wxPGArrayStringEditorDialog
993 // -----------------------------------------------------------------------
995 class WXDLLIMPEXP_PROPGRID
996 wxPGArrayStringEditorDialog
: public wxArrayEditorDialog
999 wxPGArrayStringEditorDialog();
1000 virtual ~wxPGArrayStringEditorDialog() { }
1004 virtual void SetDialogValue( const wxVariant
& value
)
1006 m_array
= value
.GetArrayString();
1009 virtual wxVariant
GetDialogValue() const
1014 void SetCustomButton( const wxChar
* custBtText
, wxArrayStringProperty
* pcc
)
1016 m_custBtText
= custBtText
;
1017 m_pCallingClass
= pcc
;
1020 void OnCustomEditClick(wxCommandEvent
& event
);
1023 wxArrayString m_array
;
1025 wxArrayStringProperty
* m_pCallingClass
;
1027 virtual wxString
ArrayGet( size_t index
);
1028 virtual size_t ArrayGetCount();
1029 virtual bool ArrayInsert( const wxString
& str
, int index
);
1030 virtual bool ArraySet( size_t index
, const wxString
& str
);
1031 virtual void ArrayRemoveAt( int index
);
1032 virtual void ArraySwap( size_t first
, size_t second
);
1036 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog
)
1037 DECLARE_EVENT_TABLE()
1041 // -----------------------------------------------------------------------
1043 #endif // wxUSE_PROPGRID
1045 #endif // _WX_PROPGRID_PROPS_H_