aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ButtonTheme.cc33
-rw-r--r--src/ButtonTheme.hh25
2 files changed, 58 insertions, 0 deletions
diff --git a/src/ButtonTheme.cc b/src/ButtonTheme.cc
new file mode 100644
index 0000000..225bbb7
--- /dev/null
+++ b/src/ButtonTheme.cc
@@ -0,0 +1,33 @@
1#include "ButtonTheme.hh"
2#include "FbTk/App.hh"
3
4//!! TODO: still missing *.pressed.picColor
5ButtonTheme::ButtonTheme(int screen_num,
6 const std::string &name,
7 const std::string &alt_name):
8 ToolTheme(screen_num, name, alt_name),
9 m_pic_color(*this, name + ".picColor", alt_name + ".PicColor"),
10 m_pressed_texture(*this, name + ".pressed", alt_name + ".Pressed"),
11 m_gc(RootWindow(FbTk::App::instance()->display(), screen_num)) {
12
13}
14
15bool ButtonTheme::fallback(FbTk::ThemeItem_base &item) {
16
17 if (item.name().find(".borderWidth") != std::string::npos) {
18 return FbTk::ThemeManager::instance().loadItem(item, "borderWidth", "BorderWidth");
19 }
20
21 if (item.name().find(".borderColor") != std::string::npos) {
22 return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor");
23 }
24
25 return ToolTheme::fallback(item);
26}
27
28void ButtonTheme::reconfigTheme() {
29 m_gc.setForeground(*m_pic_color);
30}
31
32
33
diff --git a/src/ButtonTheme.hh b/src/ButtonTheme.hh
new file mode 100644
index 0000000..2636960
--- /dev/null
+++ b/src/ButtonTheme.hh
@@ -0,0 +1,25 @@
1#ifndef BUTTONTHEME_HH
2#define BUTTONTHEME_HH
3
4#include "ToolTheme.hh"
5
6#include "FbTk/GContext.hh"
7
8class ButtonTheme: public ToolTheme {
9public:
10 ButtonTheme(int screen_num,
11 const std::string &name, const std::string &alt_name);
12 virtual ~ButtonTheme() { }
13
14 bool fallback(FbTk::ThemeItem_base &item);
15 void reconfigTheme();
16
17 inline const FbTk::Texture &pressed() const { return *m_pressed_texture; }
18 inline GC gc() const { return m_gc.gc(); }
19private:
20 FbTk::ThemeItem<FbTk::Color> m_pic_color;
21 FbTk::ThemeItem<FbTk::Texture> m_pressed_texture;
22 FbTk::GContext m_gc;
23};
24
25#endif // BUTTONTHEME_HH