aboutsummaryrefslogtreecommitdiff
path: root/src/IconButton.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r--src/IconButton.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc
index cea49c3..2ee169f 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.15 2004/01/13 12:27:51 fluxgen Exp $ 23// $Id: IconButton.cc,v 1.16 2004/01/16 09:32:44 fluxgen Exp $
24 24
25#include "IconButton.hh" 25#include "IconButton.hh"
26 26
@@ -65,8 +65,24 @@ private:
65 FluxboxWindow &m_win; 65 FluxboxWindow &m_win;
66}; 66};
67 67
68class FocusCommand: public FbTk::Command {
69public:
70 explicit FocusCommand(FluxboxWindow &win):m_win(win) { }
71 void execute() {
72 if(m_win.isIconic() || !m_win.isFocused())
73 m_win.raiseAndFocus();
74 else
75 m_win.iconify();
76 }
77private:
78 FluxboxWindow &m_win;
79};
80
81
68} // end anonymous namespace 82} // end anonymous namespace
69 83
84
85
70IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, 86IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font,
71 FluxboxWindow &win): 87 FluxboxWindow &win):
72 FbTk::TextButton(parent, font, win.winClient().title()), 88 FbTk::TextButton(parent, font, win.winClient().title()),
@@ -75,7 +91,6 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font,
75 ExposureMask | ButtonPressMask | ButtonReleaseMask), 91 ExposureMask | ButtonPressMask | ButtonReleaseMask),
76 m_use_pixmap(true) { 92 m_use_pixmap(true) {
77 93
78 FbTk::RefCount<FbTk::Command> focus(new FbTk::SimpleCommand<FluxboxWindow>(m_win, &FluxboxWindow::raiseAndFocus));
79 FbTk::RefCount<FbTk::Command> hidemenus(new FbTk::SimpleCommand<BScreen>(win.screen(), &BScreen::hideMenus)); 94 FbTk::RefCount<FbTk::Command> hidemenus(new FbTk::SimpleCommand<BScreen>(win.screen(), &BScreen::hideMenus));
80 //!! TODO: There're some issues with MacroCommand when 95 //!! TODO: There're some issues with MacroCommand when
81 // this object dies when the last macrocommand is executed (focused cmd) 96 // this object dies when the last macrocommand is executed (focused cmd)
@@ -83,7 +98,7 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font,
83 // FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand(); 98 // FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand();
84 // focus_macro->add(hidemenus); 99 // focus_macro->add(hidemenus);
85 // focus_macro->add(focus); 100 // focus_macro->add(focus);
86 FbTk::RefCount<FbTk::Command> focus_cmd(focus); 101 FbTk::RefCount<FbTk::Command> focus_cmd(new ::FocusCommand(m_win));
87 FbTk::RefCount<FbTk::Command> menu_cmd(new ::ShowMenu(m_win)); 102 FbTk::RefCount<FbTk::Command> menu_cmd(new ::ShowMenu(m_win));
88 setOnClick(focus_cmd, 1); 103 setOnClick(focus_cmd, 1);
89 setOnClick(menu_cmd, 3); 104 setOnClick(menu_cmd, 3);