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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #define WX_PG_DECLARE_BASIC_TYPE_METHODS() \
00037 virtual wxString GetValueAsString( int argFlags = 0 ) const; \
00038 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
00039
00040 #define WX_PG_DECLARE_CHOICE_METHODS() \
00041 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const; \
00042 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
00043
00044 #define WX_PG_DECLARE_EVENT_METHODS() \
00045 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event );
00046
00047 #define WX_PG_DECLARE_PARENTAL_METHODS() \
00048 virtual void ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const; \
00049 virtual void RefreshChildren();
00050
00051 #define WX_PG_DECLARE_CUSTOM_PAINT_METHODS() \
00052 virtual wxSize OnMeasureImage( int item ) const; \
00053 virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata );
00054
00055 #define WX_PG_DECLARE_ATTRIBUTE_METHODS() \
00056 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
00057
00058 #define WX_PG_DECLARE_VALIDATOR_METHODS() \
00059 virtual wxValidator* DoGetValidator() const;
00060
00061
00062 #define WX_PG_IMPLEMENT_PROPERTY_CLASS2(NAME,CLASSNAME,UPCLASS,T,T_AS_ARG,EDITOR) \
00063 IMPLEMENT_DYNAMIC_CLASS(NAME, UPCLASS) \
00064 WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(NAME,T,EDITOR)
00065
00066
00067 #define WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME,UPNAME,T,T_AS_ARG,EDITOR) \
00068 WX_PG_IMPLEMENT_PROPERTY_CLASS2(NAME,wxPG_PROPCLASS(NAME),wxPG_PROPCLASS(UPNAME),T,T_AS_ARG,EDITOR)
00069
00070 #define WX_PG_DECLARE_DERIVED_PROPERTY_CLASS(CLASSNAME) \
00071 DECLARE_DYNAMIC_CLASS(CLASSNAME)
00072
00073
00074
00075 #define WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(NAME,UPNAME,T_AS_ARG) \
00076 IMPLEMENT_DYNAMIC_CLASS(NAME, UPNAME)
00077
00078
00079
00080 #define wxPG_NO_ESCAPE wxPG_PROP_NO_ESCAPE // No escape sequences
00081 #define wxPG_ESCAPE 0 // Escape sequences
00082
00083 #define WX_PG_DECLARE_STRING_PROPERTY_WITH_DECL(NAME, DECL) \
00084 DECL NAME : public wxLongStringProperty \
00085 { \
00086 WX_PG_DECLARE_DERIVED_PROPERTY_CLASS(NAME) \
00087 public: \
00088 NAME( const wxString& name = wxPG_LABEL, const wxString& label = wxPG_LABEL, const wxString& value = wxEmptyString); \
00089 virtual ~NAME(); \
00090 virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value ); \
00091 WX_PG_DECLARE_VALIDATOR_METHODS() \
00092 };
00093
00094 #define WX_PG_DECLARE_STRING_PROPERTY(NAME) \
00095 WX_PG_DECLARE_STRING_PROPERTY_WITH_DECL(NAME, class) \
00096
00097 #define WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(NAME, FLAGS) \
00098 WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(NAME,wxLongStringProperty,const wxString&) \
00099 NAME::NAME( const wxString& name, const wxString& label, const wxString& value ) \
00100 : wxLongStringProperty(name,label,value) \
00101 { \
00102 m_flags |= FLAGS; \
00103 } \
00104 NAME::~NAME() { }
00105
00106 #define WX_PG_IMPLEMENT_STRING_PROPERTY(NAME, FLAGS) \
00107 WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(NAME,FLAGS) \
00108 wxValidator* wxPG_PROPCLASS(NAME)::DoGetValidator () const \
00109 { return (wxValidator*) NULL; }
00110
00111
00112
00113 #define WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY_WITH_DECL(CLASSNAME,DECL) \
00114 DECL CLASSNAME : public wxFlagsProperty \
00115 { \
00116 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
00117 public: \
00118 CLASSNAME( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, long value = -1 ); \
00119 virtual ~CLASSNAME(); \
00120 };
00121
00122 #define WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY(CLASSNAME) \
00123 WX_PG_DECLARE_CUSTOM_FLAGS_PROPERTY_WITH_DECL(CLASSNAME, class)
00124
00125
00126
00127 #define WX_PG_IMPLEMENT_CUSTOM_FLAGS_PROPERTY(CLASSNAME,LABELS,VALUES,DEFVAL) \
00128 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME,wxFlagsProperty,long_##CLASSNAME,long,TextCtrl) \
00129 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, long value ) \
00130 : wxFlagsProperty(label,name,LABELS,VALUES,value!=-1?value:DEFVAL) \
00131 { \
00132 m_flags |= wxPG_PROP_STATIC_CHOICES; \
00133 } \
00134 CLASSNAME::~CLASSNAME() { }
00135
00136
00137
00138
00139 #define WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY_WITH_DECL(CLASSNAME, DECL) \
00140 class CLASSNAME : public wxEnumProperty \
00141 { \
00142 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
00143 public: \
00144 CLASSNAME( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, int value = -1 ); \
00145 virtual ~CLASSNAME(); \
00146 };
00147
00148 #define WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY(CLASSNAME) \
00149 WX_PG_DECLARE_CUSTOM_ENUM_PROPERTY_WITH_DECL(CLASSNAME, class)
00150
00151 #define WX_PG_IMPLEMENT_CUSTOM_ENUM_PROPERTY(CLASSNAME,LABELS,VALUES,DEFVAL) \
00152 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME,wxEnumProperty,long_##CLASSNAME,int,Choice) \
00153 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, int value ) \
00154 : wxEnumProperty(label,name,LABELS,VALUES,value!=-1?value:DEFVAL) \
00155 { \
00156 m_flags |= wxPG_PROP_STATIC_CHOICES; \
00157 } \
00158 CLASSNAME::~CLASSNAME() { }
00159
00160
00161
00162
00163 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_WITH_DECL(CLASSNAME, DECL) \
00164 DECL CLASSNAME : public wxPG_PROPCLASS(wxSystemColourProperty) \
00165 { \
00166 DECLARE_DYNAMIC_CLASS(CLASSNAME) \
00167 public: \
00168 CLASSNAME( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, \
00169 const wxColourPropertyValue& value = wxColourPropertyValue() ); \
00170 virtual ~CLASSNAME(); \
00171 virtual wxColour GetColour( int index ) const; \
00172 };
00173
00174 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY(CLASSNAME) \
00175 WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_WITH_DECL(CLASSNAME, class)
00176
00177 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY(CLASSNAME,LABELS,VALUES,COLOURS) \
00178 static wxPGChoices gs_##CLASSNAME##_choicesCache; \
00179 WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(CLASSNAME,wxSystemColourProperty,const wxColourPropertyValue&) \
00180 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, \
00181 const wxColourPropertyValue& value ) \
00182 : wxPG_PROPCLASS(wxSystemColourProperty)(label,name,LABELS,VALUES,&gs_##CLASSNAME##_choicesCache,value ) \
00183 { \
00184 m_flags |= wxPG_PROP_TRANSLATE_CUSTOM; \
00185 } \
00186 CLASSNAME::~CLASSNAME () { } \
00187 wxColour CLASSNAME::GetColour ( int index ) const \
00188 { \
00189 return COLOURS[m_choices.GetValue(index)]; \
00190 }
00191
00192
00193
00194 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(CLASSNAME, DECL) \
00195 DECL CLASSNAME : public wxPG_PROPCLASS(wxSystemColourProperty) \
00196 { \
00197 WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
00198 public: \
00199 CLASSNAME( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, \
00200 const wxColour& value = wxColour() ); \
00201 virtual ~CLASSNAME(); \
00202 virtual wxString GetValueAsString( int argFlags ) const; \
00203 virtual wxColour GetColour( int index ) const; \
00204 virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const; \
00205 void Init( wxColour colour ); \
00206 };
00207
00208 #define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(CLASSNAME) \
00209 WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(CLASSNAME, class)
00210
00211 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(CLASSNAME,LABELS,VALUES,COLOURS,EDITOR) \
00212 static wxPGChoices gs_##CLASSNAME##_choicesCache; \
00213 WX_PG_IMPLEMENT_PROPERTY_CLASS(CLASSNAME,wxSystemColourProperty,wxColour,const wxColour&,EDITOR) \
00214 CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, const wxColour& value ) \
00215 : wxPG_PROPCLASS(wxSystemColourProperty)(label,name,LABELS,VALUES,&gs_##CLASSNAME##_choicesCache,value ) \
00216 { \
00217 if ( &value ) \
00218 Init( value ); \
00219 else \
00220 Init( *wxWHITE ); \
00221 m_flags |= wxPG_PROP_TRANSLATE_CUSTOM; \
00222 } \
00223 CLASSNAME::~CLASSNAME() { } \
00224 void CLASSNAME::Init( wxColour colour ) \
00225 { \
00226 if ( !colour.Ok() ) \
00227 colour = *wxWHITE; \
00228 wxVariant variant; \
00229 variant << colour; \
00230 m_value = variant; \
00231 int ind = ColToInd(colour); \
00232 if ( ind < 0 ) \
00233 ind = m_choices.GetCount() - 1; \
00234 SetIndex( ind ); \
00235 } \
00236 wxString CLASSNAME::GetValueAsString( int argFlags ) const \
00237 { \
00238 const wxPGEditor* editor = GetEditorClass(); \
00239 if ( editor != wxPG_EDITOR(Choice) && \
00240 editor != wxPG_EDITOR(ChoiceAndButton) && \
00241 editor != wxPG_EDITOR(ComboBox) ) \
00242 argFlags |= wxPG_PROPERTY_SPECIFIC; \
00243 return wxSystemColourProperty::GetValueAsString(argFlags); \
00244 } \
00245 wxColour CLASSNAME::GetColour( int index ) const \
00246 { \
00247 return COLOURS[m_choices.GetValue(index)]; \
00248 } \
00249 wxVariant CLASSNAME::DoTranslateVal( wxColourPropertyValue& v ) const \
00250 { \
00251 wxVariant variant; \
00252 variant << v.m_colour; \
00253 return variant; \
00254 }
00255
00256
00257 #define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(CLASSNAME,LABELS,VALUES,COLOURS) \
00258 WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(CLASSNAME,LABELS,VALUES,COLOURS,Choice)
00259
00260
00261
00262
00263
00264 #define WX_PG_DOGETVALIDATOR_ENTRY() \
00265 static wxValidator* s_ptr = (wxValidator*) NULL; \
00266 if ( s_ptr ) return s_ptr;
00267
00268
00269 #define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
00270 s_ptr = VALIDATOR; \
00271 wxPGGlobalVars->m_arrValidators.Add( (void*) VALIDATOR ); \
00272 return VALIDATOR;
00273
00274
00275
00276 #ifndef SWIG
00277
00283 class WXDLLIMPEXP_PG wxPGInDialogValidator
00284 {
00285 public:
00286 wxPGInDialogValidator()
00287 {
00288 m_textCtrl = NULL;
00289 }
00290
00291 ~wxPGInDialogValidator()
00292 {
00293 if ( m_textCtrl )
00294 m_textCtrl->Destroy();
00295 }
00296
00297 bool DoValidate( wxPropertyGrid* propGrid, wxValidator* validator, const wxString& value );
00298
00299 private:
00300 wxTextCtrl* m_textCtrl;
00301 };
00302
00303 #endif // SWIG
00304
00305
00306
00307
00308
00309
00310 #define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
00311
00323 class WXDLLIMPEXP_PG wxStringProperty : public wxPGProperty
00324 {
00325 WX_PG_DECLARE_PROPERTY_CLASS(wxStringProperty)
00326 public:
00327 wxStringProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00328 const wxString& value = wxEmptyString );
00329 virtual ~wxStringProperty();
00330
00331 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00332 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00333
00334
00336 virtual void OnSetValue();
00337
00338 protected:
00339 };
00340
00341
00342
00343 #ifndef SWIG
00344
00346 enum
00347 {
00350 wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE = 0,
00351
00354 wxPG_PROPERTY_VALIDATION_SATURATE = 1,
00355
00358 wxPG_PROPERTY_VALIDATION_WRAP = 2
00359 };
00360 #endif
00361
00362
00363
00403 class WXDLLIMPEXP_PG wxIntProperty : public wxPGProperty
00404 {
00405 WX_PG_DECLARE_PROPERTY_CLASS(wxIntProperty)
00406 public:
00407 wxIntProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00408 long value = 0 );
00409 virtual ~wxIntProperty();
00410
00411 wxIntProperty( const wxString& label, const wxString& name, const wxLongLong& value );
00412 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00413 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
00414 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
00415 static wxValidator* GetClassValidator();
00416 virtual wxValidator* DoGetValidator() const;
00417
00420 static bool DoValidation( const wxPGProperty* property, wxLongLong_t& value, wxPGValidationInfo* pValidationInfo, int mode = wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
00421
00422 protected:
00423 };
00424
00425
00426
00442 class WXDLLIMPEXP_PG wxUIntProperty : public wxPGProperty
00443 {
00444 WX_PG_DECLARE_PROPERTY_CLASS(wxUIntProperty)
00445 public:
00446 wxUIntProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00447 unsigned long value = 0 );
00448 virtual ~wxUIntProperty();
00449 wxUIntProperty( const wxString& label, const wxString& name, const wxULongLong& value );
00450 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00451 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00452 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
00453 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
00454 protected:
00455 wxByte m_base;
00456 wxByte m_realBase;
00457 wxByte m_prefix;
00458 private:
00459 void Init();
00460 };
00461
00462
00463
00472 class WXDLLIMPEXP_PG wxFloatProperty : public wxPGProperty
00473 {
00474 WX_PG_DECLARE_PROPERTY_CLASS(wxFloatProperty)
00475 public:
00476 wxFloatProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00477 double value = 0.0 );
00478 virtual ~wxFloatProperty();
00479
00480 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00481 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00482 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
00483
00486 static bool DoValidation( const wxPGProperty* property, double& value, wxPGValidationInfo* pValidationInfo, int mode = wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE );
00487
00488 protected:
00489 int m_precision;
00490 virtual wxValidator* DoGetValidator () const;
00491 };
00492
00493
00494
00503 class WXDLLIMPEXP_PG wxBoolProperty : public wxPGProperty
00504 {
00505 WX_PG_DECLARE_PROPERTY_CLASS(wxBoolProperty)
00506 public:
00507 wxBoolProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00508 bool value = false );
00509 virtual ~wxBoolProperty();
00510
00511 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00512 WX_PG_DECLARE_CHOICE_METHODS()
00513 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00514 };
00515
00516
00517
00529 class WXDLLIMPEXP_PG wxBaseEnumProperty : public wxPGProperty
00530 {
00531 public:
00532 wxBaseEnumProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL );
00533
00534 virtual void OnSetValue();
00535 virtual wxString GetValueAsString( int argFlags ) const;
00536 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
00537 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
00538
00539
00540
00541 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
00542
00543
00544
00545
00546
00547 virtual int GetIndexForValue( int value ) const;
00548
00549
00550
00551
00552 virtual const wxString* GetEntry( size_t index, int* pvalue ) const = 0;
00553
00554 int GetValueForIndex( size_t index ) const
00555 {
00556 int v;
00557 GetEntry( index, &v );
00558 return v;
00559 }
00560
00561 virtual void OnValidationFailure( wxVariant& pendingValue );
00562
00563 protected:
00564
00565 int GetIndex() const;
00566 void SetIndex( int index );
00567
00568 bool ValueFromString_( wxVariant& value, const wxString& text, int argFlags ) const;
00569 bool ValueFromInt_( wxVariant& value, int intVal, int argFlags ) const;
00570
00571 static void ResetNextIndex() { ms_nextIndex = -2; }
00572
00573 private:
00574
00575
00576 int m_index;
00577
00578
00579 static int ms_nextIndex;
00580 };
00581
00582
00583
00584
00585
00586 #define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
00587
00594 class WXDLLIMPEXP_PG wxEnumProperty : public wxBaseEnumProperty
00595 {
00596 WX_PG_DECLARE_PROPERTY_CLASS(wxEnumProperty)
00597 public:
00598
00599 #ifndef SWIG
00600 wxEnumProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00601 const wxChar** labels = NULL, const long* values = NULL, int value = 0 );
00602 wxEnumProperty( const wxString& label, const wxString& name,
00603 wxPGChoices& choices, int value = 0 );
00604
00605
00606 wxEnumProperty( const wxString& label, const wxString& name, const wxChar** labels,
00607 const long* values, wxPGChoices* choicesCache, int value = 0 );
00608
00609 wxEnumProperty( const wxString& label, const wxString& name,
00610 const wxArrayString& labels, const wxArrayInt& values = wxArrayInt(),
00611 int value = 0 );
00612 #else
00613 wxEnumProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00614 const wxArrayString& labels = wxArrayString(), const wxArrayInt& values = wxArrayInt(),
00615 int value = 0 );
00616 #endif
00617
00618 virtual ~wxEnumProperty();
00619
00620 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
00621 virtual int GetIndexForValue( int value ) const;
00622 virtual const wxString* GetEntry( size_t index, int* pvalue ) const;
00623
00624 size_t GetItemCount() const { return m_choices.GetCount(); }
00625 const wxPGChoices& GetChoices() const { return m_choices; }
00626
00627 protected:
00628 wxPGChoices m_choices;
00629 };
00630
00631
00632
00642 class WXDLLIMPEXP_PG wxEditEnumProperty : public wxEnumProperty
00643 {
00644 WX_PG_DECLARE_PROPERTY_CLASS(wxEditEnumProperty)
00645 public:
00646
00647 wxEditEnumProperty( const wxString& label, const wxString& name, const wxChar** labels,
00648 const long* values, const wxString& value );
00649 wxEditEnumProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00650 const wxArrayString& labels = wxArrayString(), const wxArrayInt& values = wxArrayInt(),
00651 const wxString& value = wxEmptyString );
00652 wxEditEnumProperty( const wxString& label, const wxString& name,
00653 wxPGChoices& choices, const wxString& value = wxEmptyString );
00654
00655
00656 wxEditEnumProperty( const wxString& label, const wxString& name, const wxChar** labels,
00657 const long* values, wxPGChoices* choicesCache, const wxString& value );
00658
00659 virtual ~wxEditEnumProperty();
00660
00661 protected:
00662 };
00663
00664
00665
00676 class WXDLLIMPEXP_PG wxFlagsProperty : public wxPGProperty
00677 {
00678 WX_PG_DECLARE_PROPERTY_CLASS(wxFlagsProperty)
00679 public:
00680
00681 #ifndef SWIG
00682 wxFlagsProperty( const wxString& label, const wxString& name, const wxChar** labels,
00683 const long* values = NULL, long value = 0 );
00684 wxFlagsProperty( const wxString& label, const wxString& name,
00685 wxPGChoices& choices, long value = 0 );
00686 #endif
00687 wxFlagsProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00688 const wxArrayString& labels = wxArrayString(),
00689 const wxArrayInt& values = wxArrayInt(), int value = 0 );
00690 virtual ~wxFlagsProperty ();
00691
00692 virtual void OnSetValue();
00693 virtual wxString GetValueAsString( int argFlags ) const;
00694 virtual bool StringToValue( wxVariant& variant, const wxString& text, int flags ) const;
00695 virtual void ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const;
00696 virtual void RefreshChildren();
00697
00698
00699 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
00700
00701
00702 size_t GetItemCount() const { return m_choices.GetCount(); }
00703 const wxString& GetLabel( size_t ind ) const { return m_choices.GetLabel(ind); }
00704
00705 protected:
00706 wxPGChoices m_choices;
00707
00708
00709 wxPGChoicesData* m_oldChoicesData;
00710
00711
00712 long m_oldValue;
00713
00714
00715 long IdToBit( const wxString& id ) const;
00716
00717
00718 void Init();
00719 };
00720
00721
00722
00726 class WXDLLIMPEXP_PG wxPGFileDialogAdapter : public wxPGEditorDialogAdapter
00727 {
00728 public:
00729 virtual bool DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
00730 };
00731
00732
00733
00734 #include <wx/filename.h>
00735
00736
00737 #define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
00738
00754 class WXDLLIMPEXP_PG wxFileProperty : public wxPGProperty
00755 {
00756 friend class wxPGFileDialogAdapter;
00757 WX_PG_DECLARE_PROPERTY_CLASS(wxFileProperty)
00758 public:
00759
00760 wxFileProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
00761 const wxString& value = wxEmptyString );
00762 virtual ~wxFileProperty ();
00763
00764 virtual void OnSetValue();
00765 virtual wxString GetValueAsString( int argFlags ) const;
00766 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
00767
00768 virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
00769
00770 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00771
00772 static wxValidator* GetClassValidator();
00773 virtual wxValidator* DoGetValidator() const;
00774
00775 protected:
00776 wxString m_wildcard;
00777 wxString m_basePath;
00778 wxString m_initialPath;
00779 wxString m_dlgTitle;
00780 wxFileName m_filename;
00781 int m_indFilter;
00782 };
00783
00784
00785
00786 #define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
00787
00788
00792 class WXDLLIMPEXP_PG wxPGLongStringDialogAdapter : public wxPGEditorDialogAdapter
00793 {
00794 public:
00795 virtual bool DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
00796 };
00797
00798
00805 class WXDLLIMPEXP_PG wxLongStringProperty : public wxPGProperty
00806 {
00807 WX_PG_DECLARE_PROPERTY_CLASS(wxLongStringProperty)
00808 public:
00809
00810 wxLongStringProperty( const wxString& label = wxPG_LABEL,
00811 const wxString& name = wxPG_LABEL,
00812 const wxString& value = wxEmptyString );
00813 virtual ~wxLongStringProperty();
00814
00815 virtual wxString GetValueAsString( int argFlags = 0 ) const;
00816 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
00817
00818 WX_PG_DECLARE_EVENT_METHODS()
00819
00820
00821
00822
00823 virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value );
00824
00825 static bool DisplayEditorDialog( wxPGProperty* prop, wxPropertyGrid* propGrid, wxString& value );
00826
00827 protected:
00828 };
00829
00830
00831
00840 class WXDLLIMPEXP_PG wxDirProperty : public wxLongStringProperty
00841 {
00842 #ifndef SWIG
00843 DECLARE_DYNAMIC_CLASS(wxDirProperty)
00844 #endif
00845 public:
00846 wxDirProperty( const wxString& name = wxPG_LABEL, const wxString& label = wxPG_LABEL,
00847 const wxString& value = wxEmptyString );
00848 virtual ~wxDirProperty();
00849
00850 WX_PG_DECLARE_ATTRIBUTE_METHODS()
00851 WX_PG_DECLARE_VALIDATOR_METHODS()
00852
00853 virtual bool OnButtonClick ( wxPropertyGrid* propGrid, wxString& value );
00854
00855 protected:
00856 wxString m_dlgMessage;
00857 };
00858
00859
00860
00861
00862
00863 #define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
00864
00865 #define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
00866
00867
00868
00869
00875 class WXDLLIMPEXP_PG wxArrayStringProperty : public wxPGProperty
00876 {
00877 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty)
00878 public:
00879
00880 wxArrayStringProperty( const wxString& label = wxPG_LABEL,
00881 const wxString& name = wxPG_LABEL,
00882 const wxArrayString& value = wxArrayString() );
00883 virtual ~wxArrayStringProperty();
00884
00885 virtual void OnSetValue();
00886 WX_PG_DECLARE_BASIC_TYPE_METHODS()
00887 WX_PG_DECLARE_EVENT_METHODS()
00888
00889 virtual void GenerateValueAsString();
00890
00891
00892
00893
00894 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value );
00895
00896
00897 virtual bool OnButtonClick( wxPropertyGrid* propgrid,
00898 wxWindow* primary,
00899 const wxChar* cbt );
00900
00901 #ifndef SWIG
00902
00903 virtual wxArrayEditorDialog* CreateEditorDialog();
00904 #endif
00905
00906 protected:
00907 wxString m_display;
00908 };
00909
00910
00911
00912 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL) \
00913 DECL wxPG_PROPCLASS(PROPNAME) : public wxPG_PROPCLASS(wxArrayStringProperty) \
00914 { \
00915 WX_PG_DECLARE_PROPERTY_CLASS(wxPG_PROPCLASS(PROPNAME)) \
00916 public: \
00917 wxPG_PROPCLASS(PROPNAME)( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, \
00918 const wxArrayString& value = wxArrayString() ); \
00919 ~wxPG_PROPCLASS(PROPNAME)(); \
00920 virtual void GenerateValueAsString(); \
00921 virtual bool StringToValue( wxVariant& value, const wxString& text, int = 0 ) const; \
00922 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ); \
00923 virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); \
00924 WX_PG_DECLARE_VALIDATOR_METHODS() \
00925 };
00926
00927 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM) \
00928 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAM, class)
00929
00930 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
00931 WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME,wxArrayStringProperty,wxArrayString,const wxArrayString&,TextCtrlAndButton) \
00932 wxPG_PROPCLASS(PROPNAME)::wxPG_PROPCLASS(PROPNAME)( const wxString& label, const wxString& name, const wxArrayString& value ) \
00933 : wxPG_PROPCLASS(wxArrayStringProperty)(label,name,value) \
00934 { \
00935 wxPG_PROPCLASS(PROPNAME)::GenerateValueAsString(); \
00936 } \
00937 wxPG_PROPCLASS(PROPNAME)::~wxPG_PROPCLASS(PROPNAME)() { } \
00938 void wxPG_PROPCLASS(PROPNAME)::GenerateValueAsString() \
00939 { \
00940 wxChar delimChar = DELIMCHAR; \
00941 if ( delimChar == wxT('"') ) \
00942 wxPG_PROPCLASS(wxArrayStringProperty)::GenerateValueAsString(); \
00943 else \
00944 wxPropertyGrid::ArrayStringToString(m_display,m_value.GetArrayString(),0,DELIMCHAR,0); \
00945 } \
00946 bool wxPG_PROPCLASS(PROPNAME)::StringToValue( wxVariant& variant, const wxString& text, int ) const \
00947 { \
00948 wxChar delimChar = DELIMCHAR; \
00949 if ( delimChar == wxT('"') ) \
00950 return wxPG_PROPCLASS(wxArrayStringProperty)::StringToValue(variant, text, 0); \
00951 \
00952 wxArrayString arr; \
00953 WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
00954 arr.Add( token ); \
00955 WX_PG_TOKENIZER1_END() \
00956 variant = arr; \
00957 return true; \
00958 } \
00959 bool wxPG_PROPCLASS(PROPNAME)::OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ) \
00960 { \
00961 if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
00962 return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
00963 return false; \
00964 }
00965
00966 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \
00967 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME)
00968
00969 #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_DECL(PROPNAME, DECL) \
00970 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(PROPNAME, DECL)
00971
00972 #define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
00973 WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
00974 wxValidator* wxPG_PROPCLASS(PROPNAME)::DoGetValidator () const \
00975 { return (wxValidator*) NULL; }
00976
00977
00978
00979
00980
00981
00982 #define wxAEDIALOG_STYLE \
00983 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
00984
00985 class WXDLLIMPEXP_PG wxArrayEditorDialog : public wxDialog
00986 {
00987 public:
00988 wxArrayEditorDialog();
00989 virtual ~wxArrayEditorDialog() { }
00990
00991 void Init();
00992
00993 wxArrayEditorDialog( wxWindow *parent,
00994 const wxString& message,
00995 const wxString& caption,
00996 long style = wxAEDIALOG_STYLE,
00997 const wxPoint& pos = wxDefaultPosition,
00998 const wxSize& sz = wxDefaultSize );
00999
01000 bool Create( wxWindow *parent,
01001 const wxString& message,
01002 const wxString& caption,
01003 long style = wxAEDIALOG_STYLE,
01004 const wxPoint& pos = wxDefaultPosition,
01005 const wxSize& sz = wxDefaultSize );
01006
01009 virtual void SetDialogValue( const wxVariant& WXUNUSED(value) )
01010 {
01011 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
01012 }
01013
01016 virtual wxVariant GetDialogValue() const
01017 {
01018 wxFAIL_MSG(wxT("re-implement this member function in derived class"));
01019 return wxVariant();
01020 }
01021
01030 virtual wxValidator* GetTextCtrlValidator() const
01031 {
01032 return (wxValidator*) NULL;
01033 }
01034
01035
01036 bool IsModified() const { return m_modified; }
01037
01038
01039
01040
01041 void OnUpdateClick(wxCommandEvent& event);
01042 void OnAddClick(wxCommandEvent& event);
01043 void OnDeleteClick(wxCommandEvent& event);
01044 void OnListBoxClick(wxCommandEvent& event);
01045 void OnUpClick(wxCommandEvent& event);
01046 void OnDownClick(wxCommandEvent& event);
01047
01048 void OnIdle(wxIdleEvent& event);
01049
01050 #if defined(__WXPYTHON__) && !defined(SWIG)
01051
01052 PyObject* m_scriptObject;
01053 #endif
01054 protected:
01055 wxTextCtrl* m_edValue;
01056 wxListBox* m_lbStrings;
01057
01058 wxButton* m_butAdd;
01059 wxButton* m_butCustom;
01060 wxButton* m_butUpdate;
01061 wxButton* m_butRemove;
01062 wxButton* m_butUp;
01063 wxButton* m_butDown;
01064
01065
01066
01067 const wxChar* m_custBtText;
01068
01069
01070 bool m_modified;
01071
01072 unsigned char m_curFocus;
01073
01074
01075 virtual wxString ArrayGet( size_t index ) = 0;
01076 virtual size_t ArrayGetCount() = 0;
01077 virtual bool ArrayInsert( const wxString& str, int index ) = 0;
01078 virtual bool ArraySet( size_t index, const wxString& str ) = 0;
01079 virtual void ArrayRemoveAt( int index ) = 0;
01080 virtual void ArraySwap( size_t first, size_t second ) = 0;
01081
01082 private:
01083 #ifndef SWIG
01084 DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog)
01085 DECLARE_EVENT_TABLE()
01086 #endif
01087 };
01088
01089
01090
01091
01092
01093 class WXDLLIMPEXP_PG wxPGArrayStringEditorDialog : public wxArrayEditorDialog
01094 {
01095 public:
01096 wxPGArrayStringEditorDialog();
01097 virtual ~wxPGArrayStringEditorDialog() { }
01098
01099 void Init();
01100
01101 virtual void SetDialogValue( const wxVariant& value )
01102 {
01103 m_array = value.GetArrayString();
01104 }
01105
01106 virtual wxVariant GetDialogValue() const
01107 {
01108 return m_array;
01109 }
01110
01111 void SetCustomButton( const wxChar* custBtText, wxArrayStringProperty* pcc )
01112 {
01113 m_custBtText = custBtText;
01114 m_pCallingClass = pcc;
01115 }
01116
01117 void OnCustomEditClick(wxCommandEvent& event);
01118
01119 protected:
01120 wxArrayString m_array;
01121
01122 wxArrayStringProperty* m_pCallingClass;
01123
01124 virtual wxString ArrayGet( size_t index );
01125 virtual size_t ArrayGetCount();
01126 virtual bool ArrayInsert( const wxString& str, int index );
01127 virtual bool ArraySet( size_t index, const wxString& str );
01128 virtual void ArrayRemoveAt( int index );
01129 virtual void ArraySwap( size_t first, size_t second );
01130
01131 private:
01132 #ifndef SWIG
01133 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPGArrayStringEditorDialog)
01134 DECLARE_EVENT_TABLE()
01135 #endif
01136 };
01137
01138
01139
01140
01141 #if wxPG_COMPATIBILITY_1_2_0
01142 typedef wxStringProperty wxParentProperty;
01143 #endif
01144
01145
01146
01156 class WXDLLIMPEXP_PG wxCustomProperty : public wxPGProperty
01157 {
01158 #ifndef SWIG
01159 WX_PG_DECLARE_PROPERTY_CLASS(wxCustomProperty)
01160 #endif
01161 public:
01162
01163 wxCustomProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL );
01164 virtual ~wxCustomProperty();
01165
01166 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
01167 virtual wxString GetValueAsString( int argFlags ) const;
01168
01169 #ifdef wxPG_COMPATIBILITY_1_0_0
01170 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event );
01171 #endif
01172 WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
01173
01174 virtual bool IntToValue( wxVariant& variant, int number, int argFlags ) const;
01175 virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
01176
01177 virtual void ChildChanged( wxVariant& a1, int a2, wxVariant& a3 ) const
01178 {
01179 wxUnusedVar(a1);
01180 wxUnusedVar(a2);
01181 wxUnusedVar(a3);
01182 }
01183
01184 WX_PG_DECLARE_ATTRIBUTE_METHODS()
01185
01186 protected:
01187 wxPGChoices m_choices;
01188 #ifdef wxPG_COMPATIBILITY_1_0_0
01189 wxPropertyGridCallback m_callback;
01190 #endif
01191 wxPGPaintCallback m_paintCallback;
01192 };
01193
01194
01195
01196
01197
01198 WXDLLIMPEXP_PG bool wxPGStringToLongLong(const wxString s, wxLongLong_t* val, int base);
01199 WXDLLIMPEXP_PG bool wxPGStringToULongLong(const wxString s, wxULongLong_t* val, int base);
01200
01201
01202
01203 #endif // _WX_PROPGRID_PROPS_H_