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
11 #ifndef _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
12 #define _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
13
14 #include "wx/fontdata.h"
15
DECLARE_VARIANT_OBJECT(wxFontData)16 DECLARE_VARIANT_OBJECT(wxFontData)
17
18
19 class wxFontDataProperty : public wxFontProperty
20 {
21 WX_PG_DECLARE_PROPERTY_CLASS(wxFontDataProperty)
22 public:
23
24 wxFontDataProperty( const wxString& label = wxPG_LABEL,
25 const wxString& name = wxPG_LABEL,
26 const wxFontData& value = wxFontData() );
27 virtual ~wxFontDataProperty ();
28
29 void OnSetValue() wxOVERRIDE;
30
31 // In order to have different value type in a derived property
32 // class, we will override GetValue to return custom variant,
33 // instead of changing the base m_value. This allows the methods
34 // in base class to function properly.
35 virtual wxVariant DoGetValue() const wxOVERRIDE;
36
37 virtual wxVariant ChildChanged( wxVariant& thisValue,
38 int childIndex,
39 wxVariant& childValue ) const wxOVERRIDE;
40 virtual void RefreshChildren() wxOVERRIDE;
41
42 protected:
43 virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
44
45 // Value must be stored as variant - otherwise it will be
46 // decreffed to oblivion on GetValue().
47 wxVariant m_value_wxFontData;
48 };
49
50 // -----------------------------------------------------------------------
51
52 class wxSizeProperty : public wxPGProperty
53 {
54 WX_PG_DECLARE_PROPERTY_CLASS(wxSizeProperty)
55 public:
56
57 wxSizeProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
58 const wxSize& value = wxSize() );
59 virtual ~wxSizeProperty();
60
61 virtual wxVariant ChildChanged( wxVariant& thisValue,
62 int childIndex,
63 wxVariant& childValue ) const wxOVERRIDE;
64 virtual void RefreshChildren() wxOVERRIDE;
65
66 protected:
67
68 // I stands for internal
SetValueI(const wxSize & value)69 void SetValueI( const wxSize& value )
70 {
71 m_value = WXVARIANT(value);
72 }
73 };
74
75 // -----------------------------------------------------------------------
76
77 class wxPointProperty : public wxPGProperty
78 {
79 WX_PG_DECLARE_PROPERTY_CLASS(wxPointProperty)
80 public:
81
82 wxPointProperty( const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL,
83 const wxPoint& value = wxPoint() );
84 virtual ~wxPointProperty();
85
86 virtual wxVariant ChildChanged( wxVariant& thisValue,
87 int childIndex,
88 wxVariant& childValue ) const wxOVERRIDE;
89 virtual void RefreshChildren() wxOVERRIDE;
90
91 protected:
92
93 // I stands for internal
SetValueI(const wxPoint & value)94 void SetValueI( const wxPoint& value )
95 {
96 m_value = WXVARIANT(value);
97 }
98 };
99
100 // -----------------------------------------------------------------------
101
WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(wxDirsProperty,class wxEMPTY_PARAMETER_VALUE)102 WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(wxDirsProperty, class wxEMPTY_PARAMETER_VALUE)
103
104 // -----------------------------------------------------------------------
105
106 WX_PG_DECLARE_VARIANT_DATA(wxArrayDouble)
107
108 class wxArrayDoubleProperty : public wxEditorDialogProperty
109 {
110 WX_PG_DECLARE_PROPERTY_CLASS(wxArrayDoubleProperty)
111 public:
112
113 wxArrayDoubleProperty( const wxString& label = wxPG_LABEL,
114 const wxString& name = wxPG_LABEL,
115 const wxArrayDouble& value = wxArrayDouble() );
116
117 virtual ~wxArrayDoubleProperty ();
118
119 virtual void OnSetValue() wxOVERRIDE;
120 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const wxOVERRIDE;
121 virtual bool StringToValue( wxVariant& variant,
122 const wxString& text,
123 int argFlags = 0 ) const wxOVERRIDE;
124 virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
125
126 // Generates cache for displayed text
127 virtual void GenerateValueAsString ( wxString& target, int prec, bool removeZeroes ) const;
128
129 wxValidator* DoGetValidator() const wxOVERRIDE;
130 bool ValidateValue(wxVariant& value,
131 wxPGValidationInfo& validationInfo) const wxOVERRIDE;
132
133 protected:
134 virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE;
135
136 wxString m_display; // Stores cache for displayed text
137 int m_precision; // Used when formatting displayed string.
138 wxChar m_delimiter; // Delimiter between array entries.
139 };
140
141 // -----------------------------------------------------------------------
142
143 #endif // _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
144