CanvasCV: CanvasCV-doxygen/src/canvascv/themes/themerepository.h Source File
CanvasCV  1.0.0
themerepository.h
1 #ifndef THEMEREPOSITORY_H
2 #define THEMEREPOSITORY_H
3 
4 #include <functional>
5 #include <map>
6 #include <vector>
7 #include <string>
8 
9 namespace canvascv
10 {
11 
12 class Widget;
13 class Shape;
14 class Theme;
15 
23 {
24 public:
34  static bool addTheme(const std::string &name, Theme *theme);
35 
42  static void setCurrentTheme(const std::string &name);
43 
45  static Theme *getCurrentTheme();
46 
48  static std::string getCurrentThemeName();
49 
51  static void applyCurrentTheme(Shape *shape);
52 
54  static void applyCurrentTheme(Widget *widget);
55 
57  static std::vector<std::string> availThemes();
58 
59 private:
60 
61  typedef std::map<std::string,Theme *> ThemeMap;
62 
63  static ThemeMap themes;
64  static std::string currentThemeName;
65  static Theme *currentTheme;
66 };
67 
68 }
69 
70 #define CCV_REGISTER_THEME(X) static bool regTheme##X = canvascv::ThemeRepository::addTheme(#X, new X())
71 
76 #endif // THEMEREPOSITORY_H
static Theme * getCurrentTheme()
returns the current theme
The ThemeRepository is used to add and get themes for Widget and Shape objects.
Definition: themerepository.h:22
The Shape class hierarchy is for geomertric user interaction.
Definition: shape.h:32
The Theme controls appearance of widgets and shapes.
Definition: theme.h:17
static void applyCurrentTheme(Shape *shape)
used automatically by the ShapeFactory when creating a shape
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
static std::vector< std::string > availThemes()
get a list of available theme names
static bool addTheme(const std::string &name, Theme *theme)
addTheme add a Theme to the repository
static void setCurrentTheme(const std::string &name)
setCurrentTheme sets a previously added theme
The Widget class.
Definition: widget.h:28
static std::string getCurrentThemeName()
returns the current theme name