TGUI  0.8-dev
Theme.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2017 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_THEME_HPP
27 #define TGUI_THEME_HPP
28 
29 #include <TGUI/Loading/ThemeLoader.hpp>
30 #include <TGUI/Renderers/WidgetRenderer.hpp>
31 
33 
34 namespace tgui
35 {
40  class TGUI_API Theme
41  {
42  public:
43 
49  Theme(const std::string& primary = "");
50 
51 
57  ~Theme();
58 
59 
68  void load(const std::string& primary);
69 
70 
80  std::shared_ptr<RendererData> getRenderer(const std::string& id);
81 
82 
92  std::shared_ptr<RendererData> getRendererNoThrow(const std::string& id);
93 
94 
104  void addRenderer(const std::string& id, std::shared_ptr<RendererData> renderer);
105 
106 
114  bool removeRenderer(const std::string& id);
115 
116 
122  static void setThemeLoader(std::shared_ptr<BaseThemeLoader> themeLoader);
123 
124 
130  static std::shared_ptr<BaseThemeLoader> getThemeLoader();
131 
132 
140  static void setDefault(Theme* theme);
141 
142 
152  static Theme* getDefault();
153 
154 
156  protected:
157 
158  static Theme* m_defaultTheme;
159  static std::shared_ptr<BaseThemeLoader> m_themeLoader;
160  std::map<std::string, std::shared_ptr<RendererData>> m_renderers;
161  std::string m_primary;
162  };
163 
165 }
166 
168 
169 #endif // TGUI_THEME_HPP
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
static std::shared_ptr< BaseThemeLoader > m_themeLoader
Theme loader which will do the actual loading.
Definition: Theme.hpp:159
This class can be used to manage the widget renderers.
Definition: Theme.hpp:40
std::map< std::string, std::shared_ptr< RendererData > > m_renderers
Maps ids to renderer datas.
Definition: Theme.hpp:160