The Gnome Chemistry Utils  0.12.13
theme.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint library
5  * theme.h
6  *
7  * Copyright (C) 2002-2009 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCHEMPAINT_THEME_H
26 #define GCHEMPAINT_THEME_H
27 
28 #include <gcu/macros.h>
29 #include <gcu/object.h>
30 #include <libxml/tree.h>
31 #include <list>
32 #include <map>
33 #include <string>
34 #include <set>
35 
38 namespace gcp {
39 
43 typedef enum {
60 } ThemeType;
61 
67 class Theme
68 {
69 friend class ThemeManager;
70 friend class PrefsDlg;
71 
72 public:
78  Theme (char const *name);
82  ~Theme ();
83 
87  std::string &GetName () {return m_Name;}
94  bool Save (xmlDocPtr xml);
100  bool Load (xmlNodePtr node);
106  bool operator== (const Theme &theme);
112  void AddClient (gcu::Object *client) {m_Clients.insert (client);}
118  void RemoveClient (gcu::Object *client);
122  void NotifyChanged ();
123 
124 private:
125  std::string m_Name;
126  std::set <gcu::Object*> m_Clients;
127  bool modified;
128  bool locked;
129 
133 GCU_RO_PROP (double, BondLength)
137 GCU_RO_PROP (double, BondAngle)
141 GCU_RO_PROP (double, BondDist)
145 GCU_RO_PROP (double, BondWidth)
149 GCU_RO_PROP (double, ArrowLength)
153 GCU_RO_PROP (double, HashWidth)
157 GCU_RO_PROP (double, HashDist)
161 GCU_RO_PROP (double, StereoBondWidth)
165 GCU_RO_PROP (double, ZoomFactor)
169 GCU_RO_PROP (double, Padding)
173 GCU_RO_PROP (double, ArrowHeadA)
177 GCU_RO_PROP (double, ArrowHeadB)
181 GCU_RO_PROP (double, ArrowHeadC)
185 GCU_RO_PROP (double, ArrowDist)
189 GCU_RO_PROP (double, ArrowWidth)
193 GCU_RO_PROP (double, ArrowPadding)
197 GCU_RO_PROP (double, ArrowObjectPadding)
201 GCU_RO_PROP (double, StoichiometryPadding)
205 GCU_RO_PROP (double, ObjectPadding)
209 GCU_RO_PROP (double, SignPadding)
213 GCU_RO_PROP (double, ChargeSignSize)
217 GCU_RO_PROP (gchar*, FontFamily)
221 GCU_RO_PROP (PangoStyle, FontStyle)
225 GCU_RO_PROP (PangoWeight, FontWeight)
229 GCU_RO_PROP (PangoVariant, FontVariant)
233 GCU_RO_PROP (PangoStretch, FontStretch)
237 GCU_RO_PROP (gint, FontSize)
241 GCU_RO_PROP (gchar*, TextFontFamily)
245 GCU_RO_PROP (PangoStyle, TextFontStyle)
249 GCU_RO_PROP (PangoWeight, TextFontWeight)
253 GCU_RO_PROP (PangoVariant, TextFontVariant)
257 GCU_RO_PROP (PangoStretch, TextFontStretch)
261 GCU_RO_PROP (gint, TextFontSize)
265 GCU_RO_PROP (ThemeType, ThemeType);
266 };
267 
275 {
276 public:
280  ThemeManager ();
284  ~ThemeManager ();
285 
291  Theme *GetTheme (char const *name);
297  Theme *GetTheme (std::string &name);
301  std::list <std::string> const &GetThemesNames ();
309  void OnConfigChanged (GOConfNode *node, gchar const *name);
315  Theme *CreateNewTheme (Theme *theme = NULL);
325  void AddFileTheme (Theme *theme, char const *label);
332  void RemoveFileTheme (Theme *theme);
339  void ChangeThemeName (Theme *theme, char const *name);
343  Theme *GetDefaultTheme () {return m_DefaultTheme;}
350  void SetDefaultTheme (char const *name);
355  void Shutdown ();
356 
357 private:
358  void ParseDir (std::string &path, ThemeType type);
359 
360 private:
361  std::map <std::string, Theme*> m_Themes;
362  std::list <std::string> m_Names;
363  GOConfNode *m_ConfNode;
364  guint m_NotificationId;
365  Theme *m_DefaultTheme;
366 };
367 
371 extern ThemeManager TheThemeManager;
372 
373 } // namespace gcp
374 
375 #endif // GCHEMPAINT_THEME_H