theme.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * theme.h
00006  *
00007  * Copyright (C) 2002-2007 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
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 
00043 namespace gcp {
00044 
00045 typedef enum {
00046         DEFAULT_THEME_TYPE,
00047         LOCAL_THEME_TYPE,
00048         GLOBAL_THEME_TYPE,
00049         FILE_THEME_TYPE
00050 } ThemeType;
00051 
00052 class Theme
00053 {
00054 friend class ThemeManager;
00055 friend class PrefsDlg;
00056 
00057 public:
00058         Theme (char const *name);
00059         ~Theme ();
00060 
00061         std::string &GetName () {return m_Name;}
00062         bool Save (xmlDocPtr);
00063         bool Load (xmlNodePtr);
00064         bool operator== (const Theme &theme);
00065         void AddClient (gcu::Object *client) {m_Clients.insert (client);}
00066         void RemoveClient (gcu::Object *client);
00067         void NotifyChanged ();
00068 
00069 private:
00070         std::string m_Name;
00071         std::set <gcu::Object*> m_Clients;
00072         bool modified;
00073 
00074 GCU_RO_PROP (double, BondLength)
00075 GCU_RO_PROP (double, BondAngle)
00076 GCU_RO_PROP (double, BondDist)
00077 GCU_RO_PROP (double, BondWidth)
00078 GCU_RO_PROP (double, ArrowLength)
00079 GCU_RO_PROP (double, HashWidth)
00080 GCU_RO_PROP (double, HashDist)
00081 GCU_RO_PROP (double, StereoBondWidth)
00082 GCU_RO_PROP (double, ZoomFactor)
00083 GCU_RO_PROP (double, Padding)
00084 GCU_RO_PROP (double, ArrowHeadA)
00085 GCU_RO_PROP (double, ArrowHeadB)
00086 GCU_RO_PROP (double, ArrowHeadC)
00087 GCU_RO_PROP (double, ArrowDist)
00088 GCU_RO_PROP (double, ArrowWidth)
00089 GCU_RO_PROP (double, ArrowPadding)
00090 GCU_RO_PROP (double, ArrowObjectPadding)
00091 GCU_RO_PROP (double, StoichiometryPadding)
00092 GCU_RO_PROP (double, ObjectPadding)
00093 GCU_RO_PROP (double, SignPadding)
00094 GCU_RO_PROP (double, ChargeSignSize)
00095 GCU_RO_PROP (gchar*, FontFamily)
00096 GCU_RO_PROP (PangoStyle, FontStyle)
00097 GCU_RO_PROP (PangoWeight, FontWeight)
00098 GCU_RO_PROP (PangoVariant, FontVariant)
00099 GCU_RO_PROP (PangoStretch, FontStretch)
00100 GCU_RO_PROP (gint, FontSize)
00101 GCU_RO_PROP (gchar*, TextFontFamily)
00102 GCU_RO_PROP (PangoStyle, TextFontStyle)
00103 GCU_RO_PROP (PangoWeight, TextFontWeight)
00104 GCU_RO_PROP (PangoVariant, TextFontVariant)
00105 GCU_RO_PROP (PangoStretch, TextFontStretch)
00106 GCU_RO_PROP (gint, TextFontSize)
00107 GCU_RO_PROP (ThemeType, ThemeType);
00108 };
00109 
00110 class ThemeManager
00111 {
00112 public:
00113         ThemeManager ();
00114         ~ThemeManager ();
00115 
00116         Theme *GetTheme (char const *name);
00117         Theme *GetTheme (std::string &name);
00118         std::list <std::string> const &GetThemesNames ();
00119 #ifdef HAVE_GO_CONF_SYNC
00120         void OnConfigChanged (GOConfNode *node, gchar const *name);
00121 #else
00122         void OnConfigChanged (GConfClient *client,  guint cnxn_id, GConfEntry *entry);
00123 #endif
00124         Theme *CreateNewTheme (Theme *theme = NULL);
00125         void AddFileTheme (Theme *theme, char const *label);
00126         void RemoveFileTheme (Theme *theme);
00127         void ChangeThemeName (Theme *theme, char const *name);
00128         Theme *GetDefaultTheme () {return m_DefaultTheme;}
00129         void SetDefaultTheme (char const *name);
00130         void Shutdown ();
00131 
00132 private:
00133         void ParseDir (std::string &path, ThemeType type);
00134 
00135 private:
00136         std::map <std::string, Theme*> m_Themes;
00137         std::list <std::string> m_Names;
00138 #ifdef HAVE_GO_CONF_SYNC
00139         GOConfNode *m_ConfNode;
00140 #else
00141         GConfClient *m_ConfClient;
00142 #endif
00143         guint m_NotificationId;
00144         Theme *m_DefaultTheme;
00145 };
00146 
00147 extern ThemeManager TheThemeManager;
00148 
00149 }       //      namespace gcp
00150 
00151 #endif  //      GCHEMPAINT_THEME_H

Generated on Sat Sep 13 18:32:53 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6