]> git.saurik.com Git - wxWidgets.git/blame - include/wx/propgrid/props.h
remove unused data member
[wxWidgets.git] / include / wx / propgrid / props.h
CommitLineData
1c4293cb
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/propgrid/props.h
3// Purpose: wxPropertyGrid Property Classes
4// Author: Jaakko Salli
5// Modified by:
6// Created: 2007-03-28
ea5af9c5 7// RCS-ID: $Id$
1c4293cb
VZ
8// Copyright: (c) Jaakko Salli
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PROPGRID_PROPS_H_
13#define _WX_PROPGRID_PROPS_H_
14
f4bc1aa2
JS
15#if wxUSE_PROPGRID
16
1c4293cb
VZ
17// -----------------------------------------------------------------------
18
19class wxArrayEditorDialog;
20
21#include "wx/propgrid/editors.h"
22
15096961
JS
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"
28
1c4293cb
VZ
29// -----------------------------------------------------------------------
30
1c4293cb
VZ
31//
32// Property class implementation helper macros.
33//
34
d61d8cff 35#define WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME, UPCLASS, T, T_AS_ARG, EDITOR) \
1c4293cb 36IMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS) \
d61d8cff 37WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME, T, EDITOR)
1c4293cb
VZ
38
39// -----------------------------------------------------------------------
40
41//
42// These macros help creating DoGetValidator
43#define WX_PG_DOGETVALIDATOR_ENTRY() \
d3b9f782 44 static wxValidator* s_ptr = NULL; \
1c4293cb
VZ
45 if ( s_ptr ) return s_ptr;
46
47// Common function exit
48#define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
49 s_ptr = VALIDATOR; \
f7a094e1 50 wxPGGlobalVars->m_arrValidators.push_back( VALIDATOR ); \
1c4293cb
VZ
51 return VALIDATOR;
52
53// -----------------------------------------------------------------------
54
55#ifndef SWIG
56
57/** @class wxPGInDialogValidator
58 @ingroup classes
59 Creates and manages a temporary wxTextCtrl for validation purposes.
60 Uses wxPropertyGrid's current editor, if available.
61*/
62class WXDLLIMPEXP_PROPGRID wxPGInDialogValidator
63{
64public:
65 wxPGInDialogValidator()
66 {
67 m_textCtrl = NULL;
68 }
69
70 ~wxPGInDialogValidator()
71 {
72 if ( m_textCtrl )
73 m_textCtrl->Destroy();
74 }
75
76 bool DoValidate( wxPropertyGrid* propGrid,
77 wxValidator* validator,
78 const wxString& value );
79
80private:
81 wxTextCtrl* m_textCtrl;
82};
83
84#endif // SWIG
85
86
87// -----------------------------------------------------------------------
88// Property classes
89// -----------------------------------------------------------------------
90
91#define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
92
93/** @class wxStringProperty
94 @ingroup classes
95 Basic property with string value.
96
97 <b>Supported special attributes:</b>
98 - "Password": set to 1 inorder to enable wxTE_PASSWORD on the editor.
99
100 @remarks
101 - If value "<composed>" is set, then actual value is formed (or composed)
102 from values of child properties.
103*/
104class WXDLLIMPEXP_PROPGRID wxStringProperty : public wxPGProperty
105{
106 WX_PG_DECLARE_PROPERTY_CLASS(wxStringProperty)
107public:
108 wxStringProperty( const wxString& label = wxPG_LABEL,
109 const wxString& name = wxPG_LABEL,
110 const wxString& value = wxEmptyString );
111 virtual ~wxStringProperty();
112
1425eca5 113 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
7eac5c53
JS
114 virtual bool StringToValue( wxVariant& variant,
115 const wxString& text,
116 int argFlags = 0 ) const;
117
118 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
1c4293cb
VZ
119
120 /** This is updated so "<composed>" special value can be handled.
121 */
122 virtual void OnSetValue();
123
124protected:
125};
126
127// -----------------------------------------------------------------------
128
129#ifndef SWIG
130/** Constants used with DoValidation() methods.
131*/
132enum
133{
134 /** Instead of modifying the value, show an error message.
135 */
136 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE = 0,
137
138 /** Modify value, but stick with the limitations.
139 */
140 wxPG_PROPERTY_VALIDATION_SATURATE = 1,
141
142 /** Modify value, wrap around on overflow.
143 */
144 wxPG_PROPERTY_VALIDATION_WRAP = 2
145};
146#endif
147
148// -----------------------------------------------------------------------
149
150/** @class wxIntProperty
151 @ingroup classes
152 Basic property with integer value.
153
154 Seamlessly supports 64-bit integer (wxLongLong) on overflow.
155
156 <b>Example how to use seamless 64-bit integer support</b>
157
158 Getting value:
159
160 @code
161 wxLongLong_t value = pg->GetPropertyValueAsLongLong();
162 @endcode
163
164 or
165
166 @code
167 wxLongLong_t value;
168 wxVariant variant = property->GetValue();
169 if ( variant.GetType() == "wxLongLong" )
170 value = wxLongLongFromVariant(variant);
171 else
172 value = variant.GetLong();
173 @endcode
174
175 Setting value:
176
177 @code
178 pg->SetPropertyValue(longLongVal);
179 @endcode
180
181 or
182
183 @code
184 property->SetValue(WXVARIANT(longLongVal));
185 @endcode
186
187
188 <b>Supported special attributes:</b>
189 - "Min", "Max": Specify acceptable value range.
190*/
191class WXDLLIMPEXP_PROPGRID wxIntProperty : public wxPGProperty
192{
193 WX_PG_DECLARE_PROPERTY_CLASS(wxIntProperty)
194public:
195 wxIntProperty( const wxString& label = wxPG_LABEL,
196 const wxString& name = wxPG_LABEL,
197 long value = 0 );
198 virtual ~wxIntProperty();
199
200 wxIntProperty( const wxString& label,
201 const wxString& name,
202 const wxLongLong& value );
1425eca5 203 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
7eac5c53
JS
204 virtual bool StringToValue( wxVariant& variant,
205 const wxString& text,
206 int argFlags = 0 ) const;
1c4293cb
VZ
207 virtual bool ValidateValue( wxVariant& value,
208 wxPGValidationInfo& validationInfo ) const;
209 virtual bool IntToValue( wxVariant& variant,
210 int number,
211 int argFlags = 0 ) const;
212 static wxValidator* GetClassValidator();
213 virtual wxValidator* DoGetValidator() const;
214
215 /** Validation helper.
216 */
217 static bool DoValidation( const wxPGProperty* property,
218 wxLongLong_t& value,
219 wxPGValidationInfo* pValidationInfo,
220 int mode =
221 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
222
223protected:
224};
225
226// -----------------------------------------------------------------------
227
228/** @class wxUIntProperty
229 @ingroup classes
230 Basic property with unsigned integer value.
231 Seamlessly supports 64-bit integer (wxULongLong) on overflow.
232
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
240 numbers.
241
242 @remarks
243 - For example how to use seamless 64-bit integer support, see wxIntProperty
244 documentation (just use wxULongLong instead of wxLongLong).
245*/
246class WXDLLIMPEXP_PROPGRID wxUIntProperty : public wxPGProperty
247{
248 WX_PG_DECLARE_PROPERTY_CLASS(wxUIntProperty)
249public:
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 );
1425eca5 257 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
7eac5c53
JS
258 virtual bool StringToValue( wxVariant& variant,
259 const wxString& text,
260 int argFlags = 0 ) const;
261 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
1c4293cb
VZ
262 virtual bool ValidateValue( wxVariant& value,
263 wxPGValidationInfo& validationInfo ) const;
264 virtual bool IntToValue( wxVariant& variant,
265 int number,
266 int argFlags = 0 ) const;
267protected:
268 wxByte m_base;
269 wxByte m_realBase; // translated to 8,16,etc.
270 wxByte m_prefix;
271private:
272 void Init();
273};
274
275// -----------------------------------------------------------------------
276
277/** @class wxFloatProperty
278 @ingroup classes
279 Basic property with double-precision floating point value.
280
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.
284*/
285class WXDLLIMPEXP_PROPGRID wxFloatProperty : public wxPGProperty
286{
287 WX_PG_DECLARE_PROPERTY_CLASS(wxFloatProperty)
288public:
289 wxFloatProperty( const wxString& label = wxPG_LABEL,
290 const wxString& name = wxPG_LABEL,
291 double value = 0.0 );
292 virtual ~wxFloatProperty();
293
1425eca5 294 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
7eac5c53
JS
295 virtual bool StringToValue( wxVariant& variant,
296 const wxString& text,
297 int argFlags = 0 ) const;
298 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
1c4293cb
VZ
299 virtual bool ValidateValue( wxVariant& value,
300 wxPGValidationInfo& validationInfo ) const;
301
302 /** Validation helper.
303 */
304 static bool DoValidation( const wxPGProperty* property,
305 double& value,
306 wxPGValidationInfo* pValidationInfo,
307 int mode =
308 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
470f357f 309 virtual wxValidator* DoGetValidator () const;
1c4293cb
VZ
310
311protected:
312 int m_precision;
1c4293cb
VZ
313};
314
315// -----------------------------------------------------------------------
316
317// Exclude class from wxPython bindings
318#ifndef SWIG
319
320/** @class wxBoolProperty
321 @ingroup classes
322 Basic property with boolean value.
323
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.
327*/
328class WXDLLIMPEXP_PROPGRID wxBoolProperty : public wxPGProperty
329{
330 WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty)
331public:
332 wxBoolProperty( const wxString& label = wxPG_LABEL,
333 const wxString& name = wxPG_LABEL,
334 bool value = false );
335 virtual ~wxBoolProperty();
336
1425eca5 337 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
7eac5c53
JS
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 );
1c4293cb
VZ
344};
345
346#endif // !SWIG
347
348// -----------------------------------------------------------------------
349
78f2d746
JS
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
353
354/** @class wxEnumProperty
1c4293cb 355 @ingroup classes
78f2d746
JS
356 You can derive custom properties with choices from this class. See
357 wxBaseEnumProperty for remarks.
1c4293cb
VZ
358
359 @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.
364*/
78f2d746 365class WXDLLIMPEXP_PROPGRID wxEnumProperty : public wxPGProperty
1c4293cb 366{
78f2d746 367 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty)
1c4293cb 368public:
78f2d746
JS
369
370#ifndef SWIG
371 wxEnumProperty( const wxString& label = wxPG_LABEL,
372 const wxString& name = wxPG_LABEL,
373 const wxChar** labels = NULL,
374 const long* values = NULL,
375 int value = 0 );
376 wxEnumProperty( const wxString& label,
377 const wxString& name,
378 wxPGChoices& choices,
379 int value = 0 );
380
381 // Special constructor for caching choices (used by derived class)
382 wxEnumProperty( const wxString& label,
383 const wxString& name,
384 const wxChar** labels,
385 const long* values,
386 wxPGChoices* choicesCache,
387 int value = 0 );
388
389 wxEnumProperty( const wxString& label,
390 const wxString& name,
391 const wxArrayString& labels,
392 const wxArrayInt& values = wxArrayInt(),
393 int value = 0 );
394#else
395 wxEnumProperty( const wxString& label = wxPG_LABEL,
396 const wxString& name = wxPG_LABEL,
397 const wxArrayString& labels = wxArrayString(),
398 const wxArrayInt& values = wxArrayInt(),
399 int value = 0 );
400#endif
401
402 virtual ~wxEnumProperty();
403
404 size_t GetItemCount() const { return m_choices.GetCount(); }
1c4293cb
VZ
405
406 virtual void OnSetValue();
1425eca5 407 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
1c4293cb
VZ
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;
413
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,
417 int number,
418 int argFlags = 0 ) const;
419
420 //
421 // Additional virtuals
422
423 // This must be overridden to have non-index based value
424 virtual int GetIndexForValue( int value ) const;
425
939d9364
JS
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; }
430
d8812c6e
JS
431 virtual void OnValidationFailure( wxVariant& pendingValue );
432
1c4293cb
VZ
433protected:
434
435 int GetIndex() const;
436 void SetIndex( int index );
437
438 bool ValueFromString_( wxVariant& value,
439 const wxString& text,
440 int argFlags ) const;
441 bool ValueFromInt_( wxVariant& value, int intVal, int argFlags ) const;
442
443 static void ResetNextIndex() { ms_nextIndex = -2; }
444
445private:
446 // This is private so that classes are guaranteed to use GetIndex
447 // for up-to-date index value.
448 int m_index;
449
450 // Relies on ValidateValue being called always before OnSetValue
451 static int ms_nextIndex;
452};
453
454// -----------------------------------------------------------------------
455
1c4293cb
VZ
456/** @class wxEditEnumProperty
457 @ingroup classes
458 wxEnumProperty with wxString value and writable combo box editor.
459
460 @remarks
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).
463*/
464class WXDLLIMPEXP_PROPGRID wxEditEnumProperty : public wxEnumProperty
465{
466 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty)
467public:
468
469 wxEditEnumProperty( const wxString& label,
470 const wxString& name,
471 const wxChar** labels,
472 const long* values,
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 );
483
484 // Special constructor for caching choices (used by derived class)
485 wxEditEnumProperty( const wxString& label,
486 const wxString& name,
487 const wxChar** labels,
488 const long* values,
489 wxPGChoices* choicesCache,
490 const wxString& value );
491
492 virtual ~wxEditEnumProperty();
493
494protected:
495};
496
497// -----------------------------------------------------------------------
498
499/** @class wxFlagsProperty
500 @ingroup classes
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
507 updated properly.
508*/
509class WXDLLIMPEXP_PROPGRID wxFlagsProperty : public wxPGProperty
510{
511 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty)
512public:
513
514#ifndef SWIG
515 wxFlagsProperty( const wxString& label,
516 const wxString& name,
517 const wxChar** labels,
518 const long* values = NULL,
519 long value = 0 );
520 wxFlagsProperty( const wxString& label,
521 const wxString& name,
522 wxPGChoices& choices,
523 long value = 0 );
524#endif
525 wxFlagsProperty( const wxString& label = wxPG_LABEL,
526 const wxString& name = wxPG_LABEL,
527 const wxArrayString& labels = wxArrayString(),
528 const wxArrayInt& values = wxArrayInt(),
529 int value = 0 );
530 virtual ~wxFlagsProperty ();
531
532 virtual void OnSetValue();
1425eca5 533 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
1c4293cb
VZ
534 virtual bool StringToValue( wxVariant& variant,
535 const wxString& text,
536 int flags ) const;
b8b1ff48
JS
537 virtual wxVariant ChildChanged( wxVariant& thisValue,
538 int childIndex,
539 wxVariant& childValue ) const;
1c4293cb 540 virtual void RefreshChildren();
16372f0d 541 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
1c4293cb 542
939d9364
JS
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; }
1c4293cb
VZ
546
547 // helpers
548 size_t GetItemCount() const { return m_choices.GetCount(); }
549 const wxString& GetLabel( size_t ind ) const
550 { return m_choices.GetLabel(ind); }
551
552protected:
1c4293cb
VZ
553 // Used to detect if choices have been changed
554 wxPGChoicesData* m_oldChoicesData;
555
556 // Needed to properly mark changed sub-properties
557 long m_oldValue;
558
559 // Converts string id to a relevant bit.
560 long IdToBit( const wxString& id ) const;
561
562 // Creates children and sets value.
563 void Init();
564};
565
566// -----------------------------------------------------------------------
567
568/** @class wxPGFileDialogAdapter
569 @ingroup classes
570*/
571class WXDLLIMPEXP_PROPGRID
572 wxPGFileDialogAdapter : public wxPGEditorDialogAdapter
573{
574public:
575 virtual bool DoShowDialog( wxPropertyGrid* propGrid,
576 wxPGProperty* property );
577};
578
579// -----------------------------------------------------------------------
580
1c4293cb
VZ
581// Indicates first bit useable by derived properties.
582#define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
583
584/** @class wxFileProperty
585 @ingroup classes
586 Like wxLongStringProperty, but the button triggers file selector instead.
587
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
594 given path string.
595 - "InitialPath": Sets the initial path of where to look for files.
596 - "DialogTitle": Sets a specific title for the dir dialog.
597*/
598class WXDLLIMPEXP_PROPGRID wxFileProperty : public wxPGProperty
599{
600 friend class wxPGFileDialogAdapter;
601 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty)
602public:
603
604 wxFileProperty( const wxString& label = wxPG_LABEL,
605 const wxString& name = wxPG_LABEL,
606 const wxString& value = wxEmptyString );
607 virtual ~wxFileProperty ();
608
609 virtual void OnSetValue();
1425eca5 610 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
1c4293cb
VZ
611 virtual bool StringToValue( wxVariant& variant,
612 const wxString& text,
613 int argFlags = 0 ) const;
614 virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
7eac5c53 615 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
1c4293cb
VZ
616
617 static wxValidator* GetClassValidator();
618 virtual wxValidator* DoGetValidator() const;
619
1425eca5
JS
620 /**
621 Returns filename to file represented by current value.
622 */
623 wxFileName GetFileName() const;
624
1c4293cb
VZ
625protected:
626 wxString m_wildcard;
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
1c4293cb
VZ
630 int m_indFilter; // index to the selected filter
631};
632
633// -----------------------------------------------------------------------
634
635#define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
636
637
638/** @class wxPGLongStringDialogAdapter
639 @ingroup classes
640*/
641class WXDLLIMPEXP_PROPGRID
642 wxPGLongStringDialogAdapter : public wxPGEditorDialogAdapter
643{
644public:
645 virtual bool DoShowDialog( wxPropertyGrid* propGrid,
646 wxPGProperty* property );
647};
648
649
650/** @class wxLongStringProperty
651 @ingroup classes
652 Like wxStringProperty, but has a button that triggers a small text
653 editor dialog.
654*/
655class WXDLLIMPEXP_PROPGRID wxLongStringProperty : public wxPGProperty
656{
657 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty)
658public:
659
660 wxLongStringProperty( const wxString& label = wxPG_LABEL,
661 const wxString& name = wxPG_LABEL,
662 const wxString& value = wxEmptyString );
663 virtual ~wxLongStringProperty();
664
1425eca5 665 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
1c4293cb
VZ
666 virtual bool StringToValue( wxVariant& variant,
667 const wxString& text,
668 int argFlags = 0 ) const;
7eac5c53
JS
669 virtual bool OnEvent( wxPropertyGrid* propgrid,
670 wxWindow* primary, wxEvent& event );
1c4293cb
VZ
671
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 );
676
677 static bool DisplayEditorDialog( wxPGProperty* prop,
678 wxPropertyGrid* propGrid,
679 wxString& value );
680
681protected:
682};
683
684// -----------------------------------------------------------------------
685
686
687// Exclude class from wxPython bindings
688#ifndef SWIG
689
690/** @class wxDirProperty
691 @ingroup classes
692 Like wxLongStringProperty, but the button triggers dir selector instead.
693
694 <b>Supported special attributes:</b>
695 - "DialogMessage": Sets specific message in the dir selector.
696*/
697class WXDLLIMPEXP_PROPGRID wxDirProperty : public wxLongStringProperty
698{
1c4293cb 699 DECLARE_DYNAMIC_CLASS(wxDirProperty)
1c4293cb
VZ
700public:
701 wxDirProperty( const wxString& name = wxPG_LABEL,
702 const wxString& label = wxPG_LABEL,
703 const wxString& value = wxEmptyString );
704 virtual ~wxDirProperty();
705
7eac5c53
JS
706 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
707 virtual wxValidator* DoGetValidator() const;
1c4293cb
VZ
708
709 virtual bool OnButtonClick ( wxPropertyGrid* propGrid, wxString& value );
710
711protected:
712 wxString m_dlgMessage;
713};
714
715#endif // !SWIG
716
717// -----------------------------------------------------------------------
718
719// wxBoolProperty specific flags
720#define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
721// DCC = Double Click Cycles
722#define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
723
724
725// -----------------------------------------------------------------------
726
727/** @class wxArrayStringProperty
728 @ingroup classes
729 Property that manages a list of strings.
730*/
731class WXDLLIMPEXP_PROPGRID wxArrayStringProperty : public wxPGProperty
732{
733 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty)
734public:
735
736 wxArrayStringProperty( const wxString& label = wxPG_LABEL,
737 const wxString& name = wxPG_LABEL,
738 const wxArrayString& value = wxArrayString() );
739 virtual ~wxArrayStringProperty();
740
741 virtual void OnSetValue();
1425eca5 742 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
7eac5c53
JS
743 virtual bool StringToValue( wxVariant& variant,
744 const wxString& text,
745 int argFlags = 0 ) const;
746 virtual bool OnEvent( wxPropertyGrid* propgrid,
747 wxWindow* primary, wxEvent& event );
1c4293cb
VZ
748
749 virtual void GenerateValueAsString();
750
751 // Shows string editor dialog. Value to be edited should be read from
752 // value, and if dialog is not cancelled, it should be stored back and true
753 // should be returned if that was the case.
754 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value );
755
756 // Helper.
757 virtual bool OnButtonClick( wxPropertyGrid* propgrid,
758 wxWindow* primary,
759 const wxChar* cbt );
760
761#ifndef SWIG
762 // Creates wxArrayEditorDialog for string editing. Called in OnButtonClick.
763 virtual wxArrayEditorDialog* CreateEditorDialog();
764#endif
765
766protected:
767 wxString m_display; // Cache for displayed text.
768};
769
770// -----------------------------------------------------------------------
771
772#define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
773 DECL) \
774DECL PROPNAME : public wxArrayStringProperty \
775{ \
776 WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
777public: \
778 PROPNAME( const wxString& label = wxPG_LABEL, \
779 const wxString& name = wxPG_LABEL, \
780 const wxArrayString& value = wxArrayString() ); \
781 ~PROPNAME(); \
782 virtual void GenerateValueAsString(); \
783 virtual bool StringToValue( wxVariant& value, \
784 const wxString& text, int = 0 ) const; \
785 virtual bool OnEvent( wxPropertyGrid* propgrid, \
786 wxWindow* primary, wxEvent& event ); \
787 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
7eac5c53 788 virtual wxValidator* DoGetValidator() const; \
1c4293cb
VZ
789};
790
791#define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
792WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
793
794#define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
795 DELIMCHAR, \
796 CUSTBUTTXT) \
797WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
798 wxArrayString, const wxArrayString&, \
799 TextCtrlAndButton) \
800PROPNAME::PROPNAME( const wxString& label, \
801 const wxString& name, \
802 const wxArrayString& value ) \
803 : wxArrayStringProperty(label,name,value) \
804{ \
805 PROPNAME::GenerateValueAsString(); \
806} \
807PROPNAME::~PROPNAME() { } \
808void PROPNAME::GenerateValueAsString() \
809{ \
810 wxChar delimChar = DELIMCHAR; \
811 if ( delimChar == wxS('"') ) \
812 wxArrayStringProperty::GenerateValueAsString(); \
813 else \
814 wxPropertyGrid::ArrayStringToString(m_display, \
815 m_value.GetArrayString(), \
816 0,DELIMCHAR,0); \
817} \
818bool PROPNAME::StringToValue( wxVariant& variant, \
819 const wxString& text, int ) const \
820{ \
821 wxChar delimChar = DELIMCHAR; \
822 if ( delimChar == wxS('"') ) \
823 return wxArrayStringProperty::StringToValue(variant, text, 0); \
824 \
825 wxArrayString arr; \
826 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
827 arr.Add( token ); \
828 WX_PG_TOKENIZER1_END() \
829 variant = arr; \
830 return true; \
831} \
832bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
833 wxWindow* primary, wxEvent& event ) \
834{ \
835 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
836 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
837 return false; \
838}
839
840#define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
841WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
842
843#define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
844WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
845
846#define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
847WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
848 DELIMCHAR, \
849 CUSTBUTTXT) \
850wxValidator* PROPNAME::DoGetValidator () const \
d3b9f782 851{ return NULL; }
1c4293cb
VZ
852
853
854// -----------------------------------------------------------------------
855// wxArrayEditorDialog
856// -----------------------------------------------------------------------
857
1c4293cb
VZ
858#define wxAEDIALOG_STYLE \
859 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
860
861class WXDLLIMPEXP_PROPGRID wxArrayEditorDialog : public wxDialog
862{
863public:
864 wxArrayEditorDialog();
865 virtual ~wxArrayEditorDialog() { }
866
867 void Init();
868
869 wxArrayEditorDialog( wxWindow *parent,
870 const wxString& message,
871 const wxString& caption,
872 long style = wxAEDIALOG_STYLE,
873 const wxPoint& pos = wxDefaultPosition,
874 const wxSize& sz = wxDefaultSize );
875
876 bool Create( wxWindow *parent,
877 const wxString& message,
878 const wxString& caption,
879 long style = wxAEDIALOG_STYLE,
880 const wxPoint& pos = wxDefaultPosition,
881 const wxSize& sz = wxDefaultSize );
882
883 /** Set value modified by dialog.
884 */
885 virtual void SetDialogValue( const wxVariant& WXUNUSED(value) )
886 {
887 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
888 }
889
890 /** Return value modified by dialog.
891 */
892 virtual wxVariant GetDialogValue() const
893 {
894 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
895 return wxVariant();
896 }
897
898 /** Override to return wxValidator to be used with the wxTextCtrl
899 in dialog. Note that the validator is used in the standard
900 wx way, ie. it immediately prevents user from entering invalid
901 input.
902
903 @remarks
904 Dialog frees the validator.
905 */
906 virtual wxValidator* GetTextCtrlValidator() const
907 {
d3b9f782 908 return NULL;
1c4293cb
VZ
909 }
910
911 // Returns true if array was actually modified
912 bool IsModified() const { return m_modified; }
913
914 //const wxArrayString& GetStrings() const { return m_array; }
915
916 // implementation from now on
917 void OnUpdateClick(wxCommandEvent& event);
918 void OnAddClick(wxCommandEvent& event);
919 void OnDeleteClick(wxCommandEvent& event);
920 void OnListBoxClick(wxCommandEvent& event);
921 void OnUpClick(wxCommandEvent& event);
922 void OnDownClick(wxCommandEvent& event);
923 //void OnCustomEditClick(wxCommandEvent& event);
924 void OnIdle(wxIdleEvent& event);
925
926protected:
927 wxTextCtrl* m_edValue;
928 wxListBox* m_lbStrings;
929
930 wxButton* m_butAdd; // Button pointers
931 wxButton* m_butCustom; // required for disabling/enabling changing.
932 wxButton* m_butUpdate;
933 wxButton* m_butRemove;
934 wxButton* m_butUp;
935 wxButton* m_butDown;
936
937 //wxArrayString m_array;
938
939 const wxChar* m_custBtText;
940 //wxArrayStringPropertyClass* m_pCallingClass;
941
942 bool m_modified;
943
944 unsigned char m_curFocus;
945
946 // These must be overridden - must return true on success.
947 virtual wxString ArrayGet( size_t index ) = 0;
948 virtual size_t ArrayGetCount() = 0;
949 virtual bool ArrayInsert( const wxString& str, int index ) = 0;
950 virtual bool ArraySet( size_t index, const wxString& str ) = 0;
951 virtual void ArrayRemoveAt( int index ) = 0;
952 virtual void ArraySwap( size_t first, size_t second ) = 0;
953
954private:
1c4293cb
VZ
955 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog)
956 DECLARE_EVENT_TABLE()
1c4293cb
VZ
957};
958
959// -----------------------------------------------------------------------
960// wxPGArrayStringEditorDialog
961// -----------------------------------------------------------------------
962
963class WXDLLIMPEXP_PROPGRID
964 wxPGArrayStringEditorDialog : public wxArrayEditorDialog
965{
966public:
967 wxPGArrayStringEditorDialog();
968 virtual ~wxPGArrayStringEditorDialog() { }
969
970 void Init();
971
972 virtual void SetDialogValue( const wxVariant& value )
973 {
974 m_array = value.GetArrayString();
975 }
976
977 virtual wxVariant GetDialogValue() const
978 {
979 return m_array;
980 }
981
982 void SetCustomButton( const wxChar* custBtText, wxArrayStringProperty* pcc )
983 {
984 m_custBtText = custBtText;
985 m_pCallingClass = pcc;
986 }
987
988 void OnCustomEditClick(wxCommandEvent& event);
989
990protected:
991 wxArrayString m_array;
992
993 wxArrayStringProperty* m_pCallingClass;
994
995 virtual wxString ArrayGet( size_t index );
996 virtual size_t ArrayGetCount();
997 virtual bool ArrayInsert( const wxString& str, int index );
998 virtual bool ArraySet( size_t index, const wxString& str );
999 virtual void ArrayRemoveAt( int index );
1000 virtual void ArraySwap( size_t first, size_t second );
1001
1002private:
1c4293cb
VZ
1003 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog)
1004 DECLARE_EVENT_TABLE()
1c4293cb
VZ
1005};
1006
1007// -----------------------------------------------------------------------
1008
f4bc1aa2
JS
1009#endif // wxUSE_PROPGRID
1010
1c4293cb 1011#endif // _WX_PROPGRID_PROPS_H_