diff options
Diffstat (limited to 'src/TooltipWindow.cc')
-rw-r--r-- | src/TooltipWindow.cc | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/src/TooltipWindow.cc b/src/TooltipWindow.cc index 42926d8..284f232 100644 --- a/src/TooltipWindow.cc +++ b/src/TooltipWindow.cc | |||
@@ -28,33 +28,35 @@ | |||
28 | TooltipWindow::TooltipWindow(const FbTk::FbWindow &parent, BScreen &screen, | 28 | TooltipWindow::TooltipWindow(const FbTk::FbWindow &parent, BScreen &screen, |
29 | FbTk::ThemeProxy<FbWinFrameTheme> &theme): | 29 | FbTk::ThemeProxy<FbWinFrameTheme> &theme): |
30 | OSDWindow(parent, screen, theme), | 30 | OSDWindow(parent, screen, theme), |
31 | delay(-1) { | 31 | m_delay(-1) { |
32 | 32 | ||
33 | FbTk::RefCount<FbTk::Command<void> > raisecmd(new FbTk::SimpleCommand<TooltipWindow>(*this, &TooltipWindow::raiseTooltip)); | 33 | FbTk::RefCount<FbTk::Command<void> > |
34 | timer.setCommand(raisecmd); | 34 | raisecmd(new FbTk::SimpleCommand<TooltipWindow>(*this, |
35 | timer.fireOnce(true); | 35 | &TooltipWindow::raiseTooltip)); |
36 | m_timer.setCommand(raisecmd); | ||
37 | m_timer.fireOnce(true); | ||
36 | 38 | ||
37 | } | 39 | } |
38 | 40 | ||
39 | void TooltipWindow::showText(const std::string &text) { | 41 | void TooltipWindow::showText(const std::string &text) { |
40 | 42 | ||
41 | lastText = text.c_str(); | 43 | m_lastText = text; |
42 | if (delay == 0) | 44 | if (m_delay == 0) |
43 | raiseTooltip(); | 45 | raiseTooltip(); |
44 | else | 46 | else |
45 | timer.start(); | 47 | m_timer.start(); |
46 | 48 | ||
47 | } | 49 | } |
48 | 50 | ||
49 | void TooltipWindow::raiseTooltip() { | 51 | void TooltipWindow::raiseTooltip() { |
50 | 52 | ||
51 | if (lastText.size() == 0) | 53 | if (m_lastText.empty()) |
52 | return; | 54 | return; |
53 | 55 | ||
54 | resize(lastText); | 56 | resize(m_lastText); |
55 | reconfigTheme(); | 57 | reconfigTheme(); |
56 | int h = m_theme->font().height() + m_theme->bevelWidth() * 2; | 58 | int h = theme()->font().height() + theme()->bevelWidth() * 2; |
57 | int w = m_theme->font().textWidth(lastText, lastText.size()) + m_theme->bevelWidth() * 2; | 59 | int w = theme()->font().textWidth(m_lastText, m_lastText.size()) + theme()->bevelWidth() * 2; |
58 | 60 | ||
59 | Window root_ret; // not used | 61 | Window root_ret; // not used |
60 | Window window_ret; // not used | 62 | Window window_ret; // not used |
@@ -62,13 +64,13 @@ void TooltipWindow::raiseTooltip() { | |||
62 | int wx, wy; // not used | 64 | int wx, wy; // not used |
63 | unsigned int mask; // not used | 65 | unsigned int mask; // not used |
64 | 66 | ||
65 | XQueryPointer(display(), m_screen.rootWindow().window(), | 67 | XQueryPointer(display(), screen().rootWindow().window(), |
66 | &root_ret, &window_ret, &rx, &ry, &wx, &wy, &mask); | 68 | &root_ret, &window_ret, &rx, &ry, &wx, &wy, &mask); |
67 | 69 | ||
68 | int head = m_screen.getHead(rx, ry); | 70 | int head = screen().getHead(rx, ry); |
69 | int head_top = m_screen.getHeadY(head); | 71 | int head_top = screen().getHeadY(head); |
70 | int head_left = m_screen.getHeadX(head); | 72 | int head_left = screen().getHeadX(head); |
71 | int head_right = head_left + m_screen.getHeadWidth(head); | 73 | int head_right = head_left + screen().getHeadWidth(head); |
72 | 74 | ||
73 | // center the mouse horizontally | 75 | // center the mouse horizontally |
74 | rx -= w/2; | 76 | rx -= w/2; |
@@ -88,22 +90,27 @@ void TooltipWindow::raiseTooltip() { | |||
88 | 90 | ||
89 | show(); | 91 | show(); |
90 | clear(); | 92 | clear(); |
91 | m_theme->font().drawText(*this, m_screen.screenNumber(), | 93 | theme()->font().drawText(*this, screen().screenNumber(), |
92 | m_theme->iconbarTheme().text().textGC(), lastText, | 94 | theme()->iconbarTheme().text().textGC(), |
93 | lastText.size(), m_theme->bevelWidth(), | 95 | m_lastText, m_lastText.size(), |
94 | m_theme->bevelWidth() + m_theme->font().ascent()); | 96 | theme()->bevelWidth(), |
97 | theme()->bevelWidth() + theme()->font().ascent()); | ||
95 | } | 98 | } |
96 | 99 | ||
100 | void TooltipWindow::updateText(const std::string &text) { | ||
101 | m_lastText = text; | ||
102 | raiseTooltip(); | ||
103 | } | ||
97 | 104 | ||
98 | void TooltipWindow::show() { | 105 | void TooltipWindow::show() { |
99 | if (m_visible) | 106 | if (isVisible()) |
100 | return; | 107 | return; |
101 | m_visible = true; | 108 | setVisible(true); |
102 | raise(); | 109 | raise(); |
103 | FbTk::FbWindow::show(); | 110 | FbTk::FbWindow::show(); |
104 | } | 111 | } |
105 | 112 | ||
106 | void TooltipWindow::hide() { | 113 | void TooltipWindow::hide() { |
107 | timer.stop(); | 114 | m_timer.stop(); |
108 | OSDWindow::hide(); | 115 | OSDWindow::hide(); |
109 | } | 116 | } |