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 #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 }       //      namespace gcp
00137 
00138 #endif  //      GCHEMPAINT_THEME_H

Generated on Sun Sep 16 14:21:55 2007 for The Gnome Chemistry Utils by  doxygen 1.5.3