theme.h

Go to the documentation of this file.
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 <goffice/app/go-conf.h>
00033 #include <libxml/tree.h>
00034 #include <list>
00035 #include <map>
00036 #include <string>
00037 #include <set>
00038 
00041 namespace gcp {
00042 
00046 typedef enum {
00050         DEFAULT_THEME_TYPE,
00054         LOCAL_THEME_TYPE,
00058         GLOBAL_THEME_TYPE,
00062         FILE_THEME_TYPE
00063 } ThemeType;
00064 
00070 class Theme
00071 {
00072 friend class ThemeManager;
00073 friend class PrefsDlg;
00074 
00075 public:
00081         Theme (char const *name);
00085         ~Theme ();
00086 
00090         std::string &GetName () {return m_Name;}
00097         bool Save (xmlDocPtr xml);
00103         bool Load (xmlNodePtr node);
00109         bool operator== (const Theme &theme);
00115         void AddClient (gcu::Object *client) {m_Clients.insert (client);}
00121         void RemoveClient (gcu::Object *client);
00125         void NotifyChanged ();
00126 
00127 private:
00128         std::string m_Name;
00129         std::set <gcu::Object*> m_Clients;
00130         bool modified;
00131 
00135 GCU_RO_PROP (double, BondLength)
00139 GCU_RO_PROP (double, BondAngle)
00143 GCU_RO_PROP (double, BondDist)
00147 GCU_RO_PROP (double, BondWidth)
00151 GCU_RO_PROP (double, ArrowLength)
00155 GCU_RO_PROP (double, HashWidth)
00159 GCU_RO_PROP (double, HashDist)
00163 GCU_RO_PROP (double, StereoBondWidth)
00167 GCU_RO_PROP (double, ZoomFactor)
00171 GCU_RO_PROP (double, Padding)
00175 GCU_RO_PROP (double, ArrowHeadA)
00179 GCU_RO_PROP (double, ArrowHeadB)
00183 GCU_RO_PROP (double, ArrowHeadC)
00187 GCU_RO_PROP (double, ArrowDist)
00191 GCU_RO_PROP (double, ArrowWidth)
00195 GCU_RO_PROP (double, ArrowPadding)
00199 GCU_RO_PROP (double, ArrowObjectPadding)
00203 GCU_RO_PROP (double, StoichiometryPadding)
00207 GCU_RO_PROP (double, ObjectPadding)
00211 GCU_RO_PROP (double, SignPadding)
00215 GCU_RO_PROP (double, ChargeSignSize)
00219 GCU_RO_PROP (gchar*, FontFamily)
00223 GCU_RO_PROP (PangoStyle, FontStyle)
00227 GCU_RO_PROP (PangoWeight, FontWeight)
00231 GCU_RO_PROP (PangoVariant, FontVariant)
00235 GCU_RO_PROP (PangoStretch, FontStretch)
00239 GCU_RO_PROP (gint, FontSize)
00243 GCU_RO_PROP (gchar*, TextFontFamily)
00247 GCU_RO_PROP (PangoStyle, TextFontStyle)
00251 GCU_RO_PROP (PangoWeight, TextFontWeight)
00255 GCU_RO_PROP (PangoVariant, TextFontVariant)
00259 GCU_RO_PROP (PangoStretch, TextFontStretch)
00263 GCU_RO_PROP (gint, TextFontSize)
00267 GCU_RO_PROP (ThemeType, ThemeType);
00268 };
00269 
00276 class ThemeManager
00277 {
00278 public:
00282         ThemeManager ();
00286         ~ThemeManager ();
00287 
00293         Theme *GetTheme (char const *name);
00299         Theme *GetTheme (std::string &name);
00303         std::list <std::string> const &GetThemesNames ();
00311         void OnConfigChanged (GOConfNode *node, gchar const *name);
00317         Theme *CreateNewTheme (Theme *theme = NULL);
00327         void AddFileTheme (Theme *theme, char const *label);
00334         void RemoveFileTheme (Theme *theme);
00341         void ChangeThemeName (Theme *theme, char const *name);
00345         Theme *GetDefaultTheme () {return m_DefaultTheme;}
00352         void SetDefaultTheme (char const *name);
00357         void Shutdown ();
00358 
00359 private:
00360         void ParseDir (std::string &path, ThemeType type);
00361 
00362 private:
00363         std::map <std::string, Theme*> m_Themes;
00364         std::list <std::string> m_Names;
00365         GOConfNode *m_ConfNode;
00366         guint m_NotificationId;
00367         Theme *m_DefaultTheme;
00368 };
00369 
00373 extern ThemeManager TheThemeManager;
00374 
00375 }       //      namespace gcp
00376 
00377 #endif  //      GCHEMPAINT_THEME_H

Generated on Wed Mar 25 12:27:20 2009 for The Gnome Chemistry Utils by  doxygen 1.5.8