theme.h
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 <glib/gtypes.h>
00031 #include <pango/pango.h>
00032 #ifdef HAVE_GO_CONF_SYNC
00033 # ifdef GOFFICE_HAS_GLOBAL_HEADER
00034 # include <goffice/goffice.h>
00035 # else
00036 # include <goffice/app/go-conf.h>
00037 # endif
00038 #else
00039 # include <gconf/gconf-client.h>
00040 #endif
00041 #include <libxml/tree.h>
00042 #include <list>
00043 #include <map>
00044 #include <string>
00045 #include <set>
00046
00049 namespace gcp {
00050
00054 typedef enum {
00058 DEFAULT_THEME_TYPE,
00062 LOCAL_THEME_TYPE,
00066 GLOBAL_THEME_TYPE,
00070 FILE_THEME_TYPE
00071 } ThemeType;
00072
00078 class Theme
00079 {
00080 friend class ThemeManager;
00081 friend class PrefsDlg;
00082
00083 public:
00089 Theme (char const *name);
00093 ~Theme ();
00094
00098 std::string &GetName () {return m_Name;}
00105 bool Save (xmlDocPtr xml);
00111 bool Load (xmlNodePtr node);
00117 bool operator== (const Theme &theme);
00123 void AddClient (gcu::Object *client) {m_Clients.insert (client);}
00129 void RemoveClient (gcu::Object *client);
00133 void NotifyChanged ();
00134
00135 private:
00136 std::string m_Name;
00137 std::set <gcu::Object*> m_Clients;
00138 bool modified;
00139
00143 GCU_RO_PROP (double, BondLength)
00147 GCU_RO_PROP (double, BondAngle)
00151 GCU_RO_PROP (double, BondDist)
00155 GCU_RO_PROP (double, BondWidth)
00159 GCU_RO_PROP (double, ArrowLength)
00163 GCU_RO_PROP (double, HashWidth)
00167 GCU_RO_PROP (double, HashDist)
00171 GCU_RO_PROP (double, StereoBondWidth)
00175 GCU_RO_PROP (double, ZoomFactor)
00179 GCU_RO_PROP (double, Padding)
00183 GCU_RO_PROP (double, ArrowHeadA)
00187 GCU_RO_PROP (double, ArrowHeadB)
00191 GCU_RO_PROP (double, ArrowHeadC)
00195 GCU_RO_PROP (double, ArrowDist)
00199 GCU_RO_PROP (double, ArrowWidth)
00203 GCU_RO_PROP (double, ArrowPadding)
00207 GCU_RO_PROP (double, ArrowObjectPadding)
00211 GCU_RO_PROP (double, StoichiometryPadding)
00215 GCU_RO_PROP (double, ObjectPadding)
00219 GCU_RO_PROP (double, SignPadding)
00223 GCU_RO_PROP (double, ChargeSignSize)
00227 GCU_RO_PROP (gchar*, FontFamily)
00231 GCU_RO_PROP (PangoStyle, FontStyle)
00235 GCU_RO_PROP (PangoWeight, FontWeight)
00239 GCU_RO_PROP (PangoVariant, FontVariant)
00243 GCU_RO_PROP (PangoStretch, FontStretch)
00247 GCU_RO_PROP (gint, FontSize)
00251 GCU_RO_PROP (gchar*, TextFontFamily)
00255 GCU_RO_PROP (PangoStyle, TextFontStyle)
00259 GCU_RO_PROP (PangoWeight, TextFontWeight)
00263 GCU_RO_PROP (PangoVariant, TextFontVariant)
00267 GCU_RO_PROP (PangoStretch, TextFontStretch)
00271 GCU_RO_PROP (gint, TextFontSize)
00275 GCU_RO_PROP (ThemeType, ThemeType);
00276 };
00277
00284 class ThemeManager
00285 {
00286 public:
00290 ThemeManager ();
00294 ~ThemeManager ();
00295
00301 Theme *GetTheme (char const *name);
00307 Theme *GetTheme (std::string &name);
00311 std::list <std::string> const &GetThemesNames ();
00312 #ifdef HAVE_GO_CONF_SYNC
00313
00320 void OnConfigChanged (GOConfNode *node, gchar const *name);
00321 #else
00322
00330 void OnConfigChanged (GConfClient *client, guint cnxn_id, GConfEntry *entry);
00331 #endif
00332
00337 Theme *CreateNewTheme (Theme *theme = NULL);
00347 void AddFileTheme (Theme *theme, char const *label);
00354 void RemoveFileTheme (Theme *theme);
00361 void ChangeThemeName (Theme *theme, char const *name);
00365 Theme *GetDefaultTheme () {return m_DefaultTheme;}
00372 void SetDefaultTheme (char const *name);
00377 void Shutdown ();
00378
00379 private:
00380 void ParseDir (std::string &path, ThemeType type);
00381
00382 private:
00383 std::map <std::string, Theme*> m_Themes;
00384 std::list <std::string> m_Names;
00385 #ifdef HAVE_GO_CONF_SYNC
00386 GOConfNode *m_ConfNode;
00387 #else
00388 GConfClient *m_ConfClient;
00389 #endif
00390 guint m_NotificationId;
00391 Theme *m_DefaultTheme;
00392 };
00393
00397 extern ThemeManager TheThemeManager;
00398
00399 }
00400
00401 #endif // GCHEMPAINT_THEME_H