diff options
author | fluxgen <fluxgen> | 2003-02-23 00:49:01 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-02-23 00:49:01 (GMT) |
commit | 19f4dc774c19a8b9ebe06aa41a41c4e3fc23b05f (patch) | |
tree | 61926eb81e0b221687b55dd6063b3d60810c0290 /src/Toolbar.cc | |
parent | 4c0fb1ff752f1cfafcac11637ce9cfec92201d13 (diff) | |
download | fluxbox_pavel-19f4dc774c19a8b9ebe06aa41a41c4e3fc23b05f.zip fluxbox_pavel-19f4dc774c19a8b9ebe06aa41a41c4e3fc23b05f.tar.bz2 |
changed layeritem to normal type instead of pointer, added placement menu and fixed font to iconbar
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r-- | src/Toolbar.cc | 113 |
1 files changed, 79 insertions, 34 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 73a8650..f0f0b82 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Toolbar.cc,v 1.60 2003/02/22 23:07:23 fluxgen Exp $ | 25 | // $Id: Toolbar.cc,v 1.61 2003/02/23 00:49:01 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Toolbar.hh" | 27 | #include "Toolbar.hh" |
28 | 28 | ||
@@ -71,9 +71,13 @@ using namespace std; | |||
71 | 71 | ||
72 | namespace { | 72 | namespace { |
73 | class SetToolbarPlacementCmd: public FbTk::Command { | 73 | class SetToolbarPlacementCmd: public FbTk::Command { |
74 | public: | ||
74 | explicit SetToolbarPlacementCmd(Toolbar &tbar, Toolbar::Placement place):m_tbar(tbar), m_place(place) { } | 75 | explicit SetToolbarPlacementCmd(Toolbar &tbar, Toolbar::Placement place):m_tbar(tbar), m_place(place) { } |
75 | void execute() { | 76 | void execute() { |
76 | m_tbar.setPlacement(m_place); | 77 | m_tbar.setPlacement(m_place); |
78 | m_tbar.reconfigure(); | ||
79 | m_tbar.screen().saveToolbarPlacement(m_place); | ||
80 | Fluxbox::instance()->save_rc(); | ||
77 | } | 81 | } |
78 | private: | 82 | private: |
79 | Toolbar &m_tbar; | 83 | Toolbar &m_tbar; |
@@ -83,21 +87,62 @@ private: | |||
83 | void setupMenus(Toolbar &tbar) { | 87 | void setupMenus(Toolbar &tbar) { |
84 | I18n *i18n = I18n::instance(); | 88 | I18n *i18n = I18n::instance(); |
85 | using namespace FBNLS; | 89 | using namespace FBNLS; |
86 | FbTk::Menu &menu = tbar.menu(); | ||
87 | menu.setLabel(i18n->getMessage( | ||
88 | ToolbarSet, ToolbarToolbarTitle, | ||
89 | "Toolbar")); | ||
90 | menu.setInternalMenu(); | ||
91 | |||
92 | menu.insert("Layer...", tbar.layermenu()); | ||
93 | |||
94 | using namespace FbTk; | 90 | using namespace FbTk; |
91 | |||
92 | FbTk::Menu &menu = tbar.menu(); | ||
93 | |||
95 | RefCount<Command> start_edit(new SimpleCommand<Toolbar>(tbar, &Toolbar::edit)); | 94 | RefCount<Command> start_edit(new SimpleCommand<Toolbar>(tbar, &Toolbar::edit)); |
96 | menu.insert(i18n->getMessage( | 95 | menu.insert(i18n->getMessage( |
97 | ToolbarSet, ToolbarEditWkspcName, | 96 | ToolbarSet, ToolbarEditWkspcName, |
98 | "Edit current workspace name"), | 97 | "Edit current workspace name"), |
99 | start_edit); | 98 | start_edit); |
100 | 99 | ||
100 | menu.setLabel(i18n->getMessage( | ||
101 | ToolbarSet, ToolbarToolbarTitle, | ||
102 | "Toolbar")); | ||
103 | menu.setInternalMenu(); | ||
104 | |||
105 | menu.insert("Layer...", &tbar.layermenu()); | ||
106 | |||
107 | // setup items in placement menu | ||
108 | struct { | ||
109 | int set; | ||
110 | int base; | ||
111 | const char *default_str; | ||
112 | Toolbar::Placement placement; | ||
113 | } place_menu[] = { | ||
114 | {0, 0, "Top Left", Toolbar::TOPLEFT}, | ||
115 | {0, 0, "Left Top", Toolbar::LEFTTOP}, | ||
116 | {0, 0, "Left Center", Toolbar::LEFTCENTER}, | ||
117 | {0, 0, "Left Bottom", Toolbar::LEFTBOTTOM}, | ||
118 | {0, 0, "Bottom Left", Toolbar::BOTTOMLEFT}, | ||
119 | {0, 0, "Top Center", Toolbar::TOPCENTER}, | ||
120 | {0, 0, 0, Toolbar::TOPCENTER}, | ||
121 | {0, 0, 0, Toolbar::BOTTOMCENTER}, | ||
122 | {0, 0, 0, Toolbar::BOTTOMCENTER}, | ||
123 | {0, 0, "Bottom Center", Toolbar::BOTTOMCENTER}, | ||
124 | {0, 0, "Top Left", Toolbar::TOPLEFT}, | ||
125 | {0, 0, "Right Top", Toolbar::RIGHTTOP}, | ||
126 | {0, 0, "Right Center", Toolbar::RIGHTCENTER}, | ||
127 | {0, 0, "Right Bottom", Toolbar::RIGHTBOTTOM}, | ||
128 | {0, 0, "Bottom Right", Toolbar::BOTTOMRIGHT} | ||
129 | }; | ||
130 | tbar.placementMenu().setMinimumSublevels(3); | ||
131 | // create items in sub menu | ||
132 | for (size_t i=0; i<15; ++i) { | ||
133 | if (place_menu[i].default_str == 0) { | ||
134 | tbar.placementMenu().insert(""); | ||
135 | } else { | ||
136 | const char *i18n_str = i18n->getMessage(place_menu[i].set, | ||
137 | place_menu[i].base, | ||
138 | place_menu[i].default_str); | ||
139 | RefCount<FbTk::Command> setplace(new SetToolbarPlacementCmd(tbar, place_menu[i].placement)); | ||
140 | tbar.placementMenu().insert(i18n_str, setplace); | ||
141 | |||
142 | } | ||
143 | } | ||
144 | menu.insert("Placement", &tbar.placementMenu()); | ||
145 | tbar.placementMenu().update(); | ||
101 | menu.update(); | 146 | menu.update(); |
102 | } | 147 | } |
103 | 148 | ||
@@ -179,18 +224,18 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): | |||
179 | hide_timer(&hide_handler), | 224 | hide_timer(&hide_handler), |
180 | m_toolbarmenu(*scrn.menuTheme(), | 225 | m_toolbarmenu(*scrn.menuTheme(), |
181 | scrn.getScreenNumber(), *scrn.getImageControl()), | 226 | scrn.getScreenNumber(), *scrn.getImageControl()), |
182 | m_layermenu(0), | 227 | m_placementmenu(*scrn.menuTheme(), |
228 | scrn.getScreenNumber(), *scrn.getImageControl()), | ||
229 | m_layermenu(*scrn.menuTheme(), | ||
230 | scrn.getScreenNumber(), | ||
231 | *scrn.getImageControl(), | ||
232 | *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), | ||
233 | this), | ||
183 | m_theme(scrn.getScreenNumber()), | 234 | m_theme(scrn.getScreenNumber()), |
184 | m_place(BOTTOMCENTER), | 235 | m_place(BOTTOMCENTER), |
185 | m_themelistener(*this), | 236 | m_themelistener(*this), |
186 | m_layeritem(0) { | 237 | m_layeritem(frame.window, layer) { |
187 | 238 | ||
188 | m_layermenu = new LayerMenu<Toolbar>( | ||
189 | *scrn.menuTheme(), | ||
190 | scrn.getScreenNumber(), | ||
191 | *scrn.getImageControl(), | ||
192 | *scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), | ||
193 | this); | ||
194 | 239 | ||
195 | // we need to get notified when the theme is reloaded | 240 | // we need to get notified when the theme is reloaded |
196 | m_theme.addListener(m_themelistener); | 241 | m_theme.addListener(m_themelistener); |
@@ -205,8 +250,6 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): | |||
205 | frame.button_w = 20; | 250 | frame.button_w = 20; |
206 | frame.bevel_w = 1; | 251 | frame.bevel_w = 1; |
207 | 252 | ||
208 | m_layeritem = new FbTk::XLayerItem(frame.window, layer); | ||
209 | |||
210 | timeval delay; | 253 | timeval delay; |
211 | delay.tv_sec = 1; | 254 | delay.tv_sec = 1; |
212 | delay.tv_usec = 0; | 255 | delay.tv_usec = 0; |
@@ -226,7 +269,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): | |||
226 | 269 | ||
227 | 270 | ||
228 | if (Fluxbox::instance()->useIconBar()) | 271 | if (Fluxbox::instance()->useIconBar()) |
229 | m_iconbar.reset(new IconBar(&screen(), frame.window_label.window())); | 272 | m_iconbar.reset(new IconBar(&screen(), frame.window_label.window(), m_theme.font())); |
230 | 273 | ||
231 | 274 | ||
232 | XMapSubwindows(display, frame.window.window()); | 275 | XMapSubwindows(display, frame.window.window()); |
@@ -247,6 +290,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): | |||
247 | frame.pwbutton.setOnClick(prevwindow); | 290 | frame.pwbutton.setOnClick(prevwindow); |
248 | frame.nwbutton.setOnClick(nextwindow); | 291 | frame.nwbutton.setOnClick(nextwindow); |
249 | 292 | ||
293 | |||
250 | reconfigure(); | 294 | reconfigure(); |
251 | 295 | ||
252 | } | 296 | } |
@@ -260,8 +304,6 @@ Toolbar::~Toolbar() { | |||
260 | if (frame.clk) image_ctrl.removeImage(frame.clk); | 304 | if (frame.clk) image_ctrl.removeImage(frame.clk); |
261 | if (frame.button) image_ctrl.removeImage(frame.button); | 305 | if (frame.button) image_ctrl.removeImage(frame.button); |
262 | if (frame.pbutton) image_ctrl.removeImage(frame.pbutton); | 306 | if (frame.pbutton) image_ctrl.removeImage(frame.pbutton); |
263 | if (m_layeritem) delete m_layeritem; | ||
264 | if (m_layermenu) delete m_layermenu; | ||
265 | 307 | ||
266 | } | 308 | } |
267 | 309 | ||
@@ -285,6 +327,10 @@ void Toolbar::delIcon(FluxboxWindow *w) { | |||
285 | } | 327 | } |
286 | 328 | ||
287 | void Toolbar::reconfigure() { | 329 | void Toolbar::reconfigure() { |
330 | bool vertical = isVertical(); | ||
331 | |||
332 | if (m_iconbar.get()) | ||
333 | m_iconbar->setVertical(vertical); | ||
288 | 334 | ||
289 | frame.bevel_w = screen().getBevelWidth(); | 335 | frame.bevel_w = screen().getBevelWidth(); |
290 | 336 | ||
@@ -357,7 +403,7 @@ void Toolbar::reconfigure() { | |||
357 | frame.width, frame.height); | 403 | frame.width, frame.height); |
358 | } | 404 | } |
359 | 405 | ||
360 | bool vertical = isVertical(); | 406 | |
361 | unsigned int next_x = frame.workspace_label_w; | 407 | unsigned int next_x = frame.workspace_label_w; |
362 | unsigned int next_y = frame.window.height(); | 408 | unsigned int next_y = frame.window.height(); |
363 | 409 | ||
@@ -370,21 +416,19 @@ void Toolbar::reconfigure() { | |||
370 | next_x = 0; | 416 | next_x = 0; |
371 | next_y = 0; | 417 | next_y = 0; |
372 | if (vertical) { | 418 | if (vertical) { |
373 | next_y += frame.workspace_label.height() + 1; | 419 | next_y += frame.workspace_label.height() + 1 + frame.bevel_w * 2; |
374 | } else { | 420 | } else { |
375 | next_x += frame.workspace_label.width() + 1; | 421 | next_x += frame.workspace_label.width() + 1 + frame.bevel_w * 2; |
376 | } | 422 | } |
377 | 423 | ||
378 | frame.psbutton.moveResize(frame.bevel_w * 2 + | 424 | frame.psbutton.moveResize(next_x , next_y, |
379 | next_x , next_y, | ||
380 | frame.button_w, frame.button_w); | 425 | frame.button_w, frame.button_w); |
381 | if (vertical) | 426 | if (vertical) |
382 | next_y += frame.psbutton.height() + 1; | 427 | next_y += frame.psbutton.height() + 1 + frame.bevel_w * 3; |
383 | else | 428 | else |
384 | next_x += frame.psbutton.width() + 1; | 429 | next_x += frame.psbutton.width() + 1 + frame.bevel_w * 3; |
385 | 430 | ||
386 | frame.nsbutton.moveResize(frame.bevel_w * 3 + | 431 | frame.nsbutton.moveResize(next_x, next_y, |
387 | next_x, next_y, | ||
388 | frame.button_w, frame.button_w); | 432 | frame.button_w, frame.button_w); |
389 | size_t label_w = frame.window_label_w; | 433 | size_t label_w = frame.window_label_w; |
390 | size_t label_h = frame.height; | 434 | size_t label_h = frame.height; |
@@ -436,7 +480,8 @@ void Toolbar::reconfigure() { | |||
436 | frame.window.height(), *texture); | 480 | frame.window.height(), *texture); |
437 | frame.window.setBackgroundPixmap(frame.base); | 481 | frame.window.setBackgroundPixmap(frame.base); |
438 | } | 482 | } |
439 | if (tmp) image_ctrl.removeImage(tmp); | 483 | if (tmp) |
484 | image_ctrl.removeImage(tmp); | ||
440 | 485 | ||
441 | tmp = frame.label; | 486 | tmp = frame.label; |
442 | texture = &(m_theme.window()); | 487 | texture = &(m_theme.window()); |
@@ -541,7 +586,7 @@ void Toolbar::reconfigure() { | |||
541 | 586 | ||
542 | if (Fluxbox::instance()->useIconBar()) { | 587 | if (Fluxbox::instance()->useIconBar()) { |
543 | if (m_iconbar.get() == 0) { // create new iconbar if we don't have one | 588 | if (m_iconbar.get() == 0) { // create new iconbar if we don't have one |
544 | m_iconbar.reset(new IconBar(&screen(), frame.window_label.window())); | 589 | m_iconbar.reset(new IconBar(&screen(), frame.window_label.window(), m_theme.font())); |
545 | if (screen().getIconCount()) { | 590 | if (screen().getIconCount()) { |
546 | BScreen::Icons & l = screen().getIconList(); | 591 | BScreen::Icons & l = screen().getIconList(); |
547 | BScreen::Icons::iterator it = l.begin(); | 592 | BScreen::Icons::iterator it = l.begin(); |