From 9911b38f8df93871542e3a7cdd5611e42e9bd106 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 13 Oct 2003 23:41:07 +0000 Subject: extends tooltheme with picColor and pressed texture for toolbar buttons --- src/ButtonTheme.cc | 33 +++++++++++++++++++++++++++++++++ src/ButtonTheme.hh | 25 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/ButtonTheme.cc create mode 100644 src/ButtonTheme.hh 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 @@ +#include "ButtonTheme.hh" +#include "FbTk/App.hh" + +//!! TODO: still missing *.pressed.picColor +ButtonTheme::ButtonTheme(int screen_num, + const std::string &name, + const std::string &alt_name): + ToolTheme(screen_num, name, alt_name), + m_pic_color(*this, name + ".picColor", alt_name + ".PicColor"), + m_pressed_texture(*this, name + ".pressed", alt_name + ".Pressed"), + m_gc(RootWindow(FbTk::App::instance()->display(), screen_num)) { + +} + +bool ButtonTheme::fallback(FbTk::ThemeItem_base &item) { + + if (item.name().find(".borderWidth") != std::string::npos) { + return FbTk::ThemeManager::instance().loadItem(item, "borderWidth", "BorderWidth"); + } + + if (item.name().find(".borderColor") != std::string::npos) { + return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor"); + } + + return ToolTheme::fallback(item); +} + +void ButtonTheme::reconfigTheme() { + m_gc.setForeground(*m_pic_color); +} + + + 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 @@ +#ifndef BUTTONTHEME_HH +#define BUTTONTHEME_HH + +#include "ToolTheme.hh" + +#include "FbTk/GContext.hh" + +class ButtonTheme: public ToolTheme { +public: + ButtonTheme(int screen_num, + const std::string &name, const std::string &alt_name); + virtual ~ButtonTheme() { } + + bool fallback(FbTk::ThemeItem_base &item); + void reconfigTheme(); + + inline const FbTk::Texture &pressed() const { return *m_pressed_texture; } + inline GC gc() const { return m_gc.gc(); } +private: + FbTk::ThemeItem m_pic_color; + FbTk::ThemeItem m_pressed_texture; + FbTk::GContext m_gc; +}; + +#endif // BUTTONTHEME_HH -- cgit v0.11.2