Moved wxPGChoices m_choices member from various property classes to base wxPGProperty...
[wxWidgets.git] / include / wx / propgrid / props.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/props.h
3 // Purpose: wxPropertyGrid Property Classes
4 // Author: Jaakko Salli
5 // Modified by:
6 // Created: 2007-03-28
7 // RCS-ID: $Id:
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PROPGRID_PROPS_H_
13 #define _WX_PROPGRID_PROPS_H_
14
15 #if wxUSE_PROPGRID
16
17 // -----------------------------------------------------------------------
18
19 class wxArrayEditorDialog;
20
21 #include "wx/propgrid/editors.h"
22
23 // -----------------------------------------------------------------------
24
25 //
26 // Additional property class declaration helper macros
27 //
28
29 //
30 // Property class implementation helper macros.
31 //
32
33 #define WX_PG_DECLARE_BASIC_TYPE_METHODS() \
34 virtual wxString GetValueAsString( int argFlags = 0 ) const; \
35 virtual bool StringToValue( wxVariant& variant, \
36 const wxString& text, \
37 int argFlags = 0 ) const;
38
39 #define WX_PG_DECLARE_CHOICE_METHODS() \
40 virtual bool IntToValue( wxVariant& variant, \
41 int number, int argFlags = 0 ) const; \
42
43 #define WX_PG_DECLARE_EVENT_METHODS() \
44 virtual bool OnEvent( wxPropertyGrid* propgrid, \
45 wxWindow* primary, wxEvent& event );
46
47 #define WX_PG_DECLARE_PARENTAL_METHODS() \
48 virtual void ChildChanged( wxVariant& thisValue, \
49 int childIndex, wxVariant& childValue ) const; \
50 virtual void RefreshChildren();
51
52 #define WX_PG_DECLARE_CUSTOM_PAINT_METHODS() \
53 virtual wxSize OnMeasureImage( int item ) const; \
54 virtual void OnCustomPaint( wxDC& dc, \
55 const wxRect& rect, wxPGPaintData& paintdata );
56
57 #define WX_PG_DECLARE_ATTRIBUTE_METHODS() \
58 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
59
60 #define WX_PG_DECLARE_VALIDATOR_METHODS() \
61 virtual wxValidator* DoGetValidator() const;
62
63 // Adds constructor function as well.
64 #define WX_PG_IMPLEMENT_PROPERTY_CLASS2(NAME,CLASSNAME,\
65 UPCLASS,T,T_AS_ARG,EDITOR) \
66 IMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS) \
67 WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME,T,EDITOR)
68
69 // A regular property
70 #define WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME,UPNAME,T,T_AS_ARG,EDITOR) \
71 WX_PG_IMPLEMENT_PROPERTY_CLASS2(NAME,NAME,UPNAME,T,T_AS_ARG,EDITOR)
72
73 #define WX_PG_DECLARE_DERIVED_PROPERTY_CLASS(CLASSNAME) \
74 DECLARE_DYNAMIC_CLASS(CLASSNAME)
75
76 // Derived property class is one that inherits from an existing working property
77 // class, but assumes same value and editor type.
78 #define WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(NAME,UPNAME,T_AS_ARG) \
79 IMPLEMENT_DYNAMIC_CLASS(NAME, UPNAME)
80
81 // -----------------------------------------------------------------------
82
83 #define wxPG_NO_ESCAPE wxPG_PROP_NO_ESCAPE // No escape sequences
84 #define wxPG_ESCAPE 0 // Escape sequences
85
86 #define WX_PG_DECLARE_STRING_PROPERTY_WITH_DECL(NAME, DECL) \
87 DECL NAME : public wxLongStringProperty \
88 { \
89 WX_PG_DECLARE_DERIVED_PROPERTY_CLASS(NAME) \
90 public: \
91 NAME( const wxString& name = wxPG_LABEL, \
92 const wxString& label = wxPG_LABEL, \
93 const wxString& value = wxEmptyString); \
94 virtual ~NAME(); \
95 virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value ); \
96 WX_PG_DECLARE_VALIDATOR_METHODS() \
97 };
98
99 #define WX_PG_DECLARE_STRING_PROPERTY(NAME) \
100 WX_PG_DECLARE_STRING_PROPERTY_WITH_DECL(NAME, class) \
101
102 #define WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(NAME, FLAGS) \
103 WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(NAME,wxLongStringProperty,\
104 const wxString&) \
105 NAME::NAME( const wxString& name, \
106 const wxString& label, \
107 const wxString& value ) \
108 : wxLongStringProperty(name,label,value) \
109 { \
110 m_flags |= FLAGS; \
111 } \
112 NAME::~NAME() { }
113
114 #define WX_PG_IMPLEMENT_STRING_PROPERTY(NAME, FLAGS) \
115 WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(NAME,FLAGS) \
116 wxValidator* NAME::DoGetValidator () const \
117 { return (wxValidator*) NULL; }
118
119 // -----------------------------------------------------------------------
120
121 #define WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY_WITH_DECL(CLASSNAME,DECL) \
122 DECL CLASSNAME : public wxFlagsProperty \
123 { \
124 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
125 public: \
126 CLASSNAME( const wxString& label = wxPG_LABEL, \
127 const wxString& name = wxPG_LABEL, \
128 long value = -1 ); \
129 virtual ~CLASSNAME(); \
130 };
131
132 #define WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY(CLASSNAME) \
133 WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY_WITH_DECL(CLASSNAME, class)
134
135 // This will create interface for wxFlagsProperty derived class
136 // named CLASSNAME.
137 #define WX_PG_IMPLEMENT_CUSTOM_FLAGS_PROPERTY(CLASSNAME,LABELS,VALUES,DEFVAL) \
138 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME,wxFlagsProperty,long_##CLASSNAME,\
139 long,TextCtrl) \
140 CLASSNAME::CLASSNAME( const wxString& label, \
141 const wxString& name, \
142 long value ) \
143 : wxFlagsProperty(label,name,LABELS,VALUES,value!=-1?value:DEFVAL) \
144 { \
145 m_flags |= wxPG_PROP_STATIC_CHOICES; \
146 } \
147 CLASSNAME::~CLASSNAME() { }
148
149
150 // -----------------------------------------------------------------------
151
152 #define WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY_WITH_DECL(CLASSNAME, DECL) \
153 class CLASSNAME : public wxEnumProperty \
154 { \
155 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
156 public: \
157 CLASSNAME( const wxString& label = wxPG_LABEL, \
158 const wxString& name = wxPG_LABEL, \
159 int value = -1 ); \
160 virtual ~CLASSNAME(); \
161 };
162
163 #define WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY(CLASSNAME) \
164 WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY_WITH_DECL(CLASSNAME, class)
165
166 #define WX_PG_IMPLEMENT_CUSTOM_ENUM_PROPERTY(CLASSNAME,LABELS,VALUES,DEFVAL) \
167 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME, wxEnumProperty, long_##CLASSNAME, \
168 int, Choice) \
169 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, int value ) \
170 : wxEnumProperty(label,name,LABELS,VALUES,value!=-1?value:DEFVAL) \
171 { \
172 m_flags |= wxPG_PROP_STATIC_CHOICES; \
173 } \
174 CLASSNAME::~CLASSNAME() { }
175
176
177 // -----------------------------------------------------------------------
178
179 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_WITH_DECL(CLASSNAME, DECL) \
180 DECL CLASSNAME : public wxSystemColourProperty \
181 { \
182 DECLARE_DYNAMIC_CLASS(CLASSNAME) \
183 public: \
184 CLASSNAME( const wxString& label = wxPG_LABEL, \
185 const wxString& name = wxPG_LABEL, \
186 const wxColourPropertyValue& value = wxColourPropertyValue() ); \
187 virtual ~CLASSNAME(); \
188 virtual wxColour GetColour( int index ) const; \
189 };
190
191 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY(CLASSNAME) \
192 WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_WITH_DECL(CLASSNAME, class)
193
194 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY(CLASSNAME,\
195 LABELS,VALUES,COLOURS) \
196 static wxPGChoices gs_##CLASSNAME##_choicesCache; \
197 WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(CLASSNAME, wxSystemColourProperty, \
198 const wxColourPropertyValue&) \
199 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, \
200 const wxColourPropertyValue& value ) \
201 : wxSystemColourProperty(label, name, LABELS, VALUES, \
202 &gs_##CLASSNAME##_choicesCache, value ) \
203 { \
204 m_flags |= wxPG_PROP_TRANSLATE_CUSTOM; \
205 } \
206 CLASSNAME::~CLASSNAME () { } \
207 wxColour CLASSNAME::GetColour ( int index ) const \
208 { \
209 if ( !m_choices.HasValue(index) ) \
210 { \
211 wxASSERT( index < (int)m_choices.GetCount() ); \
212 return COLOURS[index]; \
213 } \
214 return COLOURS[m_choices.GetValue(index)]; \
215 }
216
217 // -----------------------------------------------------------------------
218
219 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(CLASSNAME,\
220 DECL) \
221 DECL CLASSNAME : public wxSystemColourProperty \
222 { \
223 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
224 public: \
225 CLASSNAME( const wxString& label = wxPG_LABEL, \
226 const wxString& name = wxPG_LABEL, \
227 const wxColour& value = wxColour() ); \
228 virtual ~CLASSNAME(); \
229 virtual wxString GetValueAsString( int argFlags ) const; \
230 virtual wxColour GetColour( int index ) const; \
231 virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const; \
232 void Init( wxColour colour ); \
233 };
234
235 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(CLASSNAME) \
236 WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(CLASSNAME, class)
237
238 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(CLASSNAME, \
239 LABELS, \
240 VALUES, \
241 COLOURS, \
242 EDITOR) \
243 static wxPGChoices gs_##CLASSNAME##_choicesCache; \
244 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME, wxSystemColourProperty, \
245 wxColour, const wxColour&,EDITOR) \
246 CLASSNAME::CLASSNAME( const wxString& label, \
247 const wxString& name, \
248 const wxColour& value ) \
249 : wxSystemColourProperty(label, name, LABELS, VALUES, \
250 &gs_##CLASSNAME##_choicesCache, value ) \
251 { \
252 if ( &value ) \
253 Init( value ); \
254 else \
255 Init( *wxWHITE ); \
256 m_flags |= wxPG_PROP_TRANSLATE_CUSTOM; \
257 } \
258 CLASSNAME::~CLASSNAME() { } \
259 void CLASSNAME::Init( wxColour colour ) \
260 { \
261 if ( !colour.Ok() ) \
262 colour = *wxWHITE; \
263 wxVariant variant; \
264 variant << colour; \
265 m_value = variant; \
266 int ind = ColToInd(colour); \
267 if ( ind < 0 ) \
268 ind = m_choices.GetCount() - 1; \
269 SetIndex( ind ); \
270 } \
271 wxString CLASSNAME::GetValueAsString( int argFlags ) const \
272 { \
273 const wxPGEditor* editor = GetEditorClass(); \
274 if ( editor != wxPG_EDITOR(Choice) && \
275 editor != wxPG_EDITOR(ChoiceAndButton) && \
276 editor != wxPG_EDITOR(ComboBox) ) \
277 argFlags |= wxPG_PROPERTY_SPECIFIC; \
278 return wxSystemColourProperty::GetValueAsString(argFlags); \
279 } \
280 wxColour CLASSNAME::GetColour( int index ) const \
281 { \
282 if ( !m_choices.HasValue(index) ) \
283 { \
284 wxASSERT( index < (int)GetItemCount() ); \
285 return COLOURS[index]; \
286 } \
287 return COLOURS[m_choices.GetValue(index)]; \
288 } \
289 wxVariant CLASSNAME::DoTranslateVal( wxColourPropertyValue& v ) const \
290 { \
291 wxVariant variant; \
292 variant << v.m_colour; \
293 return variant; \
294 }
295
296
297 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(CLASSNAME, \
298 LABELS, \
299 VALUES, \
300 COLOURS) \
301 WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(CLASSNAME, \
302 LABELS, \
303 VALUES, \
304 COLOURS, \
305 Choice)
306
307 // -----------------------------------------------------------------------
308
309 //
310 // These macros help creating DoGetValidator
311 #define WX_PG_DOGETVALIDATOR_ENTRY() \
312 static wxValidator* s_ptr = (wxValidator*) NULL; \
313 if ( s_ptr ) return s_ptr;
314
315 // Common function exit
316 #define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
317 s_ptr = VALIDATOR; \
318 wxPGGlobalVars->m_arrValidators.Add( (void*) VALIDATOR ); \
319 return VALIDATOR;
320
321 // -----------------------------------------------------------------------
322
323 #ifndef SWIG
324
325 /** @class wxPGInDialogValidator
326 @ingroup classes
327 Creates and manages a temporary wxTextCtrl for validation purposes.
328 Uses wxPropertyGrid's current editor, if available.
329 */
330 class WXDLLIMPEXP_PROPGRID wxPGInDialogValidator
331 {
332 public:
333 wxPGInDialogValidator()
334 {
335 m_textCtrl = NULL;
336 }
337
338 ~wxPGInDialogValidator()
339 {
340 if ( m_textCtrl )
341 m_textCtrl->Destroy();
342 }
343
344 bool DoValidate( wxPropertyGrid* propGrid,
345 wxValidator* validator,
346 const wxString& value );
347
348 private:
349 wxTextCtrl* m_textCtrl;
350 };
351
352 #endif // SWIG
353
354
355 // -----------------------------------------------------------------------
356 // Property classes
357 // -----------------------------------------------------------------------
358
359 #define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
360
361 /** @class wxStringProperty
362 @ingroup classes
363 Basic property with string value.
364
365 <b>Supported special attributes:</b>
366 - "Password": set to 1 inorder to enable wxTE_PASSWORD on the editor.
367
368 @remarks
369 - If value "<composed>" is set, then actual value is formed (or composed)
370 from values of child properties.
371 */
372 class WXDLLIMPEXP_PROPGRID wxStringProperty : public wxPGProperty
373 {
374 WX_PG_DECLARE_PROPERTY_CLASS(wxStringProperty)
375 public:
376 wxStringProperty( const wxString& label = wxPG_LABEL,
377 const wxString& name = wxPG_LABEL,
378 const wxString& value = wxEmptyString );
379 virtual ~wxStringProperty();
380
381 WX_PG_DECLARE_BASIC_TYPE_METHODS()
382 WX_PG_DECLARE_ATTRIBUTE_METHODS()
383
384 /** This is updated so "<composed>" special value can be handled.
385 */
386 virtual void OnSetValue();
387
388 protected:
389 };
390
391 // -----------------------------------------------------------------------
392
393 #ifndef SWIG
394 /** Constants used with DoValidation() methods.
395 */
396 enum
397 {
398 /** Instead of modifying the value, show an error message.
399 */
400 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE = 0,
401
402 /** Modify value, but stick with the limitations.
403 */
404 wxPG_PROPERTY_VALIDATION_SATURATE = 1,
405
406 /** Modify value, wrap around on overflow.
407 */
408 wxPG_PROPERTY_VALIDATION_WRAP = 2
409 };
410 #endif
411
412 // -----------------------------------------------------------------------
413
414 /** @class wxIntProperty
415 @ingroup classes
416 Basic property with integer value.
417
418 Seamlessly supports 64-bit integer (wxLongLong) on overflow.
419
420 <b>Example how to use seamless 64-bit integer support</b>
421
422 Getting value:
423
424 @code
425 wxLongLong_t value = pg->GetPropertyValueAsLongLong();
426 @endcode
427
428 or
429
430 @code
431 wxLongLong_t value;
432 wxVariant variant = property->GetValue();
433 if ( variant.GetType() == "wxLongLong" )
434 value = wxLongLongFromVariant(variant);
435 else
436 value = variant.GetLong();
437 @endcode
438
439 Setting value:
440
441 @code
442 pg->SetPropertyValue(longLongVal);
443 @endcode
444
445 or
446
447 @code
448 property->SetValue(WXVARIANT(longLongVal));
449 @endcode
450
451
452 <b>Supported special attributes:</b>
453 - "Min", "Max": Specify acceptable value range.
454 */
455 class WXDLLIMPEXP_PROPGRID wxIntProperty : public wxPGProperty
456 {
457 WX_PG_DECLARE_PROPERTY_CLASS(wxIntProperty)
458 public:
459 wxIntProperty( const wxString& label = wxPG_LABEL,
460 const wxString& name = wxPG_LABEL,
461 long value = 0 );
462 virtual ~wxIntProperty();
463
464 wxIntProperty( const wxString& label,
465 const wxString& name,
466 const wxLongLong& value );
467 WX_PG_DECLARE_BASIC_TYPE_METHODS()
468 virtual bool ValidateValue( wxVariant& value,
469 wxPGValidationInfo& validationInfo ) const;
470 virtual bool IntToValue( wxVariant& variant,
471 int number,
472 int argFlags = 0 ) const;
473 static wxValidator* GetClassValidator();
474 virtual wxValidator* DoGetValidator() const;
475
476 /** Validation helper.
477 */
478 static bool DoValidation( const wxPGProperty* property,
479 wxLongLong_t& value,
480 wxPGValidationInfo* pValidationInfo,
481 int mode =
482 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
483
484 protected:
485 };
486
487 // -----------------------------------------------------------------------
488
489 /** @class wxUIntProperty
490 @ingroup classes
491 Basic property with unsigned integer value.
492 Seamlessly supports 64-bit integer (wxULongLong) on overflow.
493
494 <b>Supported special attributes:</b>
495 - "Min", "Max": Specify acceptable value range.
496 - "Base": Define base. Valid constants are wxPG_BASE_OCT, wxPG_BASE_DEC,
497 wxPG_BASE_HEX and wxPG_BASE_HEXL (lowercase characters). Arbitrary bases
498 are <b>not</b> supported.
499 - "Prefix": Possible values are wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and
500 wxPG_PREFIX_DOLLAR_SIGN. Only wxPG_PREFIX_NONE works with Decimal and Octal
501 numbers.
502
503 @remarks
504 - For example how to use seamless 64-bit integer support, see wxIntProperty
505 documentation (just use wxULongLong instead of wxLongLong).
506 */
507 class WXDLLIMPEXP_PROPGRID wxUIntProperty : public wxPGProperty
508 {
509 WX_PG_DECLARE_PROPERTY_CLASS(wxUIntProperty)
510 public:
511 wxUIntProperty( const wxString& label = wxPG_LABEL,
512 const wxString& name = wxPG_LABEL,
513 unsigned long value = 0 );
514 virtual ~wxUIntProperty();
515 wxUIntProperty( const wxString& label,
516 const wxString& name,
517 const wxULongLong& value );
518 WX_PG_DECLARE_BASIC_TYPE_METHODS()
519 WX_PG_DECLARE_ATTRIBUTE_METHODS()
520 virtual bool ValidateValue( wxVariant& value,
521 wxPGValidationInfo& validationInfo ) const;
522 virtual bool IntToValue( wxVariant& variant,
523 int number,
524 int argFlags = 0 ) const;
525 protected:
526 wxByte m_base;
527 wxByte m_realBase; // translated to 8,16,etc.
528 wxByte m_prefix;
529 private:
530 void Init();
531 };
532
533 // -----------------------------------------------------------------------
534
535 /** @class wxFloatProperty
536 @ingroup classes
537 Basic property with double-precision floating point value.
538
539 <b>Supported special attributes:</b>
540 - "Precision": Sets the (max) precision used when floating point value is
541 rendered as text. The default -1 means infinite precision.
542 */
543 class WXDLLIMPEXP_PROPGRID wxFloatProperty : public wxPGProperty
544 {
545 WX_PG_DECLARE_PROPERTY_CLASS(wxFloatProperty)
546 public:
547 wxFloatProperty( const wxString& label = wxPG_LABEL,
548 const wxString& name = wxPG_LABEL,
549 double value = 0.0 );
550 virtual ~wxFloatProperty();
551
552 WX_PG_DECLARE_BASIC_TYPE_METHODS()
553 WX_PG_DECLARE_ATTRIBUTE_METHODS()
554 virtual bool ValidateValue( wxVariant& value,
555 wxPGValidationInfo& validationInfo ) const;
556
557 /** Validation helper.
558 */
559 static bool DoValidation( const wxPGProperty* property,
560 double& value,
561 wxPGValidationInfo* pValidationInfo,
562 int mode =
563 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
564
565 protected:
566 int m_precision;
567 virtual wxValidator* DoGetValidator () const;
568 };
569
570 // -----------------------------------------------------------------------
571
572 // Exclude class from wxPython bindings
573 #ifndef SWIG
574
575 /** @class wxBoolProperty
576 @ingroup classes
577 Basic property with boolean value.
578
579 <b>Supported special attributes:</b>
580 - "UseCheckbox": Set to 1 to use check box editor instead of combo box.
581 - "UseDClickCycling": Set to 1 to cycle combo box instead showing the list.
582 */
583 class WXDLLIMPEXP_PROPGRID wxBoolProperty : public wxPGProperty
584 {
585 WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty)
586 public:
587 wxBoolProperty( const wxString& label = wxPG_LABEL,
588 const wxString& name = wxPG_LABEL,
589 bool value = false );
590 virtual ~wxBoolProperty();
591
592 WX_PG_DECLARE_BASIC_TYPE_METHODS()
593 WX_PG_DECLARE_CHOICE_METHODS()
594 WX_PG_DECLARE_ATTRIBUTE_METHODS()
595 };
596
597 #endif // !SWIG
598
599 // -----------------------------------------------------------------------
600
601 /** @class wxBaseEnumProperty
602 @ingroup classes
603 Derive dynamic custom properties with choices from this class.
604
605 @remarks
606 - Updating private index is important. You can do this either by calling
607 SetIndex() in IntToValue, and then letting wxBaseEnumProperty::OnSetValue
608 be called (by not implementing it, or by calling super class function in
609 it) -OR- you can just call SetIndex in OnSetValue.
610 */
611 class WXDLLIMPEXP_PROPGRID wxBaseEnumProperty : public wxPGProperty
612 {
613 public:
614 wxBaseEnumProperty( const wxString& label = wxPG_LABEL,
615 const wxString& name = wxPG_LABEL );
616
617 virtual void OnSetValue();
618 virtual wxString GetValueAsString( int argFlags ) const;
619 virtual bool StringToValue( wxVariant& variant,
620 const wxString& text,
621 int argFlags = 0 ) const;
622 virtual bool ValidateValue( wxVariant& value,
623 wxPGValidationInfo& validationInfo ) const;
624
625 // If wxPG_FULL_VALUE is not set in flags, then the value is interpreted
626 // as index to choices list. Otherwise, it is actual value.
627 virtual bool IntToValue( wxVariant& variant,
628 int number,
629 int argFlags = 0 ) const;
630
631 //
632 // Additional virtuals
633
634 // This must be overridden to have non-index based value
635 virtual int GetIndexForValue( int value ) const;
636
637 // This returns string and value for index
638 // Returns NULL if beyond last item
639 // pvalue is never NULL - always set it.
640 virtual const wxString* GetEntry( size_t index, int* pvalue ) const = 0;
641
642 // GetChoiceSelection needs to overridden since m_index is
643 // the true index, and various property classes derived from
644 // this take advantage of it.
645 virtual int GetChoiceSelection() const { return m_index; }
646
647 int GetValueForIndex( size_t index ) const
648 {
649 int v;
650 GetEntry( index, &v );
651 return v;
652 }
653
654 protected:
655
656 int GetIndex() const;
657 void SetIndex( int index );
658
659 bool ValueFromString_( wxVariant& value,
660 const wxString& text,
661 int argFlags ) const;
662 bool ValueFromInt_( wxVariant& value, int intVal, int argFlags ) const;
663
664 static void ResetNextIndex() { ms_nextIndex = -2; }
665
666 private:
667 // This is private so that classes are guaranteed to use GetIndex
668 // for up-to-date index value.
669 int m_index;
670
671 // Relies on ValidateValue being called always before OnSetValue
672 static int ms_nextIndex;
673 };
674
675 // -----------------------------------------------------------------------
676
677 // If set, then selection of choices is static and should not be
678 // changed (i.e. returns NULL in GetPropertyChoices).
679 #define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
680
681 /** @class wxEnumProperty
682 @ingroup classes
683 You can derive custom properties with choices from this class. See
684 wxBaseEnumProperty for remarks.
685 */
686 class WXDLLIMPEXP_PROPGRID wxEnumProperty : public wxBaseEnumProperty
687 {
688 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty)
689 public:
690
691 #ifndef SWIG
692 wxEnumProperty( const wxString& label = wxPG_LABEL,
693 const wxString& name = wxPG_LABEL,
694 const wxChar** labels = NULL,
695 const long* values = NULL,
696 int value = 0 );
697 wxEnumProperty( const wxString& label,
698 const wxString& name,
699 wxPGChoices& choices,
700 int value = 0 );
701
702 // Special constructor for caching choices (used by derived class)
703 wxEnumProperty( const wxString& label,
704 const wxString& name,
705 const wxChar** labels,
706 const long* values,
707 wxPGChoices* choicesCache,
708 int value = 0 );
709
710 wxEnumProperty( const wxString& label,
711 const wxString& name,
712 const wxArrayString& labels,
713 const wxArrayInt& values = wxArrayInt(),
714 int value = 0 );
715 #else
716 wxEnumProperty( const wxString& label = wxPG_LABEL,
717 const wxString& name = wxPG_LABEL,
718 const wxArrayString& labels = wxArrayString(),
719 const wxArrayInt& values = wxArrayInt(),
720 int value = 0 );
721 #endif
722
723 virtual ~wxEnumProperty();
724
725 virtual int GetIndexForValue( int value ) const;
726 virtual const wxString* GetEntry( size_t index, int* pvalue ) const;
727
728 size_t GetItemCount() const { return m_choices.GetCount(); }
729 const wxPGChoices& GetChoices() const { return m_choices; }
730 };
731
732 // -----------------------------------------------------------------------
733
734 /** @class wxEditEnumProperty
735 @ingroup classes
736 wxEnumProperty with wxString value and writable combo box editor.
737
738 @remarks
739 Uses int value, similar to wxEnumProperty, unless text entered by user is
740 is not in choices (in which case string value is used).
741 */
742 class WXDLLIMPEXP_PROPGRID wxEditEnumProperty : public wxEnumProperty
743 {
744 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty)
745 public:
746
747 wxEditEnumProperty( const wxString& label,
748 const wxString& name,
749 const wxChar** labels,
750 const long* values,
751 const wxString& value );
752 wxEditEnumProperty( const wxString& label = wxPG_LABEL,
753 const wxString& name = wxPG_LABEL,
754 const wxArrayString& labels = wxArrayString(),
755 const wxArrayInt& values = wxArrayInt(),
756 const wxString& value = wxEmptyString );
757 wxEditEnumProperty( const wxString& label,
758 const wxString& name,
759 wxPGChoices& choices,
760 const wxString& value = wxEmptyString );
761
762 // Special constructor for caching choices (used by derived class)
763 wxEditEnumProperty( const wxString& label,
764 const wxString& name,
765 const wxChar** labels,
766 const long* values,
767 wxPGChoices* choicesCache,
768 const wxString& value );
769
770 virtual ~wxEditEnumProperty();
771
772 protected:
773 };
774
775 // -----------------------------------------------------------------------
776
777 /** @class wxFlagsProperty
778 @ingroup classes
779 Represents a bit set that fits in a long integer. wxBoolProperty
780 sub-properties are created for editing individual bits. Textctrl is created
781 to manually edit the flags as a text; a continous sequence of spaces,
782 commas and semicolons is considered as a flag id separator.
783 <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
784 you will need to use SetPropertyChoices - otherwise they will not get
785 updated properly.
786 */
787 class WXDLLIMPEXP_PROPGRID wxFlagsProperty : public wxPGProperty
788 {
789 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty)
790 public:
791
792 #ifndef SWIG
793 wxFlagsProperty( const wxString& label,
794 const wxString& name,
795 const wxChar** labels,
796 const long* values = NULL,
797 long value = 0 );
798 wxFlagsProperty( const wxString& label,
799 const wxString& name,
800 wxPGChoices& choices,
801 long value = 0 );
802 #endif
803 wxFlagsProperty( const wxString& label = wxPG_LABEL,
804 const wxString& name = wxPG_LABEL,
805 const wxArrayString& labels = wxArrayString(),
806 const wxArrayInt& values = wxArrayInt(),
807 int value = 0 );
808 virtual ~wxFlagsProperty ();
809
810 virtual void OnSetValue();
811 virtual wxString GetValueAsString( int argFlags ) const;
812 virtual bool StringToValue( wxVariant& variant,
813 const wxString& text,
814 int flags ) const;
815 virtual void ChildChanged( wxVariant& thisValue,
816 int childIndex,
817 wxVariant& childValue ) const;
818 virtual void RefreshChildren();
819
820 // GetChoiceSelection needs to overridden since m_choices is
821 // used and value is integer, but it is not index.
822 virtual int GetChoiceSelection() const { return wxNOT_FOUND; }
823
824 // helpers
825 size_t GetItemCount() const { return m_choices.GetCount(); }
826 const wxString& GetLabel( size_t ind ) const
827 { return m_choices.GetLabel(ind); }
828
829 protected:
830 // Used to detect if choices have been changed
831 wxPGChoicesData* m_oldChoicesData;
832
833 // Needed to properly mark changed sub-properties
834 long m_oldValue;
835
836 // Converts string id to a relevant bit.
837 long IdToBit( const wxString& id ) const;
838
839 // Creates children and sets value.
840 void Init();
841 };
842
843 // -----------------------------------------------------------------------
844
845 /** @class wxPGFileDialogAdapter
846 @ingroup classes
847 */
848 class WXDLLIMPEXP_PROPGRID
849 wxPGFileDialogAdapter : public wxPGEditorDialogAdapter
850 {
851 public:
852 virtual bool DoShowDialog( wxPropertyGrid* propGrid,
853 wxPGProperty* property );
854 };
855
856 // -----------------------------------------------------------------------
857
858 #include "wx/filename.h"
859
860 // Indicates first bit useable by derived properties.
861 #define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
862
863 /** @class wxFileProperty
864 @ingroup classes
865 Like wxLongStringProperty, but the button triggers file selector instead.
866
867 <b>Supported special attributes:</b>
868 - "Wildcard": Sets wildcard (see wxFileDialog for format details), "All
869 files..." is default.
870 - "ShowFullPath": Default 1. When 0, only the file name is shown (i.e. drive
871 and directory are hidden).
872 - "ShowRelativePath": If set, then the filename is shown relative to the
873 given path string.
874 - "InitialPath": Sets the initial path of where to look for files.
875 - "DialogTitle": Sets a specific title for the dir dialog.
876 */
877 class WXDLLIMPEXP_PROPGRID wxFileProperty : public wxPGProperty
878 {
879 friend class wxPGFileDialogAdapter;
880 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty)
881 public:
882
883 wxFileProperty( const wxString& label = wxPG_LABEL,
884 const wxString& name = wxPG_LABEL,
885 const wxString& value = wxEmptyString );
886 virtual ~wxFileProperty ();
887
888 virtual void OnSetValue();
889 virtual wxString GetValueAsString( int argFlags ) const;
890 virtual bool StringToValue( wxVariant& variant,
891 const wxString& text,
892 int argFlags = 0 ) const;
893 virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
894
895 WX_PG_DECLARE_ATTRIBUTE_METHODS()
896
897 static wxValidator* GetClassValidator();
898 virtual wxValidator* DoGetValidator() const;
899
900 protected:
901 wxString m_wildcard;
902 wxString m_basePath; // If set, then show path relative to it
903 wxString m_initialPath; // If set, start the file dialog here
904 wxString m_dlgTitle; // If set, used as title for file dialog
905 wxFileName m_filename; // used as primary storage
906 int m_indFilter; // index to the selected filter
907 };
908
909 // -----------------------------------------------------------------------
910
911 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
912
913
914 /** @class wxPGLongStringDialogAdapter
915 @ingroup classes
916 */
917 class WXDLLIMPEXP_PROPGRID
918 wxPGLongStringDialogAdapter : public wxPGEditorDialogAdapter
919 {
920 public:
921 virtual bool DoShowDialog( wxPropertyGrid* propGrid,
922 wxPGProperty* property );
923 };
924
925
926 /** @class wxLongStringProperty
927 @ingroup classes
928 Like wxStringProperty, but has a button that triggers a small text
929 editor dialog.
930 */
931 class WXDLLIMPEXP_PROPGRID wxLongStringProperty : public wxPGProperty
932 {
933 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty)
934 public:
935
936 wxLongStringProperty( const wxString& label = wxPG_LABEL,
937 const wxString& name = wxPG_LABEL,
938 const wxString& value = wxEmptyString );
939 virtual ~wxLongStringProperty();
940
941 virtual wxString GetValueAsString( int argFlags = 0 ) const;
942 virtual bool StringToValue( wxVariant& variant,
943 const wxString& text,
944 int argFlags = 0 ) const;
945
946 WX_PG_DECLARE_EVENT_METHODS()
947
948 // Shows string editor dialog. Value to be edited should be read from
949 // value, and if dialog is not cancelled, it should be stored back and true
950 // should be returned if that was the case.
951 virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value );
952
953 static bool DisplayEditorDialog( wxPGProperty* prop,
954 wxPropertyGrid* propGrid,
955 wxString& value );
956
957 protected:
958 };
959
960 // -----------------------------------------------------------------------
961
962
963 // Exclude class from wxPython bindings
964 #ifndef SWIG
965
966 /** @class wxDirProperty
967 @ingroup classes
968 Like wxLongStringProperty, but the button triggers dir selector instead.
969
970 <b>Supported special attributes:</b>
971 - "DialogMessage": Sets specific message in the dir selector.
972 */
973 class WXDLLIMPEXP_PROPGRID wxDirProperty : public wxLongStringProperty
974 {
975 #ifndef SWIG
976 DECLARE_DYNAMIC_CLASS(wxDirProperty)
977 #endif
978 public:
979 wxDirProperty( const wxString& name = wxPG_LABEL,
980 const wxString& label = wxPG_LABEL,
981 const wxString& value = wxEmptyString );
982 virtual ~wxDirProperty();
983
984 WX_PG_DECLARE_ATTRIBUTE_METHODS()
985 WX_PG_DECLARE_VALIDATOR_METHODS()
986
987 virtual bool OnButtonClick ( wxPropertyGrid* propGrid, wxString& value );
988
989 protected:
990 wxString m_dlgMessage;
991 };
992
993 #endif // !SWIG
994
995 // -----------------------------------------------------------------------
996
997 // wxBoolProperty specific flags
998 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
999 // DCC = Double Click Cycles
1000 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
1001
1002
1003 // -----------------------------------------------------------------------
1004
1005 /** @class wxArrayStringProperty
1006 @ingroup classes
1007 Property that manages a list of strings.
1008 */
1009 class WXDLLIMPEXP_PROPGRID wxArrayStringProperty : public wxPGProperty
1010 {
1011 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty)
1012 public:
1013
1014 wxArrayStringProperty( const wxString& label = wxPG_LABEL,
1015 const wxString& name = wxPG_LABEL,
1016 const wxArrayString& value = wxArrayString() );
1017 virtual ~wxArrayStringProperty();
1018
1019 virtual void OnSetValue();
1020 WX_PG_DECLARE_BASIC_TYPE_METHODS()
1021 WX_PG_DECLARE_EVENT_METHODS()
1022
1023 virtual void GenerateValueAsString();
1024
1025 // Shows string editor dialog. Value to be edited should be read from
1026 // value, and if dialog is not cancelled, it should be stored back and true
1027 // should be returned if that was the case.
1028 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value );
1029
1030 // Helper.
1031 virtual bool OnButtonClick( wxPropertyGrid* propgrid,
1032 wxWindow* primary,
1033 const wxChar* cbt );
1034
1035 #ifndef SWIG
1036 // Creates wxArrayEditorDialog for string editing. Called in OnButtonClick.
1037 virtual wxArrayEditorDialog* CreateEditorDialog();
1038 #endif
1039
1040 protected:
1041 wxString m_display; // Cache for displayed text.
1042 };
1043
1044 // -----------------------------------------------------------------------
1045
1046 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, \
1047 DECL) \
1048 DECL PROPNAME : public wxArrayStringProperty \
1049 { \
1050 WX_PG_DECLARE_PROPERTY_CLASS(PROPNAME) \
1051 public: \
1052 PROPNAME( const wxString& label = wxPG_LABEL, \
1053 const wxString& name = wxPG_LABEL, \
1054 const wxArrayString& value = wxArrayString() ); \
1055 ~PROPNAME(); \
1056 virtual void GenerateValueAsString(); \
1057 virtual bool StringToValue( wxVariant& value, \
1058 const wxString& text, int = 0 ) const; \
1059 virtual bool OnEvent( wxPropertyGrid* propgrid, \
1060 wxWindow* primary, wxEvent& event ); \
1061 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
1062 WX_PG_DECLARE_VALIDATOR_METHODS() \
1063 };
1064
1065 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
1066 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
1067
1068 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
1069 DELIMCHAR, \
1070 CUSTBUTTXT) \
1071 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME, wxArrayStringProperty, \
1072 wxArrayString, const wxArrayString&, \
1073 TextCtrlAndButton) \
1074 PROPNAME::PROPNAME( const wxString& label, \
1075 const wxString& name, \
1076 const wxArrayString& value ) \
1077 : wxArrayStringProperty(label,name,value) \
1078 { \
1079 PROPNAME::GenerateValueAsString(); \
1080 } \
1081 PROPNAME::~PROPNAME() { } \
1082 void PROPNAME::GenerateValueAsString() \
1083 { \
1084 wxChar delimChar = DELIMCHAR; \
1085 if ( delimChar == wxS('"') ) \
1086 wxArrayStringProperty::GenerateValueAsString(); \
1087 else \
1088 wxPropertyGrid::ArrayStringToString(m_display, \
1089 m_value.GetArrayString(), \
1090 0,DELIMCHAR,0); \
1091 } \
1092 bool PROPNAME::StringToValue( wxVariant& variant, \
1093 const wxString& text, int ) const \
1094 { \
1095 wxChar delimChar = DELIMCHAR; \
1096 if ( delimChar == wxS('"') ) \
1097 return wxArrayStringProperty::StringToValue(variant, text, 0); \
1098 \
1099 wxArrayString arr; \
1100 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
1101 arr.Add( token ); \
1102 WX_PG_TOKENIZER1_END() \
1103 variant = arr; \
1104 return true; \
1105 } \
1106 bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \
1107 wxWindow* primary, wxEvent& event ) \
1108 { \
1109 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
1110 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
1111 return false; \
1112 }
1113
1114 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
1115 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
1116
1117 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
1118 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
1119
1120 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
1121 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME, \
1122 DELIMCHAR, \
1123 CUSTBUTTXT) \
1124 wxValidator* PROPNAME::DoGetValidator () const \
1125 { return (wxValidator*) NULL; }
1126
1127
1128 // -----------------------------------------------------------------------
1129 // wxArrayEditorDialog
1130 // -----------------------------------------------------------------------
1131
1132 #include "wx/textctrl.h"
1133 #include "wx/button.h"
1134 #include "wx/listbox.h"
1135
1136 #define wxAEDIALOG_STYLE \
1137 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
1138
1139 class WXDLLIMPEXP_PROPGRID wxArrayEditorDialog : public wxDialog
1140 {
1141 public:
1142 wxArrayEditorDialog();
1143 virtual ~wxArrayEditorDialog() { }
1144
1145 void Init();
1146
1147 wxArrayEditorDialog( wxWindow *parent,
1148 const wxString& message,
1149 const wxString& caption,
1150 long style = wxAEDIALOG_STYLE,
1151 const wxPoint& pos = wxDefaultPosition,
1152 const wxSize& sz = wxDefaultSize );
1153
1154 bool Create( wxWindow *parent,
1155 const wxString& message,
1156 const wxString& caption,
1157 long style = wxAEDIALOG_STYLE,
1158 const wxPoint& pos = wxDefaultPosition,
1159 const wxSize& sz = wxDefaultSize );
1160
1161 /** Set value modified by dialog.
1162 */
1163 virtual void SetDialogValue( const wxVariant& WXUNUSED(value) )
1164 {
1165 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
1166 }
1167
1168 /** Return value modified by dialog.
1169 */
1170 virtual wxVariant GetDialogValue() const
1171 {
1172 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
1173 return wxVariant();
1174 }
1175
1176 /** Override to return wxValidator to be used with the wxTextCtrl
1177 in dialog. Note that the validator is used in the standard
1178 wx way, ie. it immediately prevents user from entering invalid
1179 input.
1180
1181 @remarks
1182 Dialog frees the validator.
1183 */
1184 virtual wxValidator* GetTextCtrlValidator() const
1185 {
1186 return (wxValidator*) NULL;
1187 }
1188
1189 // Returns true if array was actually modified
1190 bool IsModified() const { return m_modified; }
1191
1192 //const wxArrayString& GetStrings() const { return m_array; }
1193
1194 // implementation from now on
1195 void OnUpdateClick(wxCommandEvent& event);
1196 void OnAddClick(wxCommandEvent& event);
1197 void OnDeleteClick(wxCommandEvent& event);
1198 void OnListBoxClick(wxCommandEvent& event);
1199 void OnUpClick(wxCommandEvent& event);
1200 void OnDownClick(wxCommandEvent& event);
1201 //void OnCustomEditClick(wxCommandEvent& event);
1202 void OnIdle(wxIdleEvent& event);
1203
1204 protected:
1205 wxTextCtrl* m_edValue;
1206 wxListBox* m_lbStrings;
1207
1208 wxButton* m_butAdd; // Button pointers
1209 wxButton* m_butCustom; // required for disabling/enabling changing.
1210 wxButton* m_butUpdate;
1211 wxButton* m_butRemove;
1212 wxButton* m_butUp;
1213 wxButton* m_butDown;
1214
1215 //wxArrayString m_array;
1216
1217 const wxChar* m_custBtText;
1218 //wxArrayStringPropertyClass* m_pCallingClass;
1219
1220 bool m_modified;
1221
1222 unsigned char m_curFocus;
1223
1224 // These must be overridden - must return true on success.
1225 virtual wxString ArrayGet( size_t index ) = 0;
1226 virtual size_t ArrayGetCount() = 0;
1227 virtual bool ArrayInsert( const wxString& str, int index ) = 0;
1228 virtual bool ArraySet( size_t index, const wxString& str ) = 0;
1229 virtual void ArrayRemoveAt( int index ) = 0;
1230 virtual void ArraySwap( size_t first, size_t second ) = 0;
1231
1232 private:
1233 #ifndef SWIG
1234 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog)
1235 DECLARE_EVENT_TABLE()
1236 #endif
1237 };
1238
1239 // -----------------------------------------------------------------------
1240 // wxPGArrayStringEditorDialog
1241 // -----------------------------------------------------------------------
1242
1243 class WXDLLIMPEXP_PROPGRID
1244 wxPGArrayStringEditorDialog : public wxArrayEditorDialog
1245 {
1246 public:
1247 wxPGArrayStringEditorDialog();
1248 virtual ~wxPGArrayStringEditorDialog() { }
1249
1250 void Init();
1251
1252 virtual void SetDialogValue( const wxVariant& value )
1253 {
1254 m_array = value.GetArrayString();
1255 }
1256
1257 virtual wxVariant GetDialogValue() const
1258 {
1259 return m_array;
1260 }
1261
1262 void SetCustomButton( const wxChar* custBtText, wxArrayStringProperty* pcc )
1263 {
1264 m_custBtText = custBtText;
1265 m_pCallingClass = pcc;
1266 }
1267
1268 void OnCustomEditClick(wxCommandEvent& event);
1269
1270 protected:
1271 wxArrayString m_array;
1272
1273 wxArrayStringProperty* m_pCallingClass;
1274
1275 virtual wxString ArrayGet( size_t index );
1276 virtual size_t ArrayGetCount();
1277 virtual bool ArrayInsert( const wxString& str, int index );
1278 virtual bool ArraySet( size_t index, const wxString& str );
1279 virtual void ArrayRemoveAt( int index );
1280 virtual void ArraySwap( size_t first, size_t second );
1281
1282 private:
1283 #ifndef SWIG
1284 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog)
1285 DECLARE_EVENT_TABLE()
1286 #endif
1287 };
1288
1289 // -----------------------------------------------------------------------
1290
1291 #endif // wxUSE_PROPGRID
1292
1293 #endif // _WX_PROPGRID_PROPS_H_