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 <glib/gtypes.h>
00031 #include <pango/pango.h>
00032 #include <gconf/gconf-client.h>
00033 #include <libxml/tree.h>
00034 #include <list>
00035 #include <map>
00036 #include <string>
00037 #include <set>
00038
00039 namespace gcp {
00040
00041 typedef enum {
00042 DEFAULT_THEME_TYPE,
00043 LOCAL_THEME_TYPE,
00044 GLOBAL_THEME_TYPE,
00045 FILE_THEME_TYPE
00046 } ThemeType;
00047
00048 class Theme
00049 {
00050 friend class ThemeManager;
00051 friend class PrefsDlg;
00052
00053 public:
00054 Theme (char const *name);
00055 ~Theme ();
00056
00057 std::string &GetName () {return m_Name;}
00058 bool Save (xmlDocPtr);
00059 bool Load (xmlNodePtr);
00060 bool operator== (const Theme &theme);
00061 void AddClient (gcu::Object *client) {m_Clients.insert (client);}
00062 void RemoveClient (gcu::Object *client);
00063 void NotifyChanged ();
00064
00065 private:
00066 std::string m_Name;
00067 std::set <gcu::Object*> m_Clients;
00068 bool modified;
00069
00070 GCU_RO_PROP (double, BondLength)
00071 GCU_RO_PROP (double, BondAngle)
00072 GCU_RO_PROP (double, BondDist)
00073 GCU_RO_PROP (double, BondWidth)
00074 GCU_RO_PROP (double, ArrowLength)
00075 GCU_RO_PROP (double, HashWidth)
00076 GCU_RO_PROP (double, HashDist)
00077 GCU_RO_PROP (double, StereoBondWidth)
00078 GCU_RO_PROP (double, ZoomFactor)
00079 GCU_RO_PROP (double, Padding)
00080 GCU_RO_PROP (double, ArrowHeadA)
00081 GCU_RO_PROP (double, ArrowHeadB)
00082 GCU_RO_PROP (double, ArrowHeadC)
00083 GCU_RO_PROP (double, ArrowDist)
00084 GCU_RO_PROP (double, ArrowWidth)
00085 GCU_RO_PROP (double, ArrowPadding)
00086 GCU_RO_PROP (double, ArrowObjectPadding)
00087 GCU_RO_PROP (double, StoichiometryPadding)
00088 GCU_RO_PROP (double, ObjectPadding)
00089 GCU_RO_PROP (double, SignPadding)
00090 GCU_RO_PROP (double, ChargeSignSize)
00091 GCU_RO_PROP (gchar*, FontFamily)
00092 GCU_RO_PROP (PangoStyle, FontStyle)
00093 GCU_RO_PROP (PangoWeight, FontWeight)
00094 GCU_RO_PROP (PangoVariant, FontVariant)
00095 GCU_RO_PROP (PangoStretch, FontStretch)
00096 GCU_RO_PROP (gint, FontSize)
00097 GCU_RO_PROP (gchar*, TextFontFamily)
00098 GCU_RO_PROP (PangoStyle, TextFontStyle)
00099 GCU_RO_PROP (PangoWeight, TextFontWeight)
00100 GCU_RO_PROP (PangoVariant, TextFontVariant)
00101 GCU_RO_PROP (PangoStretch, TextFontStretch)
00102 GCU_RO_PROP (gint, TextFontSize)
00103 GCU_RO_PROP (ThemeType, ThemeType);
00104 };
00105
00106 class ThemeManager
00107 {
00108 public:
00109 ThemeManager ();
00110 ~ThemeManager ();
00111
00112 Theme *GetTheme (char const *name);
00113 Theme *GetTheme (std::string &name);
00114 std::list <std::string> const &GetThemesNames ();
00115 void OnConfigChanged (GConfClient *client, guint cnxn_id, GConfEntry *entry);
00116 Theme *CreateNewTheme (Theme *theme = NULL);
00117 void AddFileTheme (Theme *theme, char const *label);
00118 void RemoveFileTheme (Theme *theme);
00119 void ChangeThemeName (Theme *theme, char const *name);
00120 Theme *GetDefaultTheme () {return m_DefaultTheme;}
00121 void SetDefaultTheme (char const *name);
00122
00123 private:
00124 void ParseDir (std::string &path, ThemeType type);
00125
00126 private:
00127 std::map <std::string, Theme*> m_Themes;
00128 std::list <std::string> m_Names;
00129 GConfClient *m_ConfClient;
00130 guint m_NotificationId;
00131 Theme *m_DefaultTheme;
00132 };
00133
00134 extern ThemeManager TheThemeManager;
00135
00136 }
00137
00138 #endif // GCHEMPAINT_THEME_H