TGUI  0.7.4
ThemeLoader.hpp
1 //
3 // TGUI - Texus's 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_LOADER_HPP
27 #define TGUI_THEME_LOADER_HPP
28 
29 
30 #include <TGUI/Widget.hpp>
31 
32 #include <memory>
33 #include <string>
34 #include <vector>
35 #include <map>
36 
37 namespace tgui
38 {
39  class Widget;
40 
45  class TGUI_API BaseThemeLoader
46  {
47  public:
48 
49  using PropertyValuePairs = std::map<std::string, std::string>;
50 
51 
55  virtual ~BaseThemeLoader() = default;
56 
57 
70  virtual std::string load(const std::string& primary, const std::string& secondary, PropertyValuePairs& properties) = 0;
71  };
72 
73 
83  class TGUI_API DefaultThemeLoader : public BaseThemeLoader
84  {
85  public:
86 
100  virtual std::string load(const std::string& filename, const std::string& className, PropertyValuePairs& properties);
101 
102 
110  static void flushCache(const std::string& filename = "");
111 
112 
114  protected:
115 
123  virtual void readFile(const std::string& filename, std::stringstream& contents) const;
124 
125 
127  private:
128  static std::map<std::string, std::map<std::string, PropertyValuePairs>> m_propertiesCache;
129  static std::map<std::string, std::map<std::string, std::string>> m_widgetTypeCache;
130 
131  friend struct DefaultThemeLoaderTest;
132  };
133 
134 
136 }
137 
139 
140 #endif // TGUI_THEME_LOADER_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
Default implementation for theme loading.
Definition: ThemeLoader.hpp:83
Base class for theme loader implementations.
Definition: ThemeLoader.hpp:45