summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/IconButton.cc21
-rw-r--r--src/IconButton.hh9
-rw-r--r--src/IconbarTool.cc26
-rw-r--r--src/IconbarTool.hh3
4 files changed, 48 insertions, 11 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
diff --git a/src/IconButton.hh b/src/IconButton.hh
index 6ac08b7..69fbf46 100644
--- a/src/IconButton.hh
+++ b/src/IconButton.hh
@@ -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.hh,v 1.3 2003/09/10 21:40:01 fluxgen Exp $ 23// $Id: IconButton.hh,v 1.4 2003/11/27 14:27:48 fluxgen Exp $
24 24
25#ifndef ICONBUTTON_HH 25#ifndef ICONBUTTON_HH
26#define ICONBUTTON_HH 26#define ICONBUTTON_HH
@@ -33,7 +33,8 @@ class FluxboxWindow;
33 33
34class IconButton: public FbTk::TextButton, public FbTk::Observer { 34class IconButton: public FbTk::TextButton, public FbTk::Observer {
35public: 35public:
36 IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, FluxboxWindow &window); 36 IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font,
37 FluxboxWindow &window);
37 virtual ~IconButton(); 38 virtual ~IconButton();
38 39
39 void exposeEvent(XExposeEvent &event); 40 void exposeEvent(XExposeEvent &event);
@@ -46,8 +47,11 @@ public:
46 void resize(unsigned int width, unsigned int height); 47 void resize(unsigned int width, unsigned int height);
47 48
48 void update(FbTk::Subject *subj); 49 void update(FbTk::Subject *subj);
50 void setPixmap(bool use);
51
49 FluxboxWindow &win() { return m_win; } 52 FluxboxWindow &win() { return m_win; }
50 const FluxboxWindow &win() const { return m_win; } 53 const FluxboxWindow &win() const { return m_win; }
54
51protected: 55protected:
52 void drawText(int x = 0, int y = 0); 56 void drawText(int x = 0, int y = 0);
53private: 57private:
@@ -57,6 +61,7 @@ private:
57 FbTk::FbWindow m_icon_window; 61 FbTk::FbWindow m_icon_window;
58 FbTk::FbPixmap m_icon_pixmap; 62 FbTk::FbPixmap m_icon_pixmap;
59 FbTk::FbPixmap m_icon_mask; 63 FbTk::FbPixmap m_icon_mask;
64 bool m_use_pixmap;
60}; 65};
61 66
62#endif // ICONBUTTON_HH 67#endif // ICONBUTTON_HH
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 6bcc6b8..faccc62 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.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: IconbarTool.cc,v 1.15 2003/10/26 20:13:11 fluxgen Exp $ 23// $Id: IconbarTool.cc,v 1.16 2003/11/27 14:30:11 fluxgen Exp $
24 24
25#include "IconbarTool.hh" 25#include "IconbarTool.hh"
26 26
@@ -31,12 +31,15 @@
31#include "Workspace.hh" 31#include "Workspace.hh"
32#include "fluxbox.hh" 32#include "fluxbox.hh"
33#include "FbMenu.hh" 33#include "FbMenu.hh"
34#include "BoolMenuItem.hh"
35#include "CommandParser.hh"
34 36
35#include "FbTk/Menu.hh" 37#include "FbTk/Menu.hh"
36#include "FbTk/MenuItem.hh" 38#include "FbTk/MenuItem.hh"
37#include "FbTk/RefCount.hh" 39#include "FbTk/RefCount.hh"
38#include "FbTk/SimpleCommand.hh" 40#include "FbTk/SimpleCommand.hh"
39#include "FbTk/ImageControl.hh" 41#include "FbTk/ImageControl.hh"
42#include "FbTk/MacroCommand.hh"
40 43
41#include <typeinfo> 44#include <typeinfo>
42#include <string> 45#include <string>
@@ -181,11 +184,26 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr
181 m_empty_pm(0), 184 m_empty_pm(0),
182 m_rc_mode(screen.resourceManager(), WORKSPACE, 185 m_rc_mode(screen.resourceManager(), WORKSPACE,
183 screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), 186 screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"),
187 m_rc_use_pixmap(screen.resourceManager(), true,
188 screen.name() + ".iconbar.usePixmap", screen.altName() + ".Iconbar.UsePixmap"),
184 m_menu(*screen.menuTheme(), menu.screenNumber(), screen.imageControl(), 189 m_menu(*screen.menuTheme(), menu.screenNumber(), screen.imageControl(),
185 *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())) { 190 *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())) {
186 191
187 // setup menu 192 // setup mode menu
188 setupModeMenu(m_menu, *this); 193 setupModeMenu(m_menu, *this);
194
195 using namespace FbTk;
196 // setup use pixmap item to reconfig iconbar and save resource on click
197 MacroCommand *save_and_reconfig = new MacroCommand();
198 RefCount<Command> reconfig(new SimpleCommand<IconbarTool>(*this, &IconbarTool::renderTheme));
199 RefCount<Command> save(CommandParser::instance().parseLine("saverc"));
200 save_and_reconfig->add(reconfig);
201 save_and_reconfig->add(save);
202 RefCount<Command> s_and_reconfig(save_and_reconfig);
203 m_menu.insert(new BoolMenuItem("Use Pixmap", *m_rc_use_pixmap, s_and_reconfig));
204 m_menu.update();
205
206 // add iconbar menu to toolbar menu
189 menu.insert(m_menu.label().c_str(), &m_menu); 207 menu.insert(m_menu.label().c_str(), &m_menu);
190 208
191 // setup signals 209 // setup signals
@@ -445,6 +463,8 @@ void IconbarTool::renderTheme() {
445 463
446void IconbarTool::renderButton(IconButton &button) { 464void IconbarTool::renderButton(IconButton &button) {
447 465
466 button.setPixmap(*m_rc_use_pixmap);
467
448 if (button.win().isFocused()) { // focused texture 468 if (button.win().isFocused()) { // focused texture
449 button.setGC(m_theme.focusedText().textGC()); 469 button.setGC(m_theme.focusedText().textGC());
450 button.setFont(m_theme.focusedText().font()); 470 button.setFont(m_theme.focusedText().font());
@@ -517,6 +537,7 @@ void IconbarTool::addWindow(FluxboxWindow &win) {
517 return; 537 return;
518 538
519 IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win); 539 IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win);
540 button->setPixmap(*m_rc_use_pixmap);
520 m_icon_container.insertItem(button); 541 m_icon_container.insertItem(button);
521 m_icon_list.push_back(button); 542 m_icon_list.push_back(button);
522 543
@@ -527,7 +548,6 @@ void IconbarTool::addWindow(FluxboxWindow &win) {
527 win.stateSig().attach(this); 548 win.stateSig().attach(this);
528} 549}
529 550
530
531void IconbarTool::updateIcons() { 551void IconbarTool::updateIcons() {
532 std::list<FluxboxWindow *> itemlist; 552 std::list<FluxboxWindow *> itemlist;
533 // add icons to the itemlist 553 // add icons to the itemlist
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh
index c805fec..00e1026 100644
--- a/src/IconbarTool.hh
+++ b/src/IconbarTool.hh
@@ -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: IconbarTool.hh,v 1.9 2003/10/06 06:22:42 rathnor Exp $ 23// $Id: IconbarTool.hh,v 1.10 2003/11/27 14:30:11 fluxgen Exp $
24 24
25#ifndef ICONBARTOOL_HH 25#ifndef ICONBARTOOL_HH
26#define ICONBARTOOL_HH 26#define ICONBARTOOL_HH
@@ -108,6 +108,7 @@ private:
108 108
109 IconList m_icon_list; 109 IconList m_icon_list;
110 FbTk::Resource<Mode> m_rc_mode; 110 FbTk::Resource<Mode> m_rc_mode;
111 FbTk::Resource<bool> m_rc_use_pixmap; ///< if iconbar should use win pixmap or not
111 112
112 FbMenu m_menu; 113 FbMenu m_menu;
113}; 114};