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