aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/MenuItem.cc
diff options
context:
space:
mode:
authormarkt <markt>2007-03-03 19:35:34 (GMT)
committermarkt <markt>2007-03-03 19:35:34 (GMT)
commita233229bd854d2e925ca0f1e86846ff9fde46fcd (patch)
treea30fffa38994e8ee12096c31a256ba6b3fbfa2c6 /src/FbTk/MenuItem.cc
parentd6a7bd786fd657e16c1ebad5c515d60ba1368d8a (diff)
downloadfluxbox_pavel-a233229bd854d2e925ca0f1e86846ff9fde46fcd.zip
fluxbox_pavel-a233229bd854d2e925ca0f1e86846ff9fde46fcd.tar.bz2
added support for typeahead in menus
Diffstat (limited to 'src/FbTk/MenuItem.cc')
-rw-r--r--src/FbTk/MenuItem.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc
index a2c3fe2..82dd155 100644
--- a/src/FbTk/MenuItem.cc
+++ b/src/FbTk/MenuItem.cc
@@ -38,6 +38,44 @@ void MenuItem::click(int button, int time) {
38 m_command->execute(); 38 m_command->execute();
39} 39}
40 40
41void MenuItem::drawLine(FbDrawable &draw, const MenuTheme &theme, size_t size,
42 int text_x, int text_y, unsigned int width) const {
43
44 unsigned int height = theme.itemHeight();
45 int bevelW = theme.bevelWidth();
46
47 int font_top = (height - theme.frameFont().height())/2;
48 int underline_height = font_top + theme.frameFont().ascent() + 2;
49 int bottom = height - bevelW - 1;
50
51 text_y += bottom > underline_height ? underline_height : bottom;
52 int text_w = theme.frameFont().textWidth(m_label.c_str(), m_label.size());
53
54 // width of the searchstring
55 size = size > m_label.length() ? m_label.length() : size;
56 std::string search_string = m_label.substr(0,size);
57 int search_string_w = theme.frameFont().textWidth(search_string.c_str(), size);
58
59 // pay attention to the text justification
60 switch(theme.frameFontJustify()) {
61 case FbTk::LEFT:
62 text_x += bevelW + height + 1;
63 break;
64 case FbTk::RIGHT:
65 text_x += width - (height + bevelW + text_w);
66 break;
67 default: //center
68 text_x += ((width + 1 - text_w) / 2);
69 break;
70 }
71
72 // avoid drawing an ugly dot
73 if (size != 0)
74 draw.drawLine(theme.frameUnderlineGC().gc(),
75 text_x, text_y, text_x + search_string_w, text_y);
76
77}
78
41void MenuItem::draw(FbDrawable &draw, 79void MenuItem::draw(FbDrawable &draw,
42 const MenuTheme &theme, 80 const MenuTheme &theme,
43 bool highlight, bool draw_foreground, bool draw_background, 81 bool highlight, bool draw_foreground, bool draw_background,