Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef GCHEMPAINT_THEME_H
00026 #define GCHEMPAINT_THEME_H
00027
00028 #include <gcu/macros.h>
00029 #include <gcu/object.h>
00030 #include <libxml/tree.h>
00031 #include <list>
00032 #include <map>
00033 #include <string>
00034 #include <set>
00035
00038 namespace gcp {
00039
00043 typedef enum {
00047 DEFAULT_THEME_TYPE,
00051 LOCAL_THEME_TYPE,
00055 GLOBAL_THEME_TYPE,
00059 FILE_THEME_TYPE
00060 } ThemeType;
00061
00067 class Theme
00068 {
00069 friend class ThemeManager;
00070 friend class PrefsDlg;
00071
00072 public:
00078 Theme (char const *name);
00082 ~Theme ();
00083
00087 std::string &GetName () {return m_Name;}
00088
00092 std::string &GetFileName () {return (m_FileName.length ())? m_FileName: m_Name;}
00093
00100 bool Save (xmlDocPtr xml);
00106 bool Load (xmlNodePtr node);
00112 bool operator== (const Theme &theme);
00118 void AddClient (gcu::Object *client) {m_Clients.insert (client);}
00124 void RemoveClient (gcu::Object *client);
00128 void NotifyChanged ();
00129
00130 private:
00131 std::string m_Name, m_FileName;
00132 std::set <gcu::Object*> m_Clients;
00133 bool modified;
00134 bool locked;
00135
00139 GCU_RO_PROP (double, BondLength)
00143 GCU_RO_PROP (double, BondAngle)
00147 GCU_RO_PROP (double, BondDist)
00151 GCU_RO_PROP (double, BondWidth)
00155 GCU_RO_PROP (double, ArrowLength)
00159 GCU_RO_PROP (double, HashWidth)
00163 GCU_RO_PROP (double, HashDist)
00167 GCU_RO_PROP (double, StereoBondWidth)
00171 GCU_RO_PROP (double, ZoomFactor)
00175 GCU_RO_PROP (double, Padding)
00179 GCU_RO_PROP (double, ArrowHeadA)
00183 GCU_RO_PROP (double, ArrowHeadB)
00187 GCU_RO_PROP (double, ArrowHeadC)
00191 GCU_RO_PROP (double, ArrowDist)
00195 GCU_RO_PROP (double, ArrowWidth)
00199 GCU_RO_PROP (double, ArrowPadding)
00203 GCU_RO_PROP (double, ArrowObjectPadding)
00207 GCU_RO_PROP (double, StoichiometryPadding)
00211 GCU_RO_PROP (double, ObjectPadding)
00215 GCU_RO_PROP (double, SignPadding)
00219 GCU_RO_PROP (double, ChargeSignSize)
00223 GCU_RO_PROP (gchar*, FontFamily)
00227 GCU_RO_PROP (PangoStyle, FontStyle)
00231 GCU_RO_PROP (PangoWeight, FontWeight)
00235 GCU_RO_PROP (PangoVariant, FontVariant)
00239 GCU_RO_PROP (PangoStretch, FontStretch)
00243 GCU_RO_PROP (gint, FontSize)
00247 GCU_RO_PROP (gchar*, TextFontFamily)
00251 GCU_RO_PROP (PangoStyle, TextFontStyle)
00255 GCU_RO_PROP (PangoWeight, TextFontWeight)
00259 GCU_RO_PROP (PangoVariant, TextFontVariant)
00263 GCU_RO_PROP (PangoStretch, TextFontStretch)
00267 GCU_RO_PROP (gint, TextFontSize)
00271 GCU_RO_PROP (ThemeType, ThemeType);
00272 };
00273
00280 class ThemeManager
00281 {
00282 public:
00286 ThemeManager ();
00290 ~ThemeManager ();
00291
00297 Theme *GetTheme (char const *name);
00303 Theme *GetTheme (std::string &name);
00307 std::list <std::string> const &GetThemesNames ();
00315 void OnConfigChanged (GOConfNode *node, gchar const *name);
00321 Theme *CreateNewTheme (Theme *theme = NULL);
00331 void AddFileTheme (Theme *theme, char const *label);
00338 void RemoveFileTheme (Theme *theme);
00345 void ChangeThemeName (Theme *theme, char const *name);
00349 Theme *GetDefaultTheme () {return m_DefaultTheme;}
00356 void SetDefaultTheme (char const *name);
00361 void Shutdown ();
00362
00363 private:
00364 void ParseDir (std::string &path, ThemeType type);
00365
00366 private:
00367 std::map <std::string, Theme*> m_Themes;
00368 std::list <std::string> m_Names;
00369 GOConfNode *m_ConfNode;
00370 guint m_NotificationId;
00371 Theme *m_DefaultTheme;
00372 };
00373
00377 extern ThemeManager TheThemeManager;
00378
00379 }
00380
00381 #endif // GCHEMPAINT_THEME_H