aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorVladimir A. Pavlov <pv4@bk.ru>2012-07-27 17:32:35 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2012-08-03 09:37:34 (GMT)
commit71f75c70ae4e47ba0a58590aeb17152fc648edf7 (patch)
tree3646ec2845434f897b5a73bc578129d52f80b356 /src/FbTk
parent9d25ea54a1a21c252622232e0ec959f500e638f3 (diff)
downloadfluxbox-71f75c70ae4e47ba0a58590aeb17152fc648edf7.zip
fluxbox-71f75c70ae4e47ba0a58590aeb17152fc648edf7.tar.bz2
Add menu.hilite.font and menu.hilite.justify style resources
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/MenuItem.cc32
-rw-r--r--src/FbTk/MenuTheme.cc14
-rw-r--r--src/FbTk/MenuTheme.hh11
3 files changed, 37 insertions, 20 deletions
diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc
index c1357fb..c128c57 100644
--- a/src/FbTk/MenuItem.cc
+++ b/src/FbTk/MenuItem.cc
@@ -49,20 +49,20 @@ void MenuItem::drawLine(FbDrawable &draw,
49 unsigned int height = theme->itemHeight(); 49 unsigned int height = theme->itemHeight();
50 int bevelW = theme->bevelWidth(); 50 int bevelW = theme->bevelWidth();
51 51
52 int font_top = (height - theme->frameFont().height())/2; 52 int font_top = (height - theme->hiliteFont().height())/2;
53 int underline_height = font_top + theme->frameFont().ascent() + 2; 53 int underline_height = font_top + theme->hiliteFont().ascent() + 2;
54 int bottom = height - bevelW - 1; 54 int bottom = height - bevelW - 1;
55 55
56 text_y += bottom > underline_height ? underline_height : bottom; 56 text_y += bottom > underline_height ? underline_height : bottom;
57 57
58 int text_w = theme->frameFont().textWidth(label()); 58 int text_w = theme->hiliteFont().textWidth(label());
59 59
60 const FbString& visual = m_label.visual(); 60 const FbString& visual = m_label.visual();
61 BiDiString search_string(FbString(visual, 0, size > visual.size() ? visual.size() : size)); 61 BiDiString search_string(FbString(visual, 0, size > visual.size() ? visual.size() : size));
62 int search_string_w = theme->frameFont().textWidth(search_string); 62 int search_string_w = theme->hiliteFont().textWidth(search_string);
63 63
64 // pay attention to the text justification 64 // pay attention to the text justification
65 switch(theme->frameFontJustify()) { 65 switch(theme->hiliteFontJustify()) {
66 case FbTk::LEFT: 66 case FbTk::LEFT:
67 text_x += bevelW + height + 1; 67 text_x += bevelW + height + 1;
68 break; 68 break;
@@ -76,7 +76,7 @@ void MenuItem::drawLine(FbDrawable &draw,
76 76
77 // avoid drawing an ugly dot 77 // avoid drawing an ugly dot
78 if (size != 0) 78 if (size != 0)
79 draw.drawLine(theme->frameUnderlineGC().gc(), 79 draw.drawLine(theme->hiliteUnderlineGC().gc(),
80 text_x, text_y, text_x + search_string_w, text_y); 80 text_x, text_y, text_x + search_string_w, text_y);
81 81
82} 82}
@@ -152,16 +152,17 @@ void MenuItem::draw(FbDrawable &draw,
152 const GContext &tgc = 152 const GContext &tgc =
153 (highlight ? theme->hiliteTextGC() : 153 (highlight ? theme->hiliteTextGC() :
154 (isEnabled() ? theme->frameTextGC() : theme->disableTextGC() ) ); 154 (isEnabled() ? theme->frameTextGC() : theme->disableTextGC() ) );
155 const Font& font = (highlight ? theme->hiliteFont() : theme->frameFont());
155 // 156 //
156 // Text 157 // Text
157 // 158 //
158 int text_y = y, text_x = x; 159 int text_y = y, text_x = x;
159 int text_w = theme->frameFont().textWidth(label()); 160 int text_w = font.textWidth(label());
160 161
161 int height_offset = theme->itemHeight() - (theme->frameFont().height() + 2*theme->bevelWidth()); 162 int height_offset = theme->itemHeight() - (font.height() + 2*theme->bevelWidth());
162 text_y = y + theme->bevelWidth() + theme->frameFont().ascent() + height_offset/2; 163 text_y = y + theme->bevelWidth() + font.ascent() + height_offset/2;
163 164
164 switch(theme->frameFontJustify()) { 165 switch(highlight ? theme->hiliteFontJustify() : theme->frameFontJustify()) {
165 case FbTk::LEFT: 166 case FbTk::LEFT:
166 text_x = x + theme->bevelWidth() + height + 1; 167 text_x = x + theme->bevelWidth() + height + 1;
167 break; 168 break;
@@ -174,7 +175,7 @@ void MenuItem::draw(FbDrawable &draw,
174 break; 175 break;
175 } 176 }
176 177
177 theme->frameFont().drawText(draw, theme->screenNum(), tgc.gc(), label(), text_x, text_y); 178 font.drawText(draw, theme->screenNum(), tgc.gc(), label(), text_x, text_y);
178 } 179 }
179 180
180 GC gc = (highlight) ? theme->hiliteTextGC().gc() : 181 GC gc = (highlight) ? theme->hiliteTextGC().gc() :
@@ -324,14 +325,17 @@ void MenuItem::setIcon(const std::string &filename, int screen_num) {
324} 325}
325 326
326unsigned int MenuItem::height(const FbTk::ThemeProxy<MenuTheme> &theme) const { 327unsigned int MenuItem::height(const FbTk::ThemeProxy<MenuTheme> &theme) const {
327 return std::max(theme->frameFont().height() + 2*theme->bevelWidth(), theme->itemHeight()); 328 return std::max(theme->itemHeight(),
329 std::max(theme->frameFont().height() + 2*theme->bevelWidth(),
330 theme->hiliteFont().height() + 2*theme->bevelWidth()));
328} 331}
329 332
330unsigned int MenuItem::width(const FbTk::ThemeProxy<MenuTheme> &theme) const { 333unsigned int MenuItem::width(const FbTk::ThemeProxy<MenuTheme> &theme) const {
331 // textwidth + bevel width on each side of the text 334 // textwidth + bevel width on each side of the text
332 const unsigned int icon_width = height(theme); 335 const unsigned int icon_width = height(theme);
333 const unsigned int normal = theme->frameFont().textWidth(label()) + 336 const unsigned int normal = 2 * (theme->bevelWidth() + icon_width) +
334 2 * (theme->bevelWidth() + icon_width); 337 std::max(theme->frameFont().textWidth(label()),
338 theme->hiliteFont().textWidth(label()));
335 return m_icon.get() == 0 ? normal : normal + icon_width; 339 return m_icon.get() == 0 ? normal : normal + icon_width;
336} 340}
337 341
diff --git a/src/FbTk/MenuTheme.cc b/src/FbTk/MenuTheme.cc
index 28bcc35..db54483 100644
--- a/src/FbTk/MenuTheme.cc
+++ b/src/FbTk/MenuTheme.cc
@@ -48,7 +48,9 @@ MenuTheme::MenuTheme(int screen_num):
48 hilite(*this, "menu.hilite", "Menu.Hilite"), 48 hilite(*this, "menu.hilite", "Menu.Hilite"),
49 titlefont(*this, "menu.title.font", "Menu.Title.Font"), 49 titlefont(*this, "menu.title.font", "Menu.Title.Font"),
50 framefont(*this, "menu.frame.font", "Menu.Frame.Font"), 50 framefont(*this, "menu.frame.font", "Menu.Frame.Font"),
51 hilitefont(*this, "menu.hilite.font", "Menu.Hilite.Font"),
51 framefont_justify(*this, "menu.frame.justify", "Menu.Frame.Justify"), 52 framefont_justify(*this, "menu.frame.justify", "Menu.Frame.Justify"),
53 hilitefont_justify(*this, "menu.hilite.justify", "Menu.Hilite.Justify"),
52 titlefont_justify(*this, "menu.title.justify", "Menu.Title.Justify"), 54 titlefont_justify(*this, "menu.title.justify", "Menu.Title.Justify"),
53 bullet_pos(*this, "menu.bullet.position", "Menu.Bullet.Position"), 55 bullet_pos(*this, "menu.bullet.position", "Menu.Bullet.Position"),
54 m_bullet(*this, "menu.bullet", "Menu.Bullet"), 56 m_bullet(*this, "menu.bullet", "Menu.Bullet"),
@@ -84,7 +86,9 @@ MenuTheme::MenuTheme(int screen_num):
84 86
85 ThemeManager::instance().loadTheme(*this); 87 ThemeManager::instance().loadTheme(*this);
86 88
87 m_real_item_height = std::max(*m_item_height, frameFont().height() + 2*bevelWidth()); 89 m_real_item_height = std::max(*m_item_height,
90 std::max(frameFont().height() + 2*bevelWidth(),
91 hiliteFont().height() + 2*bevelWidth()));
88 m_real_title_height = std::max(*m_title_height, 92 m_real_title_height = std::max(*m_title_height,
89 titleFont().height() + 2*bevelWidth()); 93 titleFont().height() + 2*bevelWidth());
90 94
@@ -111,7 +115,9 @@ void MenuTheme::reconfigTheme() {
111 if (*m_border_width > 20) 115 if (*m_border_width > 20)
112 *m_border_width = 20; 116 *m_border_width = 20;
113 117
114 m_real_item_height = std::max(*m_item_height, frameFont().height() + 2*bevelWidth()); 118 m_real_item_height = std::max(*m_item_height,
119 std::max(frameFont().height() + 2*bevelWidth(),
120 hiliteFont().height() + 2*bevelWidth()));
115 m_real_title_height = std::max(*m_title_height, 121 m_real_title_height = std::max(*m_title_height,
116 titleFont().height() + 2*bevelWidth()); 122 titleFont().height() + 2*bevelWidth());
117 123
@@ -143,6 +149,10 @@ bool MenuTheme::fallback(ThemeItem_base &item) {
143 return ThemeManager::instance().loadItem(item, "borderColor", "BorderColor"); 149 return ThemeManager::instance().loadItem(item, "borderColor", "BorderColor");
144 } else if (item.name() == "menu.bevelWidth") { 150 } else if (item.name() == "menu.bevelWidth") {
145 return ThemeManager::instance().loadItem(item, "bevelWidth", "BevelWidth"); 151 return ThemeManager::instance().loadItem(item, "bevelWidth", "BevelWidth");
152 } else if (item.name() == "menu.hilite.font") {
153 return ThemeManager::instance().loadItem(item, "menu.frame.font", "Menu.Frame.Font");
154 } else if (item.name() == "menu.hilite.justify") {
155 return ThemeManager::instance().loadItem(item, "menu.frame.justify", "Menu.Frame.Justify");
146 } 156 }
147 157
148 return false; 158 return false;
diff --git a/src/FbTk/MenuTheme.hh b/src/FbTk/MenuTheme.hh
index d39b5df..e217e7c 100644
--- a/src/FbTk/MenuTheme.hh
+++ b/src/FbTk/MenuTheme.hh
@@ -76,9 +76,12 @@ public:
76 Font &titleFont() { return *titlefont; } 76 Font &titleFont() { return *titlefont; }
77 const Font &frameFont() const { return *framefont; } 77 const Font &frameFont() const { return *framefont; }
78 Font &frameFont() { return *framefont; } 78 Font &frameFont() { return *framefont; }
79 const Font &hiliteFont() const { return *hilitefont; }
80 Font &hiliteFont() { return *hilitefont; }
79 ///@} 81 ///@}
80 82
81 Justify frameFontJustify() const { return *framefont_justify; } 83 Justify frameFontJustify() const { return *framefont_justify; }
84 Justify hiliteFontJustify() const { return *hilitefont_justify; }
82 Justify titleFontJustify() const { return *titlefont_justify; } 85 Justify titleFontJustify() const { return *titlefont_justify; }
83 86
84 /** 87 /**
@@ -87,13 +90,13 @@ public:
87 ///@{ 90 ///@{
88 const GContext &titleTextGC() const { return t_text_gc; } 91 const GContext &titleTextGC() const { return t_text_gc; }
89 const GContext &frameTextGC() const { return f_text_gc; } 92 const GContext &frameTextGC() const { return f_text_gc; }
90 const GContext &frameUnderlineGC() const { return u_text_gc; } 93 const GContext &hiliteUnderlineGC() const { return u_text_gc; }
91 const GContext &hiliteTextGC() const { return h_text_gc; } 94 const GContext &hiliteTextGC() const { return h_text_gc; }
92 const GContext &disableTextGC() const { return d_text_gc; } 95 const GContext &disableTextGC() const { return d_text_gc; }
93 const GContext &hiliteGC() const { return hilite_gc; } 96 const GContext &hiliteGC() const { return hilite_gc; }
94 GContext &titleTextGC() { return t_text_gc; } 97 GContext &titleTextGC() { return t_text_gc; }
95 GContext &frameTextGC() { return f_text_gc; } 98 GContext &frameTextGC() { return f_text_gc; }
96 GContext &frameUnderlineGC() { return u_text_gc; } 99 GContext &hiliteUnderlineGC() { return u_text_gc; }
97 GContext &hiliteTextGC() { return h_text_gc; } 100 GContext &hiliteTextGC() { return h_text_gc; }
98 GContext &disableTextGC() { return d_text_gc; } 101 GContext &disableTextGC() { return d_text_gc; }
99 GContext &hiliteGC() { return hilite_gc; } 102 GContext &hiliteGC() { return hilite_gc; }
@@ -138,8 +141,8 @@ public:
138private: 141private:
139 ThemeItem<Color> t_text, f_text, h_text, d_text, u_text; 142 ThemeItem<Color> t_text, f_text, h_text, d_text, u_text;
140 ThemeItem<Texture> title, frame, hilite; 143 ThemeItem<Texture> title, frame, hilite;
141 ThemeItem<Font> titlefont, framefont; 144 ThemeItem<Font> titlefont, framefont, hilitefont;
142 ThemeItem<Justify> framefont_justify, titlefont_justify; 145 ThemeItem<Justify> framefont_justify, hilitefont_justify, titlefont_justify;
143 ThemeItem<Justify> bullet_pos; 146 ThemeItem<Justify> bullet_pos;
144 ThemeItem<BulletType> m_bullet; 147 ThemeItem<BulletType> m_bullet;
145 ThemeItem<Shape::ShapePlace> m_shapeplace; 148 ThemeItem<Shape::ShapePlace> m_shapeplace;