From 60ba709c2f47cc2c7b877aef1b0f297b097853e5 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Fri, 4 Jan 2008 01:06:38 -0800 Subject: add a level of indirection to themes --- src/ButtonTheme.hh | 8 +++++++- src/FbTk/MenuTheme.hh | 8 +++++++- src/FbTk/TextTheme.cc | 4 ++-- src/FbTk/TextTheme.hh | 2 +- src/FbTk/Theme.hh | 12 ++++++++++++ src/FbWinFrameTheme.hh | 9 ++++++++- src/IconbarTheme.cc | 4 ++-- src/IconbarTheme.hh | 8 +++++++- src/RootTheme.hh | 10 ++++++++-- src/SlitTheme.hh | 9 ++++++++- src/ToolTheme.cc | 2 +- src/ToolTheme.hh | 9 ++++++++- src/ToolbarTheme.hh | 9 ++++++++- src/WinButtonTheme.hh | 9 ++++++++- src/WorkspaceNameTheme.hh | 10 +++++++++- 15 files changed, 96 insertions(+), 17 deletions(-) diff --git a/src/ButtonTheme.hh b/src/ButtonTheme.hh index 00c6446..7f43eb9 100644 --- a/src/ButtonTheme.hh +++ b/src/ButtonTheme.hh @@ -27,7 +27,7 @@ #include "FbTk/GContext.hh" -class ButtonTheme: public ToolTheme { +class ButtonTheme: public ToolTheme, public FbTk::ThemeProxy { public: ButtonTheme(int screen_num, const std::string &name, const std::string &alt_name, @@ -43,6 +43,12 @@ public: int scale() const { return *m_scale; } // scale factor for inside objects const std::string &name() { return m_name; } + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual ButtonTheme *operator ->() { return this; } + virtual const ButtonTheme *operator ->() const { return this; } + private: FbTk::ThemeItem m_pic_color; FbTk::ThemeItem m_pressed_texture; diff --git a/src/FbTk/MenuTheme.hh b/src/FbTk/MenuTheme.hh index d496f1e..017e4f3 100644 --- a/src/FbTk/MenuTheme.hh +++ b/src/FbTk/MenuTheme.hh @@ -33,7 +33,7 @@ namespace FbTk { -class MenuTheme:public Theme { +class MenuTheme: public Theme, public ThemeProxy { public: //!! TODO // this isn't actually used with a theme item @@ -140,6 +140,12 @@ public: m_hl_selected_pixmap->pixmap().dontFree(); } + virtual Subject &reconfigSig() { return Theme::reconfigSig(); } + virtual const Subject &reconfigSig() const { return Theme::reconfigSig(); } + + virtual MenuTheme *operator ->() { return this; } + virtual const MenuTheme *operator ->() const { return this; } + private: ThemeItem t_text, f_text, h_text, d_text, u_text; ThemeItem title, frame, hilite; diff --git a/src/FbTk/TextTheme.cc b/src/FbTk/TextTheme.cc index 848ee01..dad002e 100644 --- a/src/FbTk/TextTheme.cc +++ b/src/FbTk/TextTheme.cc @@ -38,10 +38,10 @@ TextTheme::TextTheme(Theme &theme, // set default values m_text_color->setFromString("white", theme.screenNum()); - update(); + updateTextColor(); } -void TextTheme::update() { +void TextTheme::updateTextColor() { m_text_gc.setForeground(*m_text_color); } diff --git a/src/FbTk/TextTheme.hh b/src/FbTk/TextTheme.hh index ea22d4b..9a83788 100644 --- a/src/FbTk/TextTheme.hh +++ b/src/FbTk/TextTheme.hh @@ -36,7 +36,7 @@ public: TextTheme(Theme &theme, const std::string &name, const std::string &altname); virtual ~TextTheme() { } - void update(); + void updateTextColor(); Font &font() { return *m_font; } const Font &font() const { return *m_font; } diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh index 159364e..1ae3387 100644 --- a/src/FbTk/Theme.hh +++ b/src/FbTk/Theme.hh @@ -118,6 +118,18 @@ private: FbTk::Subject m_reconfig_sig; }; +/// Proxy interface for themes, so they can be substituted dynamically +template +class ThemeProxy { +public: + virtual ~ThemeProxy() { } + + virtual Subject &reconfigSig() = 0; + virtual const Subject &reconfigSig() const = 0; + + virtual BaseTheme *operator ->() = 0; + virtual const BaseTheme *operator ->() const = 0; +}; /// Singleton theme manager /** diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index 7d5106c..e72d6f5 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -32,7 +32,8 @@ #include "IconbarTheme.hh" -class FbWinFrameTheme: public FbTk::Theme { +class FbWinFrameTheme: public FbTk::Theme, + public FbTk::ThemeProxy { public: explicit FbWinFrameTheme(int screen_num); ~FbWinFrameTheme(); @@ -93,6 +94,12 @@ public: IconbarTheme &iconbarTheme() { return m_iconbar_theme; } + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual FbWinFrameTheme *operator ->() { return this; } + virtual const FbWinFrameTheme *operator ->() const { return this; } + private: FbTk::ThemeItem m_title_focus, m_title_unfocus; FbTk::ThemeItem m_handle_focus, m_handle_unfocus; diff --git a/src/IconbarTheme.cc b/src/IconbarTheme.cc index 3cc2bf3..f2247aa 100644 --- a/src/IconbarTheme.cc +++ b/src/IconbarTheme.cc @@ -58,8 +58,8 @@ IconbarTheme::~IconbarTheme() { void IconbarTheme::reconfigTheme() { - m_focused_text.update(); - m_unfocused_text.update(); + m_focused_text.updateTextColor(); + m_unfocused_text.updateTextColor(); } // fallback resources diff --git a/src/IconbarTheme.hh b/src/IconbarTheme.hh index 6d41f28..3a56eb8 100644 --- a/src/IconbarTheme.hh +++ b/src/IconbarTheme.hh @@ -28,7 +28,7 @@ #include "FbTk/Texture.hh" #include "FbTk/TextTheme.hh" -class IconbarTheme:public FbTk::Theme { +class IconbarTheme: public FbTk::Theme, public FbTk::ThemeProxy { public: IconbarTheme(int screen_num, const std::string &name, const std::string &altname); virtual ~IconbarTheme(); @@ -47,6 +47,12 @@ public: const FbTk::Texture &unfocusedTexture() const { return *m_unfocused_texture; } const FbTk::Texture &emptyTexture() const { return *m_empty_texture; } + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual IconbarTheme *operator ->() { return this; } + virtual const IconbarTheme *operator ->() const { return this; } + private: FbTk::ThemeItem m_focused_texture, m_unfocused_texture, m_empty_texture; FbTk::BorderTheme m_focused_border, m_unfocused_border, m_border; diff --git a/src/RootTheme.hh b/src/RootTheme.hh index 96d9f0e..1e37cfe 100644 --- a/src/RootTheme.hh +++ b/src/RootTheme.hh @@ -34,7 +34,7 @@ class ImageControl; } /// Contains border color, border size, bevel width and opGC for objects like geometry window in BScreen -class RootTheme: public FbTk::Theme { +class RootTheme: public FbTk::Theme, public FbTk::ThemeProxy { public: /// constructor /// @param resmanager resource manager for finding specific resources @@ -53,7 +53,13 @@ public: int join_style) { m_opgc.setLineAttributes(width, line_style, cap_style, join_style); } - + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual RootTheme *operator ->() { return this; } + virtual const RootTheme *operator ->() const { return this; } + private: BackgroundItem *m_background;///< background image/texture FbTk::GContext m_opgc; diff --git a/src/SlitTheme.hh b/src/SlitTheme.hh index 33fada7..20be862 100644 --- a/src/SlitTheme.hh +++ b/src/SlitTheme.hh @@ -26,7 +26,7 @@ #include "FbTk/Texture.hh" #include "FbTk/Color.hh" -class SlitTheme:public FbTk::Theme { +class SlitTheme: public FbTk::Theme, public FbTk::ThemeProxy { public: explicit SlitTheme(int screen_num); @@ -37,6 +37,13 @@ public: const FbTk::Color &borderColor() const { return *m_border_color; } int borderWidth() const { return *m_border_width; } int bevelWidth() const { return *m_bevel_width; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual SlitTheme *operator ->() { return this; } + virtual const SlitTheme *operator ->() const { return this; } + private: FbTk::ThemeItem m_texture; FbTk::ThemeItem m_border_width, m_bevel_width; diff --git a/src/ToolTheme.cc b/src/ToolTheme.cc index 5741fd0..a5abc1a 100644 --- a/src/ToolTheme.cc +++ b/src/ToolTheme.cc @@ -38,7 +38,7 @@ ToolTheme::~ToolTheme() { void ToolTheme::reconfigTheme() { // update text theme - update(); + updateTextColor(); } bool ToolTheme::fallback(FbTk::ThemeItem_base &item) { diff --git a/src/ToolTheme.hh b/src/ToolTheme.hh index b9d98df..552e8f8 100644 --- a/src/ToolTheme.hh +++ b/src/ToolTheme.hh @@ -29,7 +29,8 @@ #include "FbTk/Texture.hh" /// Handles toolbar item theme for text and texture -class ToolTheme: public FbTk::Theme, public FbTk::TextTheme { +class ToolTheme: public FbTk::Theme, public FbTk::TextTheme, + public FbTk::ThemeProxy { public: ToolTheme(int screen_num, const std::string &name, const std::string &altname); virtual ~ToolTheme(); @@ -43,6 +44,12 @@ public: unsigned char alpha() const { return m_alpha; } void setAlpha(unsigned char alpha) { m_alpha = alpha; } + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual ToolTheme *operator ->() { return this; } + virtual const ToolTheme *operator ->() const { return this; } + protected: FbTk::ThemeItem &textureTheme() { return m_texture; } diff --git a/src/ToolbarTheme.hh b/src/ToolbarTheme.hh index 57f8eb1..1a183e2 100644 --- a/src/ToolbarTheme.hh +++ b/src/ToolbarTheme.hh @@ -27,7 +27,7 @@ #include "FbTk/BorderTheme.hh" /// toolbar theme class container -class ToolbarTheme: public FbTk::Theme { +class ToolbarTheme: public FbTk::Theme, public FbTk::ThemeProxy { public: explicit ToolbarTheme(int screen_num); virtual ~ToolbarTheme(); @@ -43,6 +43,13 @@ public: bool shape() const { return *m_shape; } int height() const { return *m_height; } int buttonSize() const { return *m_button_size; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual ToolbarTheme *operator ->() { return this; } + virtual const ToolbarTheme *operator ->() const { return this; } + private: FbTk::ThemeItem m_toolbar; FbTk::BorderTheme m_border; diff --git a/src/WinButtonTheme.hh b/src/WinButtonTheme.hh index 70a2297..7d00e1e 100644 --- a/src/WinButtonTheme.hh +++ b/src/WinButtonTheme.hh @@ -27,7 +27,8 @@ class FbWinFrameTheme; -class WinButtonTheme: public FbTk::Theme { +class WinButtonTheme: public FbTk::Theme, + public FbTk::ThemeProxy { public: WinButtonTheme(int screen_num, FbWinFrameTheme &frame_theme); ~WinButtonTheme(); @@ -84,6 +85,12 @@ public: FbTk::PixmapWithMask &titleUnfocusPixmap() { return *m_title_unfocus_pm; } const FbTk::PixmapWithMask &titleUnfocusPixmap() const { return *m_title_unfocus_pm; } + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual WinButtonTheme *operator ->() { return this; } + virtual const WinButtonTheme *operator ->() const { return this; } + private: FbTk::ThemeItem m_close_pm, m_close_unfocus_pm, m_close_pressed_pm; diff --git a/src/WorkspaceNameTheme.hh b/src/WorkspaceNameTheme.hh index 2e4dc42..860f6ec 100644 --- a/src/WorkspaceNameTheme.hh +++ b/src/WorkspaceNameTheme.hh @@ -25,7 +25,8 @@ #include "ToolTheme.hh" -class WorkspaceNameTheme:public ToolTheme { +class WorkspaceNameTheme: public ToolTheme, + public FbTk::ThemeProxy { public: WorkspaceNameTheme(int screen_num, const std::string &name, @@ -44,6 +45,13 @@ public: return ToolTheme::fallback(item); } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual WorkspaceNameTheme *operator ->() { return this; } + virtual const WorkspaceNameTheme *operator ->() const { return this; } + }; #endif // WORKSPACENAMETHEME_HH -- cgit v0.11.2