00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _WX_PROPGRID_PROPS_H_
00013 #define _WX_PROPGRID_PROPS_H_
00014
00015
00016
00017 class WXDLLIMPEXP_PG wxArrayEditorDialog;
00018
00019 #include "editors.h"
00020
00021 #include <wx/dialog.h>
00022 #include <wx/textctrl.h>
00023 #include <wx/button.h>
00024 #include <wx/listbox.h>
00025 #include <wx/valtext.h>
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #define WX_PG_DECLARE_BASIC_TYPE_METHODS() \
00038 virtual wxString GetValueAsString( int argFlags = 0 ) const; \
00039 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
00040
00041 #define WX_PG_DECLARE_CHOICE_METHODS() \
00042 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const; \
00043 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
00044
00045 #define WX_PG_DECLARE_EVENT_METHODS() \
00046 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event );
00047
00048 #define WX_PG_DECLARE_PARENTAL_METHODS() \
00049 virtual void ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const; \
00050 virtual void RefreshChildren();
00051
00052 #define WX_PG_DECLARE_CUSTOM_PAINT_METHODS() \
00053 virtual wxSize OnMeasureImage( int item ) const; \
00054 virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata );
00055
00056 #define WX_PG_DECLARE_ATTRIBUTE_METHODS() \
00057 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
00058
00059 #define WX_PG_DECLARE_VALIDATOR_METHODS() \
00060 virtual wxValidator* DoGetValidator() const;
00061
00062
00063 #define WX_PG_IMPLEMENT_PROPERTY_CLASS2(NAME,CLASSNAME,UPCLASS,T,T_AS_ARG,EDITOR) \
00064 IMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS) \
00065 WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME,T,EDITOR)
00066
00067
00068 #define WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME,UPNAME,T,T_AS_ARG,EDITOR) \
00069 WX_PG_IMPLEMENT_PROPERTY_CLASS2(NAME,wxPG_PROPCLASS(NAME),wxPG_PROPCLASS(UPNAME),T,T_AS_ARG,EDITOR)
00070
00071 #define WX_PG_DECLARE_DERIVED_PROPERTY_CLASS(CLASSNAME) \
00072 DECLARE_DYNAMIC_CLASS(CLASSNAME)
00073
00074
00075
00076 #define WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(NAME,UPNAME,T_AS_ARG) \
00077 IMPLEMENT_DYNAMIC_CLASS(NAME, UPNAME)
00078
00079
00080
00081 #define wxPG_NO_ESCAPE wxPG_PROP_NO_ESCAPE // No escape sequences
00082 #define wxPG_ESCAPE 0 // Escape sequences
00083
00084 #define WX_PG_DECLARE_STRING_PROPERTY_WITH_DECL(NAME, DECL) \
00085 DECL NAME : public wxLongStringProperty \
00086 { \
00087 WX_PG_DECLARE_DERIVED_PROPERTY_CLASS(NAME) \
00088 public: \
00089 NAME( const wxString& name = wxPG_LABEL, const wxString& label = wxPG_LABEL, const wxString& value = wxEmptyString); \
00090 virtual ~NAME(); \
00091 virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value ); \
00092 WX_PG_DECLARE_VALIDATOR_METHODS() \
00093 };
00094
00095 #define WX_PG_DECLARE_STRING_PROPERTY(NAME) \
00096 WX_PG_DECLARE_STRING_PROPERTY_WITH_DECL(NAME, class) \
00097
00098 #define WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(NAME, FLAGS) \
00099 WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(NAME,wxLongStringProperty,const wxString&) \
00100 NAME::NAME( const wxString& name, const wxString& label, const wxString& value ) \
00101 : wxLongStringProperty(name,label,value) \
00102 { \
00103 m_flags |= FLAGS; \
00104 } \
00105 NAME::~NAME() { }
00106
00107 #define WX_PG_IMPLEMENT_STRING_PROPERTY(NAME, FLAGS) \
00108 WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(NAME,FLAGS) \
00109 wxValidator* wxPG_PROPCLASS(NAME)::DoGetValidator () const \
00110 { return (wxValidator*) NULL; }
00111
00112
00113
00114 #define WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY_WITH_DECL(CLASSNAME,DECL) \
00115 DECL CLASSNAME : public wxFlagsProperty \
00116 { \
00117 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
00118 public: \
00119 CLASSNAME( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, long value = -1 ); \
00120 virtual ~CLASSNAME(); \
00121 };
00122
00123 #define WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY(CLASSNAME) \
00124 WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY_WITH_DECL(CLASSNAME, class)
00125
00126
00127
00128 #define WX_PG_IMPLEMENT_CUSTOM_FLAGS_PROPERTY(CLASSNAME,LABELS,VALUES,DEFVAL) \
00129 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME,wxFlagsProperty,long_##CLASSNAME,long,TextCtrl) \
00130 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, long value ) \
00131 : wxFlagsProperty(label,name,LABELS,VALUES,value!=-1?value:DEFVAL) \
00132 { \
00133 m_flags |= wxPG_PROP_STATIC_CHOICES; \
00134 } \
00135 CLASSNAME::~CLASSNAME() { }
00136
00137
00138
00139
00140 #define WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY_WITH_DECL(CLASSNAME, DECL) \
00141 class CLASSNAME : public wxEnumProperty \
00142 { \
00143 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
00144 public: \
00145 CLASSNAME( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, int value = -1 ); \
00146 virtual ~CLASSNAME(); \
00147 };
00148
00149 #define WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY(CLASSNAME) \
00150 WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY_WITH_DECL(CLASSNAME, class)
00151
00152 #define WX_PG_IMPLEMENT_CUSTOM_ENUM_PROPERTY(CLASSNAME,LABELS,VALUES,DEFVAL) \
00153 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME,wxEnumProperty,long_##CLASSNAME,int,Choice) \
00154 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, int value ) \
00155 : wxEnumProperty(label,name,LABELS,VALUES,value!=-1?value:DEFVAL) \
00156 { \
00157 m_flags |= wxPG_PROP_STATIC_CHOICES; \
00158 } \
00159 CLASSNAME::~CLASSNAME() { }
00160
00161
00162
00163
00164 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_WITH_DECL(CLASSNAME, DECL) \
00165 DECL CLASSNAME : public wxPG_PROPCLASS(wxSystemColourProperty) \
00166 { \
00167 DECLARE_DYNAMIC_CLASS(CLASSNAME) \
00168 public: \
00169 CLASSNAME( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, \
00170 const wxColourPropertyValue& value = wxColourPropertyValue() ); \
00171 virtual ~CLASSNAME(); \
00172 virtual wxColour GetColour( int index ) const; \
00173 };
00174
00175 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY(CLASSNAME) \
00176 WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_WITH_DECL(CLASSNAME, class)
00177
00178 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY(CLASSNAME,LABELS,VALUES,COLOURS) \
00179 static wxPGChoices gs_##CLASSNAME##_choicesCache; \
00180 WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(CLASSNAME,wxSystemColourProperty,const wxColourPropertyValue&) \
00181 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, \
00182 const wxColourPropertyValue& value ) \
00183 : wxPG_PROPCLASS(wxSystemColourProperty)(label,name,LABELS,VALUES,&gs_##CLASSNAME##_choicesCache,value ) \
00184 { \
00185 m_flags |= wxPG_PROP_TRANSLATE_CUSTOM; \
00186 } \
00187 CLASSNAME::~CLASSNAME () { } \
00188 wxColour CLASSNAME::GetColour ( int index ) const \
00189 { \
00190 return COLOURS[m_choices.GetValue(index)]; \
00191 }
00192
00193
00194
00195 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(CLASSNAME, DECL) \
00196 DECL CLASSNAME : public wxPG_PROPCLASS(wxSystemColourProperty) \
00197 { \
00198 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
00199 public: \
00200 CLASSNAME( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, \
00201 const wxColour& value = wxColour() ); \
00202 virtual ~CLASSNAME(); \
00203 virtual wxString GetValueAsString( int argFlags ) const; \
00204 virtual wxColour GetColour( int index ) const; \
00205 virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const; \
00206 void Init( wxColour colour ); \
00207 };
00208
00209 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(CLASSNAME) \
00210 WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(CLASSNAME, class)
00211
00212 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(CLASSNAME,LABELS,VALUES,COLOURS,EDITOR) \
00213 static wxPGChoices gs_##CLASSNAME##_choicesCache; \
00214 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME,wxSystemColourProperty,wxColour,const wxColour&,EDITOR) \
00215 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, const wxColour& value ) \
00216 : wxPG_PROPCLASS(wxSystemColourProperty)(label,name,LABELS,VALUES,&gs_##CLASSNAME##_choicesCache,value ) \
00217 { \
00218 if ( &value ) \
00219 Init( value ); \
00220 else \
00221 Init( *wxWHITE ); \
00222 m_flags |= wxPG_PROP_TRANSLATE_CUSTOM; \
00223 } \
00224 CLASSNAME::~CLASSNAME() { } \
00225 void CLASSNAME::Init( wxColour colour ) \
00226 { \
00227 if ( !colour.Ok() ) \
00228 colour = *wxWHITE; \
00229 wxVariant variant; \
00230 variant << colour; \
00231 m_value = variant; \
00232 int ind = ColToInd(colour); \
00233 if ( ind < 0 ) \
00234 ind = m_choices.GetCount() - 1; \
00235 SetIndex( ind ); \
00236 } \
00237 wxString CLASSNAME::GetValueAsString( int argFlags ) const \
00238 { \
00239 const wxPGEditor* editor = GetEditorClass(); \
00240 if ( editor != wxPG_EDITOR(Choice) && \
00241 editor != wxPG_EDITOR(ChoiceAndButton) && \
00242 editor != wxPG_EDITOR(ComboBox) ) \
00243 argFlags |= wxPG_PROPERTY_SPECIFIC; \
00244 return wxSystemColourProperty::GetValueAsString(argFlags); \
00245 } \
00246 wxColour CLASSNAME::GetColour( int index ) const \
00247 { \
00248 return COLOURS[m_choices.GetValue(index)]; \
00249 } \
00250 wxVariant CLASSNAME::DoTranslateVal( wxColourPropertyValue& v ) const \
00251 { \
00252 wxVariant variant; \
00253 variant << v.m_colour; \
00254 return variant; \
00255 }
00256
00257
00258 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(CLASSNAME,LABELS,VALUES,COLOURS) \
00259 WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(CLASSNAME,LABELS,VALUES,COLOURS,Choice)
00260
00261
00262
00263
00264
00265 #define WX_PG_DOGETVALIDATOR_ENTRY() \
00266 static wxValidator* s_ptr = (wxValidator*) NULL; \
00267 if ( s_ptr ) return s_ptr;
00268
00269
00270 #define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
00271 s_ptr = VALIDATOR; \
00272 wxPGGlobalVars->m_arrValidators.Add( (void*) VALIDATOR ); \
00273 return VALIDATOR;
00274
00275
00276
00277 #if wxUSE_VALIDATORS
00278
00282 class WXDLLIMPEXP_PG wxNumericPropertyValidator : public wxTextValidator
00283 {
00284 public:
00285 enum NumericType
00286 {
00287 Signed = 0,
00288 Unsigned,
00289 Float
00290 };
00291
00292 wxNumericPropertyValidator( NumericType numericType, int base = 10 );
00293 virtual ~wxNumericPropertyValidator() { }
00294 virtual bool Validate(wxWindow* parent);
00295 };
00296
00297 #endif // wxUSE_VALIDATORS
00298
00299
00300
00301 #ifndef SWIG
00302
00308 class WXDLLIMPEXP_PG wxPGInDialogValidator
00309 {
00310 public:
00311 wxPGInDialogValidator()
00312 {
00313 m_textCtrl = NULL;
00314 }
00315
00316 ~wxPGInDialogValidator()
00317 {
00318 if ( m_textCtrl )
00319 m_textCtrl->Destroy();
00320 }
00321
00322 bool DoValidate( wxPropertyGrid* propGrid, wxValidator* validator, const wxString& value );
00323
00324 private:
00325 wxTextCtrl* m_textCtrl;
00326 };
00327
00328 #endif // SWIG
00329
00330
00331
00332
00333
00334
00335 #define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
00336
00348 class WXDLLIMPEXP_PG wxStringProperty : public wxPGProperty
00349 {
00350 WX_PG_DECLARE_PROPERTY_CLASS(wxStringProperty)
00351 public:
00352 wxStringProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00353 const wxString& value = wxEmptyString );
00354 virtual ~wxStringProperty();
00355
00356 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00357 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00358
00359
00361 virtual void OnSetValue();
00362
00363 protected:
00364 };
00365
00366
00367
00368 #ifndef SWIG
00369
00371 enum
00372 {
00375 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE = 0,
00376
00379 wxPG_PROPERTY_VALIDATION_SATURATE = 1,
00380
00383 wxPG_PROPERTY_VALIDATION_WRAP = 2
00384 };
00385 #endif
00386
00387
00388
00428 class WXDLLIMPEXP_PG wxIntProperty : public wxPGProperty
00429 {
00430 WX_PG_DECLARE_PROPERTY_CLASS(wxIntProperty)
00431 public:
00432 wxIntProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00433 long value = 0 );
00434 virtual ~wxIntProperty();
00435
00436 wxIntProperty( const wxString& label, const wxString& name, const wxLongLong& value );
00437 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00438 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
00439 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
00440 static wxValidator* GetClassValidator();
00441 virtual wxValidator* DoGetValidator() const;
00442
00445 static bool DoValidation( const wxPGProperty* property, wxLongLong_t& value, wxPGValidationInfo* pValidationInfo, int mode = wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
00446
00447 protected:
00448 };
00449
00450
00451
00467 class WXDLLIMPEXP_PG wxUIntProperty : public wxPGProperty
00468 {
00469 WX_PG_DECLARE_PROPERTY_CLASS(wxUIntProperty)
00470 public:
00471 wxUIntProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00472 unsigned long value = 0 );
00473 virtual ~wxUIntProperty();
00474 wxUIntProperty( const wxString& label, const wxString& name, const wxULongLong& value );
00475 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00476 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00477 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
00478 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
00479 virtual wxValidator* DoGetValidator() const;
00480 protected:
00481 wxByte m_base;
00482 wxByte m_realBase;
00483 wxByte m_prefix;
00484 private:
00485 void Init();
00486 };
00487
00488
00489
00498 class WXDLLIMPEXP_PG wxFloatProperty : public wxPGProperty
00499 {
00500 WX_PG_DECLARE_PROPERTY_CLASS(wxFloatProperty)
00501 public:
00502 wxFloatProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00503 double value = 0.0 );
00504 virtual ~wxFloatProperty();
00505
00506 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00507 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00508 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
00509
00512 static bool DoValidation( const wxPGProperty* property, double& value, wxPGValidationInfo* pValidationInfo, int mode = wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
00513
00514 static wxValidator* GetClassValidator();
00515
00516 protected:
00517 int m_precision;
00518 virtual wxValidator* DoGetValidator () const;
00519 };
00520
00521
00522
00531 class WXDLLIMPEXP_PG wxBoolProperty : public wxPGProperty
00532 {
00533 WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty)
00534 public:
00535 wxBoolProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00536 bool value = false );
00537 virtual ~wxBoolProperty();
00538
00539 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00540 WX_PG_DECLARE_CHOICE_METHODS()
00541 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00542 };
00543
00544
00545
00557 class WXDLLIMPEXP_PG wxBaseEnumProperty : public wxPGProperty
00558 {
00559 public:
00560 wxBaseEnumProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL );
00561
00562 virtual void OnSetValue();
00563 virtual wxString GetValueAsString( int argFlags ) const;
00564 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
00565 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
00566
00567
00568
00569 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
00570
00571
00572
00573
00574
00575 virtual int GetIndexForValue( int value ) const;
00576
00577
00578
00579
00580 virtual const wxString* GetEntry( size_t index, int* pvalue ) const = 0;
00581
00582 int GetValueForIndex( size_t index ) const
00583 {
00584 int v;
00585 GetEntry( index, &v );
00586 return v;
00587 }
00588
00589 virtual void OnValidationFailure( wxVariant& pendingValue );
00590
00591 protected:
00592
00593 int GetIndex() const;
00594 void SetIndex( int index );
00595
00596 bool ValueFromString_( wxVariant& value, const wxString& text, int argFlags ) const;
00597 bool ValueFromInt_( wxVariant& value, int intVal, int argFlags ) const;
00598
00599 static void ResetNextIndex() { ms_nextIndex = -2; }
00600
00601 private:
00602
00603
00604 int m_index;
00605
00606
00607 static int ms_nextIndex;
00608 };
00609
00610
00611
00612
00613
00614 #define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
00615
00622 class WXDLLIMPEXP_PG wxEnumProperty : public wxBaseEnumProperty
00623 {
00624 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty)
00625 public:
00626
00627 #ifndef SWIG
00628 wxEnumProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00629 const wxChar** labels = NULL, const long* values = NULL, int value = 0 );
00630 wxEnumProperty( const wxString& label, const wxString& name,
00631 wxPGChoices& choices, int value = 0 );
00632
00633
00634 wxEnumProperty( const wxString& label, const wxString& name, const wxChar** labels,
00635 const long* values, wxPGChoices* choicesCache, int value = 0 );
00636
00637 wxEnumProperty( const wxString& label, const wxString& name,
00638 const wxArrayString& labels, const wxArrayInt& values = wxArrayInt(),
00639 int value = 0 );
00640 #else
00641 wxEnumProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00642 const wxArrayString& labels = wxArrayString(), const wxArrayInt& values = wxArrayInt(),
00643 int value = 0 );
00644 #endif
00645
00646 virtual ~wxEnumProperty();
00647
00648 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
00649 virtual int GetIndexForValue( int value ) const;
00650 virtual const wxString* GetEntry( size_t index, int* pvalue ) const;
00651
00652 size_t GetItemCount() const { return m_choices.GetCount(); }
00653 const wxPGChoices& GetChoices() const { return m_choices; }
00654
00655 protected:
00656 wxPGChoices m_choices;
00657 };
00658
00659
00660
00670 class WXDLLIMPEXP_PG wxEditEnumProperty : public wxEnumProperty
00671 {
00672 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty)
00673 public:
00674
00675 wxEditEnumProperty( const wxString& label, const wxString& name, const wxChar** labels,
00676 const long* values, const wxString& value );
00677 wxEditEnumProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00678 const wxArrayString& labels = wxArrayString(), const wxArrayInt& values = wxArrayInt(),
00679 const wxString& value = wxEmptyString );
00680 wxEditEnumProperty( const wxString& label, const wxString& name,
00681 wxPGChoices& choices, const wxString& value = wxEmptyString );
00682
00683
00684 wxEditEnumProperty( const wxString& label, const wxString& name, const wxChar** labels,
00685 const long* values, wxPGChoices* choicesCache, const wxString& value );
00686
00687 virtual ~wxEditEnumProperty();
00688
00689 protected:
00690 };
00691
00692
00693
00704 class WXDLLIMPEXP_PG wxFlagsProperty : public wxPGProperty
00705 {
00706 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty)
00707 public:
00708
00709 #ifndef SWIG
00710 wxFlagsProperty( const wxString& label, const wxString& name, const wxChar** labels,
00711 const long* values = NULL, long value = 0 );
00712 wxFlagsProperty( const wxString& label, const wxString& name,
00713 wxPGChoices& choices, long value = 0 );
00714 #endif
00715 wxFlagsProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00716 const wxArrayString& labels = wxArrayString(),
00717 const wxArrayInt& values = wxArrayInt(), int value = 0 );
00718 virtual ~wxFlagsProperty ();
00719
00720 virtual void OnSetValue();
00721 virtual wxString GetValueAsString( int argFlags ) const;
00722 virtual bool StringToValue( wxVariant& variant, const wxString& text, int flags ) const;
00723 virtual void ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const;
00724 virtual void RefreshChildren();
00725
00726
00727 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
00728
00729
00730 size_t GetItemCount() const { return m_choices.GetCount(); }
00731 const wxString& GetLabel( size_t ind ) const { return m_choices.GetLabel(ind); }
00732
00733 protected:
00734 wxPGChoices m_choices;
00735
00736
00737 wxPGChoicesData* m_oldChoicesData;
00738
00739
00740 long m_oldValue;
00741
00742
00743 long IdToBit( const wxString& id ) const;
00744
00745
00746 void Init();
00747 };
00748
00749
00750
00754 class WXDLLIMPEXP_PG wxPGFileDialogAdapter : public wxPGEditorDialogAdapter
00755 {
00756 public:
00757 virtual bool DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
00758 };
00759
00760
00761
00762 #include <wx/filename.h>
00763
00764
00765 #define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
00766
00782 class WXDLLIMPEXP_PG wxFileProperty : public wxPGProperty
00783 {
00784 friend class wxPGFileDialogAdapter;
00785 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty)
00786 public:
00787
00788 wxFileProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00789 const wxString& value = wxEmptyString );
00790 virtual ~wxFileProperty ();
00791
00792 virtual void OnSetValue();
00793 virtual wxString GetValueAsString( int argFlags ) const;
00794 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
00795
00796 virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
00797
00798 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00799
00800 static wxValidator* GetClassValidator();
00801 virtual wxValidator* DoGetValidator() const;
00802
00803 protected:
00804 wxString m_wildcard;
00805 wxString m_basePath;
00806 wxString m_initialPath;
00807 wxString m_dlgTitle;
00808 wxFileName m_filename;
00809 int m_indFilter;
00810 };
00811
00812
00813
00814 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
00815
00816
00820 class WXDLLIMPEXP_PG wxPGLongStringDialogAdapter : public wxPGEditorDialogAdapter
00821 {
00822 public:
00823 virtual bool DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
00824 };
00825
00826
00833 class WXDLLIMPEXP_PG wxLongStringProperty : public wxPGProperty
00834 {
00835 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty)
00836 public:
00837
00838 wxLongStringProperty( const wxString& label = wxPG_LABEL,
00839 const wxString& name = wxPG_LABEL,
00840 const wxString& value = wxEmptyString );
00841 virtual ~wxLongStringProperty();
00842
00843 virtual wxString GetValueAsString( int argFlags = 0 ) const;
00844 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
00845
00846 WX_PG_DECLARE_EVENT_METHODS()
00847
00848
00849
00850
00851 virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value );
00852
00853 static bool DisplayEditorDialog( wxPGProperty* prop, wxPropertyGrid* propGrid, wxString& value );
00854
00855 protected:
00856 };
00857
00858
00859
00868 class WXDLLIMPEXP_PG wxDirProperty : public wxLongStringProperty
00869 {
00870 #ifndef SWIG
00871 DECLARE_DYNAMIC_CLASS(wxDirProperty)
00872 #endif
00873 public:
00874 wxDirProperty( const wxString& name = wxPG_LABEL, const wxString& label = wxPG_LABEL,
00875 const wxString& value = wxEmptyString );
00876 virtual ~wxDirProperty();
00877
00878 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00879 WX_PG_DECLARE_VALIDATOR_METHODS()
00880
00881 virtual bool OnButtonClick ( wxPropertyGrid* propGrid, wxString& value );
00882
00883 protected:
00884 wxString m_dlgMessage;
00885 };
00886
00887
00888
00889
00890
00891 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
00892
00893 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
00894
00895
00896
00897
00903 class WXDLLIMPEXP_PG wxArrayStringProperty : public wxPGProperty
00904 {
00905 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty)
00906 public:
00907
00908 wxArrayStringProperty( const wxString& label = wxPG_LABEL,
00909 const wxString& name = wxPG_LABEL,
00910 const wxArrayString& value = wxArrayString() );
00911 virtual ~wxArrayStringProperty();
00912
00913 virtual void OnSetValue();
00914 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00915 WX_PG_DECLARE_EVENT_METHODS()
00916
00917 virtual void GenerateValueAsString();
00918
00919
00920
00921
00922 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value );
00923
00924
00925 virtual bool OnButtonClick( wxPropertyGrid* propgrid,
00926 wxWindow* primary,
00927 const wxChar* cbt );
00928
00929 #ifndef SWIG
00930
00931 virtual wxArrayEditorDialog* CreateEditorDialog();
00932 #endif
00933
00934 protected:
00935 wxString m_display;
00936 };
00937
00938
00939
00940 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL) \
00941 DECL wxPG_PROPCLASS(PROPNAME) : public wxPG_PROPCLASS(wxArrayStringProperty) \
00942 { \
00943 WX_PG_DECLARE_PROPERTY_CLASS(wxPG_PROPCLASS(PROPNAME)) \
00944 public: \
00945 wxPG_PROPCLASS(PROPNAME)( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, \
00946 const wxArrayString& value = wxArrayString() ); \
00947 ~wxPG_PROPCLASS(PROPNAME)(); \
00948 virtual void GenerateValueAsString(); \
00949 virtual bool StringToValue( wxVariant& value, const wxString& text, int = 0 ) const; \
00950 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ); \
00951 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
00952 WX_PG_DECLARE_VALIDATOR_METHODS() \
00953 };
00954
00955 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
00956 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
00957
00958 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
00959 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME,wxArrayStringProperty,wxArrayString,const wxArrayString&,TextCtrlAndButton) \
00960 wxPG_PROPCLASS(PROPNAME)::wxPG_PROPCLASS(PROPNAME)( const wxString& label, const wxString& name, const wxArrayString& value ) \
00961 : wxPG_PROPCLASS(wxArrayStringProperty)(label,name,value) \
00962 { \
00963 wxPG_PROPCLASS(PROPNAME)::GenerateValueAsString(); \
00964 } \
00965 wxPG_PROPCLASS(PROPNAME)::~wxPG_PROPCLASS(PROPNAME)() { } \
00966 void wxPG_PROPCLASS(PROPNAME)::GenerateValueAsString() \
00967 { \
00968 wxChar delimChar = DELIMCHAR; \
00969 if ( delimChar == wxT('"') ) \
00970 wxPG_PROPCLASS(wxArrayStringProperty)::GenerateValueAsString(); \
00971 else \
00972 wxPropertyGrid::ArrayStringToString(m_display,m_value.GetArrayString(),0,DELIMCHAR,0); \
00973 } \
00974 bool wxPG_PROPCLASS(PROPNAME)::StringToValue( wxVariant& variant, const wxString& text, int ) const \
00975 { \
00976 wxChar delimChar = DELIMCHAR; \
00977 if ( delimChar == wxT('"') ) \
00978 return wxPG_PROPCLASS(wxArrayStringProperty)::StringToValue(variant, text, 0); \
00979 \
00980 wxArrayString arr; \
00981 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
00982 arr.Add( token ); \
00983 WX_PG_TOKENIZER1_END() \
00984 variant = arr; \
00985 return true; \
00986 } \
00987 bool wxPG_PROPCLASS(PROPNAME)::OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ) \
00988 { \
00989 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
00990 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
00991 return false; \
00992 }
00993
00994 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
00995 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
00996
00997 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
00998 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
00999
01000 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
01001 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
01002 wxValidator* wxPG_PROPCLASS(PROPNAME)::DoGetValidator () const \
01003 { return (wxValidator*) NULL; }
01004
01005
01006
01007
01008
01009
01010 #define wxAEDIALOG_STYLE \
01011 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
01012
01013 class WXDLLIMPEXP_PG wxArrayEditorDialog : public wxDialog
01014 {
01015 public:
01016 wxArrayEditorDialog();
01017 virtual ~wxArrayEditorDialog() { }
01018
01019 void Init();
01020
01021 wxArrayEditorDialog( wxWindow *parent,
01022 const wxString& message,
01023 const wxString& caption,
01024 long style = wxAEDIALOG_STYLE,
01025 const wxPoint& pos = wxDefaultPosition,
01026 const wxSize& sz = wxDefaultSize );
01027
01028 bool Create( wxWindow *parent,
01029 const wxString& message,
01030 const wxString& caption,
01031 long style = wxAEDIALOG_STYLE,
01032 const wxPoint& pos = wxDefaultPosition,
01033 const wxSize& sz = wxDefaultSize );
01034
01037 virtual void SetDialogValue( const wxVariant& WXUNUSED(value) )
01038 {
01039 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
01040 }
01041
01044 virtual wxVariant GetDialogValue() const
01045 {
01046 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
01047 return wxVariant();
01048 }
01049
01058 virtual wxValidator* GetTextCtrlValidator() const
01059 {
01060 return (wxValidator*) NULL;
01061 }
01062
01063
01064 bool IsModified() const { return m_modified; }
01065
01066
01067
01068
01069 void OnUpdateClick(wxCommandEvent& event);
01070 void OnAddClick(wxCommandEvent& event);
01071 void OnDeleteClick(wxCommandEvent& event);
01072 void OnListBoxClick(wxCommandEvent& event);
01073 void OnUpClick(wxCommandEvent& event);
01074 void OnDownClick(wxCommandEvent& event);
01075
01076 void OnIdle(wxIdleEvent& event);
01077
01078 #if defined(__WXPYTHON__) && !defined(SWIG)
01079
01080 PyObject* m_scriptObject;
01081 #endif
01082 protected:
01083 wxTextCtrl* m_edValue;
01084 wxListBox* m_lbStrings;
01085
01086 wxButton* m_butAdd;
01087 wxButton* m_butCustom;
01088 wxButton* m_butUpdate;
01089 wxButton* m_butRemove;
01090 wxButton* m_butUp;
01091 wxButton* m_butDown;
01092
01093
01094
01095 const wxChar* m_custBtText;
01096
01097
01098 bool m_modified;
01099
01100 unsigned char m_curFocus;
01101
01102
01103 virtual wxString ArrayGet( size_t index ) = 0;
01104 virtual size_t ArrayGetCount() = 0;
01105 virtual bool ArrayInsert( const wxString& str, int index ) = 0;
01106 virtual bool ArraySet( size_t index, const wxString& str ) = 0;
01107 virtual void ArrayRemoveAt( int index ) = 0;
01108 virtual void ArraySwap( size_t first, size_t second ) = 0;
01109
01110 private:
01111 #ifndef SWIG
01112 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog)
01113 DECLARE_EVENT_TABLE()
01114 #endif
01115 };
01116
01117
01118
01119
01120
01121 class WXDLLIMPEXP_PG wxPGArrayStringEditorDialog : public wxArrayEditorDialog
01122 {
01123 public:
01124 wxPGArrayStringEditorDialog();
01125 virtual ~wxPGArrayStringEditorDialog() { }
01126
01127 void Init();
01128
01129 virtual void SetDialogValue( const wxVariant& value )
01130 {
01131 m_array = value.GetArrayString();
01132 }
01133
01134 virtual wxVariant GetDialogValue() const
01135 {
01136 return m_array;
01137 }
01138
01139 void SetCustomButton( const wxChar* custBtText, wxArrayStringProperty* pcc )
01140 {
01141 m_custBtText = custBtText;
01142 m_pCallingClass = pcc;
01143 }
01144
01145 void OnCustomEditClick(wxCommandEvent& event);
01146
01147 protected:
01148 wxArrayString m_array;
01149
01150 wxArrayStringProperty* m_pCallingClass;
01151
01152 virtual wxString ArrayGet( size_t index );
01153 virtual size_t ArrayGetCount();
01154 virtual bool ArrayInsert( const wxString& str, int index );
01155 virtual bool ArraySet( size_t index, const wxString& str );
01156 virtual void ArrayRemoveAt( int index );
01157 virtual void ArraySwap( size_t first, size_t second );
01158
01159 private:
01160 #ifndef SWIG
01161 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog)
01162 DECLARE_EVENT_TABLE()
01163 #endif
01164 };
01165
01166
01167
01168
01169 #if wxPG_COMPATIBILITY_1_2_0
01170 typedef wxStringProperty wxParentProperty;
01171 #endif
01172
01173
01174
01184 class WXDLLIMPEXP_PG wxCustomProperty : public wxPGProperty
01185 {
01186 #ifndef SWIG
01187 WX_PG_DECLARE_PROPERTY_CLASS(wxCustomProperty)
01188 #endif
01189 public:
01190
01191 wxCustomProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL );
01192 virtual ~wxCustomProperty();
01193
01194 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
01195 virtual wxString GetValueAsString( int argFlags ) const;
01196
01197 #ifdef wxPG_COMPATIBILITY_1_0_0
01198 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event );
01199 #endif
01200 WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
01201
01202 virtual bool IntToValue( wxVariant& variant, int number, int argFlags ) const;
01203 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
01204
01205 virtual void ChildChanged( wxVariant& a1, int a2, wxVariant& a3 ) const
01206 {
01207 wxUnusedVar(a1);
01208 wxUnusedVar(a2);
01209 wxUnusedVar(a3);
01210 }
01211
01212 WX_PG_DECLARE_ATTRIBUTE_METHODS()
01213
01214 protected:
01215 wxPGChoices m_choices;
01216 #ifdef wxPG_COMPATIBILITY_1_0_0
01217 wxPropertyGridCallback m_callback;
01218 #endif
01219 wxPGPaintCallback m_paintCallback;
01220 };
01221
01222
01223
01224
01225
01226 WXDLLIMPEXP_PG bool wxPGStringToLongLong(const wxString s, wxLongLong_t* val, int base);
01227 WXDLLIMPEXP_PG bool wxPGStringToULongLong(const wxString s, wxULongLong_t* val, int base);
01228
01229
01230
01231 #endif // _WX_PROPGRID_PROPS_H_