aboutsummaryrefslogtreecommitdiff
path: root/src/IconButton.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-11-27 14:30:11 (GMT)
committerfluxgen <fluxgen>2003-11-27 14:30:11 (GMT)
commit5ce35d9fa811358162ae44ee1ca514270d7da466 (patch)
tree10be8c9296136cb1dd265e3a01f937f1491405cc /src/IconButton.cc
parent258cb10be2dc5a7b932ee4bebb9833d597b3cb18 (diff)
downloadfluxbox-5ce35d9fa811358162ae44ee1ca514270d7da466.zip
fluxbox-5ce35d9fa811358162ae44ee1ca514270d7da466.tar.bz2
toggle pixmap for IconButton
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r--src/IconButton.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc
index 20fca8a..6c5e3e4 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: IconButton.cc,v 1.12 2003/11/19 12:57:27 rathnor Exp $ 23// $Id: IconButton.cc,v 1.13 2003/11/27 14:27:48 fluxgen Exp $
24 24
25#include "IconButton.hh" 25#include "IconButton.hh"
26 26
@@ -66,7 +66,8 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font,
66 FbTk::TextButton(parent, font, win.winClient().title()), 66 FbTk::TextButton(parent, font, win.winClient().title()),
67 m_win(win), 67 m_win(win),
68 m_icon_window(*this, 1, 1, 1, 1, 68 m_icon_window(*this, 1, 1, 1, 1,
69 ExposureMask | ButtonPressMask | ButtonReleaseMask) { 69 ExposureMask | ButtonPressMask | ButtonReleaseMask),
70 m_use_pixmap(true) {
70 71
71 FbTk::RefCount<FbTk::Command> focus(new FbTk::SimpleCommand<FluxboxWindow>(m_win, &FluxboxWindow::raiseAndFocus)); 72 FbTk::RefCount<FbTk::Command> focus(new FbTk::SimpleCommand<FluxboxWindow>(m_win, &FluxboxWindow::raiseAndFocus));
72 FbTk::RefCount<FbTk::Command> menu(new ::ShowMenu(m_win)); 73 FbTk::RefCount<FbTk::Command> menu(new ::ShowMenu(m_win));
@@ -117,6 +118,13 @@ void IconButton::clearArea(int x, int y,
117 width, height, exposure); 118 width, height, exposure);
118} 119}
119 120
121void IconButton::setPixmap(bool use) {
122 if (m_use_pixmap != use) {
123 m_use_pixmap = use;
124 update(0);
125 }
126}
127
120void IconButton::update(FbTk::Subject *subj) { 128void IconButton::update(FbTk::Subject *subj) {
121 // we got signal that either title or 129 // we got signal that either title or
122 // icon pixmap was updated, 130 // icon pixmap was updated,
@@ -130,7 +138,7 @@ void IconButton::update(FbTk::Subject *subj) {
130 if (hints == 0) 138 if (hints == 0)
131 return; 139 return;
132 140
133 if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) { 141 if (m_use_pixmap && (hints->flags & IconPixmapHint) && hints->icon_pixmap != 0) {
134 // setup icon window 142 // setup icon window
135 m_icon_window.show(); 143 m_icon_window.show();
136 int new_height = height() - 2*m_icon_window.y(); // equally padded 144 int new_height = height() - 2*m_icon_window.y(); // equally padded
@@ -148,7 +156,7 @@ void IconButton::update(FbTk::Subject *subj) {
148 m_icon_pixmap = 0; 156 m_icon_pixmap = 0;
149 } 157 }
150 158
151 if(hints->flags & IconMaskHint) { 159 if(m_use_pixmap && (hints->flags & IconMaskHint)) {
152 m_icon_mask.copy(hints->icon_mask); 160 m_icon_mask.copy(hints->icon_mask);
153 m_icon_mask.scale(m_icon_pixmap.width(), m_icon_pixmap.height()); 161 m_icon_mask.scale(m_icon_pixmap.width(), m_icon_pixmap.height());
154 } else 162 } else
@@ -186,7 +194,10 @@ void IconButton::setupWindow() {
186 194
187void IconButton::drawText(int x, int y) { 195void IconButton::drawText(int x, int y) {
188 // offset text 196 // offset text
189 FbTk::TextButton::drawText(m_icon_window.x() + m_icon_window.width() + 1, y); 197 if (m_icon_pixmap.drawable() != 0)
198 FbTk::TextButton::drawText(m_icon_window.x() + m_icon_window.width() + 1, y);
199 else
200 FbTk::TextButton::drawText(1, y);
190} 201}
191 202
192 203