aboutsummaryrefslogtreecommitdiff
path: root/src/IconButton.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r--src/IconButton.cc29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc
index 6b8118e..0511a06 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.cc
@@ -55,6 +55,7 @@ IconButton::IconButton(const FbTk::FbWindow &parent,
55 ExposureMask |EnterWindowMask | LeaveWindowMask | 55 ExposureMask |EnterWindowMask | LeaveWindowMask |
56 ButtonPressMask | ButtonReleaseMask), 56 ButtonPressMask | ButtonReleaseMask),
57 m_use_pixmap(true), 57 m_use_pixmap(true),
58 m_has_tooltip(false),
58 m_theme(win, focused_theme, unfocused_theme), 59 m_theme(win, focused_theme, unfocused_theme),
59 m_pm(win.screen().imageControl()) { 60 m_pm(win.screen().imageControl()) {
60 61
@@ -81,16 +82,12 @@ void IconButton::exposeEvent(XExposeEvent &event) {
81} 82}
82 83
83void IconButton::enterNotifyEvent(XCrossingEvent &ev) { 84void IconButton::enterNotifyEvent(XCrossingEvent &ev) {
84 85 m_has_tooltip = true;
85 int xoffset = 1; 86 showTooltip();
86 if (m_icon_pixmap.drawable() != 0)
87 xoffset = m_icon_window.x() + m_icon_window.width() + 1;
88
89 if (FbTk::TextButton::textExceeds(xoffset))
90 m_win.screen().showTooltip(m_win.title());
91} 87}
92 88
93void IconButton::leaveNotifyEvent(XCrossingEvent &ev) { 89void IconButton::leaveNotifyEvent(XCrossingEvent &ev) {
90 m_has_tooltip = false;
94 m_win.screen().hideTooltip(); 91 m_win.screen().hideTooltip();
95} 92}
96 93
@@ -113,6 +110,15 @@ void IconButton::resize(unsigned int width, unsigned int height) {
113 } 110 }
114} 111}
115 112
113void IconButton::showTooltip() {
114 int xoffset = 1;
115 if (m_icon_pixmap.drawable() != 0)
116 xoffset = m_icon_window.x() + m_icon_window.width() + 1;
117
118 if (FbTk::TextButton::textExceeds(xoffset))
119 m_win.screen().showTooltip(m_win.title());
120}
121
116void IconButton::clear() { 122void IconButton::clear() {
117 setupWindow(); 123 setupWindow();
118} 124}
@@ -230,6 +236,15 @@ void IconButton::update(FbTk::Subject *subj) {
230 } else { 236 } else {
231 m_icon_window.clear(); 237 m_icon_window.clear();
232 } 238 }
239 // if the title was changed AND the tooltip window is visible AND
240 // we have had an enter notify event ( without the leave notify )
241 // update the text inside it
242 if (subj == &m_win.titleSig() &&
243 m_has_tooltip &&
244 m_win.screen().tooltipWindow().isVisible()) {
245 m_win.screen().tooltipWindow().updateText(m_win.title());
246 }
247
233} 248}
234 249
235void IconButton::setupWindow() { 250void IconButton::setupWindow() {