From 9d7c562478b553c8f0f71acdfa93bda2f0a5ce5d Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 4 Apr 2007 18:06:54 +0000 Subject: moved some code from here to there --- ChangeLog | 3 +++ src/CommandDialog.cc | 8 ++++---- src/FbWinFrame.cc | 22 ++++++++++++---------- src/FbWinFrameTheme.cc | 17 ++++++----------- src/FbWinFrameTheme.hh | 16 +++++----------- src/IconButton.cc | 8 +++++--- src/IconButton.hh | 5 ++++- src/IconbarTheme.cc | 9 ++------- src/IconbarTheme.hh | 4 +--- src/IconbarTool.cc | 5 +---- src/Makefile.am | 3 ++- src/Screen.cc | 20 ++++++++++---------- 12 files changed, 55 insertions(+), 65 deletions(-) diff --git a/ChangeLog b/ChangeLog index 480f5f3..36fe570 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.1: +*07/04/03: + * Added window.label.(un)focused.font to styles (Mark) + FbWinFrame.cc *07/03/31: * [group] tag in apps file may now have a pattern appended to it, and a new window will only be automatically attached to the group if the group diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc index 3207a48..e19cd53 100644 --- a/src/CommandDialog.cc +++ b/src/CommandDialog.cc @@ -193,12 +193,12 @@ void CommandDialog::tabComplete() { void CommandDialog::render() { Pixmap tmp = m_pixmap; - if (!m_screen.winFrameTheme().labelFocusTexture().usePixmap()) { - m_label.setBackgroundColor(m_screen.winFrameTheme().labelFocusTexture().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().labelFocusTexture()); + m_screen.winFrameTheme().iconbarTheme().focusedTexture()); m_label.setBackgroundPixmap(m_pixmap); } @@ -213,7 +213,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().labelTextFocusGC()); + m_label.setGC(m_screen.winFrameTheme().iconbarTheme().focusedText().textGC()); m_label.show(); // setup text box diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 124883e..238cfb6 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -621,7 +621,7 @@ void FbWinFrame::removeAllButtons() { } IconButton *FbWinFrame::createTab(Focusable &client) { - IconButton *button = new IconButton(m_tab_container, theme().font(), + IconButton *button = new IconButton(m_tab_container, theme().iconbarTheme(), client); button->show(); @@ -1275,11 +1275,11 @@ void FbWinFrame::renderTitlebar() { //!! TODO: don't render label if internal tabs - render(m_theme.labelFocusTexture(), m_label_focused_color, + render(m_theme.iconbarTheme().focusedTexture(), m_label_focused_color, m_label_focused_pm, m_label.width(), m_label.height()); - render(m_theme.labelUnfocusTexture(), m_label_unfocused_color, + render(m_theme.iconbarTheme().unfocusedTexture(), m_label_unfocused_color, m_label_unfocused_pm, m_label.width(), m_label.height()); @@ -1291,8 +1291,8 @@ void FbWinFrame::renderTabContainer() { return; } - const FbTk::Texture *tc_focused = &m_theme.labelFocusTexture(); - const FbTk::Texture *tc_unfocused = &m_theme.labelUnfocusTexture(); + const FbTk::Texture *tc_focused = &m_theme.iconbarTheme().focusedTexture(); + const FbTk::Texture *tc_unfocused = &m_theme.iconbarTheme().unfocusedTexture(); if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) tc_focused = &m_theme.titleFocusTexture(); @@ -1307,11 +1307,11 @@ void FbWinFrame::renderTabContainer() { m_tabcontainer_unfocused_pm, m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); - render(m_theme.labelFocusTexture(), m_labelbutton_focused_color, + render(m_theme.iconbarTheme().focusedTexture(), m_labelbutton_focused_color, m_labelbutton_focused_pm, m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); - render(m_theme.labelUnfocusTexture(), m_labelbutton_unfocused_color, + render(m_theme.iconbarTheme().unfocusedTexture(), m_labelbutton_unfocused_color, m_labelbutton_unfocused_pm, m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); @@ -1334,7 +1334,7 @@ void FbWinFrame::applyTitlebar() { m_label.setAlpha(alpha); if (m_tabmode != INTERNAL) { - m_label.setGC(m_focused?theme().labelTextFocusGC():theme().labelTextUnfocusGC()); + m_label.setGC(m_focused?theme().iconbarTheme().focusedText().textGC():theme().iconbarTheme().unfocusedText().textGC()); m_label.setJustify(theme().justify()); if (label_pm != 0) @@ -1651,7 +1651,8 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { void FbWinFrame::applyFocusLabel(FbTk::TextButton &button) { - button.setGC(theme().labelTextFocusGC()); + button.setGC(theme().iconbarTheme().focusedText().textGC()); + button.setFont(theme().iconbarTheme().focusedText().font()); button.setJustify(theme().justify()); button.setAlpha(getAlpha(m_focused)); @@ -1664,7 +1665,8 @@ void FbWinFrame::applyFocusLabel(FbTk::TextButton &button) { void FbWinFrame::applyUnfocusLabel(FbTk::TextButton &button) { - button.setGC(theme().labelTextUnfocusGC()); + button.setGC(theme().iconbarTheme().unfocusedText().textGC()); + button.setFont(theme().iconbarTheme().unfocusedText().font()); button.setJustify(theme().justify()); button.setAlpha(getAlpha(m_focused)); diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc index e4bc196..949beaa 100644 --- a/src/FbWinFrameTheme.cc +++ b/src/FbWinFrameTheme.cc @@ -24,13 +24,12 @@ #include "FbWinFrameTheme.hh" #include "App.hh" +#include "IconbarTheme.hh" + #include FbWinFrameTheme::FbWinFrameTheme(int screen_num): FbTk::Theme(screen_num), - m_label_focus(*this, "window.label.focus", "Window.Label.Focus"), - m_label_unfocus(*this, "window.label.unfocus", "Window.Label.Unfocus"), - m_title_focus(*this, "window.title.focus", "Window.Title.Focus"), m_title_unfocus(*this, "window.title.unfocus", "Window.Title.Unfocus"), @@ -44,9 +43,6 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num): m_grip_focus(*this, "window.grip.focus", "Window.Grip.Focus"), m_grip_unfocus(*this, "window.grip.unfocus", "Window.Grip.Unfocus"), - m_label_focus_color(*this, "window.label.focus.textColor", "Window.Label.Focus.TextColor"), - m_label_unfocus_color(*this, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"), - m_button_focus_color(*this, "window.button.focus.picColor", "Window.Button.Focus.PicColor"), m_button_unfocus_color(*this, "window.button.unfocus.picColor", "Window.Button.Unfocus.PicColor"), @@ -57,12 +53,11 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num): m_bevel_width(*this, "window.bevelWidth", "Window.BevelWidth"), m_handle_width(*this, "window.handleWidth", "Window.handleWidth"), m_border(*this, "window", "Window"), // for window.border* - m_label_text_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), - m_label_text_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), m_button_pic_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), m_button_pic_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), m_focused_alpha(255), - m_unfocused_alpha(255) { + m_unfocused_alpha(255), + m_iconbar_theme(screen_num, "window.label", "Window.Label") { *m_title_height = 0; // set defaults @@ -107,9 +102,9 @@ void FbWinFrameTheme::reconfigTheme() { else if (*m_handle_width < 0) *m_handle_width = 1; - m_label_text_focus_gc.setForeground(*m_label_focus_color); - m_label_text_unfocus_gc.setForeground(*m_label_unfocus_color); m_button_pic_focus_gc.setForeground(*m_button_focus_color); m_button_pic_unfocus_gc.setForeground(*m_button_unfocus_color); + + m_iconbar_theme.reconfigTheme(); } diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index 319e01b..526bd3b 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -33,6 +33,7 @@ #include "FbTk/GContext.hh" #include "BorderTheme.hh" +#include "IconbarTheme.hh" #include "Shape.hh" class FbWinFrameTheme: public FbTk::Theme { @@ -43,9 +44,6 @@ public: @name textures */ //@{ - const FbTk::Texture &labelFocusTexture() const { return *m_label_focus; } - const FbTk::Texture &labelUnfocusTexture() const { return *m_label_unfocus; } - const FbTk::ThemeItem &label() const { return m_label_unfocus; } const FbTk::Texture &titleFocusTexture() const { return *m_title_focus; } const FbTk::Texture &titleUnfocusTexture() const { return *m_title_unfocus; } @@ -64,9 +62,6 @@ public: @name colors */ //@{ - const FbTk::Color &labelFocusColor() const { return *m_label_focus_color; } - const FbTk::Color &labelUnfocusColor() const { return *m_label_unfocus_color; } - const FbTk::Color &buttonFocuscolor() const { return *m_button_focus_color; } const FbTk::Color &buttonUnfocuscolor() const { return *m_button_unfocus_color; } //@} @@ -74,8 +69,6 @@ public: FbTk::Justify justify() const { return *m_textjustify; } - GC labelTextFocusGC() const { return m_label_text_focus_gc.gc(); } - GC labelTextUnfocusGC() const { return m_label_text_unfocus_gc.gc(); } GC buttonPicFocusGC() const { return m_button_pic_focus_gc.gc(); } GC buttonPicUnfocusGC() const { return m_button_pic_unfocus_gc.gc(); } @@ -100,14 +93,14 @@ public: void setFocusedAlpha(unsigned char alpha) { m_focused_alpha = alpha; } void setUnfocusedAlpha(unsigned char alpha) { m_unfocused_alpha = alpha; } + IconbarTheme &iconbarTheme() { return m_iconbar_theme; } + private: - FbTk::ThemeItem m_label_focus, m_label_unfocus; FbTk::ThemeItem m_title_focus, m_title_unfocus; FbTk::ThemeItem m_handle_focus, m_handle_unfocus; FbTk::ThemeItem m_button_focus, m_button_unfocus, m_button_pressed; FbTk::ThemeItem m_grip_focus, m_grip_unfocus; - FbTk::ThemeItem m_label_focus_color, m_label_unfocus_color; FbTk::ThemeItem m_button_focus_color, m_button_unfocus_color; FbTk::ThemeItem m_font; @@ -117,7 +110,6 @@ private: FbTk::ThemeItem m_title_height, m_bevel_width, m_handle_width; BorderTheme m_border; - FbTk::GContext m_label_text_focus_gc, m_label_text_unfocus_gc; FbTk::GContext m_button_pic_focus_gc, m_button_pic_unfocus_gc; Cursor m_cursor_move; @@ -127,6 +119,8 @@ private: Cursor m_cursor_upper_right_angle; unsigned char m_focused_alpha; unsigned char m_unfocused_alpha; + + IconbarTheme m_iconbar_theme; }; #endif // FBWINFRAMETHEME_HH diff --git a/src/IconButton.cc b/src/IconButton.cc index e3aae47..b884fbb 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -24,6 +24,7 @@ #include "IconButton.hh" #include "IconbarTool.hh" +#include "IconbarTheme.hh" #include "Screen.hh" #include "Focusable.hh" @@ -46,13 +47,14 @@ #endif // SHAPE -IconButton::IconButton(const FbTk::FbWindow &parent, FbTk::Font &font, +IconButton::IconButton(const FbTk::FbWindow &parent, IconbarTheme &theme, Focusable &win): - FbTk::TextButton(parent, font, win.title()), + FbTk::TextButton(parent, theme.focusedText().font(), win.title()), m_win(win), m_icon_window(*this, 1, 1, 1, 1, ExposureMask | ButtonPressMask | ButtonReleaseMask), - m_use_pixmap(true) { + m_use_pixmap(true), + m_theme(theme) { m_win.titleSig().attach(this); diff --git a/src/IconButton.hh b/src/IconButton.hh index 54dae1d..b724084 100644 --- a/src/IconButton.hh +++ b/src/IconButton.hh @@ -30,10 +30,11 @@ #include "FbTk/TextButton.hh" class Focusable; +class IconbarTheme; class IconButton: public FbTk::TextButton, public FbTk::Observer { public: - IconButton(const FbTk::FbWindow &parent, FbTk::Font &font, + IconButton(const FbTk::FbWindow &parent, IconbarTheme &theme, Focusable &window); virtual ~IconButton(); @@ -64,6 +65,8 @@ private: FbTk::FbPixmap m_icon_pixmap; FbTk::FbPixmap m_icon_mask; bool m_use_pixmap; + + IconbarTheme &m_theme; }; #endif // ICONBUTTON_HH diff --git a/src/IconbarTheme.cc b/src/IconbarTheme.cc index f4e4c55..1f25ac3 100644 --- a/src/IconbarTheme.cc +++ b/src/IconbarTheme.cc @@ -37,8 +37,7 @@ IconbarTheme::IconbarTheme(int screen_num, m_border(*this, name, altname), m_focused_text(*this, name + ".focused", altname + ".Focused"), m_unfocused_text(*this, name + ".unfocused", altname + ".Unfocused"), - m_name(name), - m_alpha(*this, name+".alpha", altname+".Alpha") { + m_name(name), m_altname(altname) { FbTk::ThemeManager::instance().loadTheme(*this); @@ -58,6 +57,7 @@ bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) { using namespace FbTk; ThemeManager &tm = ThemeManager::instance(); + // TODO: fix fallbacks for "focused" vs. "focus" if (&m_focused_texture == &item) { return (tm.loadItem(item, "window.label.focus", "Window.Label.Focus") || tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel")); @@ -91,11 +91,6 @@ bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) { } else if (item.name() == m_name + ".unfocused.textColor") { return tm.loadItem(item, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"); - } else if (item.name() == m_name + ".alpha") { - if (!tm.loadItem(item, "toolbar.alpha", "Toolbar.Alpha")) { - *m_alpha = 255; - } - return true; } return false; diff --git a/src/IconbarTheme.hh b/src/IconbarTheme.hh index 62fa2ef..419ab1a 100644 --- a/src/IconbarTheme.hh +++ b/src/IconbarTheme.hh @@ -49,14 +49,12 @@ public: const FbTk::Texture &focusedTexture() const { return *m_focused_texture; } const FbTk::Texture &unfocusedTexture() const { return *m_unfocused_texture; } const FbTk::Texture &emptyTexture() const { return *m_empty_texture; } - inline unsigned char alpha() const { return *m_alpha; } private: FbTk::ThemeItem m_focused_texture, m_unfocused_texture, m_empty_texture; BorderTheme m_focused_border, m_unfocused_border, m_border; TextTheme m_focused_text, m_unfocused_text; - std::string m_name; - FbTk::ThemeItem m_alpha; + std::string m_name, m_altname; }; #endif // ICONBARTHEME_HH diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 2b4edd1..42d5782 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -856,10 +856,7 @@ void IconbarTool::addWindow(Focusable &win) { #ifdef DEBUG cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "<