00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _AX_PROPERTY_H_
00013 #define _AX_PROPERTY_H_
00014
00015 #include "wx/variant.h"
00016
00017
00018
00019
00020 class AxPropertyCategory
00021 {
00022 public:
00023 AxPropertyCategory(const wxString& name = wxEmptyString)
00024 {
00025 m_oldCategory = sm_category;
00026 sm_category = name;
00027 }
00028 ~AxPropertyCategory()
00029 {
00030 sm_category = m_oldCategory;
00031 }
00032
00033 static void BeginCategory(const wxString& name)
00034 {
00035 sm_category = name;
00036 }
00037
00038 static void EndCategory()
00039 {
00040 sm_category = wxEmptyString;
00041 }
00042
00043 static wxString sm_category;
00044 wxString m_oldCategory;
00045 };
00046
00055 class AxProperty: public wxObject
00056 {
00057 DECLARE_CLASS(AxProperty)
00058 public:
00059 AxProperty()
00060 {
00061 m_show = TRUE;
00062 m_parentName = AxPropertyCategory::sm_category;
00063 }
00064
00065 AxProperty(const AxProperty& property) { Copy(property); }
00066 AxProperty(const wxString& descr, const wxVariant& variant,
00067 const wxString& editorType = wxEmptyString,
00068 const wxString& groupName = wxEmptyString)
00069 {
00070 m_description = descr;
00071 m_variant = variant;
00072 m_editorType = editorType;
00073 m_groupName = groupName;
00074 m_show = TRUE;
00075 m_parentName = AxPropertyCategory::sm_category;
00076 }
00077
00078 AxProperty(const wxString& name, const wxString& value = wxEmptyString)
00079 {
00080 m_variant.SetName(name);
00081 m_variant = value;
00082 m_show = TRUE;
00083 }
00084
00085 void operator= (const AxProperty& property) { Copy(property); }
00086 void Copy(const AxProperty& property)
00087 {
00088 m_variant = property.m_variant;
00089 m_groupName = property.m_groupName;
00090 m_editorType = property.m_editorType;
00091 m_description = property.m_description;
00092 m_choices = property.m_choices;
00093 m_show = property.m_show;
00094 m_parentName = property.m_parentName;
00095 m_translatedName = property.m_translatedName;
00096 }
00097
00098 bool operator== (const AxProperty& property) const
00099 {
00100 return ((m_variant == property.m_variant) &&
00101 (m_groupName == property.m_groupName) &&
00102 (m_parentName == property.m_parentName) &&
00103 (m_editorType == property.m_editorType) &&
00104 (m_description == property.m_description) &&
00105 (m_show == property.m_show) &&
00106 (m_translatedName == property.m_translatedName) &&
00107 (m_choices == property.m_choices));
00108 }
00109
00110 bool operator!= (const AxProperty& property) const
00111 {
00112 return !((*this) == property);
00113 }
00114
00115 inline const wxString& GetName() const { return m_variant.GetName(); }
00116 inline const wxString& GetParentName() const { return m_parentName; }
00117 inline wxString GetValue() const { return m_variant.GetString(); }
00118 inline wxVariant& GetVariant() { return m_variant; }
00119 inline const wxVariant& GetVariant() const { return m_variant; }
00120 inline const wxString& GetEditorType() const { return m_editorType; }
00121 inline const wxString& GetGroupName() const { return m_groupName; }
00122 inline const wxString GetCategory() const { return m_category; }
00123 inline const wxArrayString& GetChoices() const { return m_choices; }
00124 inline const wxString& GetDescription() const { return m_description; }
00125
00126 inline void SetName(const wxString& name) { m_variant.SetName(name); }
00127 inline void SetParentName(const wxString& name) { m_parentName = name; }
00128 inline void SetValue(const wxString& value) { m_variant = value; }
00129 inline void SetValue(const wxVariant& value) { m_variant = value; }
00130 inline void SetEditorType(const wxString& type) { m_editorType = type; }
00131 inline void SetGroupName(const wxString& groupName) { m_groupName = groupName; }
00132 inline void SetCategory(const wxString& category) { m_category = category; }
00133 inline void SetChoices(const wxArrayString& choices) { m_choices = choices; }
00134 inline void SetDescription(const wxString& descr) { m_description = descr; }
00135 inline void Show(bool show) { m_show = show; }
00136 inline bool IsShown() const { return m_show; }
00137
00138
00139 const wxString& GetTranslatedName() const { return m_translatedName; }
00140 void SetTranslatedName(const wxString& name) { m_translatedName = name; }
00141
00142
00143 wxString GetDisplayName() const { return m_translatedName.IsEmpty() ? GetName() : GetTranslatedName(); }
00144
00145
00146 wxVariant m_variant;
00147
00148
00149 wxString m_translatedName;
00150
00151
00152
00153 wxString m_editorType;
00154
00155
00156 wxString m_groupName;
00157
00158
00159 wxString m_parentName;
00160
00161
00162 wxArrayString m_choices;
00163
00164
00165 wxString m_description;
00166
00167
00168 wxString m_category;
00169
00170
00171 bool m_show;
00172 };
00173
00174
00175 class AxProperties: public wxObject
00176 {
00177 DECLARE_CLASS(AxProperties)
00178 public:
00179 AxProperties() {}
00180 AxProperties(const AxProperties& properties) { Copy(properties); }
00181 ~AxProperties() { Clear(); }
00182
00183 void operator = (const AxProperties& properties) { Clear(); Copy(properties); }
00184 bool operator == (const AxProperties& properties) ;
00185 void Copy(const AxProperties& properties);
00186
00187 inline const wxList& GetList() const { return m_list; }
00188
00189 inline size_t GetCount() const { return m_list.GetCount(); }
00190
00191 AxProperty* AddProperty(AxProperty* property, const wxString& insertAfter = wxEmptyString);
00192 void SetProperty(const AxProperty& prop);
00193 void SetProperty(const wxString& name, const wxString& value);
00194 void SetProperty(const wxString& name, long value);
00195 void SetProperty(const wxString& name, int value) { SetProperty(name, (long) value); }
00196 void SetProperty(const wxString& name, double value);
00197 void SetProperty(const wxString& name, bool value);
00198 void SetProperty(const wxString& name, const wxVariant& value);
00199 void RemoveProperty(AxProperty* property);
00200 void DeleteProperty(AxProperty* property);
00201 void DeleteProperty(const wxString& name);
00202 void DeleteProperty(size_t i);
00203 AxProperty* FindProperty(const wxString& name) const;
00204 AxProperty* FindPropertyByDisplayName(const wxString& name);
00205 AxProperty* FindOrCreateProperty(const wxString& name);
00206 wxString FindPropertyValueString(const wxString& name) const;
00207 bool FindPropertyValueBool(const wxString& name) const;
00208 long FindPropertyValueLong(const wxString& name) const;
00209 double FindPropertyValueDouble(const wxString& name) const;
00210 wxVariant FindPropertyValue(const wxString& name) const;
00211 AxProperty* GetNth(int i) const;
00212 AxProperty* GetProperty(int i) const { return GetNth(i); }
00213
00214 void Clear();
00215
00216 private:
00217 wxList m_list;
00218 };
00219
00220 #endif
00221
00222