diff options
author | fluxgen <fluxgen> | 2003-12-12 14:36:22 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-12-12 14:36:22 (GMT) |
commit | d2d3fbc96c72209c281bd97ba4aee12912c16d89 (patch) | |
tree | fcde0d22376d0100010a85be1241ca367959e37b | |
parent | 722036eab018d8cd57511a38b15d3fe9714ac244 (diff) | |
download | fluxbox_paul-d2d3fbc96c72209c281bd97ba4aee12912c16d89.zip fluxbox_paul-d2d3fbc96c72209c281bd97ba4aee12912c16d89.tar.bz2 |
alignment of iconbar buttons
-rw-r--r-- | src/IconbarTool.cc | 76 | ||||
-rw-r--r-- | src/IconbarTool.hh | 8 |
2 files changed, 80 insertions, 4 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index ee6095e..c14e056 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.21 2003/12/10 23:08:03 fluxgen Exp $ | 23 | // $Id: IconbarTool.cc,v 1.22 2003/12/12 14:36:22 fluxgen Exp $ |
24 | 24 | ||
25 | #include "IconbarTool.hh" | 25 | #include "IconbarTool.hh" |
26 | 26 | ||
@@ -63,6 +63,35 @@ void FbTk::Resource<IconbarTool::Mode>::setFromString(const char *strval) { | |||
63 | setDefaultValue(); | 63 | setDefaultValue(); |
64 | } | 64 | } |
65 | 65 | ||
66 | template<> | ||
67 | void FbTk::Resource<Container::Alignment>::setDefaultValue() { | ||
68 | m_value = Container::RELATIVE; | ||
69 | } | ||
70 | |||
71 | template<> | ||
72 | string FbTk::Resource<Container::Alignment>::getString() { | ||
73 | switch (m_value) { | ||
74 | case Container::LEFT: | ||
75 | return string("Left"); | ||
76 | case Container::RIGHT: | ||
77 | return string("Right"); | ||
78 | case Container::RELATIVE: | ||
79 | return string("Relative"); | ||
80 | } | ||
81 | return string("Left"); | ||
82 | } | ||
83 | |||
84 | template<> | ||
85 | void FbTk::Resource<Container::Alignment>::setFromString(const char *str) { | ||
86 | if (strcasecmp(str, "Left") == 0) | ||
87 | m_value = Container::LEFT; | ||
88 | else if (strcasecmp(str, "Right") == 0) | ||
89 | m_value = Container::RIGHT; | ||
90 | else if (strcasecmp(str, "RELATIVE") == 0) | ||
91 | m_value = Container::RELATIVE; | ||
92 | else | ||
93 | setDefaultValue(); | ||
94 | } | ||
66 | 95 | ||
67 | template<> | 96 | template<> |
68 | string FbTk::Resource<IconbarTool::Mode>::getString() { | 97 | string FbTk::Resource<IconbarTool::Mode>::getString() { |
@@ -108,6 +137,24 @@ private: | |||
108 | IconbarTool::Mode m_mode; | 137 | IconbarTool::Mode m_mode; |
109 | }; | 138 | }; |
110 | 139 | ||
140 | class ToolbarAlignMenuItem: public FbTk::MenuItem { | ||
141 | public: | ||
142 | ToolbarAlignMenuItem(const char *label, IconbarTool &handler, | ||
143 | Container::Alignment mode, | ||
144 | FbTk::RefCount<FbTk::Command> &cmd): | ||
145 | FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { | ||
146 | } | ||
147 | bool isEnabled() const { return m_handler.alignment() != m_mode; } | ||
148 | void click(int button, int time) { | ||
149 | m_handler.setAlignment(m_mode); | ||
150 | FbTk::MenuItem::click(button, time); | ||
151 | } | ||
152 | |||
153 | private: | ||
154 | IconbarTool &m_handler; | ||
155 | Container::Alignment m_mode; | ||
156 | }; | ||
157 | |||
111 | void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { | 158 | void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { |
112 | using namespace FbTk; | 159 | using namespace FbTk; |
113 | 160 | ||
@@ -129,6 +176,14 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { | |||
129 | IconbarTool::WORKSPACE, saverc_cmd)); | 176 | IconbarTool::WORKSPACE, saverc_cmd)); |
130 | menu.insert(new ToolbarModeMenuItem("All Windows", handler, | 177 | menu.insert(new ToolbarModeMenuItem("All Windows", handler, |
131 | IconbarTool::ALLWINDOWS, saverc_cmd)); | 178 | IconbarTool::ALLWINDOWS, saverc_cmd)); |
179 | menu.insert("---"); // separator line | ||
180 | menu.insert(new ToolbarAlignMenuItem("Left", handler, | ||
181 | Container::LEFT, saverc_cmd)); | ||
182 | menu.insert(new ToolbarAlignMenuItem("Relative", handler, | ||
183 | Container::RELATIVE, saverc_cmd)); | ||
184 | menu.insert(new ToolbarAlignMenuItem("Right", handler, | ||
185 | Container::RIGHT, saverc_cmd)); | ||
186 | menu.insert("---"); // separator line | ||
132 | menu.update(); | 187 | menu.update(); |
133 | } | 188 | } |
134 | 189 | ||
@@ -184,6 +239,10 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr | |||
184 | m_empty_pm(0), | 239 | m_empty_pm(0), |
185 | m_rc_mode(screen.resourceManager(), WORKSPACE, | 240 | m_rc_mode(screen.resourceManager(), WORKSPACE, |
186 | screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), | 241 | screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), |
242 | m_rc_alignment(screen.resourceManager(), Container::LEFT, | ||
243 | screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"), | ||
244 | m_rc_client_width(screen.resourceManager(), 70, | ||
245 | screen.name() + ".iconbar.clientWidth", screen.altName() + ".Iconbar.ClientWidth"), | ||
187 | m_rc_use_pixmap(screen.resourceManager(), true, | 246 | m_rc_use_pixmap(screen.resourceManager(), true, |
188 | screen.name() + ".iconbar.usePixmap", screen.altName() + ".Iconbar.UsePixmap"), | 247 | screen.name() + ".iconbar.usePixmap", screen.altName() + ".Iconbar.UsePixmap"), |
189 | m_menu(*screen.menuTheme(), screen.imageControl(), | 248 | m_menu(*screen.menuTheme(), screen.imageControl(), |
@@ -254,6 +313,11 @@ void IconbarTool::hide() { | |||
254 | m_icon_container.hide(); | 313 | m_icon_container.hide(); |
255 | } | 314 | } |
256 | 315 | ||
316 | void IconbarTool::setAlignment(Container::Alignment align) { | ||
317 | *m_rc_alignment = align; | ||
318 | update(0); | ||
319 | } | ||
320 | |||
257 | void IconbarTool::setMode(Mode mode) { | 321 | void IconbarTool::setMode(Mode mode) { |
258 | if (mode == *m_rc_mode) | 322 | if (mode == *m_rc_mode) |
259 | return; | 323 | return; |
@@ -306,6 +370,16 @@ void IconbarTool::update(FbTk::Subject *subj) { | |||
306 | if (m_screen.isShuttingdown()) | 370 | if (m_screen.isShuttingdown()) |
307 | return; | 371 | return; |
308 | 372 | ||
373 | m_icon_container.setAlignment(*m_rc_alignment); | ||
374 | // clamp to normal values | ||
375 | if (*m_rc_client_width < 1) | ||
376 | *m_rc_client_width = 10; | ||
377 | else if (*m_rc_client_width > 400) | ||
378 | *m_rc_client_width = 400; | ||
379 | |||
380 | m_icon_container.setMaxSizePerClient(*m_rc_client_width); | ||
381 | |||
382 | |||
309 | if (mode() == NONE) { | 383 | if (mode() == NONE) { |
310 | if (subj != 0 && typeid(*subj) == typeid(IconbarTheme)) | 384 | if (subj != 0 && typeid(*subj) == typeid(IconbarTheme)) |
311 | renderTheme(); | 385 | renderTheme(); |
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 00e1026..d60d14b 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.10 2003/11/27 14:30:11 fluxgen Exp $ | 23 | // $Id: IconbarTool.hh,v 1.11 2003/12/12 14:36:22 fluxgen Exp $ |
24 | 24 | ||
25 | #ifndef ICONBARTOOL_HH | 25 | #ifndef ICONBARTOOL_HH |
26 | #define ICONBARTOOL_HH | 26 | #define ICONBARTOOL_HH |
@@ -66,7 +66,7 @@ public: | |||
66 | void update(FbTk::Subject *subj); | 66 | void update(FbTk::Subject *subj); |
67 | void show(); | 67 | void show(); |
68 | void hide(); | 68 | void hide(); |
69 | 69 | void setAlignment(Container::Alignment a); | |
70 | void setMode(Mode mode); | 70 | void setMode(Mode mode); |
71 | 71 | ||
72 | unsigned int width() const; | 72 | unsigned int width() const; |
@@ -74,7 +74,7 @@ public: | |||
74 | unsigned int borderWidth() const; | 74 | unsigned int borderWidth() const; |
75 | 75 | ||
76 | Mode mode() const { return *m_rc_mode; } | 76 | Mode mode() const { return *m_rc_mode; } |
77 | 77 | Container::Alignment alignment() const { return m_icon_container.alignment(); } | |
78 | private: | 78 | private: |
79 | 79 | ||
80 | /// render single button that holds win | 80 | /// render single button that holds win |
@@ -108,6 +108,8 @@ 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<Container::Alignment> m_rc_alignment; ///< alignment of buttons | ||
112 | FbTk::Resource<int> m_rc_client_width; ///< size of client button in LEFT/RIGHT mode | ||
111 | FbTk::Resource<bool> m_rc_use_pixmap; ///< if iconbar should use win pixmap or not | 113 | FbTk::Resource<bool> m_rc_use_pixmap; ///< if iconbar should use win pixmap or not |
112 | 114 | ||
113 | FbMenu m_menu; | 115 | FbMenu m_menu; |