From ac1bd7e0981222bf340ce7defb2bb8307d42a0a2 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Fri, 4 Jan 2008 17:39:19 -0800 Subject: update code to use ThemeProxy --- src/AlphaMenu.cc | 4 +- src/AlphaMenu.hh | 4 +- src/ButtonTheme.hh | 4 +- src/ButtonTool.cc | 26 +++++----- src/ButtonTool.hh | 3 +- src/ClockTool.cc | 28 +++++------ src/ClockTool.hh | 6 ++- src/CommandDialog.cc | 12 ++--- src/Ewmh.cc | 10 ++-- src/FbMenu.cc | 4 +- src/FbMenu.hh | 2 +- src/FbTk/Menu.cc | 124 +++++++++++++++++++++++----------------------- src/FbTk/Menu.hh | 9 ++-- src/FbTk/MenuItem.cc | 103 +++++++++++++++++++------------------- src/FbTk/MenuItem.hh | 11 ++-- src/FbTk/MenuSeparator.cc | 12 ++--- src/FbTk/MenuSeparator.hh | 2 +- src/FbTk/MenuTheme.hh | 4 +- src/FbTk/Theme.hh | 6 ++- src/FbWinFrame.cc | 104 +++++++++++++++++++------------------- src/FbWinFrame.hh | 8 +-- src/FbWinFrameTheme.hh | 4 +- src/GenericTool.cc | 2 +- src/GenericTool.hh | 8 +-- src/IconButton.cc | 38 +++++++------- src/IconButton.hh | 10 ++-- src/IconbarTheme.hh | 4 +- src/IconbarTool.cc | 11 ++-- src/IconbarTool.hh | 5 +- src/LayerMenu.cc | 3 +- src/LayerMenu.hh | 3 +- src/RootTheme.hh | 4 +- src/Screen.cc | 72 ++++++++++++--------------- src/Screen.hh | 20 ++++---- src/Slit.cc | 12 ++--- src/Slit.hh | 7 ++- src/SlitTheme.hh | 4 +- src/SystemTray.cc | 17 ++++--- src/SystemTray.hh | 9 +++- src/ToggleMenu.hh | 7 +-- src/ToolFactory.cc | 4 +- src/ToolTheme.hh | 4 +- src/Toolbar.cc | 36 +++++++------- src/Toolbar.hh | 4 +- src/ToolbarTheme.hh | 4 +- src/WinButton.cc | 56 ++++++++++----------- src/WinButton.hh | 5 +- src/WinButtonTheme.cc | 11 ++-- src/WinButtonTheme.hh | 9 ++-- src/Window.cc | 66 ++++++++++++------------ src/Window.hh | 3 +- src/WorkspaceNameTheme.hh | 4 +- src/WorkspaceNameTool.cc | 26 +++++----- src/WorkspaceNameTool.hh | 8 ++- src/Xinerama.hh | 11 ++-- 55 files changed, 503 insertions(+), 474 deletions(-) diff --git a/src/AlphaMenu.cc b/src/AlphaMenu.cc index 00c9033..ef67956 100644 --- a/src/AlphaMenu.cc +++ b/src/AlphaMenu.cc @@ -34,8 +34,8 @@ #include "FbTk/I18n.hh" #include "Window.hh" -AlphaMenu::AlphaMenu(FbTk::MenuTheme &tm, FbTk::ImageControl &imgctrl, - FbTk::XLayer &layer): +AlphaMenu::AlphaMenu(FbTk::ThemeProxy &tm, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer): ToggleMenu(tm, imgctrl, layer) { diff --git a/src/AlphaMenu.hh b/src/AlphaMenu.hh index 8539176..41580c3 100644 --- a/src/AlphaMenu.hh +++ b/src/AlphaMenu.hh @@ -29,8 +29,8 @@ class AlphaMenu : public ToggleMenu { public: - AlphaMenu(FbTk::MenuTheme &tm, FbTk::ImageControl &imgctrl, - FbTk::XLayer &layer); + AlphaMenu(FbTk::ThemeProxy &tm, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer); // we override these to update the menu when the active window changes void move(int x, int y); diff --git a/src/ButtonTheme.hh b/src/ButtonTheme.hh index 7f43eb9..95a4e32 100644 --- a/src/ButtonTheme.hh +++ b/src/ButtonTheme.hh @@ -46,8 +46,8 @@ public: 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; } + virtual ButtonTheme &operator *() { return *this; } + virtual const ButtonTheme &operator *() const { return *this; } private: FbTk::ThemeItem m_pic_color; diff --git a/src/ButtonTool.cc b/src/ButtonTool.cc index a88e47b..0e11733 100644 --- a/src/ButtonTool.cc +++ b/src/ButtonTool.cc @@ -26,9 +26,9 @@ ButtonTool::ButtonTool(FbTk::Button *button, ToolbarItem::Type type, - ButtonTheme &theme, + FbTk::ThemeProxy &theme, FbTk::ImageControl &img_ctrl): - GenericTool(button, type, theme), + GenericTool(button, type, dynamic_cast &>(theme)), m_cache_pm(0), m_cache_pressed_pm(0), m_image_ctrl(img_ctrl) { @@ -46,37 +46,37 @@ ButtonTool::~ButtonTool() { void ButtonTool::updateSizing() { FbTk::Button &btn = static_cast(window()); - btn.setBorderWidth(theme().border().width()); + btn.setBorderWidth(theme()->border().width()); } void ButtonTool::renderTheme(unsigned char alpha) { FbTk::Button &btn = static_cast(window()); - btn.setGC(static_cast(theme()).gc()); - btn.setBorderColor(theme().border().color()); - btn.setBorderWidth(theme().border().width()); + btn.setGC(static_cast(*theme()).gc()); + btn.setBorderColor(theme()->border().color()); + btn.setBorderWidth(theme()->border().width()); btn.setAlpha(alpha); - btn.updateTheme(static_cast(theme())); + btn.updateTheme(*theme()); Pixmap old_pm = m_cache_pm; - if (!theme().texture().usePixmap()) { + if (!theme()->texture().usePixmap()) { m_cache_pm = 0; - btn.setBackgroundColor(theme().texture().color()); + btn.setBackgroundColor(theme()->texture().color()); } else { m_cache_pm = m_image_ctrl.renderImage(width(), height(), - theme().texture(), orientation()); + theme()->texture(), orientation()); btn.setBackgroundPixmap(m_cache_pm); } if (old_pm) m_image_ctrl.removeImage(old_pm); old_pm = m_cache_pressed_pm; - if (! static_cast(theme()).pressed().usePixmap()) { + if (! static_cast(*theme()).pressed().usePixmap()) { m_cache_pressed_pm = 0; - btn.setPressedColor(static_cast(theme()).pressed().color()); + btn.setPressedColor(static_cast(*theme()).pressed().color()); } else { m_cache_pressed_pm = m_image_ctrl.renderImage(width(), height(), - static_cast(theme()).pressed(), orientation()); + static_cast(*theme()).pressed(), orientation()); btn.setPressedPixmap(m_cache_pressed_pm); } diff --git a/src/ButtonTool.hh b/src/ButtonTool.hh index f4f535a..4339722 100644 --- a/src/ButtonTool.hh +++ b/src/ButtonTool.hh @@ -36,7 +36,8 @@ class ImageControl; class ButtonTool: public GenericTool { public: ButtonTool(FbTk::Button *button, ToolbarItem::Type type, - ButtonTheme &theme, FbTk::ImageControl &img_ctrl); + FbTk::ThemeProxy &theme, + FbTk::ImageControl &img_ctrl); virtual ~ButtonTool(); protected: diff --git a/src/ClockTool.cc b/src/ClockTool.cc index d106408..adc6adc 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -134,9 +134,10 @@ public: }; ClockTool::ClockTool(const FbTk::FbWindow &parent, - ToolTheme &theme, BScreen &screen, FbTk::Menu &menu): + FbTk::ThemeProxy &theme, BScreen &screen, + FbTk::Menu &menu): ToolbarItem(ToolbarItem::FIXED), - m_button(parent, theme.font(), ""), + m_button(parent, theme->font(), ""), m_theme(theme), m_screen(screen), m_pixmap(0), @@ -164,7 +165,7 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent, m_timer.setCommand(update_graphic); m_timer.start(); - m_button.setGC(m_theme.textGC()); + m_button.setGC(m_theme->textGC()); // setup menu FbTk::RefCount saverc(FbTk::ObjectRegistry::instance().parse("saverc")); @@ -233,16 +234,13 @@ void ClockTool::update(FbTk::Subject *subj) { unsigned int new_width = m_button.width(); unsigned int new_height = m_button.height(); translateSize(orientation(), new_width, new_height); - new_width = m_theme.font().textWidth(text.c_str(), text.size()); + new_width = m_theme->font().textWidth(text.c_str(), text.size()); translateSize(orientation(), new_width, new_height); if (new_width != m_button.width() || new_height != m_button.height()) { resize(new_width, new_height); resizeSig().notify(); } - if (subj != 0 && typeid(*subj) == typeid(ToolTheme)) - renderTheme(m_button.alpha()); - } unsigned int ClockTool::borderWidth() const { @@ -280,7 +278,7 @@ void ClockTool::updateTime() { m_button.setText(text); - unsigned int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2; + unsigned int new_width = m_theme->font().textWidth(time_string, time_string_len) + 2; if (new_width > m_button.width()) { resize(new_width, m_button.height()); resizeSig().notify(); @@ -293,7 +291,7 @@ void ClockTool::updateTime() { // Just change things that affect the size void ClockTool::updateSizing() { - m_button.setBorderWidth(m_theme.border().width()); + m_button.setBorderWidth(m_theme->border().width()); // resizes if new timeformat update(0); } @@ -302,25 +300,25 @@ void ClockTool::reRender() { if (m_pixmap) m_screen.imageControl().removeImage(m_pixmap); - if (m_theme.texture().usePixmap()) { + if (m_theme->texture().usePixmap()) { m_pixmap = m_screen.imageControl().renderImage(width(), height(), - m_theme.texture(), orientation()); + m_theme->texture(), orientation()); m_button.setBackgroundPixmap(m_pixmap); } else { m_pixmap = 0; - m_button.setBackgroundColor(m_theme.texture().color()); + m_button.setBackgroundColor(m_theme->texture().color()); } } void ClockTool::renderTheme(unsigned char alpha) { m_button.setAlpha(alpha); - m_button.setJustify(m_theme.justify()); + m_button.setJustify(m_theme->justify()); reRender(); - m_button.setBorderWidth(m_theme.border().width()); - m_button.setBorderColor(m_theme.border().color()); + m_button.setBorderWidth(m_theme->border().width()); + m_button.setBorderColor(m_theme->border().color()); m_button.clear(); } diff --git a/src/ClockTool.hh b/src/ClockTool.hh index 4b1a62c..cbc676f 100644 --- a/src/ClockTool.hh +++ b/src/ClockTool.hh @@ -39,11 +39,13 @@ namespace FbTk { class ImageControl; class Subject; class Menu; +template class ThemeProxy; } class ClockTool:public ToolbarItem, public FbTk::Observer { public: - ClockTool(const FbTk::FbWindow &parent, ToolTheme &theme, BScreen &screen, FbTk::Menu &menu); + ClockTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy &theme, + BScreen &screen, FbTk::Menu &menu); virtual ~ClockTool(); void move(int x, int y); @@ -73,7 +75,7 @@ private: FbTk::TextButton m_button; - const ToolTheme &m_theme; + const FbTk::ThemeProxy &m_theme; BScreen &m_screen; Pixmap m_pixmap; FbTk::Timer m_timer; diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc index fb184e7..d88d755 100644 --- a/src/CommandDialog.cc +++ b/src/CommandDialog.cc @@ -50,8 +50,8 @@ using std::out_of_range; CommandDialog::CommandDialog(BScreen &screen, const string &title, const string precommand) : FbTk::FbWindow(screen.rootWindow().screenNumber(), 0, 0, 200, 1, ExposureMask), - m_textbox(*this, screen.winFrameTheme().font(), ""), - m_label(*this, screen.winFrameTheme().font(), title), + m_textbox(*this, screen.winFrameTheme()->font(), ""), + m_label(*this, screen.winFrameTheme()->font(), title), m_gc(m_textbox), m_screen(screen), m_move_x(0), @@ -190,12 +190,12 @@ void CommandDialog::tabComplete() { void CommandDialog::render() { Pixmap tmp = m_pixmap; - if (!m_screen.winFrameTheme().iconbarTheme().focusedTexture().usePixmap()) { - m_label.setBackgroundColor(m_screen.winFrameTheme().iconbarTheme().focusedTexture().color()); + if (!m_screen.winFrameTheme()->iconbarTheme().focusedTexture().usePixmap()) { + m_label.setBackgroundColor(m_screen.winFrameTheme()->iconbarTheme().focusedTexture().color()); m_pixmap = 0; } else { m_pixmap = m_screen.imageControl().renderImage(m_label.width(), m_label.height(), - m_screen.winFrameTheme().iconbarTheme().focusedTexture()); + m_screen.winFrameTheme()->iconbarTheme().focusedTexture()); m_label.setBackgroundPixmap(m_pixmap); } @@ -210,7 +210,7 @@ void CommandDialog::init() { // setup label // we listen to motion notify too m_label.setEventMask(m_label.eventMask() | ButtonPressMask | ButtonMotionMask); - m_label.setGC(m_screen.winFrameTheme().iconbarTheme().focusedText().textGC()); + m_label.setGC(m_screen.winFrameTheme()->iconbarTheme().focusedText().textGC()); m_label.show(); // setup text box diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 07d4e3c..f0b23b3 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -974,11 +974,11 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, } else if (ce.message_type == m_net->request_frame_extents) { if (!screen) return true; - FbWinFrameTheme &theme = screen->winFrameTheme(); - unsigned int bw = theme.border(true).width(); - long title_h = theme.titleHeight() || - theme.font().height() + 2*theme.bevelWidth() + 2 + 2*bw; - long handle_h = theme.handleWidth() + 2*bw; + FbTk::ThemeProxy &theme = screen->winFrameTheme(); + unsigned int bw = theme->border(true).width(); + long title_h = theme->titleHeight() || + theme->font().height() + 2*theme->bevelWidth() + 2 + 2*bw; + long handle_h = theme->handleWidth() + 2*bw; long extents[4]; // our frames currently don't protrude from left/right extents[0] = bw; diff --git a/src/FbMenu.cc b/src/FbMenu.cc index 3ec9a29..54b6c4a 100644 --- a/src/FbMenu.cc +++ b/src/FbMenu.cc @@ -24,8 +24,8 @@ #include "fluxbox.hh" #include "Screen.hh" -FbMenu::FbMenu(FbTk::MenuTheme &tm, FbTk::ImageControl &imgctrl, - FbTk::XLayer &layer): +FbMenu::FbMenu(FbTk::ThemeProxy &tm, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer): FbTk::Menu(tm, imgctrl), m_layeritem(fbwindow(), layer) { diff --git a/src/FbMenu.hh b/src/FbMenu.hh index 62edc7f..9114192 100644 --- a/src/FbMenu.hh +++ b/src/FbMenu.hh @@ -32,7 +32,7 @@ class MenuTheme; /// a layered and shaped menu class FbMenu:public FbTk::Menu { public: - FbMenu(FbTk::MenuTheme &tm, FbTk::ImageControl &imgctrl, + FbMenu(FbTk::ThemeProxy &tm, FbTk::ImageControl &imgctrl, FbTk::XLayer &layer); virtual ~FbMenu() { } void raise() { m_layeritem.raise(); } diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 48dd4d9..51fca9d 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -81,17 +81,17 @@ Menu *Menu::shown = 0; Menu *Menu::s_focused = 0; -Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): +Menu::Menu(FbTk::ThemeProxy &tm, ImageControl &imgctrl): m_theme(tm), m_parent(0), m_image_ctrl(imgctrl), m_screen_x(0), m_screen_y(0), - m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())), - m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())), + m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm->screenNum())), + m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm->screenNum())), m_alignment(ALIGNDONTCARE), m_active_index(-1), - m_shape(new Shape(fbwindow(), tm.shapePlaces())), + m_shape(new Shape(fbwindow(), tm->shapePlaces())), m_need_update(true) { // setup timers @@ -128,7 +128,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): menu.hilite_pixmap = None; menu.item_w = menu.frame_h = - theme().titleFont().height() + theme().bevelWidth() * 2; + theme()->titleFont().height() + theme()->bevelWidth() * 2; menu.sublevels = menu.persub = @@ -137,7 +137,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): long event_mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | KeyPressMask | ExposureMask | FocusChangeMask; // create menu window - menu.window = FbTk::FbWindow(tm.screenNum(), + menu.window = FbTk::FbWindow(tm->screenNum(), 0, 0, 10, 10, event_mask, true, // override redirect @@ -153,7 +153,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): event_mask |= EnterWindowMask | LeaveWindowMask; //create menu title menu.title = FbTk::FbWindow(menu.window, // parent - 0, 0, width(), theme().titleHeight(), // pos and size + 0, 0, width(), theme()->titleHeight(), // pos and size event_mask, // mask false, // override redirect true); // save under @@ -163,7 +163,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): event_mask |= PointerMotionMask; menu.frame = FbTk::FbWindow(menu.window, // parent - 0, theme().titleHeight(), // pos + 0, theme()->titleHeight(), // pos width(), menu.frame_h ? menu.frame_h : 1, // size event_mask, // mask false, // override redirect @@ -366,9 +366,9 @@ void Menu::enableTitle() { void Menu::updateMenu(int active_index) { if (m_title_vis) { - menu.item_w = theme().titleFont().textWidth(menu.label, + menu.item_w = theme()->titleFont().textWidth(menu.label, menu.label.size()); - menu.item_w += (theme().bevelWidth() * 2); + menu.item_w += (theme()->bevelWidth() * 2); } else menu.item_w = 1; @@ -386,8 +386,8 @@ void Menu::updateMenu(int active_index) { if (!menuitems.empty()) { menu.sublevels = 1; - while (theme().itemHeight() * (menuitems.size() + 1) / menu.sublevels + - theme().titleHeight() + theme().borderWidth() > m_screen_height) { + while (theme()->itemHeight() * (menuitems.size() + 1) / menu.sublevels + + theme()->titleHeight() + theme()->borderWidth() > m_screen_height) { menu.sublevels++; } @@ -401,14 +401,14 @@ void Menu::updateMenu(int active_index) { menu.persub = 0; } - int itmp = (theme().itemHeight() * menu.persub); + int itmp = (theme()->itemHeight() * menu.persub); menu.frame_h = itmp < 1 ? 1 : itmp; unsigned int new_width = (menu.sublevels * menu.item_w); unsigned int new_height = menu.frame_h; if (m_title_vis) - new_height += theme().titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0); + new_height += theme()->titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0); if (new_width == 0) @@ -431,29 +431,29 @@ void Menu::updateMenu(int active_index) { menu.frame.setAlpha(alpha()); Pixmap tmp = menu.hilite_pixmap; - const FbTk::Texture &hilite_tex = theme().hiliteTexture(); + const FbTk::Texture &hilite_tex = theme()->hiliteTexture(); if (!hilite_tex.usePixmap()) { menu.hilite_pixmap = None; } else menu.hilite_pixmap = - m_image_ctrl.renderImage(menu.item_w, theme().itemHeight(), hilite_tex); + m_image_ctrl.renderImage(menu.item_w, theme()->itemHeight(), hilite_tex); if (tmp) m_image_ctrl.removeImage(tmp); - if (!theme().selectedPixmap().pixmap().drawable()) { - int hw = theme().itemHeight() / 2; - m_theme.setSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().hiliteTexture()), true); + if (!theme()->selectedPixmap().pixmap().drawable()) { + int hw = theme()->itemHeight() / 2; + theme()->setSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme()->hiliteTexture()), true); - if (!theme().highlightSelectedPixmap().pixmap().drawable()) { - int hw = theme().itemHeight() / 2; - m_theme.setHighlightSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().frameTexture()), true); + if (!theme()->highlightSelectedPixmap().pixmap().drawable()) { + int hw = theme()->itemHeight() / 2; + theme()->setHighlightSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme()->frameTexture()), true); } } if (m_title_vis) { menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), - width() + menu.title.borderWidth(), theme().titleHeight()); + width() + menu.title.borderWidth(), theme()->titleHeight()); } menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + @@ -462,13 +462,13 @@ void Menu::updateMenu(int active_index) { if (m_title_vis && m_need_update) { tmp = menu.title_pixmap; - const FbTk::Texture &tex = theme().titleTexture(); + const FbTk::Texture &tex = theme()->titleTexture(); if (!tex.usePixmap()) { menu.title_pixmap = None; menu.title.setBackgroundColor(tex.color()); } else { menu.title_pixmap = - m_image_ctrl.renderImage(width(), theme().titleHeight(), tex); + m_image_ctrl.renderImage(width(), theme()->titleHeight(), tex); // set pixmap that we have as real face to the user menu.title.setBackgroundPixmap(menu.title_pixmap); } @@ -478,7 +478,7 @@ void Menu::updateMenu(int active_index) { } tmp = menu.frame_pixmap; - const FbTk::Texture &frame_tex = theme().frameTexture(); + const FbTk::Texture &frame_tex = theme()->frameTexture(); if (m_need_update) { if (!frame_tex.usePixmap()) { menu.frame_pixmap = None; @@ -630,12 +630,12 @@ void Menu::move(int x, int y) { void Menu::redrawTitle(FbDrawable &drawable) { - const FbTk::Font &font = theme().titleFont(); - int dx = theme().bevelWidth(); + const FbTk::Font &font = theme()->titleFont(); + int dx = theme()->bevelWidth(); size_t len = menu.label.size(); - unsigned int l = font.textWidth(menu.label, len) + theme().bevelWidth()*2; + unsigned int l = font.textWidth(menu.label, len) + theme()->bevelWidth()*2; - switch (theme().titleFontJustify()) { + switch (theme()->titleFontJustify()) { case FbTk::RIGHT: dx += width() - l; break; @@ -648,12 +648,12 @@ void Menu::redrawTitle(FbDrawable &drawable) { } // difference between height based on font, and style-set height - int height_offset = theme().titleHeight() - (font.height() + 2*theme().bevelWidth()); + int height_offset = theme()->titleHeight() - (font.height() + 2*theme()->bevelWidth()); font.drawText(drawable, // drawable screenNumber(), - theme().titleTextGC().gc(), // graphic context + theme()->titleTextGC().gc(), // graphic context menu.label, len, // text string with length - dx, font.ascent() + theme().bevelWidth() + height_offset/2); // position + dx, font.ascent() + theme()->bevelWidth() + height_offset/2); // position } @@ -683,14 +683,14 @@ void Menu::drawSubmenu(unsigned int index) { int new_y; if (m_alignment == ALIGNTOP) { - new_y = (y() + ((m_title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - + new_y = (y() + ((m_title_vis) ? theme()->titleHeight() + menu.title.borderWidth() : 0) - ((item->submenu()->m_title_vis) ? - item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); + item->submenu()->theme()->titleHeight() + menu.window.borderWidth() : 0)); } else { - new_y = (y() + (theme().itemHeight() * i) + - ((m_title_vis) ? theme().titleHeight() + menu.window.borderWidth() : 0) - + new_y = (y() + (theme()->itemHeight() * i) + + ((m_title_vis) ? theme()->titleHeight() + menu.window.borderWidth() : 0) - ((item->submenu()->m_title_vis) ? - item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); + item->submenu()->theme()->titleHeight() + menu.window.borderWidth() : 0)); } if (m_alignment == ALIGNBOTTOM && @@ -745,7 +745,7 @@ int Menu::drawItem(FbDrawable &drawable, unsigned int index, if (! item) return 0; int sbl = index / menu.persub, i = index - (sbl * menu.persub); - int item_x = (sbl * menu.item_w), item_y = (i * theme().itemHeight()); + int item_x = (sbl * menu.item_w), item_y = (i * theme()->itemHeight()); if (exclusive_drawable) item_x = item_y = 0; @@ -753,7 +753,7 @@ int Menu::drawItem(FbDrawable &drawable, unsigned int index, item->draw(drawable, theme(), highlight, exclusive_drawable, true, // draw fg, draw bg item_x, item_y, - menu.item_w, theme().itemHeight()); + menu.item_w, theme()->itemHeight()); return item_y; } @@ -845,7 +845,7 @@ void Menu::buttonPressEvent(XButtonEvent &be) { if (be.window == menu.frame && menu.item_w != 0) { - int sbl = (be.x / menu.item_w), i = (be.y / theme().itemHeight()); + int sbl = (be.x / menu.item_w), i = (be.y / theme()->itemHeight()); int w = (sbl * menu.persub) + i; if (validIndex(w) && isItemSelectable(static_cast(w))) { @@ -885,14 +885,14 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { } else if (re.window == menu.frame) { - int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), - ix = sbl * menu.item_w, iy = i * theme().itemHeight(), + int sbl = (re.x / menu.item_w), i = (re.y / theme()->itemHeight()), + ix = sbl * menu.item_w, iy = i * theme()->itemHeight(), w = (sbl * menu.persub) + i; if (validIndex(w) && isItemSelectable(static_cast(w))) { if (m_active_index == w && isItemEnabled(w) && re.x > ix && re.x < (signed) (ix + menu.item_w) && - re.y > iy && re.y < (signed) (iy + theme().itemHeight())) { + re.y > iy && re.y < (signed) (iy + theme()->itemHeight())) { menuitems[w]->click(re.button, re.time, re.state); } else { int old = m_active_index; @@ -930,7 +930,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { } else if (!(me.state & Button1Mask) && me.window == menu.frame) { stopHide(); int sbl = (me.x / menu.item_w), - i = (me.y / theme().itemHeight()), + i = (me.y / theme()->itemHeight()), w = (sbl * menu.persub) + i; if (w == m_active_index || !validIndex(w)) @@ -960,11 +960,11 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { } - if (itmp->submenu() && theme().menuMode() == MenuTheme::DELAY_OPEN) { + if (itmp->submenu() && theme()->menuMode() == MenuTheme::DELAY_OPEN) { // start submenu open delay timeval timeout; timeout.tv_sec = 0; - timeout.tv_usec = theme().delayOpen() * 1000; // transformed to usec + timeout.tv_usec = theme()->delayOpen() * 1000; // transformed to usec m_submenu_timer.setTimeout(timeout); m_submenu_timer.start(); } else if (isItemSelectable(w)){ @@ -986,11 +986,11 @@ void Menu::exposeEvent(XExposeEvent &ee) { // first... we see in which sub level the expose starts... and how many // items down in that sublevel - int sbl = (ee.x / menu.item_w), id = (ee.y / theme().itemHeight()), + int sbl = (ee.x / menu.item_w), id = (ee.y / theme()->itemHeight()), // next... figure out how many sublevels over the redrawspans sbl_d = ((ee.x + ee.width) / menu.item_w), // then we see how many items down to redraw - id_d = ((ee.y + ee.height) / theme().itemHeight()); + id_d = ((ee.y + ee.height) / theme()->itemHeight()); if (id_d > menu.persub) id_d = menu.persub; // draw the sublevels and the number of items the exposure spans @@ -1093,7 +1093,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { void Menu::reconfigure() { - m_shape->setPlaces(theme().shapePlaces()); + m_shape->setPlaces(theme()->shapePlaces()); if (FbTk::Transparent::haveComposite()) { menu.window.setOpaque(alpha()); @@ -1107,12 +1107,12 @@ void Menu::reconfigure() { m_need_update = true; // redraw items - menu.window.setBorderColor(theme().borderColor()); - menu.title.setBorderColor(theme().borderColor()); - menu.frame.setBorderColor(theme().borderColor()); + menu.window.setBorderColor(theme()->borderColor()); + menu.title.setBorderColor(theme()->borderColor()); + menu.frame.setBorderColor(theme()->borderColor()); - menu.window.setBorderWidth(theme().borderWidth()); - menu.title.setBorderWidth(theme().borderWidth()); + menu.window.setBorderWidth(theme()->borderWidth()); + menu.title.setBorderWidth(theme()->borderWidth()); updateMenu(); } @@ -1145,7 +1145,7 @@ void Menu::closeMenu() { void Menu::startHide() { timeval timeout; timeout.tv_sec = 0; - timeout.tv_usec = theme().delayClose() * 1000; // transformed to usec + timeout.tv_usec = theme()->delayClose() * 1000; // transformed to usec m_hide_timer.setTimeout(timeout); m_hide_timer.start(); } @@ -1192,7 +1192,7 @@ void Menu::clearItem(int index, bool clear, int search_index) { return; int sbl = index / menu.persub, i = index - (sbl * menu.persub); - unsigned int item_w = menu.item_w, item_h = theme().itemHeight(); + unsigned int item_w = menu.item_w, item_h = theme()->itemHeight(); int item_x = (sbl * item_w), item_y = (i * item_h); bool highlight = (index == m_active_index && isItemSelectable(index)); @@ -1224,7 +1224,7 @@ void Menu::clearItem(int index, bool clear, int search_index) { // Area must have been cleared before calling highlight void Menu::highlightItem(int index) { int sbl = index / menu.persub, i = index - (sbl * menu.persub); - unsigned int item_w = menu.item_w, item_h = theme().itemHeight(); + unsigned int item_w = menu.item_w, item_h = theme()->itemHeight(); int item_x = (sbl * menu.item_w), item_y = (i * item_h); FbPixmap buffer = FbPixmap(menu.frame, item_w, item_h, menu.frame.depth()); @@ -1234,18 +1234,18 @@ void Menu::highlightItem(int index) { int pixmap_x = parent_rel ? item_x : 0, pixmap_y = parent_rel ? item_y : 0; if (pixmap) { buffer.copyArea(pixmap, - theme().hiliteGC().gc(), pixmap_x, pixmap_y, + theme()->hiliteGC().gc(), pixmap_x, pixmap_y, 0, 0, item_w, item_h); } else { - buffer.fillRectangle(theme().hiliteGC().gc(), + buffer.fillRectangle(theme()->hiliteGC().gc(), 0, 0, item_w, item_h); } menu.frame.updateTransparent(item_x, item_y, item_w, item_h, buffer.drawable(), true); drawItem(buffer, index, true, true); - menu.frame.copyArea(buffer.drawable(), theme().hiliteGC().gc(), + menu.frame.copyArea(buffer.drawable(), theme()->hiliteGC().gc(), 0, 0, item_x, item_y, item_w, item_h); @@ -1278,7 +1278,7 @@ void Menu::drawLine(int index, int size){ return; int sbl = index / menu.persub, i = index - (sbl * menu.persub); - int item_x = (sbl * menu.item_w), item_y = (i * theme().itemHeight()); + int item_x = (sbl * menu.item_w), item_y = (i * theme()->itemHeight()); FbTk::MenuItem *item = find(index); item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w); diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index e719053..2f37234 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -55,7 +55,7 @@ public: */ enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND }; - Menu(MenuTheme &tm, ImageControl &imgctrl); + Menu(FbTk::ThemeProxy &tm, ImageControl &imgctrl); virtual ~Menu(); /** @@ -151,8 +151,9 @@ public: bool isItemSelected(unsigned int index) const; bool isItemEnabled(unsigned int index) const; bool isItemSelectable(unsigned int index) const; - const MenuTheme &theme() const { return m_theme; } - unsigned char alpha() const { return theme().alpha(); } + FbTk::ThemeProxy &theme() { return m_theme; } + const FbTk::ThemeProxy &theme() const { return m_theme; } + unsigned char alpha() const { return theme()->alpha(); } static Menu *shownMenu() { return shown; } static Menu *focused() { return s_focused; } static void hideShownMenu(); @@ -198,7 +199,7 @@ private: void startHide(); void stopHide(); - MenuTheme &m_theme; + FbTk::ThemeProxy &m_theme; Menu *m_parent; ImageControl &m_image_ctrl; diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index ce3846a..1e8c8e9 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -42,26 +42,27 @@ void MenuItem::click(int button, int time, unsigned int mods) { } } -void MenuItem::drawLine(FbDrawable &draw, const MenuTheme &theme, size_t size, +void MenuItem::drawLine(FbDrawable &draw, + const FbTk::ThemeProxy &theme, size_t size, int text_x, int text_y, unsigned int width) const { - unsigned int height = theme.itemHeight(); - int bevelW = theme.bevelWidth(); + unsigned int height = theme->itemHeight(); + int bevelW = theme->bevelWidth(); - int font_top = (height - theme.frameFont().height())/2; - int underline_height = font_top + theme.frameFont().ascent() + 2; + int font_top = (height - theme->frameFont().height())/2; + int underline_height = font_top + theme->frameFont().ascent() + 2; int bottom = height - bevelW - 1; text_y += bottom > underline_height ? underline_height : bottom; - int text_w = theme.frameFont().textWidth(m_label.c_str(), m_label.size()); + int text_w = theme->frameFont().textWidth(m_label.c_str(), m_label.size()); // width of the searchstring size = size > m_label.length() ? m_label.length() : size; std::string search_string = m_label.substr(0,size); - int search_string_w = theme.frameFont().textWidth(search_string.c_str(), size); + int search_string_w = theme->frameFont().textWidth(search_string.c_str(), size); // pay attention to the text justification - switch(theme.frameFontJustify()) { + switch(theme->frameFontJustify()) { case FbTk::LEFT: text_x += bevelW + height + 1; break; @@ -75,13 +76,13 @@ void MenuItem::drawLine(FbDrawable &draw, const MenuTheme &theme, size_t size, // avoid drawing an ugly dot if (size != 0) - draw.drawLine(theme.frameUnderlineGC().gc(), + draw.drawLine(theme->frameUnderlineGC().gc(), text_x, text_y, text_x + search_string_w, text_y); } void MenuItem::draw(FbDrawable &draw, - const MenuTheme &theme, + const FbTk::ThemeProxy &theme, bool highlight, bool draw_foreground, bool draw_background, int x, int y, unsigned int width, unsigned int height) const { @@ -101,16 +102,16 @@ void MenuItem::draw(FbDrawable &draw, tmp_mask.copy(icon()->mask()); // scale pixmap to right size - if (height - 2*theme.bevelWidth() != tmp_pixmap.height()) { - unsigned int scale_size = height - 2*theme.bevelWidth(); + if (height - 2*theme->bevelWidth() != tmp_pixmap.height()) { + unsigned int scale_size = height - 2*theme->bevelWidth(); tmp_pixmap.scale(scale_size, scale_size); tmp_mask.scale(scale_size, scale_size); } if (tmp_pixmap.drawable() != 0) { - GC gc = theme.frameTextGC().gc(); - int icon_x = x + theme.bevelWidth(); - int icon_y = y + theme.bevelWidth(); + GC gc = theme->frameTextGC().gc(); + int icon_x = x + theme->bevelWidth(); + int icon_y = y + theme->bevelWidth(); // enable clip mask XSetClipMask(disp, gc, tmp_mask.drawable()); XSetClipOrigin(disp, gc, icon_x, icon_y); @@ -126,9 +127,9 @@ void MenuItem::draw(FbDrawable &draw, XGetGCValues(draw.display(), gc, GCForeground|GCBackground, &backup); XSetForeground(draw.display(), gc, - Color("black", theme.screenNum()).pixel()); + Color("black", theme->screenNum()).pixel()); XSetBackground(draw.display(), gc, - Color("white", theme.screenNum()).pixel()); + Color("white", theme->screenNum()).pixel()); XCopyPlane(draw.display(), tmp_pixmap.drawable(), draw.drawable(), gc, 0, 0, tmp_pixmap.width(), tmp_pixmap.height(), @@ -149,46 +150,46 @@ void MenuItem::draw(FbDrawable &draw, // text is background if (draw_background) { const GContext &tgc = - (highlight ? theme.hiliteTextGC() : - (isEnabled() ? theme.frameTextGC() : theme.disableTextGC() ) ); + (highlight ? theme->hiliteTextGC() : + (isEnabled() ? theme->frameTextGC() : theme->disableTextGC() ) ); // // Text // int text_y = y, text_x = x; - int text_w = theme.frameFont().textWidth(label().c_str(), label().size()); + int text_w = theme->frameFont().textWidth(label().c_str(), label().size()); - int height_offset = theme.itemHeight() - (theme.frameFont().height() + 2*theme.bevelWidth()); - text_y = y + theme.bevelWidth() + theme.frameFont().ascent() + height_offset/2; + int height_offset = theme->itemHeight() - (theme->frameFont().height() + 2*theme->bevelWidth()); + text_y = y + theme->bevelWidth() + theme->frameFont().ascent() + height_offset/2; - switch(theme.frameFontJustify()) { + switch(theme->frameFontJustify()) { case FbTk::LEFT: - text_x = x + theme.bevelWidth() + height + 1; + text_x = x + theme->bevelWidth() + height + 1; break; case FbTk::RIGHT: - text_x = x + width - (height + theme.bevelWidth() + text_w); + text_x = x + width - (height + theme->bevelWidth() + text_w); break; default: //center text_x = x + ((width + 1 - text_w) / 2); break; } - theme.frameFont().drawText(draw, // drawable - theme.screenNum(), + theme->frameFont().drawText(draw, // drawable + theme->screenNum(), tgc.gc(), label().c_str(), label().size(), // text string and lenght text_x, text_y); // position } - GC gc = (highlight) ? theme.hiliteTextGC().gc() : - theme.frameTextGC().gc(); + GC gc = (highlight) ? theme->hiliteTextGC().gc() : + theme->frameTextGC().gc(); int sel_x = x; int sel_y = y; - unsigned int item_pm_height = theme.itemHeight(); + unsigned int item_pm_height = theme->itemHeight(); - if (theme.bulletPos() == FbTk::RIGHT) - sel_x += width - height - theme.bevelWidth(); + if (theme->bulletPos() == FbTk::RIGHT) + sel_x += width - height - theme->bevelWidth(); // selected pixmap is foreground if (draw_foreground && isToggleItem()) { @@ -199,15 +200,15 @@ void MenuItem::draw(FbDrawable &draw, const PixmapWithMask *pm = 0; if (isSelected()) { - if (highlight && theme.highlightSelectedPixmap().pixmap().drawable() != 0) - pm = &theme.highlightSelectedPixmap(); + if (highlight && theme->highlightSelectedPixmap().pixmap().drawable() != 0) + pm = &theme->highlightSelectedPixmap(); else - pm = &theme.selectedPixmap(); + pm = &theme->selectedPixmap(); } else { - if (highlight && theme.highlightUnselectedPixmap().pixmap().drawable() != 0) - pm = &theme.highlightUnselectedPixmap(); + if (highlight && theme->highlightUnselectedPixmap().pixmap().drawable() != 0) + pm = &theme->highlightUnselectedPixmap(); else - pm = &theme.unselectedPixmap(); + pm = &theme->unselectedPixmap(); } if (pm != 0 && pm->pixmap().drawable() != 0) { unsigned int selw = pm->width(); @@ -231,7 +232,7 @@ void MenuItem::draw(FbDrawable &draw, // disable clip mask XSetClipMask(disp, gc, None); } else if (isSelected()) { - draw.fillRectangle(theme.hiliteGC().gc(), + draw.fillRectangle(theme->hiliteGC().gc(), sel_x+item_pm_height/4, sel_y+item_pm_height/4, item_pm_height/2, item_pm_height/2); } } @@ -243,10 +244,10 @@ void MenuItem::draw(FbDrawable &draw, const PixmapWithMask *pm = 0; - if (highlight && theme.highlightBulletPixmap().pixmap().drawable() != 0) - pm = &theme.highlightBulletPixmap(); + if (highlight && theme->highlightBulletPixmap().pixmap().drawable() != 0) + pm = &theme->highlightBulletPixmap(); else - pm = &theme.bulletPixmap(); + pm = &theme->bulletPixmap(); if (pm && pm->pixmap().drawable() != 0) { unsigned int selw = pm->width(); @@ -273,13 +274,13 @@ void MenuItem::draw(FbDrawable &draw, } else { unsigned int half_w = item_pm_height / 2, quarter_w = item_pm_height / 4; - switch (theme.bullet()) { + switch (theme->bullet()) { case MenuTheme::SQUARE: draw.drawRectangle(gc, sel_x+quarter_w, y+quarter_w, half_w, half_w); break; case MenuTheme::TRIANGLE: - draw.drawTriangle(gc, ((theme.bulletPos() == FbTk::RIGHT)? + draw.drawTriangle(gc, ((theme->bulletPos() == FbTk::RIGHT)? FbTk::FbDrawable::RIGHT: FbTk::FbDrawable::LEFT), sel_x, sel_y, @@ -327,23 +328,23 @@ void MenuItem::setIcon(const std::string &filename, int screen_num) { screen_num)); } -unsigned int MenuItem::height(const MenuTheme &theme) const { - return std::max(theme.frameFont().height() + 2*theme.bevelWidth(), theme.itemHeight()); +unsigned int MenuItem::height(const FbTk::ThemeProxy &theme) const { + return std::max(theme->frameFont().height() + 2*theme->bevelWidth(), theme->itemHeight()); } -unsigned int MenuItem::width(const MenuTheme &theme) const { +unsigned int MenuItem::width(const FbTk::ThemeProxy &theme) const { // textwidth + bevel width on each side of the text const unsigned int icon_width = height(theme); - const unsigned int normal = theme.frameFont().textWidth(label(), label().size()) + - 2 * (theme.bevelWidth() + icon_width); + const unsigned int normal = theme->frameFont().textWidth(label(), label().size()) + + 2 * (theme->bevelWidth() + icon_width); return m_icon.get() == 0 ? normal : normal + icon_width; } -void MenuItem::updateTheme(const MenuTheme &theme) { +void MenuItem::updateTheme(const FbTk::ThemeProxy &theme) { if (m_icon.get() == 0) return; - m_icon->pixmap.reset(Image::load(m_icon->filename.c_str(), theme.screenNum())); + m_icon->pixmap.reset(Image::load(m_icon->filename.c_str(), theme->screenNum())); } diff --git a/src/FbTk/MenuItem.hh b/src/FbTk/MenuItem.hh index d858340..8c73036 100644 --- a/src/FbTk/MenuItem.hh +++ b/src/FbTk/MenuItem.hh @@ -35,6 +35,7 @@ namespace FbTk { class Menu; class MenuTheme; class FbDrawable; +template class ThemeProxy; /// An interface for a menu item in Menu class MenuItem : public FbTk::ITypeAheadable { @@ -116,21 +117,21 @@ public: virtual int getIndex() { return m_index; } const std::string &iTypeString() const { return m_label; } virtual void drawLine(FbDrawable &draw, - const MenuTheme &theme, + const FbTk::ThemeProxy &theme, size_t size, int text_x, int text_y, unsigned int width) const; - virtual unsigned int width(const MenuTheme &theme) const; - virtual unsigned int height(const MenuTheme &theme) const; + virtual unsigned int width(const FbTk::ThemeProxy &theme) const; + virtual unsigned int height(const FbTk::ThemeProxy &theme) const; virtual void draw(FbDrawable &drawable, - const MenuTheme &theme, + const FbTk::ThemeProxy &theme, bool highlight, // "foreground" is the transient bits - more likely to change bool draw_foreground, bool draw_background, int x, int y, unsigned int width, unsigned int height) const; - virtual void updateTheme(const MenuTheme &theme); + virtual void updateTheme(const FbTk::ThemeProxy &theme); /** Called when the item was clicked with a specific button @param button the button number diff --git a/src/FbTk/MenuSeparator.cc b/src/FbTk/MenuSeparator.cc index 928fe77..ea73a0c 100644 --- a/src/FbTk/MenuSeparator.cc +++ b/src/FbTk/MenuSeparator.cc @@ -29,7 +29,7 @@ namespace FbTk { void MenuSeparator::draw(FbDrawable &drawable, - const MenuTheme &theme, + const FbTk::ThemeProxy &theme, bool highlight, bool draw_foreground, bool draw_background, int x, int y, unsigned int width, unsigned int height) const { @@ -37,13 +37,13 @@ void MenuSeparator::draw(FbDrawable &drawable, if (draw_background) { const GContext &tgc = // its a separator, it shouldn't be highlighted! or shown as disabled -// (highlight ? theme.hiliteTextGC() : -// (isEnabled() ? theme.frameTextGC() : theme.disableTextGC() ) ); - theme.frameTextGC(); +// (highlight ? theme->hiliteTextGC() : +// (isEnabled() ? theme->frameTextGC() : theme->disableTextGC() ) ); + theme->frameTextGC(); drawable.drawRectangle(tgc.gc(), - x + theme.bevelWidth() + height + 1, y + height / 2, - width - ((theme.bevelWidth() + height) * 2) - 1, 0); + x + theme->bevelWidth() + height + 1, y + height / 2, + width - ((theme->bevelWidth() + height) * 2) - 1, 0); } } diff --git a/src/FbTk/MenuSeparator.hh b/src/FbTk/MenuSeparator.hh index fd4ddbd..a2b0af7 100644 --- a/src/FbTk/MenuSeparator.hh +++ b/src/FbTk/MenuSeparator.hh @@ -30,7 +30,7 @@ namespace FbTk { class MenuSeparator: public MenuItem { public: virtual void draw(FbDrawable &drawable, - const MenuTheme &theme, + const FbTk::ThemeProxy &theme, bool highlight, bool draw_foreground, bool draw_background, int x, int y, unsigned int width, unsigned int height) const; diff --git a/src/FbTk/MenuTheme.hh b/src/FbTk/MenuTheme.hh index 017e4f3..273104c 100644 --- a/src/FbTk/MenuTheme.hh +++ b/src/FbTk/MenuTheme.hh @@ -143,8 +143,8 @@ public: 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; } + virtual MenuTheme &operator *() { return *this; } + virtual const MenuTheme &operator *() const { return *this; } private: ThemeItem t_text, f_text, h_text, d_text, u_text; diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh index 1ae3387..c331ba5 100644 --- a/src/FbTk/Theme.hh +++ b/src/FbTk/Theme.hh @@ -127,8 +127,10 @@ public: virtual Subject &reconfigSig() = 0; virtual const Subject &reconfigSig() const = 0; - virtual BaseTheme *operator ->() = 0; - virtual const BaseTheme *operator ->() const = 0; + virtual BaseTheme &operator *() = 0; + virtual const BaseTheme &operator *() const = 0; + virtual BaseTheme *operator ->() { return &(**this); } + virtual const BaseTheme *operator ->() const { return &(**this); } }; /// Singleton theme manager diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 9056d54..36bf251 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -39,14 +39,16 @@ using std::mem_fun; using std::string; -FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, +FbWinFrame::FbWinFrame(BScreen &screen, + FbTk::ThemeProxy &theme, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, int x, int y, unsigned int width, unsigned int height): m_screen(screen), m_theme(theme), m_imagectrl(imgctrl), - m_window(theme.screenNum(), x, y, width, height, + m_window(theme->screenNum(), x, y, width, height, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask, true), @@ -56,7 +58,7 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask), m_tab_container(m_titlebar), - m_label(m_titlebar, m_theme.font(), ""), + m_label(m_titlebar, m_theme->font(), ""), m_handle(m_window, 0, 0, 100, 5, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | @@ -88,9 +90,9 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr m_button_size(1), m_height_before_shade(1), m_shaded(false), - m_focused_alpha(AlphaAcc(theme, &FbWinFrameTheme::focusedAlpha)), - m_unfocused_alpha(AlphaAcc(theme, &FbWinFrameTheme::unfocusedAlpha)), - m_shape(m_window, theme.shapePlace()), + m_focused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::focusedAlpha)), + m_unfocused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::unfocusedAlpha)), + m_shape(m_window, theme->shapePlace()), m_disable_themeshape(false) { init(); } @@ -117,7 +119,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { if (tabmode == EXTERNAL) { m_label.show(); m_tab_container.setBorderWidth(m_window.borderWidth()); - m_tab_container.setBorderColor(theme().border(m_focused).color()); + m_tab_container.setBorderColor(theme()->border(m_focused).color()); m_tab_container.setEventMask( ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | @@ -484,10 +486,10 @@ void FbWinFrame::setFocus(bool newvalue) { } if (m_decoration_mask & DECORM_BORDER && - (theme().border(true).width() != theme().border(false).width() || - theme().border(true).color().pixel() != - theme().border(false).color().pixel())) - setBorderWidth(theme().border(newvalue).width()); + (theme()->border(true).width() != theme()->border(false).width() || + theme()->border(true).color().pixel() != + theme()->border(false).color().pixel())) + setBorderWidth(theme()->border(newvalue).width()); applyAll(); clearAll(); @@ -562,7 +564,7 @@ void FbWinFrame::removeAllButtons() { } IconButton *FbWinFrame::createTab(Focusable &client) { - IconButton *button = new IconButton(m_tab_container, theme().iconbarTheme(), + IconButton *button = new IconButton(m_tab_container, theme()->iconbarTheme(), client); button->show(); @@ -742,7 +744,7 @@ bool FbWinFrame::hideHandle() { } bool FbWinFrame::showHandle() { - if (m_use_handle || theme().handleWidth() == 0) + if (m_use_handle || theme()->handleWidth() == 0) return false; m_use_handle = true; @@ -870,19 +872,19 @@ void FbWinFrame::reconfigure() { // negate gravity gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); - m_bevel = theme().bevelWidth(); + m_bevel = theme()->bevelWidth(); // reconfigure can't set borderwidth, as it doesn't know // if it's meant to be borderless or not unsigned int orig_handle_h = handle().height(); - if (m_use_handle && orig_handle_h != theme().handleWidth()) + if (m_use_handle && orig_handle_h != theme()->handleWidth()) m_window.resize(m_window.width(), m_window.height() - - orig_handle_h + theme().handleWidth()); + orig_handle_h + theme()->handleWidth()); handle().resize(handle().width(), - theme().handleWidth()); + theme()->handleWidth()); gripLeft().resize(buttonHeight(), - theme().handleWidth()); + theme()->handleWidth()); gripRight().resize(gripLeft().width(), gripLeft().height()); @@ -988,7 +990,7 @@ void FbWinFrame::reconfigure() { if (m_disable_themeshape) m_shape.setPlaces(FbTk::Shape::NONE); else - m_shape.setPlaces(theme().shapePlace()); + m_shape.setPlaces(theme()->shapePlace()); m_shape.setShapeOffsets(0, titlebarHeight()); @@ -1001,7 +1003,7 @@ void FbWinFrame::setUseShape(bool value) { if (m_disable_themeshape) m_shape.setPlaces(FbTk::Shape::NONE); else - m_shape.setPlaces(theme().shapePlace()); + m_shape.setPlaces(theme()->shapePlace()); } @@ -1038,10 +1040,10 @@ void FbWinFrame::reconfigureTitlebar() { int orig_height = m_titlebar.height(); // resize titlebar to window size with font height - int title_height = m_theme.font().height() == 0 ? 16 : - m_theme.font().height() + m_bevel*2 + 2; - if (m_theme.titleHeight() != 0) - title_height = m_theme.titleHeight(); + int title_height = theme()->font().height() == 0 ? 16 : + theme()->font().height() + m_bevel*2 + 2; + if (theme()->titleHeight() != 0) + title_height = theme()->titleHeight(); // if the titlebar grows in size, make sure the whole window does too if (orig_height != title_height) @@ -1128,21 +1130,21 @@ void FbWinFrame::renderTitlebar() { } // render pixmaps - render(m_theme.titleFocusTexture(), m_title_focused_color, + render(theme()->titleFocusTexture(), m_title_focused_color, m_title_focused_pm, m_titlebar.width(), m_titlebar.height()); - render(m_theme.titleUnfocusTexture(), m_title_unfocused_color, + render(theme()->titleUnfocusTexture(), m_title_unfocused_color, m_title_unfocused_pm, m_titlebar.width(), m_titlebar.height()); //!! TODO: don't render label if internal tabs - render(m_theme.iconbarTheme().focusedTexture(), m_label_focused_color, + render(theme()->iconbarTheme()->focusedTexture(), m_label_focused_color, m_label_focused_pm, m_label.width(), m_label.height()); - render(m_theme.iconbarTheme().unfocusedTexture(), m_label_unfocused_color, + render(theme()->iconbarTheme()->unfocusedTexture(), m_label_unfocused_color, m_label_unfocused_pm, m_label.width(), m_label.height()); @@ -1154,13 +1156,13 @@ void FbWinFrame::renderTabContainer() { return; } - const FbTk::Texture *tc_focused = &m_theme.iconbarTheme().focusedTexture(); - const FbTk::Texture *tc_unfocused = &m_theme.iconbarTheme().unfocusedTexture(); + const FbTk::Texture *tc_focused = &theme()->iconbarTheme()->focusedTexture(); + const FbTk::Texture *tc_unfocused = &theme()->iconbarTheme()->unfocusedTexture(); if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) - tc_focused = &m_theme.titleFocusTexture(); + tc_focused = &theme()->titleFocusTexture(); if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE) - tc_unfocused = &m_theme.titleUnfocusTexture(); + tc_unfocused = &theme()->titleUnfocusTexture(); render(*tc_focused, m_tabcontainer_focused_color, m_tabcontainer_focused_pm, @@ -1190,11 +1192,11 @@ void FbWinFrame::applyTitlebar() { if (m_tabmode != INTERNAL) { m_label.setGC(m_focused ? - theme().iconbarTheme().focusedText().textGC() : - theme().iconbarTheme().unfocusedText().textGC()); + theme()->iconbarTheme()->focusedText().textGC() : + theme()->iconbarTheme()->unfocusedText().textGC()); m_label.setJustify(m_focused ? - theme().iconbarTheme().focusedText().justify() : - theme().iconbarTheme().unfocusedText().justify()); + theme()->iconbarTheme()->focusedText().justify() : + theme()->iconbarTheme()->unfocusedText().justify()); if (label_pm != 0) m_label.setBackgroundPixmap(label_pm); @@ -1220,18 +1222,18 @@ void FbWinFrame::renderHandles() { return; } - render(m_theme.handleFocusTexture(), m_handle_focused_color, + render(theme()->handleFocusTexture(), m_handle_focused_color, m_handle_focused_pm, m_handle.width(), m_handle.height()); - render(m_theme.handleUnfocusTexture(), m_handle_unfocused_color, + render(theme()->handleUnfocusTexture(), m_handle_unfocused_color, m_handle_unfocused_pm, m_handle.width(), m_handle.height()); - render(m_theme.gripFocusTexture(), m_grip_focused_color, m_grip_focused_pm, + render(theme()->gripFocusTexture(), m_grip_focused_color, m_grip_focused_pm, m_grip_left.width(), m_grip_left.height()); - render(m_theme.gripUnfocusTexture(), m_grip_unfocused_color, + render(theme()->gripUnfocusTexture(), m_grip_unfocused_color, m_grip_unfocused_pm, m_grip_left.width(), m_grip_left.height()); @@ -1286,15 +1288,15 @@ void FbWinFrame::renderButtons() { return; } - render(m_theme.buttonFocusTexture(), m_button_color, + render(theme()->buttonFocusTexture(), m_button_color, m_button_pm, m_button_size, m_button_size); - render(m_theme.buttonUnfocusTexture(), m_button_unfocused_color, + render(theme()->buttonUnfocusTexture(), m_button_unfocused_color, m_button_unfocused_pm, m_button_size, m_button_size); - render(m_theme.buttonPressedTexture(), m_button_pressed_color, + render(theme()->buttonPressedTexture(), m_button_pressed_color, m_button_pressed_pm, m_button_size, m_button_size); } @@ -1310,7 +1312,7 @@ void FbWinFrame::applyButtons() { void FbWinFrame::init() { - if (theme().handleWidth() == 0) + if (theme()->handleWidth() == 0) m_use_handle = false; m_disable_themeshape = false; @@ -1357,7 +1359,7 @@ void FbWinFrame::applyButton(FbTk::Button &btn) { if (focused()) { // focused btn.setAlpha(getAlpha(true)); - btn.setGC(m_theme.buttonPicFocusGC()); + btn.setGC(theme()->buttonPicFocusGC()); if (m_button_pm) btn.setBackgroundPixmap(m_button_pm); else @@ -1365,7 +1367,7 @@ void FbWinFrame::applyButton(FbTk::Button &btn) { } else { // unfocused btn.setAlpha(getAlpha(false)); - btn.setGC(m_theme.buttonPicUnfocusGC()); + btn.setGC(theme()->buttonPicUnfocusGC()); if (m_button_unfocused_pm) btn.setBackgroundPixmap(m_button_unfocused_pm); else @@ -1463,21 +1465,21 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { bw_changes += static_cast(border_width - handle().borderWidth()); window().setBorderWidth(border_width); - window().setBorderColor(theme().border(m_focused).color()); + window().setBorderColor(theme()->border(m_focused).color()); setTabMode(NOTSET); titlebar().setBorderWidth(border_width); - titlebar().setBorderColor(theme().border(m_focused).color()); + titlebar().setBorderColor(theme()->border(m_focused).color()); handle().setBorderWidth(border_width); - handle().setBorderColor(theme().border(m_focused).color()); + handle().setBorderColor(theme()->border(m_focused).color()); gripLeft().setBorderWidth(border_width); - gripLeft().setBorderColor(theme().border(m_focused).color()); + gripLeft().setBorderColor(theme()->border(m_focused).color()); gripRight().setBorderWidth(border_width); - gripRight().setBorderColor(theme().border(m_focused).color()); + gripRight().setBorderColor(theme()->border(m_focused).color()); if (bw_changes != 0) resize(width(), height() + bw_changes); diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 5d81dba..82c33dc 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -46,6 +46,7 @@ class ImageControl; class Command; class Texture; class XLayer; +template class ThemeProxy; } /// holds a window frame with a client window @@ -95,7 +96,8 @@ public: }; /// create a top level window - FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, + FbWinFrame(BScreen &screen, FbTk::ThemeProxy &theme, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, int x, int y, unsigned int width, unsigned int height); @@ -254,7 +256,7 @@ public: const IconButton *currentLabel() const { return m_current_label; } bool focused() const { return m_focused; } bool isShaded() const { return m_shaded; } - FbWinFrameTheme &theme() const { return m_theme; } + FbTk::ThemeProxy &theme() const { return m_theme; } /// @return titlebar height unsigned int titlebarHeight() const { return (m_use_titlebar?m_titlebar.height()+m_window.borderWidth():0); } unsigned int handleHeight() const { return (m_use_handle?m_handle.height()+m_window.borderWidth():0); } @@ -313,7 +315,7 @@ private: BScreen &m_screen; - FbWinFrameTheme &m_theme; ///< theme to be used + FbTk::ThemeProxy &m_theme; ///< theme to be used FbTk::ImageControl &m_imagectrl; ///< Image control for rendering /** @name windows diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index e72d6f5..66448b6 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -97,8 +97,8 @@ public: 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; } + virtual FbWinFrameTheme &operator *() { return *this; } + virtual const FbWinFrameTheme &operator *() const { return *this; } private: FbTk::ThemeItem m_title_focus, m_title_unfocus; diff --git a/src/GenericTool.cc b/src/GenericTool.cc index 92f8e32..67d737f 100644 --- a/src/GenericTool.cc +++ b/src/GenericTool.cc @@ -26,7 +26,7 @@ #include GenericTool::GenericTool(FbTk::FbWindow *new_window, ToolbarItem::Type type, - ToolTheme &theme): + FbTk::ThemeProxy &theme): ToolbarItem(type), m_window(new_window), m_theme(theme) { diff --git a/src/GenericTool.hh b/src/GenericTool.hh index 8f565a5..b64edcf 100644 --- a/src/GenericTool.hh +++ b/src/GenericTool.hh @@ -33,12 +33,14 @@ class ToolTheme; namespace FbTk { class FbWindow; +template class ThemeProxy; } /// helper class for simple tools, i.e buttons etc class GenericTool: public ToolbarItem, public FbTk::Observer, private FbTk::NotCopyable { public: - GenericTool(FbTk::FbWindow *new_window, ToolbarItem::Type type, ToolTheme &theme); + GenericTool(FbTk::FbWindow *new_window, ToolbarItem::Type type, + FbTk::ThemeProxy &theme); virtual ~GenericTool(); void move(int x, int y); void resize(unsigned int x, unsigned int y); @@ -53,7 +55,7 @@ public: void parentMoved(); - const ToolTheme &theme() const { return m_theme; } + const FbTk::ThemeProxy &theme() const { return m_theme; } FbTk::FbWindow &window() { return *m_window; } const FbTk::FbWindow &window() const { return *m_window; } @@ -64,7 +66,7 @@ private: void update(FbTk::Subject *subj); std::auto_ptr m_window; - ToolTheme &m_theme; + FbTk::ThemeProxy &m_theme; }; #endif // GENERICTOOL_HH diff --git a/src/IconButton.cc b/src/IconButton.cc index 456312b..d64e23c 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -46,9 +46,9 @@ #endif // SHAPE -IconButton::IconButton(const FbTk::FbWindow &parent, IconbarTheme &theme, - Focusable &win): - FbTk::TextButton(parent, theme.focusedText().font(), win.title()), +IconButton::IconButton(const FbTk::FbWindow &parent, + FbTk::ThemeProxy &theme, Focusable &win): + FbTk::TextButton(parent, theme->focusedText().font(), win.title()), m_win(win), m_icon_window(*this, 1, 1, 1, 1, ExposureMask | ButtonPressMask | ButtonReleaseMask), @@ -118,16 +118,16 @@ void IconButton::setPixmap(bool use) { void IconButton::reconfigTheme() { - if (m_theme.focusedTexture().usePixmap()) + if (m_theme->focusedTexture().usePixmap()) m_focused_pm.reset(m_win.screen().imageControl().renderImage( - width(), height(), m_theme.focusedTexture(), + width(), height(), m_theme->focusedTexture(), orientation())); else m_focused_pm.reset(0); - if (m_theme.unfocusedTexture().usePixmap()) + if (m_theme->unfocusedTexture().usePixmap()) m_unfocused_pm.reset(m_win.screen().imageControl().renderImage( - width(), height(), m_theme.unfocusedTexture(), + width(), height(), m_theme->unfocusedTexture(), orientation())); else m_unfocused_pm.reset(0); @@ -138,25 +138,25 @@ void IconButton::reconfigTheme() { if (m_focused_pm != 0) setBackgroundPixmap(m_focused_pm); else - setBackgroundColor(m_theme.focusedTexture().color()); + setBackgroundColor(m_theme->focusedTexture().color()); - setGC(m_theme.focusedText().textGC()); - setFont(m_theme.focusedText().font()); - setJustify(m_theme.focusedText().justify()); - setBorderWidth(m_theme.focusedBorder().width()); - setBorderColor(m_theme.focusedBorder().color()); + setGC(m_theme->focusedText().textGC()); + setFont(m_theme->focusedText().font()); + setJustify(m_theme->focusedText().justify()); + setBorderWidth(m_theme->focusedBorder().width()); + setBorderColor(m_theme->focusedBorder().color()); } else { if (m_unfocused_pm != 0) setBackgroundPixmap(m_unfocused_pm); else - setBackgroundColor(m_theme.unfocusedTexture().color()); + setBackgroundColor(m_theme->unfocusedTexture().color()); - setGC(m_theme.unfocusedText().textGC()); - setFont(m_theme.unfocusedText().font()); - setJustify(m_theme.unfocusedText().justify()); - setBorderWidth(m_theme.unfocusedBorder().width()); - setBorderColor(m_theme.unfocusedBorder().color()); + setGC(m_theme->unfocusedText().textGC()); + setFont(m_theme->unfocusedText().font()); + setJustify(m_theme->unfocusedText().justify()); + setBorderWidth(m_theme->unfocusedBorder().width()); + setBorderColor(m_theme->unfocusedBorder().color()); } diff --git a/src/IconButton.hh b/src/IconButton.hh index fdec547..a0cd82e 100644 --- a/src/IconButton.hh +++ b/src/IconButton.hh @@ -31,10 +31,14 @@ class Focusable; class IconbarTheme; +namespace FbTk { +template class ThemeProxy; +} + class IconButton: public FbTk::TextButton, public FbTk::Observer { public: - IconButton(const FbTk::FbWindow &parent, IconbarTheme &theme, - Focusable &window); + IconButton(const FbTk::FbWindow &parent, + FbTk::ThemeProxy &theme, Focusable &window); virtual ~IconButton(); void exposeEvent(XExposeEvent &event); @@ -67,7 +71,7 @@ private: FbTk::FbPixmap m_icon_mask; bool m_use_pixmap; - IconbarTheme &m_theme; + FbTk::ThemeProxy &m_theme; // cached pixmaps FbTk::CachedPixmap m_focused_pm, m_unfocused_pm; }; diff --git a/src/IconbarTheme.hh b/src/IconbarTheme.hh index 3a56eb8..4dc5f32 100644 --- a/src/IconbarTheme.hh +++ b/src/IconbarTheme.hh @@ -50,8 +50,8 @@ public: 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; } + virtual IconbarTheme &operator *() { return *this; } + virtual const IconbarTheme &operator *() const { return *this; } private: FbTk::ThemeItem m_focused_texture, m_unfocused_texture, m_empty_texture; diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 76f6035..3984b52 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -252,7 +252,8 @@ private: }; // end anonymous namespace -IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, +IconbarTool::IconbarTool(const FbTk::FbWindow &parent, + FbTk::ThemeProxy &theme, BScreen &screen, FbTk::Menu &menu): ToolbarItem(ToolbarItem::RELATIVE), m_screen(screen), @@ -467,7 +468,7 @@ void IconbarTool::reset() { } void IconbarTool::updateSizing() { - m_icon_container.setBorderWidth(m_theme.border().width()); + m_icon_container.setBorderWidth(m_theme->border().width()); IconMap::iterator icon_it = m_icons.begin(); const IconMap::iterator icon_it_end = m_icons.end(); @@ -488,14 +489,14 @@ void IconbarTool::renderTheme() { updateSizing(); // if we dont have any icons then we should render empty texture - if (!m_theme.emptyTexture().usePixmap()) { + if (!m_theme->emptyTexture().usePixmap()) { m_empty_pm.reset( 0 ); - m_icon_container.setBackgroundColor(m_theme.emptyTexture().color()); + m_icon_container.setBackgroundColor(m_theme->emptyTexture().color()); } else { m_empty_pm.reset(m_screen.imageControl(). renderImage(m_icon_container.width(), m_icon_container.height(), - m_theme.emptyTexture(), orientation())); + m_theme->emptyTexture(), orientation())); m_icon_container.setBackgroundPixmap(m_empty_pm); } diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 4ff962d..36609cc 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -43,7 +43,8 @@ class IconbarTool: public ToolbarItem, public FbTk::Observer { public: typedef std::map IconMap; - IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, + IconbarTool(const FbTk::FbWindow &parent, + FbTk::ThemeProxy &theme, BScreen &screen, FbTk::Menu &menu); ~IconbarTool(); @@ -95,7 +96,7 @@ private: BScreen &m_screen; FbTk::Container m_icon_container; - IconbarTheme &m_theme; + FbTk::ThemeProxy &m_theme; FbTk::CachedPixmap m_empty_pm; ///< pixmap for empty container diff --git a/src/LayerMenu.cc b/src/LayerMenu.cc index 40ee09f..1a52f04 100644 --- a/src/LayerMenu.cc +++ b/src/LayerMenu.cc @@ -28,7 +28,8 @@ #include "FbTk/SimpleCommand.hh" #include "FbTk/I18n.hh" -LayerMenu::LayerMenu(FbTk::MenuTheme &tm, FbTk::ImageControl &imgctrl, +LayerMenu::LayerMenu(FbTk::ThemeProxy &tm, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, LayerObject *object, bool save_rc): ToggleMenu(tm, imgctrl, layer) { _FB_USES_NLS; diff --git a/src/LayerMenu.hh b/src/LayerMenu.hh index 4113137..68b8dec 100644 --- a/src/LayerMenu.hh +++ b/src/LayerMenu.hh @@ -62,7 +62,8 @@ private: /// Create a layer menu inside from the given menu class LayerMenu : public ToggleMenu { public: - LayerMenu(class FbTk::MenuTheme &tm, FbTk::ImageControl &imgctrl, + LayerMenu(FbTk::ThemeProxy &tm, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, LayerObject *item, bool save_rc); void show(); }; diff --git a/src/RootTheme.hh b/src/RootTheme.hh index 1e37cfe..5ae5165 100644 --- a/src/RootTheme.hh +++ b/src/RootTheme.hh @@ -57,8 +57,8 @@ public: 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; } + virtual RootTheme &operator *() { return *this; } + virtual const RootTheme &operator *() const { return *this; } private: BackgroundItem *m_background;///< background image/texture diff --git a/src/Screen.cc b/src/Screen.cc index 7deab8b..5edbcaf 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -34,12 +34,6 @@ #include "FocusControl.hh" #include "ScreenPlacement.hh" -// themes -#include "FbWinFrameTheme.hh" -#include "RootTheme.hh" -#include "WinButtonTheme.hh" -#include "SlitTheme.hh" - // menu items #include "FbTk/BoolMenuItem.hh" #include "FbTk/IntMenuItem.hh" @@ -451,7 +445,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, imageControl().setDither(*resource.image_dither); - winFrameTheme().reconfigSig().attach(this);// for geom window + winFrameTheme()->reconfigSig().attach(this);// for geom window geom_visible = false; @@ -1799,13 +1793,13 @@ void BScreen::showPosition(int x, int y) { m_pos_window.clear(); - winFrameTheme().font().drawText(m_pos_window, + winFrameTheme()->font().drawText(m_pos_window, screenNumber(), - winFrameTheme().iconbarTheme().focusedText().textGC(), + winFrameTheme()->iconbarTheme().focusedText().textGC(), label, strlen(label), - winFrameTheme().bevelWidth(), - winFrameTheme().bevelWidth() + - winFrameTheme().font().ascent()); + winFrameTheme()->bevelWidth(), + winFrameTheme()->bevelWidth() + + winFrameTheme()->font().ascent()); } @@ -1851,13 +1845,13 @@ void BScreen::showGeometry(int gx, int gy) { m_geom_window.clear(); //!! TODO: geom window again?! repeated - winFrameTheme().font().drawText(m_geom_window, + winFrameTheme()->font().drawText(m_geom_window, screenNumber(), - winFrameTheme().iconbarTheme().focusedText().textGC(), + winFrameTheme()->iconbarTheme().focusedText().textGC(), label, strlen(label), - winFrameTheme().bevelWidth(), - winFrameTheme().bevelWidth() + - winFrameTheme().font().ascent()); + winFrameTheme()->bevelWidth(), + winFrameTheme()->bevelWidth() + + winFrameTheme()->font().ascent()); } @@ -1914,32 +1908,32 @@ void BScreen::renderGeomWindow() { "W: %04d x H: %04d", "Representative maximum sized text for width and height dialog").c_str(), 0, 0); - int geom_h = winFrameTheme().font().height() + winFrameTheme().bevelWidth()*2; - int geom_w = winFrameTheme().font().textWidth(label, strlen(label)) + winFrameTheme().bevelWidth()*2; + int geom_h = winFrameTheme()->font().height() + winFrameTheme()->bevelWidth()*2; + int geom_w = winFrameTheme()->font().textWidth(label, strlen(label)) + winFrameTheme()->bevelWidth()*2; m_geom_window.resize(geom_w, geom_h); - m_geom_window.setBorderWidth(winFrameTheme().border(true).width()); - m_geom_window.setBorderColor(winFrameTheme().border(true).color()); + m_geom_window.setBorderWidth(winFrameTheme()->border(true).width()); + m_geom_window.setBorderColor(winFrameTheme()->border(true).color()); Pixmap tmp = geom_pixmap; - if (winFrameTheme().iconbarTheme().focusedTexture().type() & FbTk::Texture::PARENTRELATIVE) { - if (!winFrameTheme().titleFocusTexture().usePixmap()) { + if (winFrameTheme()->iconbarTheme().focusedTexture().type() & FbTk::Texture::PARENTRELATIVE) { + if (!winFrameTheme()->titleFocusTexture().usePixmap()) { geom_pixmap = None; - m_geom_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color()); + m_geom_window.setBackgroundColor(winFrameTheme()->titleFocusTexture().color()); } else { geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(), - winFrameTheme().titleFocusTexture()); + winFrameTheme()->titleFocusTexture()); m_geom_window.setBackgroundPixmap(geom_pixmap); } } else { - if (!winFrameTheme().iconbarTheme().focusedTexture().usePixmap()) { + if (!winFrameTheme()->iconbarTheme().focusedTexture().usePixmap()) { geom_pixmap = None; - m_geom_window.setBackgroundColor(winFrameTheme().iconbarTheme().focusedTexture().color()); + m_geom_window.setBackgroundColor(winFrameTheme()->iconbarTheme().focusedTexture().color()); } else { geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(), - winFrameTheme().iconbarTheme().focusedTexture()); + winFrameTheme()->iconbarTheme().focusedTexture()); m_geom_window.setBackgroundPixmap(geom_pixmap); } } @@ -1952,32 +1946,32 @@ void BScreen::renderGeomWindow() { void BScreen::renderPosWindow() { - int pos_h = winFrameTheme().font().height() + winFrameTheme().bevelWidth()*2; - int pos_w = winFrameTheme().font().textWidth("0:00000 x 0:00000", 17) + winFrameTheme().bevelWidth()*2; + int pos_h = winFrameTheme()->font().height() + winFrameTheme()->bevelWidth()*2; + int pos_w = winFrameTheme()->font().textWidth("0:00000 x 0:00000", 17) + winFrameTheme()->bevelWidth()*2; m_pos_window.resize(pos_w, pos_h); - m_pos_window.setBorderWidth(winFrameTheme().border(true).width()); - m_pos_window.setBorderColor(winFrameTheme().border(true).color()); + m_pos_window.setBorderWidth(winFrameTheme()->border(true).width()); + m_pos_window.setBorderColor(winFrameTheme()->border(true).color()); Pixmap tmp = pos_pixmap; - if (winFrameTheme().iconbarTheme().focusedTexture().type() & FbTk::Texture::PARENTRELATIVE) { - if (!winFrameTheme().titleFocusTexture().usePixmap()) { + if (winFrameTheme()->iconbarTheme().focusedTexture().type() & FbTk::Texture::PARENTRELATIVE) { + if (!winFrameTheme()->titleFocusTexture().usePixmap()) { pos_pixmap = None; - m_pos_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color()); + m_pos_window.setBackgroundColor(winFrameTheme()->titleFocusTexture().color()); } else { pos_pixmap = imageControl().renderImage(m_pos_window.width(), m_pos_window.height(), - winFrameTheme().titleFocusTexture()); + winFrameTheme()->titleFocusTexture()); m_pos_window.setBackgroundPixmap(pos_pixmap); } } else { - if (!winFrameTheme().iconbarTheme().focusedTexture().usePixmap()) { + if (!winFrameTheme()->iconbarTheme().focusedTexture().usePixmap()) { pos_pixmap = None; - m_pos_window.setBackgroundColor(winFrameTheme().iconbarTheme().focusedTexture().color()); + m_pos_window.setBackgroundColor(winFrameTheme()->iconbarTheme().focusedTexture().color()); } else { pos_pixmap = imageControl().renderImage(m_pos_window.width(), m_pos_window.height(), - winFrameTheme().iconbarTheme().focusedTexture()); + winFrameTheme()->iconbarTheme().focusedTexture()); m_pos_window.setBackgroundPixmap(pos_pixmap); } } diff --git a/src/Screen.hh b/src/Screen.hh index 651cdd6..deb51b8 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -27,6 +27,9 @@ #include "FbWinFrame.hh" #include "FbRootWindow.hh" +#include "RootTheme.hh" +#include "WinButtonTheme.hh" +#include "FbWinFrameTheme.hh" #include "FbTk/MenuTheme.hh" #include "FbTk/EventHandler.hh" @@ -52,9 +55,6 @@ class ClientPattern; class Focusable; class FluxboxWindow; -class FbWinFrameTheme; -class RootTheme; -class WinButtonTheme; class WinClient; class Workspace; class Strut; @@ -273,13 +273,13 @@ public: void saveMenu(FbTk::Menu &menu) { m_rootmenu_list.push_back(&menu); } - FbWinFrameTheme &winFrameTheme() { return *m_windowtheme.get(); } - const FbWinFrameTheme &winFrameTheme() const { return *m_windowtheme.get(); } - FbTk::MenuTheme &menuTheme() { return *m_menutheme.get(); } - const FbTk::MenuTheme &menuTheme() const { return *m_menutheme.get(); } - const RootTheme &rootTheme() const { return *m_root_theme.get(); } - WinButtonTheme &winButtonTheme() { return *m_winbutton_theme.get(); } - const WinButtonTheme &winButtonTheme() const { return *m_winbutton_theme.get(); } + FbTk::ThemeProxy &winFrameTheme() { return *m_windowtheme.get(); } + const FbTk::ThemeProxy &winFrameTheme() const { return *m_windowtheme.get(); } + FbTk::ThemeProxy &menuTheme() { return *m_menutheme.get(); } + const FbTk::ThemeProxy &menuTheme() const { return *m_menutheme.get(); } + const FbTk::ThemeProxy &rootTheme() const { return *m_root_theme.get(); } + FbTk::ThemeProxy &winButtonTheme() { return *m_winbutton_theme.get(); } + const FbTk::ThemeProxy &winButtonTheme() const { return *m_winbutton_theme.get(); } FbRootWindow &rootWindow() { return m_root_window; } const FbRootWindow &rootWindow() const { return m_root_window; } diff --git a/src/Slit.cc b/src/Slit.cc index fcbfe62..b412eec 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -304,7 +304,7 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) _FB_USES_NLS; // attach to theme and root window change signal - m_slit_theme->reconfigSig().attach(this); + theme().reconfigSig().attach(this); scr.resizeSig().attach(this); scr.bgChangeSig().attach(this); scr.reconfigureSig().attach(this); // if alpha changed (we disablethis signal when we get theme change sig) @@ -634,7 +634,7 @@ void Slit::reconfigure() { // Need to count windows because not all client list entries // actually correspond to mapped windows. int num_windows = 0; - const int bevel_width = theme().bevelWidth(); + const int bevel_width = theme()->bevelWidth(); // determine width or height increase bool height_inc = false; switch (direction()) { @@ -686,8 +686,8 @@ void Slit::reconfigure() { Display *disp = FbTk::App::instance()->display(); - frame.window.setBorderWidth(theme().borderWidth()); - frame.window.setBorderColor(theme().borderColor()); + frame.window.setBorderWidth(theme()->borderWidth()); + frame.window.setBorderColor(theme()->borderColor()); Pixmap tmp = frame.pixmap; FbTk::ImageControl &image_ctrl = screen().imageControl(); @@ -817,8 +817,8 @@ void Slit::reposition() { head_h = screen().height(); } - int border_width = theme().borderWidth(); - int bevel_width = theme().bevelWidth(); + int border_width = theme()->borderWidth(); + int bevel_width = theme()->bevelWidth(); // make sure at leaste one pixel is visible if (border_width >= bevel_width) bevel_width = border_width + 1; diff --git a/src/Slit.hh b/src/Slit.hh index 984a4c6..64ae6b4 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -25,7 +25,7 @@ #ifndef SLIT_HH #define SLIT_HH - +#include "SlitTheme.hh" #include "LayerMenu.hh" #include "Layer.hh" @@ -40,7 +40,6 @@ #include #include -class SlitTheme; class SlitClient; class BScreen; class FbMenu; @@ -102,8 +101,8 @@ public: BScreen &screen() { return m_screen; } const BScreen &screen() const { return m_screen; } - SlitTheme &theme() { return *m_slit_theme.get(); } - const SlitTheme &theme() const { return *m_slit_theme.get(); } + FbTk::ThemeProxy &theme() { return *m_slit_theme.get(); } + const FbTk::ThemeProxy &theme() const { return *m_slit_theme.get(); } int layerNumber() const { return m_layeritem->getLayerNum(); } diff --git a/src/SlitTheme.hh b/src/SlitTheme.hh index 20be862..d6b410b 100644 --- a/src/SlitTheme.hh +++ b/src/SlitTheme.hh @@ -41,8 +41,8 @@ public: 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; } + virtual SlitTheme &operator *() { return *this; } + virtual const SlitTheme &operator *() const { return *this; } private: FbTk::ThemeItem m_texture; diff --git a/src/SystemTray.cc b/src/SystemTray.cc index 85f0fba..5ba89c3 100644 --- a/src/SystemTray.cc +++ b/src/SystemTray.cc @@ -153,7 +153,8 @@ private: SystemTray &m_tray; }; -SystemTray::SystemTray(const FbTk::FbWindow& parent, ButtonTheme& theme, BScreen& screen): +SystemTray::SystemTray(const FbTk::FbWindow& parent, + FbTk::ThemeProxy &theme, BScreen& screen): ToolbarItem(ToolbarItem::FIXED), m_window(parent, 0, 0, 1, 1, ExposureMask | ButtonPressMask | ButtonReleaseMask | SubstructureNotifyMask | SubstructureRedirectMask), @@ -164,7 +165,7 @@ SystemTray::SystemTray(const FbTk::FbWindow& parent, ButtonTheme& theme, BScreen FbTk::EventManager::instance()->add(*this, m_window); FbTk::EventManager::instance()->add(*this, m_selection_owner); - m_theme.reconfigSig().attach(this); + m_theme->reconfigSig().attach(this); screen.bgChangeSig().attach(this); Fluxbox* fluxbox = Fluxbox::instance(); @@ -282,14 +283,14 @@ unsigned int SystemTray::width() const { if (orientation() == FbTk::ROT90 || orientation() == FbTk::ROT270) return m_window.width(); - return m_num_visible_clients * (height() - 2 * m_theme.border().width()); + return m_num_visible_clients * (height() - 2 * m_theme->border().width()); } unsigned int SystemTray::height() const { if (orientation() == FbTk::ROT0 || orientation() == FbTk::ROT180) return m_window.height(); - return m_num_visible_clients * (width() - 2 * m_theme.border().width()); + return m_num_visible_clients * (width() - 2 * m_theme->border().width()); } unsigned int SystemTray::borderWidth() const { @@ -463,7 +464,7 @@ void SystemTray::handleEvent(XEvent &event) { void SystemTray::rearrangeClients() { unsigned int w_rot0 = width(), h_rot0 = height(); - const unsigned int bw = m_theme.border().width(); + const unsigned int bw = m_theme->border().width(); FbTk::translateSize(orientation(), w_rot0, h_rot0); unsigned int trayw = m_num_visible_clients*h_rot0 + bw, trayh = h_rot0; FbTk::translateSize(orientation(), trayw, trayh); @@ -529,14 +530,14 @@ void SystemTray::showClient(TrayWindow *traywin) { void SystemTray::update(FbTk::Subject* subject) { - if (!m_theme.texture().usePixmap()) { - m_window.setBackgroundColor(m_theme.texture().color()); + if (!m_theme->texture().usePixmap()) { + m_window.setBackgroundColor(m_theme->texture().color()); } else { if(m_pixmap) m_screen.imageControl().removeImage(m_pixmap); m_pixmap = m_screen.imageControl().renderImage(width(), height(), - m_theme.texture(), orientation()); + m_theme->texture(), orientation()); m_window.setBackgroundPixmap(m_pixmap); } diff --git a/src/SystemTray.hh b/src/SystemTray.hh index e06f7f9..2e3a4ea 100644 --- a/src/SystemTray.hh +++ b/src/SystemTray.hh @@ -36,10 +36,15 @@ class ButtonTheme; class TrayWindow; class AtomHandler; +namespace FbTk { +template class ThemeProxy; +} + class SystemTray: public ToolbarItem, public FbTk::EventHandler, public FbTk::Observer { public: - explicit SystemTray(const FbTk::FbWindow &parent, ButtonTheme &theme, BScreen& screen); + explicit SystemTray(const FbTk::FbWindow &parent, + FbTk::ThemeProxy &theme, BScreen& screen); virtual ~SystemTray(); void move(int x, int y); @@ -85,7 +90,7 @@ private: void showClient(TrayWindow *traywin); FbTk::FbWindow m_window; - ButtonTheme& m_theme; + FbTk::ThemeProxy &m_theme; BScreen& m_screen; Pixmap m_pixmap; diff --git a/src/ToggleMenu.hh b/src/ToggleMenu.hh index c47462d..e7c0ad0 100644 --- a/src/ToggleMenu.hh +++ b/src/ToggleMenu.hh @@ -30,9 +30,10 @@ */ class ToggleMenu: public FbMenu { public: - ToggleMenu(class FbTk::MenuTheme &tm, FbTk::ImageControl &imgctrl, - FbTk::XLayer &layer):FbMenu(tm, imgctrl, layer) - {} + ToggleMenu(class FbTk::ThemeProxy &tm, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer): + FbMenu(tm, imgctrl, layer) { } + virtual ~ToggleMenu() {} void buttonReleaseEvent(XButtonEvent &ev) { diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc index 38c9ce2..cee0d93 100644 --- a/src/ToolFactory.cc +++ b/src/ToolFactory.cc @@ -84,8 +84,8 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow & ToolbarItem * item = 0; unsigned int button_size = 24; - if (tbar.theme().buttonSize() > 0) - button_size = tbar.theme().buttonSize(); + if (tbar.theme()->buttonSize() > 0) + button_size = tbar.theme()->buttonSize(); if (name == "workspacename") { WorkspaceNameTool *witem = new WorkspaceNameTool(parent, diff --git a/src/ToolTheme.hh b/src/ToolTheme.hh index 552e8f8..9c34114 100644 --- a/src/ToolTheme.hh +++ b/src/ToolTheme.hh @@ -47,8 +47,8 @@ public: 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; } + virtual ToolTheme &operator *() { return *this; } + virtual const ToolTheme &operator *() const { return *this; } protected: FbTk::ThemeItem &textureTheme() { return m_texture; } diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 7ade11a..24bc66d 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -328,22 +328,22 @@ void Toolbar::updateStrut() { case TOPLEFT: case TOPCENTER: case TOPRIGHT: - top = height() + 2 * theme().border().width(); + top = height() + 2 * theme()->border().width(); break; case BOTTOMLEFT: case BOTTOMCENTER: case BOTTOMRIGHT: - bottom = height() + 2 * theme().border().width(); + bottom = height() + 2 * theme()->border().width(); break; case RIGHTTOP: case RIGHTCENTER: case RIGHTBOTTOM: - right = width() + 2 * theme().border().width(); + right = width() + 2 * theme()->border().width(); break; case LEFTTOP: case LEFTCENTER: case LEFTBOTTOM: - left = width() + 2 * theme().border().width(); + left = width() + 2 * theme()->border().width(); break; }; m_strut = screen().requestStrut(getOnHead(), left, right, top, bottom); @@ -442,12 +442,12 @@ void Toolbar::reconfigure() { if (doAutoHide()) m_hide_timer.start(); - frame.bevel_w = theme().bevelWidth(); + frame.bevel_w = theme()->bevelWidth(); // destroy shape if the theme wasn't specified with one, // or create one - if (theme().shape() == false && m_shape.get()) + if (theme()->shape() == false && m_shape.get()) m_shape.reset(0); - else if (theme().shape() && m_shape.get() == 0) { + else if (theme()->shape() && m_shape.get() == 0) { m_shape.reset(new FbTk::Shape(frame.window, 0)); } @@ -464,9 +464,9 @@ void Toolbar::reconfigure() { // render frame window Pixmap tmp = m_window_pm; - if (!theme().toolbar().usePixmap()) { + if (!theme()->toolbar().usePixmap()) { m_window_pm = 0; - frame.window.setBackgroundColor(theme().toolbar().color()); + frame.window.setBackgroundColor(theme()->toolbar().color()); } else { FbTk::Orientation orient = FbTk::ROT0; Toolbar::Placement where = *m_rc_placement; @@ -477,14 +477,14 @@ void Toolbar::reconfigure() { m_window_pm = screen().imageControl().renderImage( frame.window.width(), frame.window.height(), - theme().toolbar(), orient); + theme()->toolbar(), orient); frame.window.setBackgroundPixmap(m_window_pm); } if (tmp) screen().imageControl().removeImage(tmp); - frame.window.setBorderColor(theme().border().color()); - frame.window.setBorderWidth(theme().border().width()); + frame.window.setBorderColor(theme()->border().color()); + frame.window.setBorderWidth(theme()->border().width()); bool have_composite = FbTk::Transparent::haveComposite(); // have_composite could have changed, so we need to change both @@ -497,7 +497,7 @@ void Toolbar::reconfigure() { } frame.window.clear(); - if (theme().shape() && m_shape.get()) + if (theme()->shape() && m_shape.get()) m_shape->update(); ItemList::iterator item_it = m_item_list.begin(); @@ -637,16 +637,16 @@ void Toolbar::setPlacement(Toolbar::Placement where) { head_h = screen().getHeadHeight(head); } - int bevel_width = theme().bevelWidth(); - int border_width = theme().border().width(); + int bevel_width = theme()->bevelWidth(); + int border_width = theme()->border().width(); frame.width = (head_w - 2*border_width) * (*m_rc_width_percent) / 100; //!! TODO: change this // max height of each toolbar items font... unsigned int max_height = m_tool_factory.maxFontHeight() + 2; - if (theme().height() > 0) - max_height = theme().height(); + if (theme()->height() > 0) + max_height = theme()->height(); if (*m_rc_height > 0 && *m_rc_height < 100) max_height = *m_rc_height; @@ -971,7 +971,7 @@ void Toolbar::rearrangeItems() { // calculate size for fixed items ItemList::iterator item_it = m_item_list.begin(); ItemList::iterator item_it_end = m_item_list.end(); - int bevel_width = theme().bevelWidth(); + int bevel_width = theme()->bevelWidth(); int fixed_width = bevel_width; // combined size of all fixed items int relative_items = 0; int last_bw = 0; // we show the largest border of adjoining items diff --git a/src/Toolbar.hh b/src/Toolbar.hh index ae143f0..c528102 100644 --- a/src/Toolbar.hh +++ b/src/Toolbar.hh @@ -121,8 +121,8 @@ public: int y() const { return isHidden() ? frame.y_hidden : frame.y; } Placement placement() const { return *m_rc_placement; } /// @return pointer to iconbar if it got one, else 0 - const ToolbarTheme &theme() const { return m_theme; } - ToolbarTheme &theme() { return m_theme; } + const FbTk::ThemeProxy &theme() const { return m_theme; } + FbTk::ThemeProxy &theme() { return m_theme; } bool isVertical() const; int getOnHead() const { return *m_rc_on_head; } diff --git a/src/ToolbarTheme.hh b/src/ToolbarTheme.hh index 1a183e2..077198f 100644 --- a/src/ToolbarTheme.hh +++ b/src/ToolbarTheme.hh @@ -47,8 +47,8 @@ public: 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; } + virtual ToolbarTheme &operator *() { return *this; } + virtual const ToolbarTheme &operator *() const { return *this; } private: FbTk::ThemeItem m_toolbar; diff --git a/src/WinButton.cc b/src/WinButton.cc index 39540db..5c6c99c 100644 --- a/src/WinButton.cc +++ b/src/WinButton.cc @@ -33,7 +33,7 @@ WinButton::WinButton(const FluxboxWindow &listen_to, - WinButtonTheme &theme, + FbTk::ThemeProxy &theme, Type buttontype, const FbTk::FbWindow &parent, int x, int y, unsigned int width, unsigned int height): @@ -112,59 +112,59 @@ Pixmap WinButton::getBackgroundPixmap() const { switch(m_type) { case MAXIMIZE: if (focused) - return m_theme.maximizePixmap().pixmap().drawable(); + return m_theme->maximizePixmap().pixmap().drawable(); else - return m_theme.maximizeUnfocusPixmap().pixmap().drawable(); + return m_theme->maximizeUnfocusPixmap().pixmap().drawable(); break; case MINIMIZE: if (focused) - return m_theme.iconifyPixmap().pixmap().drawable(); + return m_theme->iconifyPixmap().pixmap().drawable(); else - return m_theme.iconifyUnfocusPixmap().pixmap().drawable(); + return m_theme->iconifyUnfocusPixmap().pixmap().drawable(); break; case STICK: if (m_listen_to.isStuck()) { if (focused) - return m_theme.stuckPixmap().pixmap().drawable(); + return m_theme->stuckPixmap().pixmap().drawable(); else - return m_theme.stuckUnfocusPixmap().pixmap().drawable(); + return m_theme->stuckUnfocusPixmap().pixmap().drawable(); } else { if (focused) - return m_theme.stickPixmap().pixmap().drawable(); + return m_theme->stickPixmap().pixmap().drawable(); else - return m_theme.stickUnfocusPixmap().pixmap().drawable(); + return m_theme->stickUnfocusPixmap().pixmap().drawable(); } break; case CLOSE: if (focused) - return m_theme.closePixmap().pixmap().drawable(); + return m_theme->closePixmap().pixmap().drawable(); else - return m_theme.closeUnfocusPixmap().pixmap().drawable(); + return m_theme->closeUnfocusPixmap().pixmap().drawable(); break; case SHADE: if (m_listen_to.isShaded()) { if (focused) - return m_theme.unshadePixmap().pixmap().drawable(); + return m_theme->unshadePixmap().pixmap().drawable(); else - return m_theme.unshadeUnfocusPixmap().pixmap().drawable(); + return m_theme->unshadeUnfocusPixmap().pixmap().drawable(); } else { if (focused) - return m_theme.shadePixmap().pixmap().drawable(); + return m_theme->shadePixmap().pixmap().drawable(); else - return m_theme.shadeUnfocusPixmap().pixmap().drawable(); + return m_theme->shadeUnfocusPixmap().pixmap().drawable(); } break; case MENUICON: if (m_icon_pixmap.drawable()) { if (focused) - return m_theme.titleFocusPixmap().pixmap().drawable(); + return m_theme->titleFocusPixmap().pixmap().drawable(); else - return m_theme.titleUnfocusPixmap().pixmap().drawable(); + return m_theme->titleUnfocusPixmap().pixmap().drawable(); } else { if (focused) - return m_theme.menuiconPixmap().pixmap().drawable(); + return m_theme->menuiconPixmap().pixmap().drawable(); else - return m_theme.menuiconUnfocusPixmap().pixmap().drawable(); + return m_theme->menuiconUnfocusPixmap().pixmap().drawable(); } break; } @@ -174,26 +174,26 @@ Pixmap WinButton::getBackgroundPixmap() const { Pixmap WinButton::getPressedPixmap() const { switch(m_type) { case MAXIMIZE: - return m_theme.maximizePressedPixmap().pixmap().drawable(); + return m_theme->maximizePressedPixmap().pixmap().drawable(); case MINIMIZE: - return m_theme.iconifyPressedPixmap().pixmap().drawable(); + return m_theme->iconifyPressedPixmap().pixmap().drawable(); case STICK: - return m_theme.stickPressedPixmap().pixmap().drawable(); + return m_theme->stickPressedPixmap().pixmap().drawable(); case CLOSE: - return m_theme.closePressedPixmap().pixmap().drawable(); + return m_theme->closePressedPixmap().pixmap().drawable(); case SHADE: if (m_listen_to.isShaded()) - return m_theme.unshadePressedPixmap().pixmap().drawable(); + return m_theme->unshadePressedPixmap().pixmap().drawable(); else - return m_theme.shadePressedPixmap().pixmap().drawable(); + return m_theme->shadePressedPixmap().pixmap().drawable(); case MENUICON: if (m_icon_pixmap.drawable()) if (m_listen_to.isFocused()) - return m_theme.titleFocusPixmap().pixmap().drawable(); + return m_theme->titleFocusPixmap().pixmap().drawable(); else - return m_theme.titleUnfocusPixmap().pixmap().drawable(); + return m_theme->titleUnfocusPixmap().pixmap().drawable(); else - return m_theme.menuiconPressedPixmap().pixmap().drawable(); + return m_theme->menuiconPressedPixmap().pixmap().drawable(); } return None; } diff --git a/src/WinButton.hh b/src/WinButton.hh index d6f84e6..c493491 100644 --- a/src/WinButton.hh +++ b/src/WinButton.hh @@ -31,6 +31,7 @@ class WinButtonTheme; namespace FbTk{ class Color; +template class ThemeProxy; } /// draws and handles basic window button graphic @@ -39,7 +40,7 @@ public: /// draw type for the button enum Type {MAXIMIZE, MINIMIZE, SHADE, STICK, CLOSE, MENUICON}; WinButton(const FluxboxWindow &listen_to, - WinButtonTheme &theme, + FbTk::ThemeProxy &theme, Type buttontype, const FbTk::FbWindow &parent, int x, int y, unsigned int width, unsigned int height); /// override for drawing @@ -59,7 +60,7 @@ private: void drawType(); Type m_type; ///< the button type const FluxboxWindow &m_listen_to; - WinButtonTheme &m_theme; + FbTk::ThemeProxy &m_theme; FbTk::FbPixmap m_icon_pixmap; FbTk::FbPixmap m_icon_mask; diff --git a/src/WinButtonTheme.cc b/src/WinButtonTheme.cc index b724817..d58af35 100644 --- a/src/WinButtonTheme.cc +++ b/src/WinButtonTheme.cc @@ -27,7 +27,8 @@ #include "FbWinFrameTheme.hh" -WinButtonTheme::WinButtonTheme(int screen_num, FbWinFrameTheme &frame_theme): +WinButtonTheme::WinButtonTheme(int screen_num, + FbTk::ThemeProxy &frame_theme): FbTk::Theme(screen_num), m_close_pm(*this, "window.close.pixmap", "Window.Close.Pixmap"), m_close_unfocus_pm(*this, "window.close.unfocus.pixmap", "Window.Close.Unfocus.Pixmap"), @@ -66,11 +67,11 @@ WinButtonTheme::~WinButtonTheme() { void WinButtonTheme::reconfigTheme() { // rescale the pixmaps to match frame theme height - unsigned int size = m_frame_theme.titleHeight() - - 2 * m_frame_theme.bevelWidth(); - if (m_frame_theme.titleHeight() == 0) { + unsigned int size = m_frame_theme->titleHeight() + - 2 * m_frame_theme->bevelWidth(); + if (m_frame_theme->titleHeight() == 0) { // calculate height from font and border width to scale pixmaps - size = m_frame_theme.font().height() + 2; + size = m_frame_theme->font().height() + 2; } // else use specified height to scale pixmaps diff --git a/src/WinButtonTheme.hh b/src/WinButtonTheme.hh index 7d00e1e..5d3e3fe 100644 --- a/src/WinButtonTheme.hh +++ b/src/WinButtonTheme.hh @@ -30,7 +30,8 @@ class FbWinFrameTheme; class WinButtonTheme: public FbTk::Theme, public FbTk::ThemeProxy { public: - WinButtonTheme(int screen_num, FbWinFrameTheme &frame_theme); + WinButtonTheme(int screen_num, + FbTk::ThemeProxy &frame_theme); ~WinButtonTheme(); void reconfigTheme(); @@ -88,8 +89,8 @@ public: 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; } + virtual WinButtonTheme &operator *() { return *this; } + virtual const WinButtonTheme &operator *() const { return *this; } private: @@ -104,7 +105,7 @@ private: FbTk::ThemeItem m_stick_pm, m_stick_unfocus_pm, m_stick_pressed_pm; FbTk::ThemeItem m_stuck_pm, m_stuck_unfocus_pm; - FbWinFrameTheme &m_frame_theme; + FbTk::ThemeProxy &m_frame_theme; }; #endif // WINBUTTONTHEME_HH diff --git a/src/Window.cc b/src/Window.cc index 7f14ee8..a2a256e 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -261,8 +261,8 @@ private: int FluxboxWindow::s_num_grabs = 0; -FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, - FbTk::XLayer &layer): +FluxboxWindow::FluxboxWindow(WinClient &client, + FbTk::ThemeProxy &tm, FbTk::XLayer &layer): Focusable(client.screen(), this), oplock(false), m_hintsig(*this), @@ -401,8 +401,8 @@ void FluxboxWindow::init() { Fluxbox &fluxbox = *Fluxbox::instance(); // setup cursors for resize grips - frame().gripLeft().setCursor(frame().theme().lowerLeftAngleCursor()); - frame().gripRight().setCursor(frame().theme().lowerRightAngleCursor()); + frame().gripLeft().setCursor(frame().theme()->lowerLeftAngleCursor()); + frame().gripRight().setCursor(frame().theme()->lowerRightAngleCursor()); associateClient(*m_client); @@ -2777,12 +2777,12 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { doSnapping(dx, dy); if (! screen().doOpaqueMove()) { - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_move_x, m_last_move_y, frame().width() + 2*frame().window().borderWidth()-1, frame().height() + 2*frame().window().borderWidth()-1); - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), dx, dy, frame().width() + 2*frame().window().borderWidth()-1, frame().height() + 2*frame().window().borderWidth()-1); @@ -2874,13 +2874,13 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { old_resize_h != m_last_resize_h ) { // draw over old rect - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), old_resize_x, old_resize_y, old_resize_w - 1 + 2 * frame().window().borderWidth(), old_resize_h - 1 + 2 * frame().window().borderWidth()); // draw resize rectangle - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_resize_x, m_last_resize_y, m_last_resize_w - 1 + 2 * frame().window().borderWidth(), m_last_resize_h - 1 + 2 * frame().window().borderWidth()); @@ -2897,10 +2897,10 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { // so we update drag'n'drop-rectangle int dx = me.x_root - m_button_grab_x, dy = me.y_root - m_button_grab_y; - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_move_x, m_last_move_y, m_last_resize_w, m_last_resize_h); - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), dx, dy, m_last_resize_w, m_last_resize_h); @@ -3010,7 +3010,7 @@ void FluxboxWindow::update(FbTk::Subject *subj) { if (FocusControl::focusedFbWindow()) setFullscreenLayer(); } - } else if (subj == &frame().theme().reconfigSig()) { + } else if (subj == &frame().theme()->reconfigSig()) { reconfigTheme(); frame().reconfigure(); } @@ -3022,7 +3022,7 @@ void FluxboxWindow::applyDecorations(bool initial) { unsigned int border_width = 0; if (decorations.border) - border_width = frame().theme().border(m_focused).width(); + border_width = frame().theme()->border(m_focused).width(); bool client_move = false; @@ -3165,7 +3165,7 @@ void FluxboxWindow::startMoving(int x, int y) { // freely map and unmap the window we're moving. grabPointer(screen().rootWindow().window(), False, ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, - screen().rootWindow().window(), frame().theme().moveCursor(), CurrentTime); + screen().rootWindow().window(), frame().theme()->moveCursor(), CurrentTime); if (menu().isVisible()) menu().hide(); @@ -3176,7 +3176,7 @@ void FluxboxWindow::startMoving(int x, int y) { m_last_move_y = frame().y(); if (! screen().doOpaqueMove()) { fluxbox->grab(); - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), frame().x(), frame().y(), frame().width() + 2*frame().window().borderWidth()-1, frame().height() + 2*frame().window().borderWidth()-1); @@ -3200,7 +3200,7 @@ void FluxboxWindow::stopMoving(bool interrupted) { if (! screen().doOpaqueMove()) { - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_move_x, m_last_move_y, frame().width() + 2*frame().window().borderWidth()-1, frame().height() + 2*frame().window().borderWidth()-1); @@ -3230,7 +3230,7 @@ void FluxboxWindow::pauseMoving() { return; } - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_move_x, m_last_move_y, frame().width() + 2*frame().window().borderWidth()-1, frame().height() + 2*frame().window().borderWidth()-1); @@ -3250,7 +3250,7 @@ void FluxboxWindow::resumeMoving() { FbTk::App::instance()->sync(false); - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_move_x, m_last_move_y, frame().width() + 2*frame().window().borderWidth()-1, frame().height() + 2*frame().window().borderWidth()-1); @@ -3463,14 +3463,14 @@ void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { resizing = true; maximized = MAX_NONE; - const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme().upperLeftAngleCursor() : - (m_resize_corner == RIGHTTOP) ? frame().theme().upperRightAngleCursor() : - (m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() : - (m_resize_corner == LEFT) ? frame().theme().leftSideCursor() : - (m_resize_corner == RIGHT) ? frame().theme().rightSideCursor() : - (m_resize_corner == TOP) ? frame().theme().topSideCursor() : - (m_resize_corner == BOTTOM) ? frame().theme().bottomSideCursor() : - frame().theme().lowerLeftAngleCursor(); + const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme()->upperLeftAngleCursor() : + (m_resize_corner == RIGHTTOP) ? frame().theme()->upperRightAngleCursor() : + (m_resize_corner == RIGHTBOTTOM) ? frame().theme()->lowerRightAngleCursor() : + (m_resize_corner == LEFT) ? frame().theme()->leftSideCursor() : + (m_resize_corner == RIGHT) ? frame().theme()->rightSideCursor() : + (m_resize_corner == TOP) ? frame().theme()->topSideCursor() : + (m_resize_corner == BOTTOM) ? frame().theme()->bottomSideCursor() : + frame().theme()->lowerLeftAngleCursor(); grabPointer(fbWindow().window(), false, ButtonMotionMask | ButtonReleaseMask, @@ -3488,7 +3488,7 @@ void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { screen().showGeometry(gx, gy); - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_resize_x, m_last_resize_y, m_last_resize_w - 1 + 2 * frame().window().borderWidth(), m_last_resize_h - 1 + 2 * frame().window().borderWidth()); @@ -3497,7 +3497,7 @@ void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) { void FluxboxWindow::stopResizing(bool interrupted) { resizing = false; - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_resize_x, m_last_resize_y, m_last_resize_w - 1 + 2 * frame().window().borderWidth(), m_last_resize_h - 1 + 2 * frame().window().borderWidth()); @@ -3533,7 +3533,7 @@ void FluxboxWindow::startTabbing(const XButtonEvent &be) { // start drag'n'drop for tab grabPointer(be.window, False, ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, - None, frame().theme().moveCursor(), CurrentTime); + None, frame().theme()->moveCursor(), CurrentTime); // relative position on the button m_button_grab_x = be.x; @@ -3558,7 +3558,7 @@ void FluxboxWindow::startTabbing(const XButtonEvent &be) { m_last_resize_h = frame().height() + bw; } - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_move_x, m_last_move_y, m_last_resize_w, m_last_resize_h); @@ -3569,7 +3569,7 @@ void FluxboxWindow::attachTo(int x, int y, bool interrupted) { if (m_attaching_tab == 0) return; - parent().drawRectangle(screen().rootTheme().opGC(), + parent().drawRectangle(screen().rootTheme()->opGC(), m_last_move_x, m_last_move_y, m_last_resize_w, m_last_resize_h); @@ -3978,7 +3978,7 @@ void FluxboxWindow::updateButtons() { CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick)); CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu)); - WinButtonTheme &winbutton_theme = screen().winButtonTheme(); + FbTk::ThemeProxy &winbutton_theme = screen().winButtonTheme(); for (size_t c = 0; c < 2 ; c++) { // get titlebar configuration for current side @@ -4073,8 +4073,8 @@ void FluxboxWindow::updateButtons() { void FluxboxWindow::reconfigTheme() { m_frame.setBorderWidth(decorations.border ? - frame().theme().border(m_focused).width() : 0); - if (decorations.handle && frame().theme().handleWidth() != 0) + frame().theme()->border(m_focused).width() : 0); + if (decorations.handle && frame().theme()->handleWidth() != 0) frame().showHandle(); else frame().hideHandle(); diff --git a/src/Window.hh b/src/Window.hh index 8d0c6f1..a4c0fa2 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -151,8 +151,7 @@ public: /// create a window from a client FluxboxWindow(WinClient &client, - FbWinFrameTheme &tm, - FbTk::XLayer &layer); + FbTk::ThemeProxy &tm, FbTk::XLayer &layer); virtual ~FluxboxWindow(); diff --git a/src/WorkspaceNameTheme.hh b/src/WorkspaceNameTheme.hh index 860f6ec..e4f426f 100644 --- a/src/WorkspaceNameTheme.hh +++ b/src/WorkspaceNameTheme.hh @@ -49,8 +49,8 @@ public: 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; } + virtual WorkspaceNameTheme &operator *() { return *this; } + virtual const WorkspaceNameTheme &operator *() const { return *this; } }; diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc index b261423..79ac724 100644 --- a/src/WorkspaceNameTool.cc +++ b/src/WorkspaceNameTool.cc @@ -31,14 +31,14 @@ #include WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent, - ToolTheme &theme, BScreen &screen): + FbTk::ThemeProxy &theme, BScreen &screen): ToolbarItem(ToolbarItem::FIXED), - m_button(parent, theme.font(), "a workspace name"), + m_button(parent, theme->font(), "a workspace name"), m_theme(theme), m_screen(screen), m_pixmap(0) { // set text - m_button.setGC(m_theme.textGC()); + m_button.setGC(m_theme->textGC()); m_button.setText(m_screen.currentWorkspace()->name()); // setup signals @@ -88,7 +88,7 @@ unsigned int WorkspaceNameTool::width() const { BScreen::Workspaces::const_iterator it; for (it = workspaces.begin(); it != workspaces.end(); it++) { const std::string &name = (*it)->name(); - max_size = std::max(m_theme.font().textWidth(name, name.size()), + max_size = std::max(m_theme->font().textWidth(name, name.size()), max_size); } // so align text dont cut the last character @@ -106,7 +106,7 @@ unsigned int WorkspaceNameTool::height() const { BScreen::Workspaces::const_iterator it; for (it = workspaces.begin(); it != workspaces.end(); it++) { const std::string &name = (*it)->name(); - max_size = std::max(m_theme.font().textWidth(name, name.size()), + max_size = std::max(m_theme->font().textWidth(name, name.size()), max_size); } // so align text dont cut the last character @@ -128,31 +128,31 @@ void WorkspaceNameTool::hide() { } void WorkspaceNameTool::updateSizing() { - m_button.setBorderWidth(m_theme.border().width()); + m_button.setBorderWidth(m_theme->border().width()); } void WorkspaceNameTool::reRender() { - if (m_theme.texture().usePixmap()) { + if (m_theme->texture().usePixmap()) { if (m_pixmap) m_screen.imageControl().removeImage(m_pixmap); m_pixmap = m_screen.imageControl().renderImage(width(), height(), - m_theme.texture(), orientation()); + m_theme->texture(), orientation()); m_button.setBackgroundPixmap(m_pixmap); } } void WorkspaceNameTool::renderTheme(unsigned char alpha) { - m_button.setJustify(m_theme.justify()); - m_button.setBorderWidth(m_theme.border().width()); - m_button.setBorderColor(m_theme.border().color()); + m_button.setJustify(m_theme->justify()); + m_button.setBorderWidth(m_theme->border().width()); + m_button.setBorderColor(m_theme->border().color()); m_button.setAlpha(alpha); - if (!m_theme.texture().usePixmap()) { + if (!m_theme->texture().usePixmap()) { if (m_pixmap) m_screen.imageControl().removeImage(m_pixmap); m_pixmap = 0; - m_button.setBackgroundColor(m_theme.texture().color()); + m_button.setBackgroundColor(m_theme->texture().color()); } else { reRender(); } diff --git a/src/WorkspaceNameTool.hh b/src/WorkspaceNameTool.hh index 4af9136..0bdb528 100644 --- a/src/WorkspaceNameTool.hh +++ b/src/WorkspaceNameTool.hh @@ -31,9 +31,13 @@ class BScreen; class ToolTheme; +namespace FbTk { +template class ThemeProxy; +} + class WorkspaceNameTool: public ToolbarItem, public FbTk::Observer { public: - WorkspaceNameTool(const FbTk::FbWindow &parent, ToolTheme &theme, BScreen &screen); + WorkspaceNameTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy &theme, BScreen &screen); virtual ~WorkspaceNameTool(); void move(int x, int y); @@ -59,7 +63,7 @@ private: void reRender(); void updateSizing(); FbTk::TextButton m_button; - const ToolTheme &m_theme; + const FbTk::ThemeProxy &m_theme; BScreen &m_screen; Pixmap m_pixmap; }; diff --git a/src/Xinerama.hh b/src/Xinerama.hh index dfc0d86..4e7d06f 100644 --- a/src/Xinerama.hh +++ b/src/Xinerama.hh @@ -61,8 +61,9 @@ private: template class XineramaHeadMenu : public FbMenu { public: - XineramaHeadMenu(FbTk::MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl, - FbTk::XLayer &layer, ItemType &item, const FbTk::FbString & title = ""); + XineramaHeadMenu(FbTk::ThemeProxy &tm, BScreen &screen, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, + ItemType &item, const FbTk::FbString & title = ""); private: ItemType &m_object; @@ -70,8 +71,10 @@ private: template -XineramaHeadMenu::XineramaHeadMenu(FbTk::MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl, - FbTk::XLayer &layer, ItemType &item, const FbTk::FbString & title): +XineramaHeadMenu::XineramaHeadMenu( + FbTk::ThemeProxy &tm, BScreen &screen, + FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, ItemType &item, + const FbTk::FbString & title): FbMenu(tm, imgctrl, layer), m_object(item) { -- cgit v0.11.2