include/tts/tts_property.h

Go to the documentation of this file.
00001 
00002 // Name:        ttsproperty.h
00003 // Purpose:     Text to speech property classes
00004 // Author:      Julian Smart
00005 // Modified by:
00006 // Created:     2009-02-14
00007 // RCS-ID:      $Id$
00008 // Copyright:   (c) Julian Smart
00009 // Licence:     
00011 
00012 #ifndef _WX_TTSPROPERTY_H_
00013 #define _WX_TTSPROPERTY_H_
00014 
00015 #include "wx/variant.h"
00016 
00017 /* Use to give the subsequently-created properties a category name
00018  */
00019 
00020 class wxTTSPropertyCategory
00021 {
00022 public:
00023     wxTTSPropertyCategory(const wxString& name = wxEmptyString)
00024     {
00025         m_oldCategory = sm_category;
00026         sm_category = name;
00027     }
00028     ~wxTTSPropertyCategory()
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 
00053 class wxTTSProperty: public wxObject
00054 {
00055     DECLARE_CLASS(wxTTSProperty)
00056 public:
00057     wxTTSProperty()
00058     {
00059        m_show = TRUE;
00060         m_parentName = wxTTSPropertyCategory::sm_category;
00061     }
00062 
00063     wxTTSProperty(const wxTTSProperty& property) { Copy(property); }
00064     wxTTSProperty(const wxString& descr, const wxVariant& variant,
00065         const wxString& editorType = wxEmptyString,
00066         const wxString& groupName = wxEmptyString)
00067     {
00068         m_description = descr;
00069         m_variant = variant;
00070         m_editorType = editorType;
00071         m_groupName = groupName;
00072         m_show = TRUE;
00073         m_parentName = wxTTSPropertyCategory::sm_category;
00074     }
00075 
00076     wxTTSProperty(const wxString& name, const wxString& value = wxEmptyString)
00077     {
00078         m_variant.SetName(name);
00079         m_variant = value;
00080         m_show = TRUE;
00081     }
00082 
00083     void operator= (const wxTTSProperty& property) { Copy(property); }
00084     void Copy(const wxTTSProperty& property)
00085     {
00086         m_variant = property.m_variant;
00087         m_groupName = property.m_groupName;
00088         m_editorType = property.m_editorType;
00089         m_description = property.m_description;
00090         m_choices = property.m_choices;
00091         m_show = property.m_show;
00092         m_parentName = property.m_parentName;
00093         m_translatedName = property.m_translatedName;
00094     }
00095 
00096     bool operator== (const wxTTSProperty& property) const
00097     {
00098         return ((m_variant == property.m_variant) &&
00099             (m_groupName == property.m_groupName) &&
00100             (m_parentName == property.m_parentName) &&
00101             (m_editorType == property.m_editorType) &&
00102             (m_description == property.m_description) &&
00103             (m_show == property.m_show) &&
00104             (m_translatedName == property.m_translatedName) &&
00105             (m_choices == property.m_choices));
00106     }
00107 
00108     bool operator!= (const wxTTSProperty& property) const
00109     {
00110         return !((*this) == property);
00111     }
00112 
00113     inline const wxString& GetName() const { return m_variant.GetName(); }
00114     inline const wxString& GetParentName() const { return m_parentName; }
00115     inline wxString GetValue() const { return m_variant.GetString(); }
00116     inline wxVariant& GetVariant() { return m_variant; }
00117     inline const wxVariant& GetVariant() const { return m_variant; }
00118     inline const wxString& GetEditorType() const { return m_editorType; }
00119     inline const wxString& GetGroupName() const { return m_groupName; }
00120     inline const wxString GetCategory() const { return m_category; }
00121     inline const wxArrayString& GetChoices() const { return m_choices; }
00122     inline const wxString& GetDescription() const { return m_description; }
00123     
00124     inline void SetName(const wxString& name) { m_variant.SetName(name); }
00125     inline void SetParentName(const wxString& name) { m_parentName = name; }
00126     inline void SetValue(const wxString& value) { m_variant = value; }
00127     inline void SetValue(const wxVariant& value) { m_variant = value; }
00128     inline void SetEditorType(const wxString& type) { m_editorType = type; }
00129     inline void SetGroupName(const wxString& groupName) { m_groupName = groupName; }
00130     inline void SetCategory(const wxString& category) { m_category = category; }
00131     inline void SetChoices(const wxArrayString& choices) { m_choices = choices; }
00132     inline void SetDescription(const wxString& descr) { m_description = descr; }
00133     inline void Show(bool show) { m_show = show; }
00134     inline bool IsShown() const { return m_show; }
00135 
00136     // Get/set the visible translation, if any
00137     const wxString& GetTranslatedName() const { return m_translatedName; }
00138     void SetTranslatedName(const wxString& name) { m_translatedName = name; }
00139 
00140     // Get display name - translation if available, or actual
00141     wxString GetDisplayName() const { return m_translatedName.IsEmpty() ? GetName() : GetTranslatedName(); }
00142 
00143     // The name and value
00144     wxVariant   m_variant;
00145 
00146     // The visible translation, if any
00147     wxString    m_translatedName;
00148 
00149     // The editor type name (e.g. "file")
00150     // used to choose an editor.
00151     wxString    m_editorType;
00152 
00153     // The group name, e.g. window-style
00154     wxString    m_groupName;
00155 
00156     // The parent property name. Can be dot-separated if more than one.
00157     wxString    m_parentName;
00158 
00159     // Array of choices
00160     wxArrayString   m_choices;
00161 
00162     // Description
00163     wxString        m_description;
00164 
00165     // Category for this property
00166     wxString        m_category;
00167 
00168     // Whether to show or hide
00169     bool            m_show;
00170 };
00171 
00178 class wxTTSProperties: public wxObject
00179 {
00180     DECLARE_CLASS(wxTTSProperties)
00181 public:
00182     wxTTSProperties() {}
00183     wxTTSProperties(const wxTTSProperties& properties) { Copy(properties); }
00184     ~wxTTSProperties() { Clear(); }
00185 
00186     void operator = (const wxTTSProperties& properties) { Clear(); Copy(properties); }
00187     bool operator == (const wxTTSProperties& properties) ;
00188     void Copy(const wxTTSProperties& properties);
00189 
00190     inline const wxList& GetList() const { return m_list; }
00191 
00192     inline size_t GetCount() const { return m_list.GetCount(); }
00193 
00194     wxTTSProperty* AddProperty(wxTTSProperty* property, const wxString& insertAfter = wxEmptyString);
00195     void SetProperty(const wxTTSProperty& prop);
00196     void SetProperty(const wxString& name, const wxString& value);
00197     void SetProperty(const wxString& name, long value);
00198     void SetProperty(const wxString& name, int value) { SetProperty(name, (long) value); }
00199     void SetProperty(const wxString& name, double value);
00200     void SetProperty(const wxString& name, bool value);
00201     void SetProperty(const wxString& name, const wxVariant& value);
00202     void RemoveProperty(wxTTSProperty* property);
00203     void DeleteProperty(wxTTSProperty* property);
00204     void DeleteProperty(const wxString& name);
00205     void DeleteProperty(size_t i);
00206     wxTTSProperty* FindProperty(const wxString& name) const;
00207     wxTTSProperty* FindPropertyByDisplayName(const wxString& name);
00208     wxTTSProperty* FindOrCreateProperty(const wxString& name);
00209     wxString FindPropertyValueString(const wxString& name) const;
00210     bool FindPropertyValueBool(const wxString& name) const;
00211     long FindPropertyValueLong(const wxString& name) const;
00212     double FindPropertyValueDouble(const wxString& name) const;
00213     wxVariant FindPropertyValue(const wxString& name) const;
00214     wxTTSProperty* GetNth(int i) const;
00215     wxTTSProperty* GetProperty(int i) const { return GetNth(i); }
00216     
00217     void Clear();
00218 
00219 private:
00220     wxList      m_list;
00221 };
00222 
00223 #endif
00224     // _WX_TTSPROPERTY_H_
00225 

Generated on Wed May 6 19:20:19 2009 for AxTk by  doxygen 1.5.1