sampleprops.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: samples/propgrid/sampleprops.h
  3. // Purpose: wxPropertyGrid Sample Properties Header
  4. // Author: Jaakko Salli
  5. // Modified by:
  6. // Created: 2006-03-05
  7. // Copyright: (c) Jaakko Salli
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
  11. #define _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
  12. #include "wx/fontdata.h"
  13. DECLARE_VARIANT_OBJECT(wxFontData)
  14. class wxFontDataProperty : public wxFontProperty
  15. {
  16. WX_PG_DECLARE_PROPERTY_CLASS(wxFontDataProperty)
  17. public:
  18. wxFontDataProperty( const wxString& label = wxPG_LABEL,
  19. const wxString& name = wxPG_LABEL,
  20. const wxFontData& value = wxFontData() );
  21. virtual ~wxFontDataProperty ();
  22. void OnSetValue();
  23. // In order to have different value type in a derived property
  24. // class, we will override GetValue to return custom variant,
  25. // instead of changing the base m_value. This allows the methods
  26. // in base class to function properly.
  27. virtual wxVariant DoGetValue() const;
  28. virtual wxVariant ChildChanged( wxVariant& thisValue,
  29. int childIndex,
  30. wxVariant& childValue ) const;
  31. virtual void RefreshChildren();
  32. virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event );
  33. protected:
  34. // Value must be stored as variant - otherwise it will be
  35. // decreffed to oblivion on GetValue().
  36. wxVariant m_value_wxFontData;
  37. };
  38. // -----------------------------------------------------------------------
  39. class wxSizeProperty : public wxPGProperty
  40. {
  41. WX_PG_DECLARE_PROPERTY_CLASS(wxSizeProperty)
  42. public:
  43. wxSizeProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
  44. const wxSize& value = wxSize() );
  45. virtual ~wxSizeProperty();
  46. virtual wxVariant ChildChanged( wxVariant& thisValue,
  47. int childIndex,
  48. wxVariant& childValue ) const;
  49. virtual void RefreshChildren();
  50. protected:
  51. // I stands for internal
  52. void SetValueI( const wxSize& value )
  53. {
  54. m_value = WXVARIANT(value);
  55. }
  56. };
  57. // -----------------------------------------------------------------------
  58. class wxPointProperty : public wxPGProperty
  59. {
  60. WX_PG_DECLARE_PROPERTY_CLASS(wxPointProperty)
  61. public:
  62. wxPointProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
  63. const wxPoint& value = wxPoint() );
  64. virtual ~wxPointProperty();
  65. virtual wxVariant ChildChanged( wxVariant& thisValue,
  66. int childIndex,
  67. wxVariant& childValue ) const;
  68. virtual void RefreshChildren();
  69. protected:
  70. // I stands for internal
  71. void SetValueI( const wxPoint& value )
  72. {
  73. m_value = WXVARIANT(value);
  74. }
  75. };
  76. // -----------------------------------------------------------------------
  77. WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(wxDirsProperty, class wxEMPTY_PARAMETER_VALUE)
  78. // -----------------------------------------------------------------------
  79. WX_PG_DECLARE_VARIANT_DATA(wxArrayDouble)
  80. class wxArrayDoubleProperty : public wxPGProperty
  81. {
  82. WX_PG_DECLARE_PROPERTY_CLASS(wxArrayDoubleProperty)
  83. public:
  84. wxArrayDoubleProperty( const wxString& label = wxPG_LABEL,
  85. const wxString& name = wxPG_LABEL,
  86. const wxArrayDouble& value = wxArrayDouble() );
  87. virtual ~wxArrayDoubleProperty ();
  88. virtual void OnSetValue();
  89. virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
  90. virtual bool StringToValue( wxVariant& variant,
  91. const wxString& text,
  92. int argFlags = 0 ) const;
  93. virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event );
  94. virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
  95. // Generates cache for displayed text
  96. virtual void GenerateValueAsString ( wxString& target, int prec, bool removeZeroes ) const;
  97. protected:
  98. wxString m_display; // Stores cache for displayed text
  99. int m_precision; // Used when formatting displayed string.
  100. wxChar m_delimiter; // Delimiter between array entries.
  101. };
  102. // -----------------------------------------------------------------------
  103. #endif // _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_