1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/propgrid/sampleprops.h
3 // Purpose: wxPropertyGrid Sample Properties Header
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
13 #define _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
15 #include "wx/fontdata.h"
17 DECLARE_VARIANT_OBJECT(wxFontData
)
20 class wxFontDataProperty
: public wxFontProperty
22 WX_PG_DECLARE_PROPERTY_CLASS(wxFontDataProperty
)
25 wxFontDataProperty( const wxString
& label
= wxPG_LABEL
,
26 const wxString
& name
= wxPG_LABEL
,
27 const wxFontData
& value
= wxFontData() );
28 virtual ~wxFontDataProperty ();
32 // In order to have different value type in a derived property
33 // class, we will override GetValue to return custom variant,
34 // instead of changing the base m_value. This allows the methods
35 // in base class to function properly.
36 virtual wxVariant
DoGetValue() const;
38 virtual wxVariant
ChildChanged( wxVariant
& thisValue
,
40 wxVariant
& childValue
) const;
41 virtual void RefreshChildren();
42 virtual bool OnEvent( wxPropertyGrid
* propgrid
, wxWindow
* primary
, wxEvent
& event
);
45 // Value must be stored as variant - otherwise it will be
46 // decreffed to oblivion on GetValue().
47 wxVariant m_value_wxFontData
;
50 // -----------------------------------------------------------------------
52 class wxSizeProperty
: public wxPGProperty
54 WX_PG_DECLARE_PROPERTY_CLASS(wxSizeProperty
)
57 wxSizeProperty( const wxString
& label
= wxPG_LABEL
, const wxString
& name
= wxPG_LABEL
,
58 const wxSize
& value
= wxSize() );
59 virtual ~wxSizeProperty();
61 virtual wxVariant
ChildChanged( wxVariant
& thisValue
,
63 wxVariant
& childValue
) const;
64 virtual void RefreshChildren();
68 // I stands for internal
69 void SetValueI( const wxSize
& value
)
71 m_value
= WXVARIANT(value
);
75 // -----------------------------------------------------------------------
77 class wxPointProperty
: public wxPGProperty
79 WX_PG_DECLARE_PROPERTY_CLASS(wxPointProperty
)
82 wxPointProperty( const wxString
& label
= wxPG_LABEL
, const wxString
& name
= wxPG_LABEL
,
83 const wxPoint
& value
= wxPoint() );
84 virtual ~wxPointProperty();
86 virtual wxVariant
ChildChanged( wxVariant
& thisValue
,
88 wxVariant
& childValue
) const;
89 virtual void RefreshChildren();
93 // I stands for internal
94 void SetValueI( const wxPoint
& value
)
96 m_value
= WXVARIANT(value
);
100 // -----------------------------------------------------------------------
102 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(wxDirsProperty
, class wxEMPTY_PARAMETER_VALUE
)
104 // -----------------------------------------------------------------------
106 WX_PG_DECLARE_VARIANT_DATA(wxArrayDouble
)
108 class wxArrayDoubleProperty
: public wxPGProperty
110 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayDoubleProperty
)
113 wxArrayDoubleProperty( const wxString
& label
= wxPG_LABEL
,
114 const wxString
& name
= wxPG_LABEL
,
115 const wxArrayDouble
& value
= wxArrayDouble() );
117 virtual ~wxArrayDoubleProperty ();
119 virtual void OnSetValue();
120 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
121 virtual bool StringToValue( wxVariant
& variant
,
122 const wxString
& text
,
123 int argFlags
= 0 ) const;
124 virtual bool OnEvent( wxPropertyGrid
* propgrid
, wxWindow
* primary
, wxEvent
& event
);
125 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
127 // Generates cache for displayed text
128 virtual void GenerateValueAsString ( wxString
& target
, int prec
, bool removeZeroes
) const;
131 wxString m_display
; // Stores cache for displayed text
132 int m_precision
; // Used when formatting displayed string.
133 wxChar m_delimiter
; // Delimiter between array entries.
136 // -----------------------------------------------------------------------
138 #endif // _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_