aboutsummaryrefslogtreecommitdiff
path: root/src/IconbarTheme.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-01-07 10:26:32 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-01-07 10:26:32 (GMT)
commitdbfddf8e0bcf8e7abbba671eff64c9679332a774 (patch)
tree37cefce75eef2f7e0c749c3489008608e71dcd6c /src/IconbarTheme.cc
parentac1bd7e0981222bf340ce7defb2bb8307d42a0a2 (diff)
downloadfluxbox_pavel-dbfddf8e0bcf8e7abbba671eff64c9679332a774.zip
fluxbox_pavel-dbfddf8e0bcf8e7abbba671eff64c9679332a774.tar.bz2
added new ThemeProxy for automatically handling focused vs. unfocused ThemeItems
Diffstat (limited to 'src/IconbarTheme.cc')
-rw-r--r--src/IconbarTheme.cc60
1 files changed, 21 insertions, 39 deletions
diff --git a/src/IconbarTheme.cc b/src/IconbarTheme.cc
index f2247aa..0be9cd1 100644
--- a/src/IconbarTheme.cc
+++ b/src/IconbarTheme.cc
@@ -27,26 +27,10 @@ IconbarTheme::IconbarTheme(int screen_num,
27 const std::string &name, 27 const std::string &name,
28 const std::string &altname): 28 const std::string &altname):
29 FbTk::Theme(screen_num), 29 FbTk::Theme(screen_num),
30 m_focused_texture(*this, 30 m_texture(*this, name, altname),
31 name + (name == "window.label" ? ".focus" : ".focused"),
32 altname + (name == "window.label" ? ".Focus" : ".Focused")),
33 m_unfocused_texture(*this,
34 name + (name == "window.label" ? ".unfocus" : ".unfocused"),
35 altname + (name == "window.label" ? ".Unfocus" : ".Unfocused")),
36 m_empty_texture(*this, name + ".empty", altname + ".Empty"), 31 m_empty_texture(*this, name + ".empty", altname + ".Empty"),
37 m_focused_border(*this,
38 name + (name == "window.label" ? ".focus" : ".focused"),
39 altname + (name == "window.label" ? ".Focus" : ".Focused")),
40 m_unfocused_border(*this,
41 name + (name == "window.label" ? ".unfocus" : ".unfocused"),
42 altname + (name == "window.label" ? ".Unfocus" : ".Unfocused")),
43 m_border(*this, name, altname), 32 m_border(*this, name, altname),
44 m_focused_text(*this, 33 m_text(*this, name, altname),
45 name + (name == "window.label" ? ".focus" : ".focused"),
46 altname + (name == "window.label" ? ".Focus" : ".Focused")),
47 m_unfocused_text(*this,
48 name + (name == "window.label" ? ".unfocus" : ".unfocused"),
49 altname + (name == "window.label" ? ".Unfocus" : ".Unfocused")),
50 m_name(name), m_altname(altname) { 34 m_name(name), m_altname(altname) {
51 35
52 FbTk::ThemeManager::instance().loadTheme(*this); 36 FbTk::ThemeManager::instance().loadTheme(*this);
@@ -58,48 +42,46 @@ IconbarTheme::~IconbarTheme() {
58 42
59 43
60void IconbarTheme::reconfigTheme() { 44void IconbarTheme::reconfigTheme() {
61 m_focused_text.updateTextColor(); 45 m_text.updateTextColor();
62 m_unfocused_text.updateTextColor();
63} 46}
64 47
65// fallback resources 48// fallback resources
66bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) { 49bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) {
67 using namespace FbTk; 50 using namespace FbTk;
68 ThemeManager &tm = ThemeManager::instance(); 51 ThemeManager &tm = ThemeManager::instance();
69 std::string focus = (m_name == "window.label" ? ".focus" : ".focused"); 52 std::string base = m_name;
70 std::string un = (m_name == "window.label" ? ".unfocus" : ".unfocused"); 53 base.erase(base.find_last_of("."));
54 std::string altbase = m_altname;
55 altbase.erase(altbase.find_last_of("."));
71 56
72 if (&m_focused_texture == &item || &m_unfocused_texture == &item) { 57 if (&m_texture == &item) {
73 return tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel"); 58 return tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel");
74 } else if (&m_empty_texture == &item) { 59 } else if (&m_empty_texture == &item) {
75 return (tm.loadItem(item, m_focused_texture.name(), 60 return (tm.loadItem(item, "toolbar.iconbar.empty",
76 m_focused_texture.altName()) || 61 "Toolbar.Iconbar.Empty") ||
62 tm.loadItem(item, m_texture.name(), m_texture.altName()) ||
77 tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel") 63 tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel")
78 || tm.loadItem(item, "toolbar", "toolbar")); 64 || tm.loadItem(item, "toolbar", "toolbar"));
79 } else if (item.name() == m_name + focus + ".borderWidth" || 65 } else if (item.name() == m_name + ".borderWidth")
80 item.name() == m_name + un + ".borderWidth")
81 // don't fallback for base border, for theme backwards compatibility 66 // don't fallback for base border, for theme backwards compatibility
82 return (tm.loadItem(item, m_name + ".borderWidth", 67 return (tm.loadItem(item, base + ".borderWidth",
83 m_altname + ".BorderWidth") || 68 altbase + ".BorderWidth") ||
84 tm.loadItem(item, "window.borderWidth", "Window.BorderWidth") || 69 tm.loadItem(item, "window.borderWidth", "Window.BorderWidth") ||
85 tm.loadItem(item, "borderWidth", "BorderWidth")); 70 tm.loadItem(item, "borderWidth", "BorderWidth"));
86 71
87 else if (item.name() == m_name + focus + ".borderColor" || 72 else if (item.name() == m_name + ".borderColor")
88 item.name() == m_name + un + ".borderColor")
89 73
90 return (tm.loadItem(item, m_name + ".borderColor", 74 return (tm.loadItem(item, base + ".borderColor",
91 m_altname + ".BorderColor") || 75 altbase + ".BorderColor") ||
92 tm.loadItem(item, "window.borderColor", "Window.BorderColor") || 76 tm.loadItem(item, "window.borderColor", "Window.BorderColor") ||
93 tm.loadItem(item, "borderColor", "BorderColor")); 77 tm.loadItem(item, "borderColor", "BorderColor"));
94 78
95 else if (item.name() == m_name + focus + ".font" || 79 else if (item.name() == m_name + ".font")
96 item.name() == m_name + un + ".font")
97 80
98 return tm.loadItem(item, "window.font", "Window.Font"); 81 return tm.loadItem(item, "window.font", "Window.Font");
99 82
100 else if (item.name() == m_name + focus + ".justify" || 83 else if (item.name() == m_name + ".justify") {
101 item.name() == m_name + un + ".justify") { 84 return (tm.loadItem(item, base + ".justify", altbase + ".Justify")
102 return (tm.loadItem(item, m_name + ".justify", m_altname + ".Justify")
103 || tm.loadItem(item, "window.justify", "Window.Justify")); 85 || tm.loadItem(item, "window.justify", "Window.Justify"));
104 } 86 }
105 87