add a level of indirection to themes

This commit is contained in:
Mark Tiefenbruck 2008-01-04 01:06:38 -08:00
parent b20b243b48
commit 60ba709c2f
15 changed files with 96 additions and 17 deletions

View file

@ -27,7 +27,7 @@
#include "FbTk/GContext.hh"
class ButtonTheme: public ToolTheme {
class ButtonTheme: public ToolTheme, public FbTk::ThemeProxy<ButtonTheme> {
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<FbTk::Color> m_pic_color;
FbTk::ThemeItem<FbTk::Texture> m_pressed_texture;

View file

@ -33,7 +33,7 @@
namespace FbTk {
class MenuTheme:public Theme {
class MenuTheme: public Theme, public ThemeProxy<MenuTheme> {
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<Color> t_text, f_text, h_text, d_text, u_text;
ThemeItem<Texture> title, frame, hilite;

View file

@ -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);
}

View file

@ -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; }

View file

@ -118,6 +118,18 @@ private:
FbTk::Subject m_reconfig_sig;
};
/// Proxy interface for themes, so they can be substituted dynamically
template <class BaseTheme>
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
/**

View file

@ -32,7 +32,8 @@
#include "IconbarTheme.hh"
class FbWinFrameTheme: public FbTk::Theme {
class FbWinFrameTheme: public FbTk::Theme,
public FbTk::ThemeProxy<FbWinFrameTheme> {
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<FbTk::Texture> m_title_focus, m_title_unfocus;
FbTk::ThemeItem<FbTk::Texture> m_handle_focus, m_handle_unfocus;

View file

@ -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

View file

@ -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<IconbarTheme> {
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<FbTk::Texture> m_focused_texture, m_unfocused_texture, m_empty_texture;
FbTk::BorderTheme m_focused_border, m_unfocused_border, m_border;

View file

@ -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<RootTheme> {
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;

View file

@ -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<SlitTheme> {
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<FbTk::Texture> m_texture;
FbTk::ThemeItem<int> m_border_width, m_bevel_width;

View file

@ -38,7 +38,7 @@ ToolTheme::~ToolTheme() {
void ToolTheme::reconfigTheme() {
// update text theme
update();
updateTextColor();
}
bool ToolTheme::fallback(FbTk::ThemeItem_base &item) {

View file

@ -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<ToolTheme> {
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<FbTk::Texture> &textureTheme() { return m_texture; }

View file

@ -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<ToolbarTheme> {
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<FbTk::Texture> m_toolbar;
FbTk::BorderTheme m_border;

View file

@ -27,7 +27,8 @@
class FbWinFrameTheme;
class WinButtonTheme: public FbTk::Theme {
class WinButtonTheme: public FbTk::Theme,
public FbTk::ThemeProxy<WinButtonTheme> {
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<FbTk::PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm;

View file

@ -25,7 +25,8 @@
#include "ToolTheme.hh"
class WorkspaceNameTheme:public ToolTheme {
class WorkspaceNameTheme: public ToolTheme,
public FbTk::ThemeProxy<WorkspaceNameTheme> {
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