]>
git.saurik.com Git - wxWidgets.git/blob - utils/configtool/src/property.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: ctProperty objects represent name/value pairs,
4 // for properties of a configuration item.
5 // Author: Julian Smart
9 // Copyright: (c) Julian Smart
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _CT_PROPERTY_H_
14 #define _CT_PROPERTY_H_
16 #include "wx/variant.h"
19 * A property/name pair, with other specialised members for
20 * storing window/sizer information.
23 class ctProperty
: public wxObject
25 DECLARE_CLASS(ctProperty
)
33 ctProperty(const ctProperty
& property
) : wxObject() { Copy(property
); }
34 ctProperty(const wxString
& descr
, const wxVariant
& variant
,
35 const wxString
& editorType
= wxEmptyString
,
36 bool readOnly
= false)
38 m_description
= descr
;
40 m_editorType
= editorType
;
42 m_readOnly
= readOnly
;
46 ctProperty(const wxString
& name
, const wxString
& value
= wxEmptyString
)
48 m_variant
.SetName(name
);
55 void operator= (const ctProperty
& property
) { Copy(property
); }
56 void Copy(const ctProperty
& property
)
58 m_variant
= property
.m_variant
;
59 m_editorType
= property
.m_editorType
;
60 m_description
= property
.m_description
;
61 m_choices
= property
.m_choices
;
62 m_show
= property
.m_show
;
63 m_readOnly
= property
.m_readOnly
;
64 m_custom
= property
.m_custom
;
67 bool operator== (const ctProperty
& property
) const
69 return ((m_variant
== property
.m_variant
) &&
70 (m_editorType
== property
.m_editorType
) &&
71 (m_description
== property
.m_description
) &&
72 (m_show
== property
.m_show
) &&
73 (m_custom
== property
.m_custom
) &&
74 (m_readOnly
== property
.m_readOnly
) &&
75 (m_choices
== property
.m_choices
));
78 bool operator!= (const ctProperty
& property
) const
80 return !((*this) == property
);
83 inline const wxString
& GetName() const { return m_variant
.GetName(); }
84 inline wxString
GetValue() const { return m_variant
.GetString(); }
85 inline wxVariant
& GetVariant() { return m_variant
; }
86 inline const wxString
& GetEditorType() const { return m_editorType
; }
87 inline const wxArrayString
& GetChoices() const { return m_choices
; }
88 inline const wxString
& GetDescription() const { return m_description
; }
89 inline bool IsCustom() const { return m_custom
; }
91 inline void SetName(const wxString
& name
) { m_variant
.SetName(name
); }
92 inline void SetValue(const wxString
& value
) { m_variant
= value
; }
93 inline void SetValue(const wxVariant
& value
) { m_variant
= value
; }
94 inline void SetEditorType(const wxString
& type
) { m_editorType
= type
; }
95 inline void SetChoices(const wxArrayString
& choices
) { m_choices
= choices
; }
96 inline void SetDescription(const wxString
& descr
) { m_description
= descr
; }
97 inline void Show(bool show
) { m_show
= show
; }
98 inline bool IsShown() const { return m_show
; }
99 inline bool GetReadOnly() const { return m_readOnly
; }
100 inline void SetReadOnly(bool readOnly
) { m_readOnly
= readOnly
; }
101 inline void SetCustom(bool custom
) { m_custom
= custom
; }
103 // The name and value
106 // The editor type name (e.g. "file")
107 // used to choose an editor.
108 wxString m_editorType
;
111 wxArrayString m_choices
;
114 wxString m_description
;
116 // Whether to show or hide (e.g. not properly initialized)
122 // Whether it's a custom property (so save
127 // A class to manage properties
128 class ctProperties
: public wxObject
130 DECLARE_CLASS(ctProperties
)
133 ctProperties(const ctProperties
& properties
) : wxObject() { Copy(properties
); }
134 ~ctProperties() { Clear(); }
136 void operator = (const ctProperties
& properties
) { Clear(); Copy(properties
); }
137 void Copy(const ctProperties
& properties
);
139 inline const wxList
& GetList() const { return m_list
; }
141 inline size_t GetCount() const { return m_list
.GetCount(); }
143 void AddProperty(ctProperty
* property
, const wxString
& insertAfter
= wxEmptyString
);
144 void SetProperty(const wxString
& name
, const wxString
& value
);
145 void SetProperty(const wxString
& name
, long value
);
146 void SetProperty(const wxString
& name
, bool value
);
147 void SetProperty(const wxString
& name
, const wxVariant
& value
);
148 void RemoveProperty(ctProperty
* property
);
149 void DeleteProperty(const wxString
& name
);
150 ctProperty
* FindProperty(const wxString
& name
) const;
151 ctProperty
* FindOrCreateProperty(const wxString
& name
);
152 wxString
FindPropertyValueString(const wxString
& name
) const;
153 wxVariant
FindPropertyValue(const wxString
& name
) const;
154 ctProperty
* GetNth(int i
) const;