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         bool locked;
00129 
00133 GCU_RO_PROP (double, BondLength)
00137 GCU_RO_PROP (double, BondAngle)
00141 GCU_RO_PROP (double, BondDist)
00145 GCU_RO_PROP (double, BondWidth)
00149 GCU_RO_PROP (double, ArrowLength)
00153 GCU_RO_PROP (double, HashWidth)
00157 GCU_RO_PROP (double, HashDist)
00161 GCU_RO_PROP (double, StereoBondWidth)
00165 GCU_RO_PROP (double, ZoomFactor)
00169 GCU_RO_PROP (double, Padding)
00173 GCU_RO_PROP (double, ArrowHeadA)
00177 GCU_RO_PROP (double, ArrowHeadB)
00181 GCU_RO_PROP (double, ArrowHeadC)
00185 GCU_RO_PROP (double, ArrowDist)
00189 GCU_RO_PROP (double, ArrowWidth)
00193 GCU_RO_PROP (double, ArrowPadding)
00197 GCU_RO_PROP (double, ArrowObjectPadding)
00201 GCU_RO_PROP (double, StoichiometryPadding)
00205 GCU_RO_PROP (double, ObjectPadding)
00209 GCU_RO_PROP (double, SignPadding)
00213 GCU_RO_PROP (double, ChargeSignSize)
00217 GCU_RO_PROP (gchar*, FontFamily)
00221 GCU_RO_PROP (PangoStyle, FontStyle)
00225 GCU_RO_PROP (PangoWeight, FontWeight)
00229 GCU_RO_PROP (PangoVariant, FontVariant)
00233 GCU_RO_PROP (PangoStretch, FontStretch)
00237 GCU_RO_PROP (gint, FontSize)
00241 GCU_RO_PROP (gchar*, TextFontFamily)
00245 GCU_RO_PROP (PangoStyle, TextFontStyle)
00249 GCU_RO_PROP (PangoWeight, TextFontWeight)
00253 GCU_RO_PROP (PangoVariant, TextFontVariant)
00257 GCU_RO_PROP (PangoStretch, TextFontStretch)
00261 GCU_RO_PROP (gint, TextFontSize)
00265 GCU_RO_PROP (ThemeType, ThemeType);
00266 };
00267 
00274 class ThemeManager
00275 {
00276 public:
00280         ThemeManager ();
00284         ~ThemeManager ();
00285 
00291         Theme *GetTheme (char const *name);
00297         Theme *GetTheme (std::string &name);
00301         std::list <std::string> const &GetThemesNames ();
00309         void OnConfigChanged (GOConfNode *node, gchar const *name);
00315         Theme *CreateNewTheme (Theme *theme = NULL);
00325         void AddFileTheme (Theme *theme, char const *label);
00332         void RemoveFileTheme (Theme *theme);
00339         void ChangeThemeName (Theme *theme, char const *name);
00343         Theme *GetDefaultTheme () {return m_DefaultTheme;}
00350         void SetDefaultTheme (char const *name);
00355         void Shutdown ();
00356 
00357 private:
00358         void ParseDir (std::string &path, ThemeType type);
00359 
00360 private:
00361         std::map <std::string, Theme*> m_Themes;
00362         std::list <std::string> m_Names;
00363         GOConfNode *m_ConfNode;
00364         guint m_NotificationId;
00365         Theme *m_DefaultTheme;
00366 };
00367 
00371 extern ThemeManager TheThemeManager;
00372 
00373 }       //      namespace gcp
00374 
00375 #endif  //      GCHEMPAINT_THEME_H

Generated on Fri Sep 24 15:58:42 2010 for The Gnome Chemistry Utils by  doxygen 1.5.9