]> git.saurik.com Git - wxWidgets.git/blob - utils/configtool/src/property.h
Added Find dialog
[wxWidgets.git] / utils / configtool / src / property.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: property.h
3 // Purpose: ctProperty objects represent name/value pairs,
4 // for properties of a configuration item.
5 // Author: Julian Smart
6 // Modified by:
7 // Created: 2003-06-03
8 // RCS-ID: $Id$
9 // Copyright: (c) Julian Smart
10 // Licence:
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _CT_PROPERTY_H_
14 #define _CT_PROPERTY_H_
15
16 #ifdef __GNUG__
17 #pragma interface "property.cpp"
18 #endif
19
20 #include "wx/variant.h"
21
22 /*!
23 * A property/name pair, with other specialised members for
24 * storing window/sizer information.
25 */
26
27 class ctProperty: public wxObject
28 {
29 DECLARE_CLASS(ctProperty)
30 public:
31 ctProperty()
32 {
33 m_readOnly = FALSE;
34 m_custom = FALSE;
35 m_show = TRUE;
36 }
37 ctProperty(const ctProperty& property) { Copy(property); }
38 ctProperty(const wxString& descr, const wxVariant& variant,
39 const wxString& editorType = wxEmptyString,
40 bool readOnly = FALSE)
41 {
42 m_description = descr;
43 m_variant = variant;
44 m_editorType = editorType;
45 m_show = TRUE;
46 m_readOnly = readOnly;
47 m_custom = FALSE;
48 }
49
50 ctProperty(const wxString& name, const wxString& value = wxEmptyString)
51 {
52 m_variant.SetName(name);
53 m_variant = value;
54 m_readOnly = FALSE;
55 m_custom = FALSE;
56 m_show = TRUE;
57 }
58
59 void operator= (const ctProperty& property) { Copy(property); }
60 void Copy(const ctProperty& property)
61 {
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;
69 }
70
71 bool operator== (const ctProperty& property) const
72 {
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));
80 }
81
82 bool operator!= (const ctProperty& property) const
83 {
84 return !((*this) == property);
85 }
86
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; }
94
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; }
106
107 // The name and value
108 wxVariant m_variant;
109
110 // The editor type name (e.g. "file")
111 // used to choose an editor.
112 wxString m_editorType;
113
114 // Array of choices
115 wxArrayString m_choices;
116
117 // Description
118 wxString m_description;
119
120 // Whether to show or hide (e.g. not properly initialized)
121 bool m_show;
122
123 // Read-only
124 bool m_readOnly;
125
126 // Whether it's a custom property (so save
127 // type/description)
128 bool m_custom;
129 };
130
131 // A class to manage properties
132 class ctProperties: public wxObject
133 {
134 DECLARE_CLASS(ctProperties)
135 public:
136 ctProperties() {}
137 ctProperties(const ctProperties& properties) { Copy(properties); }
138 ~ctProperties() { Clear(); }
139
140 void operator = (const ctProperties& properties) { Clear(); Copy(properties); }
141 void Copy(const ctProperties& properties);
142
143 inline const wxList& GetList() const { return m_list; }
144
145 inline size_t GetCount() const { return m_list.GetCount(); }
146
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;
159
160 void Clear();
161
162 private:
163 wxList m_list;
164 };
165
166 #endif
167 // _CT_PROPERTY_H_
168