aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Toolbar.cc92
1 files changed, 17 insertions, 75 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index ad53499..3d75923 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -22,21 +22,16 @@
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.123 2003/10/06 06:22:42 rathnor Exp $ 25// $Id: Toolbar.cc,v 1.124 2003/10/13 23:48:48 fluxgen Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
29// tool
30#include "ToolbarItem.hh"
31
29// themes 32// themes
30#include "ToolbarTheme.hh" 33#include "ToolbarTheme.hh"
31#include "WorkspaceNameTheme.hh"
32
33// tools
34#include "IconbarTool.hh"
35#include "WorkspaceNameTool.hh"
36#include "ClockTool.hh"
37#include "SystemTray.hh"
38 34
39
40#include "I18n.hh" 35#include "I18n.hh"
41#include "fluxbox.hh" 36#include "fluxbox.hh"
42#include "Screen.hh" 37#include "Screen.hh"
@@ -44,7 +39,7 @@
44#include "BoolMenuItem.hh" 39#include "BoolMenuItem.hh"
45#include "Xinerama.hh" 40#include "Xinerama.hh"
46#include "Strut.hh" 41#include "Strut.hh"
47#include "FbCommands.hh" 42#include "CommandParser.hh"
48 43
49#include "FbTk/ImageControl.hh" 44#include "FbTk/ImageControl.hh"
50#include "FbTk/MacroCommand.hh" 45#include "FbTk/MacroCommand.hh"
@@ -165,32 +160,6 @@ private:
165 Toolbar::Placement m_place; 160 Toolbar::Placement m_place;
166}; 161};
167 162
168class ShowMenuAboveToolbar: public FbTk::Command {
169public:
170 explicit ShowMenuAboveToolbar(Toolbar &tbar):m_tbar(tbar) { }
171 void execute() {
172
173 // get last button pos
174 const XEvent &event = Fluxbox::instance()->lastEvent();
175 int x = event.xbutton.x_root - (m_tbar.menu().width() / 2);
176 int y = event.xbutton.y_root - (m_tbar.menu().height() / 2);
177
178 if (x < 0)
179 x = 0;
180 else if (x + m_tbar.menu().width() > m_tbar.screen().width())
181 x = m_tbar.screen().width() - m_tbar.menu().width();
182
183 if (y < 0)
184 y = 0;
185 else if (y + m_tbar.menu().height() > m_tbar.screen().height())
186 y = m_tbar.screen().height() - m_tbar.menu().height();
187
188 m_tbar.menu().move(x, y);
189 m_tbar.menu().show();
190 }
191private:
192 Toolbar &m_tbar;
193};
194}; // end anonymous 163}; // end anonymous
195 164
196// toolbar frame 165// toolbar frame
@@ -233,10 +202,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi
233 this, 202 this,
234 true), 203 true),
235 m_theme(scrn.screenNumber()), 204 m_theme(scrn.screenNumber()),
236 m_clock_theme(scrn.screenNumber(), "toolbar.clock", "Toolbar.Clock"),
237 m_workspace_theme(new WorkspaceNameTheme(scrn.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")),
238 m_iconbar_theme(scrn.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar"),
239 m_layeritem(frame.window, layer), 205 m_layeritem(frame.window, layer),
206 m_tool_factory(scrn),
240 m_strut(0), 207 m_strut(0),
241 // lock rcmanager here 208 // lock rcmanager here
242 m_rc_auto_hide(scrn.resourceManager().lock(), false, 209 m_rc_auto_hide(scrn.resourceManager().lock(), false,
@@ -280,9 +247,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi
280 frame.grab_x = frame.grab_y = 0; 247 frame.grab_x = frame.grab_y = 0;
281 248
282 // set antialias on themes 249 // set antialias on themes
283 m_clock_theme.setAntialias(screen().antialias()); 250 m_tool_factory.updateThemes();
284 m_iconbar_theme.setAntialias(screen().antialias());
285 m_workspace_theme->setAntialias(screen().antialias());
286 251
287 // setup hide timer 252 // setup hide timer
288 m_hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); 253 m_hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay());
@@ -379,11 +344,7 @@ void Toolbar::lower() {
379} 344}
380 345
381void Toolbar::reconfigure() { 346void Toolbar::reconfigure() {
382 m_clock_theme.setAntialias(screen().antialias()); 347 m_tool_factory.updateThemes();
383 m_iconbar_theme.setAntialias(screen().antialias());
384 m_workspace_theme->setAntialias(screen().antialias());
385
386
387 348
388 // parse resource tools and determine if we need to rebuild toolbar 349 // parse resource tools and determine if we need to rebuild toolbar
389 350
@@ -427,20 +388,11 @@ void Toolbar::reconfigure() {
427 StringList::const_iterator item_it = m_tools.begin(); 388 StringList::const_iterator item_it = m_tools.begin();
428 StringList::const_iterator item_it_end = m_tools.end(); 389 StringList::const_iterator item_it_end = m_tools.end();
429 for (; item_it != item_it_end; ++item_it) { 390 for (; item_it != item_it_end; ++item_it) {
430 if (*item_it == "workspacename") { 391 ToolbarItem *item = m_tool_factory.create(*item_it, frame.window, *this);
431 WorkspaceNameTool *item = new WorkspaceNameTool(frame.window, *m_workspace_theme, screen()); 392 if (item == 0)
432 using namespace FbTk; 393 continue;
433 RefCount<Command> showmenu(new ShowMenuAboveToolbar(*this)); 394 m_item_list.push_back(item);
434 item->button().setOnClick(showmenu); 395
435 m_item_list.push_back(item);
436 } else if (*item_it == "iconbar") {
437 m_item_list.push_back(new IconbarTool(frame.window, m_iconbar_theme,
438 screen(), menu()));
439 } else if (*item_it == "systemtray") {
440 m_item_list.push_back(new SystemTray(frame.window));
441 } else if (*item_it == "clock") {
442 m_item_list.push_back(new ClockTool(frame.window, m_clock_theme, screen()));
443 }
444 } 396 }
445 // show all items 397 // show all items
446 frame.window.showSubwindows(); 398 frame.window.showSubwindows();
@@ -469,6 +421,7 @@ void Toolbar::reconfigure() {
469 frame.window.moveResize(frame.x, frame.y, 421 frame.window.moveResize(frame.x, frame.y,
470 frame.width, frame.height); 422 frame.width, frame.height);
471 } 423 }
424
472 // render frame window 425 // render frame window
473 Pixmap tmp = m_window_pm; 426 Pixmap tmp = m_window_pm;
474 if (theme().toolbar().type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { 427 if (theme().toolbar().type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
@@ -621,18 +574,7 @@ void Toolbar::setPlacement(Toolbar::Placement where) {
621 frame.width = head_w * (*m_rc_width_percent) / 100; 574 frame.width = head_w * (*m_rc_width_percent) / 100;
622 //!! TODO: change this 575 //!! TODO: change this
623 // max height of each toolbar items font... 576 // max height of each toolbar items font...
624 unsigned int max_height = 0; 577 unsigned int max_height = m_tool_factory.maxFontHeight();
625 if (max_height < m_clock_theme.font().height())
626 max_height = m_clock_theme.font().height();
627
628 if (max_height < m_workspace_theme->font().height())
629 max_height = m_workspace_theme->font().height();
630
631 if (max_height < m_iconbar_theme.focusedText().font().height())
632 max_height = m_iconbar_theme.focusedText().font().height();
633
634 if (max_height < m_iconbar_theme.unfocusedText().font().height())
635 max_height = m_iconbar_theme.unfocusedText().font().height();
636 578
637 if (theme().height() > 0) 579 if (theme().height() > 0)
638 max_height = theme().height(); 580 max_height = theme().height();
@@ -791,7 +733,7 @@ void Toolbar::setupMenus() {
791 //!! TODO: this should be inserted by the workspace tool 733 //!! TODO: this should be inserted by the workspace tool
792 734
793 735
794 RefCount<Command> start_edit(new FbCommands::SetWorkspaceNameCmd()); 736 RefCount<Command> start_edit(CommandParser::instance().parseLine("setworkspacename"));
795 menu.insert(i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarEditWkspcName, 737 menu.insert(i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarEditWkspcName,
796 "Edit current workspace name"), 738 "Edit current workspace name"),
797 start_edit); 739 start_edit);
@@ -807,7 +749,7 @@ void Toolbar::setupMenus() {
807 FbTk::RefCount<FbTk::Command> reconfig_toolbar(new FbTk:: 749 FbTk::RefCount<FbTk::Command> reconfig_toolbar(new FbTk::
808 SimpleCommand<Toolbar> 750 SimpleCommand<Toolbar>
809 (tbar, &Toolbar::reconfigure)); 751 (tbar, &Toolbar::reconfigure));
810 FbTk::RefCount<FbTk::Command> save_resources(new FbCommands::SaveResources()); 752 FbTk::RefCount<FbTk::Command> save_resources(CommandParser::instance().parseLine("saverc"));
811 FbTk::MacroCommand *toolbar_menuitem_macro = new FbTk::MacroCommand(); 753 FbTk::MacroCommand *toolbar_menuitem_macro = new FbTk::MacroCommand();
812 toolbar_menuitem_macro->add(reconfig_toolbar); 754 toolbar_menuitem_macro->add(reconfig_toolbar);
813 toolbar_menuitem_macro->add(save_resources); 755 toolbar_menuitem_macro->add(save_resources);