summaryrefslogtreecommitdiff
path: root/src/IconButton.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r--src/IconButton.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc
index 09791c8..0511a06 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.cc
@@ -52,8 +52,10 @@ IconButton::IconButton(const FbTk::FbWindow &parent,
52 FbTk::TextButton(parent, focused_theme->text().font(), win.title()), 52 FbTk::TextButton(parent, focused_theme->text().font(), win.title()),
53 m_win(win), 53 m_win(win),
54 m_icon_window(*this, 1, 1, 1, 1, 54 m_icon_window(*this, 1, 1, 1, 1,
55 ExposureMask | ButtonPressMask | ButtonReleaseMask), 55 ExposureMask |EnterWindowMask | LeaveWindowMask |
56 ButtonPressMask | ButtonReleaseMask),
56 m_use_pixmap(true), 57 m_use_pixmap(true),
58 m_has_tooltip(false),
57 m_theme(win, focused_theme, unfocused_theme), 59 m_theme(win, focused_theme, unfocused_theme),
58 m_pm(win.screen().imageControl()) { 60 m_pm(win.screen().imageControl()) {
59 61
@@ -79,6 +81,16 @@ void IconButton::exposeEvent(XExposeEvent &event) {
79 FbTk::TextButton::exposeEvent(event); 81 FbTk::TextButton::exposeEvent(event);
80} 82}
81 83
84void IconButton::enterNotifyEvent(XCrossingEvent &ev) {
85 m_has_tooltip = true;
86 showTooltip();
87}
88
89void IconButton::leaveNotifyEvent(XCrossingEvent &ev) {
90 m_has_tooltip = false;
91 m_win.screen().hideTooltip();
92}
93
82void IconButton::moveResize(int x, int y, 94void IconButton::moveResize(int x, int y,
83 unsigned int width, unsigned int height) { 95 unsigned int width, unsigned int height) {
84 96
@@ -98,6 +110,15 @@ void IconButton::resize(unsigned int width, unsigned int height) {
98 } 110 }
99} 111}
100 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
101void IconButton::clear() { 122void IconButton::clear() {
102 setupWindow(); 123 setupWindow();
103} 124}
@@ -215,6 +236,15 @@ void IconButton::update(FbTk::Subject *subj) {
215 } else { 236 } else {
216 m_icon_window.clear(); 237 m_icon_window.clear();
217 } 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
218} 248}
219 249
220void IconButton::setupWindow() { 250void IconButton::setupWindow() {