]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
17 #pragma interface "property.cpp"
20 #include "wx/variant.h"
23 * A property/name pair, with other specialised members for
24 * storing window/sizer information.
27 class ctProperty
: public wxObject
29 DECLARE_CLASS(ctProperty
)
37 ctProperty(const ctProperty
& property
) { Copy(property
); }
38 ctProperty(const wxString
& descr
, const wxVariant
& variant
,
39 const wxString
& editorType
= wxEmptyString
,
40 bool readOnly
= FALSE
)
42 m_description
= descr
;
44 m_editorType
= editorType
;
46 m_readOnly
= readOnly
;
50 ctProperty(const wxString
& name
, const wxString
& value
= wxEmptyString
)
52 m_variant
.SetName(name
);
59 void operator= (const ctProperty
& property
) { Copy(property
); }
60 void Copy(const ctProperty
& property
)
62 m_variant
= property
.m_variant
;
63 m_editorType
= property
.m_editorType
;
64 m_description
= property
.m_description
;
65 m_choices
= property
.m_choices
;
66 m_show
= property
.m_show
;
67 m_readOnly
= property
.m_readOnly
;
68 m_custom
= property
.m_custom
;
71 bool operator== (const ctProperty
& property
) const
73 return ((m_variant
== property
.m_variant
) &&
74 (m_editorType
== property
.m_editorType
) &&
75 (m_description
== property
.m_description
) &&
76 (m_show
== property
.m_show
) &&
77 (m_custom
== property
.m_custom
) &&
78 (m_readOnly
== property
.m_readOnly
) &&
79 (m_choices
== property
.m_choices
));
82 bool operator!= (const ctProperty
& property
) const
84 return !((*this) == property
);
87 inline const wxString
& GetName() const { return m_variant
.GetName(); }
88 inline wxString
GetValue() const { return m_variant
.GetString(); }
89 inline wxVariant
& GetVariant() { return m_variant
; }
90 inline const wxString
& GetEditorType() const { return m_editorType
; }
91 inline const wxArrayString
& GetChoices() const { return m_choices
; }
92 inline const wxString
& GetDescription() const { return m_description
; }
93 inline bool IsCustom() const { return m_custom
; }
95 inline void SetName(const wxString
& name
) { m_variant
.SetName(name
); }
96 inline void SetValue(const wxString
& value
) { m_variant
= value
; }
97 inline void SetValue(const wxVariant
& value
) { m_variant
= value
; }
98 inline void SetEditorType(const wxString
& type
) { m_editorType
= type
; }
99 inline void SetChoices(const wxArrayString
& choices
) { m_choices
= choices
; }
100 inline void SetDescription(const wxString
& descr
) { m_description
= descr
; }
101 inline void Show(bool show
) { m_show
= show
; }
102 inline bool IsShown() const { return m_show
; }
103 inline bool GetReadOnly() const { return m_readOnly
; }
104 inline void SetReadOnly(bool readOnly
) { m_readOnly
= readOnly
; }
105 inline void SetCustom(bool custom
) { m_custom
= custom
; }
107 // The name and value
110 // The editor type name (e.g. "file")
111 // used to choose an editor.
112 wxString m_editorType
;
115 wxArrayString m_choices
;
118 wxString m_description
;
120 // Whether to show or hide (e.g. not properly initialized)
126 // Whether it's a custom property (so save
131 // A class to manage properties
132 class ctProperties
: public wxObject
134 DECLARE_CLASS(ctProperties
)
137 ctProperties(const ctProperties
& properties
) { Copy(properties
); }
138 ~ctProperties() { Clear(); }
140 void operator = (const ctProperties
& properties
) { Clear(); Copy(properties
); }
141 void Copy(const ctProperties
& properties
);
143 inline const wxList
& GetList() const { return m_list
; }
145 inline size_t GetCount() const { return m_list
.GetCount(); }
147 void AddProperty(ctProperty
* property
, const wxString
& insertAfter
= wxEmptyString
);
148 void SetProperty(const wxString
& name
, const wxString
& value
);
149 void SetProperty(const wxString
& name
, long value
);
150 void SetProperty(const wxString
& name
, bool value
);
151 void SetProperty(const wxString
& name
, const wxVariant
& value
);
152 void RemoveProperty(ctProperty
* property
);
153 void DeleteProperty(const wxString
& name
);
154 ctProperty
* FindProperty(const wxString
& name
) const;
155 ctProperty
* FindOrCreateProperty(const wxString
& name
);
156 wxString
FindPropertyValueString(const wxString
& name
) const;
157 wxVariant
FindPropertyValue(const wxString
& name
) const;
158 ctProperty
* GetNth(int i
) const;