aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/MenuItem.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/MenuItem.cc')
-rw-r--r--src/FbTk/MenuItem.cc32
1 files changed, 18 insertions, 14 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