summaryrefslogtreecommitdiff
path: root/src/IconbarTool.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/IconbarTool.cc')
-rw-r--r--src/IconbarTool.cc25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index b2a57d0..f2ed082 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -39,7 +39,7 @@
39#include "FbTk/STLUtil.hh" 39#include "FbTk/STLUtil.hh"
40#include "FbTk/I18n.hh" 40#include "FbTk/I18n.hh"
41#include "FbTk/Menu.hh" 41#include "FbTk/Menu.hh"
42#include "FbTk/MenuItem.hh" 42#include "FbTk/RadioMenuItem.hh"
43#include "FbTk/BoolMenuItem.hh" 43#include "FbTk/BoolMenuItem.hh"
44#include "FbTk/RefCount.hh" 44#include "FbTk/RefCount.hh"
45#include "FbTk/SimpleCommand.hh" 45#include "FbTk/SimpleCommand.hh"
@@ -99,18 +99,18 @@ void FbTk::Resource<FbTk::Container::Alignment>::setFromString(const char *str)
99 99
100namespace { 100namespace {
101 101
102class ToolbarModeMenuItem : public FbTk::MenuItem { 102class ToolbarModeMenuItem : public FbTk::RadioMenuItem {
103public: 103public:
104 ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler, 104 ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler,
105 string mode, 105 string mode,
106 FbTk::RefCount<FbTk::Command<void> > &cmd): 106 FbTk::RefCount<FbTk::Command<void> > &cmd):
107 FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { 107 FbTk::RadioMenuItem(label, cmd), m_handler(handler), m_mode(mode) {
108 setCloseOnClick(false); 108 setCloseOnClick(false);
109 } 109 }
110 bool isEnabled() const { return m_handler.mode() != m_mode; } 110 bool isSelected() const { return m_handler.mode() == m_mode; }
111 void click(int button, int time, unsigned int mods) { 111 void click(int button, int time, unsigned int mods) {
112 m_handler.setMode(m_mode); 112 m_handler.setMode(m_mode);
113 FbTk::MenuItem::click(button, time, mods); 113 FbTk::RadioMenuItem::click(button, time, mods);
114 } 114 }
115 115
116private: 116private:
@@ -118,18 +118,18 @@ private:
118 string m_mode; 118 string m_mode;
119}; 119};
120 120
121class ToolbarAlignMenuItem: public FbTk::MenuItem { 121class ToolbarAlignMenuItem: public FbTk::RadioMenuItem {
122public: 122public:
123 ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler, 123 ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler,
124 FbTk::Container::Alignment mode, 124 FbTk::Container::Alignment mode,
125 FbTk::RefCount<FbTk::Command<void> > &cmd): 125 FbTk::RefCount<FbTk::Command<void> > &cmd):
126 FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { 126 FbTk::RadioMenuItem(label, cmd), m_handler(handler), m_mode(mode) {
127 setCloseOnClick(false); 127 setCloseOnClick(false);
128 } 128 }
129 bool isEnabled() const { return m_handler.alignment() != m_mode; } 129 bool isSelected() const { return m_handler.alignment() == m_mode; }
130 void click(int button, int time, unsigned int mods) { 130 void click(int button, int time, unsigned int mods) {
131 m_handler.setAlignment(m_mode); 131 m_handler.setAlignment(m_mode);
132 FbTk::MenuItem::click(button, time, mods); 132 FbTk::RadioMenuItem::click(button, time, mods);
133 } 133 }
134 134
135private: 135private:
@@ -214,16 +214,11 @@ class ShowMenu: public FbTk::Command<void> {
214public: 214public:
215 explicit ShowMenu(FluxboxWindow &win):m_win(win) { } 215 explicit ShowMenu(FluxboxWindow &win):m_win(win) { }
216 void execute() { 216 void execute() {
217 // hide the menu if it's already showing for this FluxboxWindow
218 if (m_win.menu().isVisible() && FbMenu::window() == &m_win) {
219 m_win.menu().hide();
220 return;
221 }
222 // get last button pos 217 // get last button pos
223 const XEvent &event = Fluxbox::instance()->lastEvent(); 218 const XEvent &event = Fluxbox::instance()->lastEvent();
224 int x = event.xbutton.x_root - (m_win.menu().width() / 2); 219 int x = event.xbutton.x_root - (m_win.menu().width() / 2);
225 int y = event.xbutton.y_root - (m_win.menu().height() / 2); 220 int y = event.xbutton.y_root - (m_win.menu().height() / 2);
226 m_win.showMenu(x, y); 221 m_win.popupMenu(x, y);
227 } 222 }
228private: 223private:
229 FluxboxWindow &m_win; 224 FluxboxWindow &m_win;