theme.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * theme.h
00006  *
00007  * Copyright (C) 2002-2009 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 <libxml/tree.h>
00031 #include <list>
00032 #include <map>
00033 #include <string>
00034 #include <set>
00035 
00038 namespace gcp {
00039 
00043 typedef enum {
00047         DEFAULT_THEME_TYPE,
00051         LOCAL_THEME_TYPE,
00055         GLOBAL_THEME_TYPE,
00059         FILE_THEME_TYPE
00060 } ThemeType;
00061 
00067 class Theme
00068 {
00069 friend class ThemeManager;
00070 friend class PrefsDlg;
00071 
00072 public:
00078         Theme (char const *name);
00082         ~Theme ();
00083 
00087         std::string &GetName () {return m_Name;}
00094         bool Save (xmlDocPtr xml);
00100         bool Load (xmlNodePtr node);
00106         bool operator== (const Theme &theme);
00112         void AddClient (gcu::Object *client) {m_Clients.insert (client);}
00118         void RemoveClient (gcu::Object *client);
00122         void NotifyChanged ();
00123 
00124 private:
00125         std::string m_Name;
00126         std::set <gcu::Object*> m_Clients;
00127         bool modified;
00128 
00132 GCU_RO_PROP (double, BondLength)
00136 GCU_RO_PROP (double, BondAngle)
00140 GCU_RO_PROP (double, BondDist)
00144 GCU_RO_PROP (double, BondWidth)
00148 GCU_RO_PROP (double, ArrowLength)
00152 GCU_RO_PROP (double, HashWidth)
00156 GCU_RO_PROP (double, HashDist)
00160 GCU_RO_PROP (double, StereoBondWidth)
00164 GCU_RO_PROP (double, ZoomFactor)
00168 GCU_RO_PROP (double, Padding)
00172 GCU_RO_PROP (double, ArrowHeadA)
00176 GCU_RO_PROP (double, ArrowHeadB)
00180 GCU_RO_PROP (double, ArrowHeadC)
00184 GCU_RO_PROP (double, ArrowDist)
00188 GCU_RO_PROP (double, ArrowWidth)
00192 GCU_RO_PROP (double, ArrowPadding)
00196 GCU_RO_PROP (double, ArrowObjectPadding)
00200 GCU_RO_PROP (double, StoichiometryPadding)
00204 GCU_RO_PROP (double, ObjectPadding)
00208 GCU_RO_PROP (double, SignPadding)
00212 GCU_RO_PROP (double, ChargeSignSize)
00216 GCU_RO_PROP (gchar*, FontFamily)
00220 GCU_RO_PROP (PangoStyle, FontStyle)
00224 GCU_RO_PROP (PangoWeight, FontWeight)
00228 GCU_RO_PROP (PangoVariant, FontVariant)
00232 GCU_RO_PROP (PangoStretch, FontStretch)
00236 GCU_RO_PROP (gint, FontSize)
00240 GCU_RO_PROP (gchar*, TextFontFamily)
00244 GCU_RO_PROP (PangoStyle, TextFontStyle)
00248 GCU_RO_PROP (PangoWeight, TextFontWeight)
00252 GCU_RO_PROP (PangoVariant, TextFontVariant)
00256 GCU_RO_PROP (PangoStretch, TextFontStretch)
00260 GCU_RO_PROP (gint, TextFontSize)
00264 GCU_RO_PROP (ThemeType, ThemeType);
00265 };
00266 
00273 class ThemeManager
00274 {
00275 public:
00279         ThemeManager ();
00283         ~ThemeManager ();
00284 
00290         Theme *GetTheme (char const *name);
00296         Theme *GetTheme (std::string &name);
00300         std::list <std::string> const &GetThemesNames ();
00308         void OnConfigChanged (GOConfNode *node, gchar const *name);
00314         Theme *CreateNewTheme (Theme *theme = NULL);
00324         void AddFileTheme (Theme *theme, char const *label);
00331         void RemoveFileTheme (Theme *theme);
00338         void ChangeThemeName (Theme *theme, char const *name);
00342         Theme *GetDefaultTheme () {return m_DefaultTheme;}
00349         void SetDefaultTheme (char const *name);
00354         void Shutdown ();
00355 
00356 private:
00357         void ParseDir (std::string &path, ThemeType type);
00358 
00359 private:
00360         std::map <std::string, Theme*> m_Themes;
00361         std::list <std::string> m_Names;
00362         GOConfNode *m_ConfNode;
00363         guint m_NotificationId;
00364         Theme *m_DefaultTheme;
00365 };
00366 
00370 extern ThemeManager TheThemeManager;
00371 
00372 }       //      namespace gcp
00373 
00374 #endif  //      GCHEMPAINT_THEME_H

Generated on Sun Sep 6 18:29:26 2009 for The Gnome Chemistry Utils by  doxygen 1.6.1