diff options
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r-- | src/IconButton.cc | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc index ce89651..320918c 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc | |||
@@ -59,15 +59,18 @@ IconButton::IconButton(const FbTk::FbWindow &parent, | |||
59 | m_theme(win, focused_theme, unfocused_theme), | 59 | m_theme(win, focused_theme, unfocused_theme), |
60 | m_pm(win.screen().imageControl()) { | 60 | m_pm(win.screen().imageControl()) { |
61 | 61 | ||
62 | m_win.titleSig().attach(this); | 62 | m_signals.join(m_win.titleSig(), |
63 | MemFunIgnoreArgs(*this, &IconButton::clientTitleChanged)); | ||
64 | |||
63 | m_signals.join(m_win.focusSig(), | 65 | m_signals.join(m_win.focusSig(), |
64 | MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear)); | 66 | MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear)); |
67 | |||
65 | m_win.attentionSig().attach(this); | 68 | m_win.attentionSig().attach(this); |
66 | 69 | ||
67 | FbTk::EventManager::instance()->add(*this, m_icon_window); | 70 | FbTk::EventManager::instance()->add(*this, m_icon_window); |
68 | 71 | ||
69 | reconfigTheme(); | 72 | reconfigTheme(); |
70 | update(0); | 73 | refreshEverything(false); |
71 | } | 74 | } |
72 | 75 | ||
73 | IconButton::~IconButton() { | 76 | IconButton::~IconButton() { |
@@ -102,7 +105,7 @@ void IconButton::moveResize(int x, int y, | |||
102 | if (m_icon_window.width() != FbTk::Button::width() || | 105 | if (m_icon_window.width() != FbTk::Button::width() || |
103 | m_icon_window.height() != FbTk::Button::height()) { | 106 | m_icon_window.height() != FbTk::Button::height()) { |
104 | reconfigTheme(); | 107 | reconfigTheme(); |
105 | update(0); // update icon window | 108 | refreshEverything(false); // update icon window |
106 | } | 109 | } |
107 | } | 110 | } |
108 | 111 | ||
@@ -111,7 +114,7 @@ void IconButton::resize(unsigned int width, unsigned int height) { | |||
111 | if (m_icon_window.width() != FbTk::Button::width() || | 114 | if (m_icon_window.width() != FbTk::Button::width() || |
112 | m_icon_window.height() != FbTk::Button::height()) { | 115 | m_icon_window.height() != FbTk::Button::height()) { |
113 | reconfigTheme(); | 116 | reconfigTheme(); |
114 | update(0); // update icon window | 117 | refreshEverything(false); // update icon window |
115 | } | 118 | } |
116 | } | 119 | } |
117 | 120 | ||
@@ -140,7 +143,7 @@ void IconButton::clearArea(int x, int y, | |||
140 | void IconButton::setPixmap(bool use) { | 143 | void IconButton::setPixmap(bool use) { |
141 | if (m_use_pixmap != use) { | 144 | if (m_use_pixmap != use) { |
142 | m_use_pixmap = use; | 145 | m_use_pixmap = use; |
143 | update(0); | 146 | refreshEverything(false); |
144 | } | 147 | } |
145 | } | 148 | } |
146 | 149 | ||
@@ -175,16 +178,7 @@ void IconButton::reconfigAndClear() { | |||
175 | clear(); | 178 | clear(); |
176 | } | 179 | } |
177 | 180 | ||
178 | void IconButton::update(FbTk::Subject *subj) { | 181 | void IconButton::refreshEverything(bool setup) { |
179 | // if the window's focus state changed, we need to update the background | ||
180 | if (subj == &m_win.attentionSig()) { | ||
181 | reconfigAndClear(); | ||
182 | return; | ||
183 | } | ||
184 | |||
185 | // we got signal that either title or | ||
186 | // icon pixmap was updated, | ||
187 | // so we refresh everything | ||
188 | 182 | ||
189 | Display *display = FbTk::App::instance()->display(); | 183 | Display *display = FbTk::App::instance()->display(); |
190 | int screen = m_win.screen().screenNumber(); | 184 | int screen = m_win.screen().screenNumber(); |
@@ -242,17 +236,36 @@ void IconButton::update(FbTk::Subject *subj) { | |||
242 | 236 | ||
243 | #endif // SHAPE | 237 | #endif // SHAPE |
244 | 238 | ||
245 | if (subj != 0) { | 239 | if (setup) { |
246 | setupWindow(); | 240 | setupWindow(); |
247 | } else { | 241 | } else { |
248 | m_icon_window.clear(); | 242 | m_icon_window.clear(); |
249 | } | 243 | } |
250 | 244 | ||
245 | |||
246 | } | ||
247 | |||
248 | void IconButton::clientTitleChanged() { | ||
249 | refreshEverything(true); | ||
250 | |||
251 | if (m_has_tooltip) | ||
252 | showTooltip(); | ||
253 | } | ||
254 | |||
255 | void IconButton::update(FbTk::Subject *subj) { | ||
256 | // if the window's focus state changed, we need to update the background | ||
257 | if (subj == &m_win.attentionSig()) { | ||
258 | reconfigAndClear(); | ||
259 | return; | ||
260 | } | ||
261 | |||
262 | // we got signal that either title or | ||
263 | // icon pixmap was updated, | ||
264 | // so we refresh everything | ||
251 | // if the title was changed AND the mouse is over *this, | 265 | // if the title was changed AND the mouse is over *this, |
252 | // update the tooltip | 266 | // update the tooltip |
253 | if (subj == &m_win.titleSig() && m_has_tooltip) | ||
254 | showTooltip(); | ||
255 | 267 | ||
268 | refreshEverything(subj != 0); | ||
256 | } | 269 | } |
257 | 270 | ||
258 | void IconButton::setupWindow() { | 271 | void IconButton::setupWindow() { |