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 #include <goffice/app/go-conf.h>
00034 #else
00035 #include <gconf/gconf-client.h>
00036 #endif
00037 #include <libxml/tree.h>
00038 #include <list>
00039 #include <map>
00040 #include <string>
00041 #include <set>
00042
00045 namespace gcp {
00046
00050 typedef enum {
00054 DEFAULT_THEME_TYPE,
00058 LOCAL_THEME_TYPE,
00062 GLOBAL_THEME_TYPE,
00066 FILE_THEME_TYPE
00067 } ThemeType;
00068
00074 class Theme
00075 {
00076 friend class ThemeManager;
00077 friend class PrefsDlg;
00078
00079 public:
00085 Theme (char const *name);
00089 ~Theme ();
00090
00094 std::string &GetName () {return m_Name;}
00101 bool Save (xmlDocPtr xml);
00107 bool Load (xmlNodePtr node);
00113 bool operator== (const Theme &theme);
00119 void AddClient (gcu::Object *client) {m_Clients.insert (client);}
00125 void RemoveClient (gcu::Object *client);
00129 void NotifyChanged ();
00130
00131 private:
00132 std::string m_Name;
00133 std::set <gcu::Object*> m_Clients;
00134 bool modified;
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 ();
00308 #ifdef HAVE_GO_CONF_SYNC
00309
00316 void OnConfigChanged (GOConfNode *node, gchar const *name);
00317 #else
00318
00326 void OnConfigChanged (GConfClient *client, guint cnxn_id, GConfEntry *entry);
00327 #endif
00328
00333 Theme *CreateNewTheme (Theme *theme = NULL);
00343 void AddFileTheme (Theme *theme, char const *label);
00350 void RemoveFileTheme (Theme *theme);
00357 void ChangeThemeName (Theme *theme, char const *name);
00361 Theme *GetDefaultTheme () {return m_DefaultTheme;}
00368 void SetDefaultTheme (char const *name);
00373 void Shutdown ();
00374
00375 private:
00376 void ParseDir (std::string &path, ThemeType type);
00377
00378 private:
00379 std::map <std::string, Theme*> m_Themes;
00380 std::list <std::string> m_Names;
00381 #ifdef HAVE_GO_CONF_SYNC
00382 GOConfNode *m_ConfNode;
00383 #else
00384 GConfClient *m_ConfClient;
00385 #endif
00386 guint m_NotificationId;
00387 Theme *m_DefaultTheme;
00388 };
00389
00393 extern ThemeManager TheThemeManager;
00394
00395 }
00396
00397 #endif // GCHEMPAINT_THEME_H