2002-03-19 14:30:43 +00:00
|
|
|
// Toolbar.cc for Fluxbox
|
2003-04-14 15:01:55 +00:00
|
|
|
// Copyright (c) 2002 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
2002-03-19 14:30:43 +00:00
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// Toolbar.cc for Blackbox - an X11 Window manager
|
2002-12-13 20:37:55 +00:00
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
|
2001-12-11 20:47:02 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
2002-03-19 14:30:43 +00:00
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2001-12-11 20:47:02 +00:00
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2003-07-10 15:52:58 +00:00
|
|
|
// $Id: Toolbar.cc,v 1.100 2003/07/10 15:52:58 fluxgen Exp $
|
2002-08-04 15:12:51 +00:00
|
|
|
|
|
|
|
#include "Toolbar.hh"
|
2002-02-07 15:12:23 +00:00
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
#include "IconBar.hh"
|
2003-06-13 05:04:14 +00:00
|
|
|
#include "I18n.hh"
|
2001-12-11 20:47:02 +00:00
|
|
|
#include "fluxbox.hh"
|
|
|
|
#include "Screen.hh"
|
|
|
|
#include "Window.hh"
|
|
|
|
#include "Workspace.hh"
|
2002-11-30 20:29:27 +00:00
|
|
|
#include "ImageControl.hh"
|
2002-12-02 21:54:30 +00:00
|
|
|
#include "ToolbarTheme.hh"
|
|
|
|
#include "EventManager.hh"
|
|
|
|
#include "Text.hh"
|
2002-12-13 20:37:55 +00:00
|
|
|
#include "ArrowButton.hh"
|
|
|
|
#include "SimpleCommand.hh"
|
2003-04-16 12:53:14 +00:00
|
|
|
#include "IntResMenuItem.hh"
|
|
|
|
#include "MacroCommand.hh"
|
2003-04-25 11:19:45 +00:00
|
|
|
#include "RootTheme.hh"
|
2003-05-12 23:05:19 +00:00
|
|
|
#include "BoolMenuItem.hh"
|
2003-05-15 11:17:29 +00:00
|
|
|
#include "FbWinFrameTheme.hh"
|
2003-05-19 14:26:30 +00:00
|
|
|
#include "Xinerama.hh"
|
2003-06-18 13:55:17 +00:00
|
|
|
#include "Strut.hh"
|
2003-05-19 14:26:30 +00:00
|
|
|
|
2002-08-12 03:25:55 +00:00
|
|
|
// use GNU extensions
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif // _GNU_SOURCE
|
|
|
|
|
2002-10-13 21:51:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
2002-08-12 03:25:55 +00:00
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2003-07-10 11:48:14 +00:00
|
|
|
#include "Shape.hh"
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
2002-08-12 03:25:55 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <cstdio>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-12 03:25:55 +00:00
|
|
|
#ifdef TIME_WITH_SYS_TIME
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
#else // !TIME_WITH_SYS_TIME
|
2002-08-12 03:25:55 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#else // !HAVE_SYS_TIME_H
|
|
|
|
#include <time.h>
|
|
|
|
#endif // HAVE_SYS_TIME_H
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // TIME_WITH_SYS_TIME
|
|
|
|
|
2003-01-09 18:42:32 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace std;
|
2002-12-04 17:58:01 +00:00
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
template<>
|
|
|
|
void FbTk::Resource<Toolbar::Placement>::
|
|
|
|
setFromString(const char *strval) {
|
|
|
|
if (strcasecmp(strval, "TopLeft")==0)
|
|
|
|
m_value = Toolbar::TOPLEFT;
|
|
|
|
else if (strcasecmp(strval, "BottomLeft")==0)
|
|
|
|
m_value = Toolbar::BOTTOMLEFT;
|
|
|
|
else if (strcasecmp(strval, "TopCenter")==0)
|
|
|
|
m_value = Toolbar::TOPCENTER;
|
|
|
|
else if (strcasecmp(strval, "BottomCenter")==0)
|
|
|
|
m_value = Toolbar::BOTTOMCENTER;
|
|
|
|
else if (strcasecmp(strval, "TopRight")==0)
|
|
|
|
m_value = Toolbar::TOPRIGHT;
|
|
|
|
else if (strcasecmp(strval, "BottomRight")==0)
|
|
|
|
m_value = Toolbar::BOTTOMRIGHT;
|
|
|
|
else if (strcasecmp(strval, "LeftTop") == 0)
|
|
|
|
m_value = Toolbar::LEFTTOP;
|
|
|
|
else if (strcasecmp(strval, "LeftCenter") == 0)
|
|
|
|
m_value = Toolbar::LEFTCENTER;
|
|
|
|
else if (strcasecmp(strval, "LeftBottom") == 0)
|
|
|
|
m_value = Toolbar::LEFTBOTTOM;
|
|
|
|
else if (strcasecmp(strval, "RightTop") == 0)
|
|
|
|
m_value = Toolbar::RIGHTTOP;
|
|
|
|
else if (strcasecmp(strval, "RightCenter") == 0)
|
|
|
|
m_value = Toolbar::RIGHTCENTER;
|
|
|
|
else if (strcasecmp(strval, "RightBottom") == 0)
|
|
|
|
m_value = Toolbar::RIGHTBOTTOM;
|
|
|
|
else
|
|
|
|
setDefaultValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
string FbTk::Resource<Toolbar::Placement>::
|
|
|
|
getString() {
|
|
|
|
switch (m_value) {
|
|
|
|
case Toolbar::TOPLEFT:
|
|
|
|
return string("TopLeft");
|
|
|
|
break;
|
|
|
|
case Toolbar::BOTTOMLEFT:
|
|
|
|
return string("BottomLeft");
|
|
|
|
break;
|
|
|
|
case Toolbar::TOPCENTER:
|
|
|
|
return string("TopCenter");
|
|
|
|
break;
|
|
|
|
case Toolbar::BOTTOMCENTER:
|
|
|
|
return string("BottomCenter");
|
|
|
|
break;
|
|
|
|
case Toolbar::TOPRIGHT:
|
|
|
|
return string("TopRight");
|
|
|
|
break;
|
|
|
|
case Toolbar::BOTTOMRIGHT:
|
|
|
|
return string("BottomRight");
|
|
|
|
break;
|
|
|
|
case Toolbar::LEFTTOP:
|
|
|
|
return string("LeftTop");
|
|
|
|
break;
|
|
|
|
case Toolbar::LEFTCENTER:
|
|
|
|
return string("LeftCenter");
|
|
|
|
break;
|
|
|
|
case Toolbar::LEFTBOTTOM:
|
|
|
|
return string("LeftBottom");
|
|
|
|
break;
|
|
|
|
case Toolbar::RIGHTTOP:
|
|
|
|
return string("RightTop");
|
|
|
|
break;
|
|
|
|
case Toolbar::RIGHTCENTER:
|
|
|
|
return string("RightCenter");
|
|
|
|
break;
|
|
|
|
case Toolbar::RIGHTBOTTOM:
|
|
|
|
return string("RightBottom");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//default string
|
|
|
|
return string("BottomCenter");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-12 18:04:39 +00:00
|
|
|
namespace {
|
|
|
|
class SetToolbarPlacementCmd: public FbTk::Command {
|
2003-02-23 00:49:01 +00:00
|
|
|
public:
|
2003-01-12 18:04:39 +00:00
|
|
|
explicit SetToolbarPlacementCmd(Toolbar &tbar, Toolbar::Placement place):m_tbar(tbar), m_place(place) { }
|
|
|
|
void execute() {
|
|
|
|
m_tbar.setPlacement(m_place);
|
2003-06-23 13:17:57 +00:00
|
|
|
m_tbar.reconfigure();
|
2003-02-23 00:49:01 +00:00
|
|
|
Fluxbox::instance()->save_rc();
|
2003-01-12 18:04:39 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
Toolbar &m_tbar;
|
|
|
|
Toolbar::Placement m_place;
|
|
|
|
};
|
|
|
|
|
|
|
|
}; // end anonymous
|
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
// toolbar frame
|
|
|
|
Toolbar::Frame::Frame(FbTk::EventHandler &evh, int screen_num):
|
|
|
|
window(screen_num, // screen (parent)
|
|
|
|
0, 0, // pos
|
2003-02-22 23:07:23 +00:00
|
|
|
10, 10, // size
|
2002-12-13 20:37:55 +00:00
|
|
|
// event mask
|
2002-12-03 17:02:53 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask,
|
|
|
|
true), // override redirect
|
|
|
|
workspace_label(window, // parent
|
|
|
|
0, 0, //pos
|
|
|
|
1, 1, // size
|
2002-12-13 20:37:55 +00:00
|
|
|
// event mask
|
2002-12-03 17:02:53 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
2003-02-22 23:07:23 +00:00
|
|
|
ExposureMask | KeyPressMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask),
|
2002-12-03 17:02:53 +00:00
|
|
|
window_label(window, // parent
|
|
|
|
0, 0, // pos
|
|
|
|
1, 1, // size
|
2002-12-13 20:37:55 +00:00
|
|
|
// event mask
|
2003-04-23 00:17:51 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ExposureMask |
|
2003-02-22 23:07:23 +00:00
|
|
|
EnterWindowMask | LeaveWindowMask),
|
|
|
|
clock(window, //parent
|
2003-04-23 00:17:51 +00:00
|
|
|
0, 0, // pos
|
|
|
|
1, 1, // size
|
|
|
|
// event mask
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ExposureMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask),
|
2002-12-13 20:37:55 +00:00
|
|
|
psbutton(ArrowButton::LEFT, // arrow type
|
|
|
|
window, // parent
|
2002-12-03 17:02:53 +00:00
|
|
|
0, 0, // pos
|
2002-12-13 20:37:55 +00:00
|
|
|
1, 1), // size
|
|
|
|
nsbutton(ArrowButton::RIGHT, // arrow type
|
|
|
|
window, // parent
|
|
|
|
0, 0, // pos
|
|
|
|
1, 1), // size
|
|
|
|
pwbutton(ArrowButton::LEFT, // arrow type
|
|
|
|
window, // parent
|
|
|
|
0, 0, // pos
|
|
|
|
1, 1), // size
|
|
|
|
nwbutton(ArrowButton::RIGHT, // arrow type
|
|
|
|
window, // parent
|
|
|
|
0, 0, // pos
|
2003-04-09 17:20:06 +00:00
|
|
|
1, 1), // size
|
|
|
|
hour(-1), // start with invalid number to force update
|
2003-04-23 00:17:51 +00:00
|
|
|
minute(-1) {
|
2002-12-13 20:37:55 +00:00
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
FbTk::EventManager &evm = *FbTk::EventManager::instance();
|
2002-12-13 20:37:55 +00:00
|
|
|
// add windows to eventmanager
|
2002-12-03 17:02:53 +00:00
|
|
|
evm.add(evh, window);
|
|
|
|
evm.add(evh, workspace_label);
|
|
|
|
evm.add(evh, window_label);
|
|
|
|
evm.add(evh, clock);
|
2003-04-23 00:17:51 +00:00
|
|
|
|
2003-05-17 11:30:59 +00:00
|
|
|
psbutton.setMouseMotionHandler(&evh);
|
|
|
|
nsbutton.setMouseMotionHandler(&evh);
|
|
|
|
pwbutton.setMouseMotionHandler(&evh);
|
|
|
|
nwbutton.setMouseMotionHandler(&evh);
|
2002-12-03 17:02:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Toolbar::Frame::~Frame() {
|
|
|
|
FbTk::EventManager &evm = *FbTk::EventManager::instance();
|
2002-12-13 20:37:55 +00:00
|
|
|
// remove windows from eventmanager
|
2002-12-03 17:02:53 +00:00
|
|
|
evm.remove(window);
|
|
|
|
evm.remove(workspace_label);
|
|
|
|
evm.remove(window_label);
|
|
|
|
evm.remove(clock);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t width):
|
2003-06-23 13:17:57 +00:00
|
|
|
m_editing(false),
|
|
|
|
m_hidden(false),
|
2003-05-15 12:00:46 +00:00
|
|
|
frame(*this, scrn.screenNumber()),
|
2002-12-01 13:42:15 +00:00
|
|
|
m_screen(scrn),
|
2003-05-10 13:57:07 +00:00
|
|
|
m_clock_timer(this), // get the clock updating every minute
|
|
|
|
m_hide_timer(&hide_handler),
|
2003-03-03 21:51:13 +00:00
|
|
|
m_toolbarmenu(menu),
|
2003-02-23 00:49:01 +00:00
|
|
|
m_placementmenu(*scrn.menuTheme(),
|
2003-05-15 23:30:07 +00:00
|
|
|
scrn.screenNumber(), scrn.imageControl()),
|
2003-02-23 00:49:01 +00:00
|
|
|
m_layermenu(*scrn.menuTheme(),
|
2003-05-15 12:00:46 +00:00
|
|
|
scrn.screenNumber(),
|
2003-05-15 23:30:07 +00:00
|
|
|
scrn.imageControl(),
|
2003-02-23 00:49:01 +00:00
|
|
|
*scrn.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
|
2003-04-16 13:43:50 +00:00
|
|
|
this,
|
|
|
|
true),
|
2003-05-15 12:00:46 +00:00
|
|
|
m_theme(scrn.screenNumber()),
|
2003-02-18 15:11:12 +00:00
|
|
|
m_themelistener(*this),
|
2003-06-18 13:55:17 +00:00
|
|
|
m_layeritem(frame.window, layer),
|
2003-06-23 13:17:57 +00:00
|
|
|
m_strut(0),
|
|
|
|
m_rc_auto_hide(scrn.resourceManager(), false,
|
|
|
|
scrn.name() + ".toolbar.autoHide", scrn.altName() + ".Toolbar.AutoHide"),
|
2003-07-10 15:52:58 +00:00
|
|
|
m_rc_maximize_over(scrn.resourceManager(), false,
|
|
|
|
scrn.name() + ".toolbar.maxOver", scrn.altName() + ".Toolbar.MaxOver"),
|
2003-06-23 13:17:57 +00:00
|
|
|
m_rc_width_percent(scrn.resourceManager(), 65,
|
|
|
|
scrn.name() + ".toolbar.widthPercent", scrn.altName() + ".Toolbar.WidthPercent"),
|
|
|
|
m_rc_layernum(scrn.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDesktopLayer()),
|
|
|
|
scrn.name() + ".toolbar.layer", scrn.altName() + ".Toolbar.Layer"),
|
|
|
|
m_rc_on_head(scrn.resourceManager(), 0,
|
|
|
|
scrn.name() + ".toolbar.onhead", scrn.altName() + ".Toolbar.onHead"),
|
|
|
|
m_rc_placement(scrn.resourceManager(), Toolbar::BOTTOMCENTER,
|
2003-07-10 11:48:14 +00:00
|
|
|
scrn.name() + ".toolbar.placement", scrn.altName() + ".Toolbar.Placement"),
|
|
|
|
m_shape(new Shape(frame.window, 0)) {
|
2003-02-23 00:49:01 +00:00
|
|
|
|
2003-02-15 02:00:29 +00:00
|
|
|
// we need to get notified when the theme is reloaded
|
|
|
|
m_theme.addListener(m_themelistener);
|
2003-07-01 12:41:44 +00:00
|
|
|
// listen to screen reconfigure
|
|
|
|
screen().reconfigureSig().attach(&m_themelistener);
|
2002-12-02 21:54:30 +00:00
|
|
|
|
2003-05-24 13:13:22 +00:00
|
|
|
m_layermenu.setInternalMenu();
|
|
|
|
m_placementmenu.setInternalMenu();
|
2003-06-23 13:17:57 +00:00
|
|
|
setupMenus();
|
2003-01-12 18:04:39 +00:00
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
// geometry settings
|
|
|
|
frame.width = width;
|
|
|
|
frame.height = frame.label_h = 10;
|
|
|
|
frame.window_label_w =
|
|
|
|
frame.workspace_label_w = frame.clock_w = width/3;
|
|
|
|
frame.button_w = 20;
|
|
|
|
frame.bevel_w = 1;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
timeval delay;
|
|
|
|
delay.tv_sec = 1;
|
|
|
|
delay.tv_usec = 0;
|
2003-05-10 13:57:07 +00:00
|
|
|
m_clock_timer.setTimeout(delay);
|
|
|
|
m_clock_timer.start();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-05-17 11:30:59 +00:00
|
|
|
m_theme.font().setAntialias(screen().antialias());
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
hide_handler.toolbar = this;
|
2003-05-10 13:57:07 +00:00
|
|
|
m_hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay());
|
|
|
|
m_hide_timer.fireOnce(true);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
frame.grab_x = frame.grab_y = 0;
|
|
|
|
|
|
|
|
frame.base = frame.label = frame.wlabel = frame.clk = frame.button =
|
|
|
|
frame.pbutton = None;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-04-15 12:15:44 +00:00
|
|
|
m_iconbar.reset(new IconBar(screen(), frame.window_label.window(), m_theme.font()));
|
2002-11-27 12:20:23 +00:00
|
|
|
|
2002-12-13 20:37:55 +00:00
|
|
|
// finaly: setup Commands for the buttons in the frame
|
2003-02-16 00:09:34 +00:00
|
|
|
typedef FbTk::SimpleCommand<BScreen> ScreenCmd;
|
|
|
|
FbTk::RefCount<FbTk::Command> nextworkspace(new ScreenCmd(screen(),
|
|
|
|
&BScreen::nextWorkspace));
|
|
|
|
FbTk::RefCount<FbTk::Command> prevworkspace(new ScreenCmd(screen(),
|
|
|
|
&BScreen::prevWorkspace));
|
|
|
|
FbTk::RefCount<FbTk::Command> nextwindow(new ScreenCmd(screen(),
|
|
|
|
&BScreen::nextFocus));
|
|
|
|
FbTk::RefCount<FbTk::Command> prevwindow(new ScreenCmd(screen(),
|
|
|
|
&BScreen::prevFocus));
|
2002-12-13 20:37:55 +00:00
|
|
|
frame.psbutton.setOnClick(prevworkspace);
|
|
|
|
frame.nsbutton.setOnClick(nextworkspace);
|
|
|
|
frame.pwbutton.setOnClick(prevwindow);
|
|
|
|
frame.nwbutton.setOnClick(nextwindow);
|
|
|
|
|
2003-05-24 05:49:31 +00:00
|
|
|
reconfigure(); // get everything together
|
2003-05-17 11:30:59 +00:00
|
|
|
frame.window.showSubwindows();
|
|
|
|
frame.window.show();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
Toolbar::~Toolbar() {
|
2003-06-18 13:55:17 +00:00
|
|
|
clearStrut();
|
2003-05-15 23:30:07 +00:00
|
|
|
FbTk::ImageControl &image_ctrl = screen().imageControl();
|
2002-12-02 21:54:30 +00:00
|
|
|
if (frame.base) image_ctrl.removeImage(frame.base);
|
|
|
|
if (frame.label) image_ctrl.removeImage(frame.label);
|
|
|
|
if (frame.wlabel) image_ctrl.removeImage(frame.wlabel);
|
|
|
|
if (frame.clk) image_ctrl.removeImage(frame.clk);
|
|
|
|
if (frame.button) image_ctrl.removeImage(frame.button);
|
|
|
|
if (frame.pbutton) image_ctrl.removeImage(frame.pbutton);
|
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-06-18 13:55:17 +00:00
|
|
|
void Toolbar::clearStrut() {
|
|
|
|
if (m_strut) {
|
|
|
|
screen().clearStrut(m_strut);
|
|
|
|
m_strut = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::updateStrut() {
|
2003-06-22 19:39:47 +00:00
|
|
|
bool had_strut = m_strut ? true : false;
|
2003-06-18 13:55:17 +00:00
|
|
|
clearStrut();
|
|
|
|
// we should request space if we're in autohide mode or
|
|
|
|
// if the user dont want to request space for toolbar.
|
2003-07-10 15:52:58 +00:00
|
|
|
if (doAutoHide() || *m_rc_maximize_over) {
|
2003-06-22 19:39:47 +00:00
|
|
|
if (had_strut)
|
|
|
|
screen().updateAvailableWorkspaceArea();
|
2003-06-18 13:55:17 +00:00
|
|
|
return;
|
2003-06-22 19:39:47 +00:00
|
|
|
}
|
2003-06-18 13:55:17 +00:00
|
|
|
|
|
|
|
// request area on screen
|
|
|
|
int top = 0, bottom = 0, left = 0, right = 0;
|
2003-06-23 13:17:57 +00:00
|
|
|
switch (placement()) {
|
2003-06-18 13:55:17 +00:00
|
|
|
case TOPLEFT:
|
|
|
|
case TOPCENTER:
|
|
|
|
case TOPRIGHT:
|
|
|
|
top = height();
|
|
|
|
break;
|
|
|
|
case BOTTOMLEFT:
|
|
|
|
case BOTTOMCENTER:
|
|
|
|
case BOTTOMRIGHT:
|
|
|
|
bottom = height();
|
|
|
|
break;
|
|
|
|
case RIGHTTOP:
|
|
|
|
case RIGHTCENTER:
|
|
|
|
case RIGHTBOTTOM:
|
|
|
|
right = width();
|
|
|
|
break;
|
|
|
|
case LEFTTOP:
|
|
|
|
case LEFTCENTER:
|
|
|
|
case LEFTBOTTOM:
|
|
|
|
left = width();
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
m_strut = screen().requestStrut(left, right, top, bottom);
|
|
|
|
screen().updateAvailableWorkspaceArea();
|
|
|
|
}
|
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
bool Toolbar::isVertical() const {
|
2003-06-23 13:17:57 +00:00
|
|
|
return (placement() == RIGHTCENTER ||
|
|
|
|
placement() == RIGHTTOP ||
|
|
|
|
placement() == RIGHTBOTTOM ||
|
|
|
|
placement() == LEFTCENTER ||
|
|
|
|
placement() == LEFTTOP ||
|
|
|
|
placement() == LEFTBOTTOM);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::addIcon(FluxboxWindow *w) {
|
2003-07-10 11:48:14 +00:00
|
|
|
if (w == 0)
|
|
|
|
return;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (m_iconbar.get() != 0)
|
2002-12-02 21:54:30 +00:00
|
|
|
FbTk::EventManager::instance()->add(*this, m_iconbar->addIcon(w));
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::delIcon(FluxboxWindow *w) {
|
2003-07-10 11:48:14 +00:00
|
|
|
if (w == 0)
|
|
|
|
return;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (m_iconbar.get() != 0)
|
2002-12-02 21:54:30 +00:00
|
|
|
FbTk::EventManager::instance()->remove(m_iconbar->delIcon(w));
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2003-03-03 21:51:13 +00:00
|
|
|
|
2003-06-26 12:22:43 +00:00
|
|
|
void Toolbar::delAllIcons(bool ignore_stuck) {
|
2003-03-03 21:51:13 +00:00
|
|
|
if (m_iconbar.get() == 0)
|
|
|
|
return;
|
|
|
|
|
2003-06-26 12:22:43 +00:00
|
|
|
IconBar::WindowList *deleted = m_iconbar->delAllIcons(ignore_stuck);
|
2003-03-03 21:51:13 +00:00
|
|
|
IconBar::WindowList::iterator it = deleted->begin();
|
|
|
|
IconBar::WindowList::iterator it_end = deleted->end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
FbTk::EventManager::instance()->remove(*it);
|
|
|
|
}
|
|
|
|
delete deleted;
|
|
|
|
}
|
|
|
|
|
2003-06-11 14:51:22 +00:00
|
|
|
bool Toolbar::containsIcon(const FluxboxWindow &win) const {
|
2003-03-03 21:51:13 +00:00
|
|
|
return (m_iconbar->findIcon(&win) != 0);
|
|
|
|
}
|
|
|
|
|
2003-06-26 12:22:43 +00:00
|
|
|
void Toolbar::enableUpdates() {
|
|
|
|
if (m_iconbar.get() != 0)
|
|
|
|
m_iconbar->enableUpdates();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::disableUpdates() {
|
|
|
|
if (m_iconbar.get() != 0)
|
|
|
|
m_iconbar->disableUpdates();
|
|
|
|
}
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
void Toolbar::enableIconBar() {
|
|
|
|
if (m_iconbar.get() != 0)
|
2003-04-27 04:28:04 +00:00
|
|
|
return; // already on
|
|
|
|
|
2003-06-13 05:04:14 +00:00
|
|
|
m_iconbar.reset(new IconBar(screen(),
|
|
|
|
frame.window_label.window(),
|
|
|
|
m_theme.font()));
|
2003-03-03 21:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::disableIconBar() {
|
|
|
|
if (m_iconbar.get() == 0)
|
2003-04-27 04:28:04 +00:00
|
|
|
return; // already off
|
|
|
|
|
2003-03-03 21:51:13 +00:00
|
|
|
delAllIcons();
|
|
|
|
|
|
|
|
m_iconbar.reset(0); // destroy iconbar
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
void Toolbar::raise() {
|
|
|
|
m_layeritem.raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::lower() {
|
|
|
|
m_layeritem.lower();
|
|
|
|
}
|
2003-03-03 21:51:13 +00:00
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::reconfigure() {
|
2003-02-23 12:04:27 +00:00
|
|
|
|
2003-07-01 12:41:44 +00:00
|
|
|
theme().font().setAntialias(screen().antialias());
|
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
if (doAutoHide())
|
2003-05-10 13:57:07 +00:00
|
|
|
m_hide_timer.start();
|
2003-02-23 12:04:27 +00:00
|
|
|
|
2003-02-23 00:49:01 +00:00
|
|
|
bool vertical = isVertical();
|
|
|
|
|
|
|
|
if (m_iconbar.get())
|
|
|
|
m_iconbar->setVertical(vertical);
|
2002-03-19 14:30:43 +00:00
|
|
|
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.bevel_w = theme().bevelWidth();
|
2003-07-10 11:48:14 +00:00
|
|
|
// destroy shape if the theme wasn't specified with one,
|
|
|
|
// or create one
|
|
|
|
if (theme().shape() == false && m_shape.get())
|
|
|
|
m_shape.reset(0);
|
|
|
|
else if (theme().shape() && m_shape.get() == 0) {
|
|
|
|
m_shape.reset(new Shape(frame.window, 0));
|
|
|
|
}
|
2002-12-03 17:02:53 +00:00
|
|
|
// recallibrate size
|
2003-06-23 13:17:57 +00:00
|
|
|
setPlacement(placement());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-10-29 16:09:37 +00:00
|
|
|
#ifdef HAVE_STRFTIME
|
2002-12-01 13:42:15 +00:00
|
|
|
time_t ttmp = time(0);
|
|
|
|
struct tm *tt = 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (ttmp != -1) {
|
|
|
|
tt = localtime(&ttmp);
|
|
|
|
if (tt) {
|
|
|
|
char t[1024], *time_string = (char *) 0;
|
2003-02-16 00:09:34 +00:00
|
|
|
int len = strftime(t, 1024, screen().getStrftimeFormat(), tt);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
time_string = new char[len + 1];
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
memset(time_string, '0', len);
|
|
|
|
*(time_string + len) = '\0';
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
frame.clock_w = m_theme.font().textWidth(time_string, len);
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.clock_w += (frame.bevel_w * 4);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
delete [] time_string;
|
|
|
|
} else
|
|
|
|
frame.clock_w = 0;
|
|
|
|
} else
|
|
|
|
frame.clock_w = 0;
|
2002-10-29 16:09:37 +00:00
|
|
|
#else // !HAVE_STRFTIME
|
2002-01-21 00:53:02 +00:00
|
|
|
|
2003-03-23 04:18:59 +00:00
|
|
|
I18n *i18n = I18n::instance();
|
2002-12-02 21:54:30 +00:00
|
|
|
frame.clock_w = m_theme.font().textWidth(
|
2003-04-23 00:17:51 +00:00
|
|
|
i18n->
|
2003-06-22 19:39:47 +00:00
|
|
|
getMessage(FBNLS::ToolbarSet,
|
2003-04-23 00:17:51 +00:00
|
|
|
FBNLS::ToolbarNoStrftimeLength,
|
|
|
|
"00:00000"),
|
|
|
|
strlen(i18n->
|
2003-06-22 19:39:47 +00:00
|
|
|
getMessage(FBNLS::ToolbarSet,
|
2003-04-23 00:17:51 +00:00
|
|
|
FBNLS::ToolbarNoStrftimeLength,
|
|
|
|
"00:00000"))) + (frame.bevel_w * 4);
|
2002-01-21 00:53:02 +00:00
|
|
|
|
2002-10-29 16:09:37 +00:00
|
|
|
#endif // HAVE_STRFTIME
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int w = 0;
|
|
|
|
frame.workspace_label_w = 0;
|
|
|
|
|
2003-02-16 00:09:34 +00:00
|
|
|
for (i = 0; i < screen().getCount(); i++) {
|
|
|
|
w = m_theme.font().textWidth(screen().getWorkspace(i)->name().c_str(),
|
|
|
|
screen().getWorkspace(i)->name().size());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
w += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
if (w > frame.workspace_label_w)
|
|
|
|
frame.workspace_label_w = w;
|
|
|
|
}
|
2002-12-04 17:58:01 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (frame.workspace_label_w < frame.clock_w)
|
|
|
|
frame.workspace_label_w = frame.clock_w;
|
|
|
|
else if (frame.workspace_label_w > frame.clock_w)
|
|
|
|
frame.clock_w = frame.workspace_label_w;
|
|
|
|
|
2003-07-10 13:48:35 +00:00
|
|
|
frame.psbutton.window().setBorderWidth(theme().buttonBorderWidth());
|
|
|
|
frame.nsbutton.window().setBorderWidth(theme().buttonBorderWidth());
|
|
|
|
frame.pwbutton.window().setBorderWidth(theme().buttonBorderWidth());
|
|
|
|
frame.nwbutton.window().setBorderWidth(theme().buttonBorderWidth());
|
|
|
|
|
2003-04-28 16:48:23 +00:00
|
|
|
// Right, let's break this one down....
|
|
|
|
// full width, minus clock, workspace label and the 4 arrow buttons.
|
|
|
|
// each of the (6) aforementioned items are separated by a bevel width,
|
|
|
|
// plus outside (+1), plus the window label (+1).
|
|
|
|
|
|
|
|
i = frame.clock_w + (frame.button_w * 4) +
|
|
|
|
frame.workspace_label_w + (frame.bevel_w * 8) + 6;
|
|
|
|
|
|
|
|
// of course if your toolbar is set too small, this could go negative.
|
|
|
|
// which is bad mmmkay. Since we are unsigned, we check that *first*.
|
|
|
|
if (vertical)
|
|
|
|
w = frame.height;
|
|
|
|
else
|
|
|
|
w = frame.width;
|
|
|
|
|
|
|
|
if (i > w)
|
|
|
|
frame.window_label_w = 0;
|
|
|
|
else
|
|
|
|
frame.window_label_w = w - i;
|
|
|
|
|
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
if (isHidden())
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.window.moveResize(frame.x_hidden, frame.y_hidden,
|
|
|
|
frame.width, frame.height);
|
|
|
|
else {
|
|
|
|
frame.window.moveResize(frame.x, frame.y,
|
|
|
|
frame.width, frame.height);
|
|
|
|
}
|
2002-12-04 17:58:01 +00:00
|
|
|
|
2003-02-23 00:49:01 +00:00
|
|
|
|
2002-12-04 17:58:01 +00:00
|
|
|
unsigned int next_x = frame.workspace_label_w;
|
|
|
|
unsigned int next_y = frame.window.height();
|
2003-04-28 16:48:23 +00:00
|
|
|
unsigned int text_x=0, text_y=0;
|
|
|
|
if (vertical)
|
|
|
|
text_x = frame.bevel_w;
|
|
|
|
else
|
|
|
|
text_y = frame.bevel_w;
|
|
|
|
|
2002-12-04 17:58:01 +00:00
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
if (vertical) {
|
2002-12-04 17:58:01 +00:00
|
|
|
next_x = frame.window.width();
|
|
|
|
next_y = frame.workspace_label_w;
|
2002-12-03 17:02:53 +00:00
|
|
|
}
|
|
|
|
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.workspace_label.moveResize(frame.bevel_w, frame.bevel_w, next_x, next_y);
|
|
|
|
next_x = 0;
|
|
|
|
next_y = 0;
|
2002-12-03 17:02:53 +00:00
|
|
|
if (vertical) {
|
2003-02-23 00:49:01 +00:00
|
|
|
next_y += frame.workspace_label.height() + 1 + frame.bevel_w * 2;
|
2002-12-04 17:58:01 +00:00
|
|
|
} else {
|
2003-02-23 00:49:01 +00:00
|
|
|
next_x += frame.workspace_label.width() + 1 + frame.bevel_w * 2;
|
2002-12-03 17:02:53 +00:00
|
|
|
}
|
2002-12-04 17:58:01 +00:00
|
|
|
|
2003-02-23 00:49:01 +00:00
|
|
|
frame.psbutton.moveResize(next_x , next_y,
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.button_w, frame.button_w);
|
|
|
|
if (vertical)
|
2003-02-23 16:29:26 +00:00
|
|
|
next_y += frame.psbutton.height() + 1;
|
2002-12-01 13:42:15 +00:00
|
|
|
else
|
2003-02-23 16:29:26 +00:00
|
|
|
next_x += frame.psbutton.width() + 1;
|
2002-12-03 17:02:53 +00:00
|
|
|
|
2003-02-23 00:49:01 +00:00
|
|
|
frame.nsbutton.moveResize(next_x, next_y,
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.button_w, frame.button_w);
|
2002-12-04 17:58:01 +00:00
|
|
|
size_t label_w = frame.window_label_w;
|
|
|
|
size_t label_h = frame.height;
|
|
|
|
|
|
|
|
if (vertical) {
|
|
|
|
next_y += frame.nsbutton.height() + 1;
|
|
|
|
label_w = frame.width;
|
2003-04-28 16:48:23 +00:00
|
|
|
label_h = frame.window_label_w/* - frame.width + frame.height*/;
|
2002-12-04 17:58:01 +00:00
|
|
|
|
|
|
|
} else
|
|
|
|
next_x += frame.nsbutton.width() + 1;
|
|
|
|
|
|
|
|
frame.window_label.moveResize(next_x, next_y,
|
|
|
|
label_w, label_h);
|
|
|
|
if (vertical)
|
|
|
|
next_y += frame.window_label.height() + 1;
|
|
|
|
else
|
|
|
|
next_x += frame.window_label.width() + 1;
|
|
|
|
|
|
|
|
frame.pwbutton.moveResize(next_x, next_y,
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.button_w, frame.button_w);
|
2002-12-04 17:58:01 +00:00
|
|
|
if (vertical)
|
|
|
|
next_y += frame.pwbutton.height() + 1;
|
|
|
|
else
|
|
|
|
next_x += frame.pwbutton.width() + 1;
|
|
|
|
|
|
|
|
frame.nwbutton.moveResize(next_x, next_y,
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.button_w, frame.button_w);
|
2003-06-22 19:39:47 +00:00
|
|
|
|
2002-12-04 17:58:01 +00:00
|
|
|
size_t clock_w = frame.width - next_x - frame.nwbutton.width() - 1;
|
|
|
|
size_t clock_h = frame.height;
|
|
|
|
if (vertical) {
|
|
|
|
next_y += frame.nwbutton.height() + 1;
|
|
|
|
clock_w = frame.width;
|
|
|
|
clock_h = frame.height - next_y;
|
|
|
|
} else
|
|
|
|
next_x += frame.nwbutton.width() + 1;
|
|
|
|
|
2003-04-28 16:48:23 +00:00
|
|
|
frame.clock.moveResize(next_x + text_x, next_y + text_y,
|
2002-12-04 17:58:01 +00:00
|
|
|
clock_w, clock_h);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-05-15 23:30:07 +00:00
|
|
|
FbTk::ImageControl &image_ctrl = screen().imageControl();
|
2003-05-10 13:57:07 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
Pixmap tmp = frame.base;
|
2002-12-02 21:54:30 +00:00
|
|
|
const FbTk::Texture *texture = &(m_theme.toolbar());
|
2002-12-01 13:42:15 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
frame.base = None;
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.window.setBackgroundColor(texture->color());
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-02-15 02:00:29 +00:00
|
|
|
frame.base = image_ctrl.renderImage(frame.window.width(),
|
|
|
|
frame.window.height(), *texture);
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.window.setBackgroundPixmap(frame.base);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-02-23 00:49:01 +00:00
|
|
|
if (tmp)
|
|
|
|
image_ctrl.removeImage(tmp);
|
2002-12-02 21:54:30 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
tmp = frame.label;
|
2002-12-02 21:54:30 +00:00
|
|
|
texture = &(m_theme.window());
|
2002-12-01 13:42:15 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
frame.label = None;
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.window_label.setBackgroundColor(texture->color());
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
|
|
|
frame.label =
|
2003-02-15 02:00:29 +00:00
|
|
|
image_ctrl.renderImage(frame.window_label.width(),
|
|
|
|
frame.window_label.height(), *texture);
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.window_label.setBackgroundPixmap(frame.label);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2002-12-02 21:54:30 +00:00
|
|
|
if (tmp) image_ctrl.removeImage(tmp);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
tmp = frame.wlabel;
|
2002-12-02 21:54:30 +00:00
|
|
|
texture = &(m_theme.label());
|
2002-12-01 13:42:15 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
frame.wlabel = None;
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.workspace_label.setBackgroundColor(texture->color());
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
|
|
|
frame.wlabel =
|
2002-12-04 17:58:01 +00:00
|
|
|
image_ctrl.renderImage(frame.workspace_label.width(),
|
|
|
|
frame.workspace_label.height(), *texture);
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.workspace_label.setBackgroundPixmap(frame.wlabel);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2002-12-02 21:54:30 +00:00
|
|
|
if (tmp) image_ctrl.removeImage(tmp);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
tmp = frame.clk;
|
2002-12-02 21:54:30 +00:00
|
|
|
texture = &(m_theme.clock());
|
2002-12-01 13:42:15 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
frame.clk = None;
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.clock.setBackgroundColor(texture->color());
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
|
|
|
frame.clk =
|
2002-12-04 17:58:01 +00:00
|
|
|
image_ctrl.renderImage(frame.clock.width(), frame.clock.height(), *texture);
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.clock.setBackgroundPixmap(frame.clk);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2002-12-02 21:54:30 +00:00
|
|
|
if (tmp) image_ctrl.removeImage(tmp);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
tmp = frame.button;
|
2002-12-02 21:54:30 +00:00
|
|
|
texture = &(m_theme.button());
|
2002-12-01 13:42:15 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
frame.button = None;
|
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
const FbTk::Color &color = texture->color();
|
|
|
|
frame.psbutton.setBackgroundColor(color);
|
|
|
|
frame.nsbutton.setBackgroundColor(color);
|
|
|
|
frame.pwbutton.setBackgroundColor(color);
|
|
|
|
frame.nwbutton.setBackgroundColor(color);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
|
|
|
frame.button =
|
2002-12-02 21:54:30 +00:00
|
|
|
image_ctrl.renderImage(frame.button_w, frame.button_w, *texture);
|
2002-12-03 17:02:53 +00:00
|
|
|
|
|
|
|
frame.psbutton.setBackgroundPixmap(frame.button);
|
|
|
|
frame.nsbutton.setBackgroundPixmap(frame.button);
|
|
|
|
frame.pwbutton.setBackgroundPixmap(frame.button);
|
|
|
|
frame.nwbutton.setBackgroundPixmap(frame.button);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
if (tmp)
|
2002-12-02 21:54:30 +00:00
|
|
|
image_ctrl.removeImage(tmp);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2002-12-13 20:37:55 +00:00
|
|
|
// pressed button pixmap
|
2002-12-01 13:42:15 +00:00
|
|
|
tmp = frame.pbutton;
|
2002-12-02 21:54:30 +00:00
|
|
|
texture = &(m_theme.pressedButton());
|
2002-12-01 13:42:15 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
frame.pbutton = None;
|
2002-12-13 20:37:55 +00:00
|
|
|
} else {
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.pbutton =
|
2002-12-02 21:54:30 +00:00
|
|
|
image_ctrl.renderImage(frame.button_w, frame.button_w, *texture);
|
2002-12-13 20:37:55 +00:00
|
|
|
frame.psbutton.setPressedPixmap(frame.pbutton);
|
|
|
|
frame.nsbutton.setPressedPixmap(frame.pbutton);
|
|
|
|
frame.pwbutton.setPressedPixmap(frame.pbutton);
|
|
|
|
frame.nwbutton.setPressedPixmap(frame.pbutton);
|
|
|
|
}
|
|
|
|
// setup button gc
|
|
|
|
frame.psbutton.setGC(m_theme.buttonPicGC());
|
|
|
|
frame.nsbutton.setGC(m_theme.buttonPicGC());
|
|
|
|
frame.pwbutton.setGC(m_theme.buttonPicGC());
|
|
|
|
frame.nwbutton.setGC(m_theme.buttonPicGC());
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (tmp)
|
2002-12-02 21:54:30 +00:00
|
|
|
image_ctrl.removeImage(tmp);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.window.setBorderColor(theme().borderColor());
|
|
|
|
frame.window.setBorderWidth(theme().borderWidth());
|
2002-12-03 17:02:53 +00:00
|
|
|
|
|
|
|
frame.window.clear();
|
2003-02-22 23:07:23 +00:00
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.workspace_label.clear();
|
|
|
|
frame.window_label.clear();
|
2003-07-10 11:48:14 +00:00
|
|
|
frame.clock.clear();
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.psbutton.clear();
|
|
|
|
frame.nsbutton.clear();
|
|
|
|
frame.pwbutton.clear();
|
|
|
|
frame.nwbutton.clear();
|
2003-07-10 11:48:14 +00:00
|
|
|
|
|
|
|
if (theme().shape() && m_shape.get())
|
|
|
|
m_shape->update();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
redrawWindowLabel();
|
2003-04-28 16:48:23 +00:00
|
|
|
if (m_iconbar.get())
|
|
|
|
m_iconbar->reconfigure();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
redrawWorkspaceLabel();
|
|
|
|
checkClock(true);
|
|
|
|
|
|
|
|
m_toolbarmenu.reconfigure();
|
2003-06-18 13:55:17 +00:00
|
|
|
// we're done with all resizing and stuff now we can request a new
|
|
|
|
// area to be reserv on screen
|
|
|
|
updateStrut();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-27 12:20:23 +00:00
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::checkClock(bool redraw, bool date) {
|
2002-12-01 13:42:15 +00:00
|
|
|
time_t tmp = 0;
|
|
|
|
struct tm *tt = 0;
|
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
if ((tmp = time(0)) != -1) {
|
|
|
|
if (! (tt = localtime(&tmp)))
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2003-06-22 19:39:47 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (tt->tm_min != frame.minute || tt->tm_hour != frame.hour) {
|
|
|
|
frame.hour = tt->tm_hour;
|
|
|
|
frame.minute = tt->tm_min;
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.clock.clear();
|
2002-12-01 13:42:15 +00:00
|
|
|
redraw = true;
|
|
|
|
}
|
2003-06-22 19:39:47 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-02-15 02:00:29 +00:00
|
|
|
if (!redraw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
frame.clock.clear();
|
2002-10-29 16:09:37 +00:00
|
|
|
#ifdef HAVE_STRFTIME
|
2003-02-15 02:00:29 +00:00
|
|
|
char t[1024];
|
2003-02-16 00:09:34 +00:00
|
|
|
if (! strftime(t, 1024, screen().getStrftimeFormat(), tt))
|
2003-02-15 02:00:29 +00:00
|
|
|
return;
|
2002-10-29 16:09:37 +00:00
|
|
|
#else // !HAVE_STRFTIME
|
2003-03-23 04:18:59 +00:00
|
|
|
I18n *i18n = I18n::instance();
|
2003-02-15 02:00:29 +00:00
|
|
|
char t[9];
|
|
|
|
if (date) {
|
|
|
|
// format the date... with special consideration for y2k ;)
|
2003-03-23 01:33:31 +00:00
|
|
|
if (screen().getDateFormat() == Fluxbox::B_EUROPEANDATE) {
|
2003-02-15 02:00:29 +00:00
|
|
|
sprintf(t,
|
2003-06-22 19:39:47 +00:00
|
|
|
i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarNoStrftimeDateFormatEu,
|
2003-02-15 02:00:29 +00:00
|
|
|
"%02d.%02d.%02d"),
|
|
|
|
tt->tm_mday, tt->tm_mon + 1,
|
|
|
|
(tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-02-15 02:00:29 +00:00
|
|
|
sprintf(t,
|
2003-06-22 19:39:47 +00:00
|
|
|
i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarNoStrftimeDateFormat,
|
2003-02-15 02:00:29 +00:00
|
|
|
"%02d/%02d/%02d"),
|
|
|
|
tt->tm_mon + 1, tt->tm_mday,
|
|
|
|
(tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-02-15 02:00:29 +00:00
|
|
|
} else {
|
2003-02-16 00:09:34 +00:00
|
|
|
if (screen().isClock24Hour()) {
|
2003-02-15 02:00:29 +00:00
|
|
|
sprintf(t,
|
2003-06-22 19:39:47 +00:00
|
|
|
i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarNoStrftimeTimeFormat24,
|
2003-02-15 02:00:29 +00:00
|
|
|
" %02d:%02d "),
|
|
|
|
frame.hour, frame.minute);
|
|
|
|
} else {
|
|
|
|
sprintf(t,
|
2003-06-22 19:39:47 +00:00
|
|
|
i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarNoStrftimeTimeFormat12,
|
2003-02-15 02:00:29 +00:00
|
|
|
"%02d:%02d %sm"),
|
|
|
|
((frame.hour > 12) ? frame.hour - 12 :
|
|
|
|
((frame.hour == 0) ? 12 : frame.hour)), frame.minute,
|
|
|
|
((frame.hour >= 12) ?
|
2003-06-22 19:39:47 +00:00
|
|
|
i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarNoStrftimeTimeFormatP,
|
2003-02-15 02:00:29 +00:00
|
|
|
"p") :
|
2003-06-22 19:39:47 +00:00
|
|
|
i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarNoStrftimeTimeFormatA,
|
2003-02-15 02:00:29 +00:00
|
|
|
"a")));
|
|
|
|
}
|
|
|
|
}
|
2002-10-29 16:09:37 +00:00
|
|
|
#endif // HAVE_STRFTIME
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-02-23 19:13:22 +00:00
|
|
|
unsigned int newlen = strlen(t);
|
2003-02-15 02:00:29 +00:00
|
|
|
int dx = FbTk::doAlignment(frame.clock_w,
|
|
|
|
frame.bevel_w*2,
|
|
|
|
m_theme.justify(),
|
|
|
|
m_theme.font(),
|
|
|
|
t, strlen(t), newlen);
|
|
|
|
int dy = 1 + m_theme.font().ascent();
|
|
|
|
if (m_theme.font().isRotated()) {
|
|
|
|
int tmp = dy;
|
|
|
|
dy = frame.clock.height() - dx;
|
|
|
|
dx = tmp;
|
|
|
|
}
|
2003-04-23 00:17:51 +00:00
|
|
|
frame.clock.clear();
|
2003-06-22 19:39:47 +00:00
|
|
|
m_theme.font().drawText(frame.clock.window(),
|
2003-05-15 12:00:46 +00:00
|
|
|
screen().screenNumber(),
|
2003-02-15 02:00:29 +00:00
|
|
|
m_theme.clockTextGC(),
|
|
|
|
t, newlen,
|
|
|
|
dx, dy);
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::redrawWindowLabel(bool redraw) {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (Fluxbox::instance()->getFocusedWindow()) {
|
|
|
|
if (redraw)
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.window_label.clear();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
FluxboxWindow *foc = Fluxbox::instance()->getFocusedWindow();
|
2003-02-16 00:09:34 +00:00
|
|
|
// don't draw focused window if it's not on the same screen
|
2003-05-15 11:17:29 +00:00
|
|
|
if (&foc->screen() != &screen() || foc->title().size() == 0)
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2002-05-03 13:14:06 +00:00
|
|
|
|
2003-05-15 11:17:29 +00:00
|
|
|
unsigned int newlen = foc->title().size();
|
2002-12-02 21:54:30 +00:00
|
|
|
int dx = FbTk::doAlignment(frame.window_label_w, frame.bevel_w*2,
|
2003-02-16 00:09:34 +00:00
|
|
|
m_theme.justify(),
|
|
|
|
m_theme.font(),
|
2003-05-15 11:17:29 +00:00
|
|
|
foc->title().c_str(),
|
|
|
|
foc->title().size(), newlen);
|
2002-12-04 17:58:01 +00:00
|
|
|
int dy = 1 + m_theme.font().ascent();
|
|
|
|
|
|
|
|
if (m_theme.font().isRotated()) {
|
|
|
|
int tmp = dy;
|
|
|
|
dy = frame.window_label.height() - dx;
|
2003-04-28 16:48:23 +00:00
|
|
|
dx = tmp + frame.bevel_w;
|
|
|
|
} else
|
|
|
|
dy += frame.bevel_w;
|
2002-12-04 17:58:01 +00:00
|
|
|
|
2003-06-25 12:33:28 +00:00
|
|
|
m_theme.font().drawText(frame.window_label.window(),
|
2003-05-15 12:00:46 +00:00
|
|
|
screen().screenNumber(),
|
2003-02-16 00:09:34 +00:00
|
|
|
m_theme.windowTextGC(),
|
2003-05-15 11:17:29 +00:00
|
|
|
foc->title().c_str(), newlen,
|
2003-02-16 00:09:34 +00:00
|
|
|
dx, dy);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.window_label.clear();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::redrawWorkspaceLabel(bool redraw) {
|
2003-05-15 12:00:46 +00:00
|
|
|
if (screen().currentWorkspace()->name().size()==0)
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (redraw)
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.workspace_label.clear();
|
2002-10-29 16:09:37 +00:00
|
|
|
|
2003-05-15 12:00:46 +00:00
|
|
|
const char *text = screen().currentWorkspace()->name().c_str();
|
|
|
|
size_t textlen = screen().currentWorkspace()->name().size();
|
2003-02-23 19:13:22 +00:00
|
|
|
unsigned int newlen = textlen;
|
2002-12-02 21:54:30 +00:00
|
|
|
int dx = FbTk::doAlignment(frame.workspace_label_w, frame.bevel_w,
|
2003-04-23 00:17:51 +00:00
|
|
|
m_theme.justify(),
|
|
|
|
m_theme.font(),
|
|
|
|
text, textlen, newlen);
|
2002-12-04 17:58:01 +00:00
|
|
|
int dy = 1 + m_theme.font().ascent();
|
|
|
|
if (m_theme.font().isRotated()) {
|
|
|
|
int tmp = dy;
|
|
|
|
dy = frame.workspace_label_w - dx;
|
|
|
|
dx = tmp;
|
|
|
|
}
|
2002-12-02 21:54:30 +00:00
|
|
|
m_theme.font().drawText(
|
2003-04-23 00:17:51 +00:00
|
|
|
frame.workspace_label.window(),
|
2003-05-15 12:00:46 +00:00
|
|
|
screen().screenNumber(),
|
2003-04-23 00:17:51 +00:00
|
|
|
m_theme.labelTextGC(),
|
|
|
|
text, newlen,
|
|
|
|
dx, dy);
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::edit() {
|
2002-12-01 13:42:15 +00:00
|
|
|
Window window;
|
|
|
|
int foo;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
m_editing = true; //mark for editing
|
|
|
|
Display *display = FbTk::App::instance()->display();
|
2002-12-04 17:58:01 +00:00
|
|
|
//workspace label already has intput focus ?
|
2002-12-01 13:42:15 +00:00
|
|
|
if (XGetInputFocus(display, &window, &foo) &&
|
|
|
|
window == frame.workspace_label)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//set input focus to workspace label
|
2002-12-03 17:02:53 +00:00
|
|
|
XSetInputFocus(display, frame.workspace_label.window(),
|
2003-02-16 00:09:34 +00:00
|
|
|
((screen().isSloppyFocus() || screen().isSemiSloppyFocus()) ?
|
2002-12-01 13:42:15 +00:00
|
|
|
RevertToPointerRoot : RevertToParent), CurrentTime);
|
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.workspace_label.clear();
|
2002-12-01 13:42:15 +00:00
|
|
|
Fluxbox * const fluxbox = Fluxbox::instance();
|
|
|
|
if (fluxbox->getFocusedWindow()) //disable focus on current focused window
|
|
|
|
fluxbox->getFocusedWindow()->setFocusFlag(false);
|
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
frame.workspace_label.drawRectangle(screen().winFrameTheme().labelTextFocusGC(),
|
|
|
|
frame.workspace_label_w / 2, 0, 1,
|
|
|
|
frame.label_h - 1);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
void Toolbar::buttonPressEvent(XButtonEvent &be) {
|
2002-12-01 13:42:15 +00:00
|
|
|
FluxboxWindow *fluxboxwin=0;
|
2002-12-02 21:54:30 +00:00
|
|
|
if (be.button == 1) {
|
2002-12-13 20:37:55 +00:00
|
|
|
if ( m_iconbar.get() != 0 ) {
|
2002-12-02 21:54:30 +00:00
|
|
|
if ( (fluxboxwin = m_iconbar->findWindow(be.window)) )
|
2002-12-01 13:42:15 +00:00
|
|
|
fluxboxwin->deiconify();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
#ifndef HAVE_STRFTIME
|
2002-12-02 21:54:30 +00:00
|
|
|
else if (be.window == frame.clock) {
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.clock.clear();
|
2002-12-01 13:42:15 +00:00
|
|
|
checkClock(true, true);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_STRFTIME
|
2003-06-23 13:17:57 +00:00
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
} else if (be.button == 3) {
|
2002-12-01 13:42:15 +00:00
|
|
|
FluxboxWindow *fluxboxwin = 0;
|
|
|
|
// if we clicked on a icon then show window menu
|
2002-12-02 21:54:30 +00:00
|
|
|
if ( m_iconbar.get() != 0 && (fluxboxwin = m_iconbar->findWindow(be.window)) ) {
|
2003-05-15 11:17:29 +00:00
|
|
|
const FbTk::Menu &wm = fluxboxwin->menu();
|
2003-01-07 02:07:43 +00:00
|
|
|
|
|
|
|
int menu_y = be.y_root - wm.height();
|
|
|
|
int menu_x = be.x_root;
|
|
|
|
// make sure the menu is visible
|
|
|
|
if (menu_y < 0) {
|
|
|
|
menu_y = 0;
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-01-07 02:07:43 +00:00
|
|
|
if (menu_x < 0) {
|
|
|
|
menu_x = 0;
|
2003-05-15 12:00:46 +00:00
|
|
|
} else if (menu_x + wm.width() > screen().width()) {
|
|
|
|
menu_x = screen().width() - wm.width();
|
2003-01-07 02:07:43 +00:00
|
|
|
}
|
|
|
|
fluxboxwin->showMenu(menu_x, menu_y);
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
} else if (! m_toolbarmenu.isVisible()) {
|
|
|
|
int x, y;
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
x = be.x_root - (m_toolbarmenu.width() / 2);
|
|
|
|
y = be.y_root - (m_toolbarmenu.height() / 2);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
2003-05-15 12:00:46 +00:00
|
|
|
else if (x + m_toolbarmenu.width() > screen().width())
|
|
|
|
x = screen().width() - m_toolbarmenu.width();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
2003-05-15 12:00:46 +00:00
|
|
|
else if (y + m_toolbarmenu.height() > screen().height())
|
|
|
|
y = screen().height() - m_toolbarmenu.height();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
m_toolbarmenu.move(x, y);
|
|
|
|
m_toolbarmenu.show();
|
|
|
|
} else
|
|
|
|
m_toolbarmenu.hide();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
void Toolbar::buttonReleaseEvent(XButtonEvent &re) {
|
|
|
|
if (re.button == 1) {
|
2003-06-23 13:17:57 +00:00
|
|
|
raise();
|
2002-12-13 20:37:55 +00:00
|
|
|
if (re.window == frame.workspace_label) {
|
2003-02-16 00:09:34 +00:00
|
|
|
FbTk::Menu *menu = screen().getWorkspacemenu();
|
2002-12-01 13:42:15 +00:00
|
|
|
//move the workspace label and make it visible
|
2002-12-02 21:54:30 +00:00
|
|
|
menu->move(re.x_root, re.y_root);
|
2003-04-23 00:17:51 +00:00
|
|
|
// make sure the entire menu is visible
|
|
|
|
//!!TODO: this is repeated by other menus, make a function!)
|
2002-12-01 13:42:15 +00:00
|
|
|
int newx = menu->x(); // new x position of menu
|
|
|
|
int newy = menu->y(); // new y position of menu
|
|
|
|
if (menu->x() < 0)
|
|
|
|
newx = 0;
|
2003-05-15 12:00:46 +00:00
|
|
|
else if (menu->x() + menu->width() > screen().width())
|
|
|
|
newx = screen().width() - menu->width();
|
2002-11-16 22:17:06 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (menu->y() < 0)
|
|
|
|
newy = 0;
|
2003-05-15 12:00:46 +00:00
|
|
|
else if (menu->y() + menu->height() > screen().height())
|
|
|
|
newy = screen().height() - menu->height();
|
2002-12-01 13:42:15 +00:00
|
|
|
// move and show menu
|
|
|
|
menu->move(newx, newy);
|
|
|
|
menu->show();
|
2002-12-02 21:54:30 +00:00
|
|
|
} else if (re.window == frame.window_label)
|
2003-02-16 00:09:34 +00:00
|
|
|
screen().raiseFocus();
|
2001-12-11 20:47:02 +00:00
|
|
|
#ifndef HAVE_STRFTIME
|
2002-12-02 21:54:30 +00:00
|
|
|
else if (re.window == frame.clock) {
|
2003-03-23 04:18:59 +00:00
|
|
|
frame.clock.clear();
|
2002-12-01 13:42:15 +00:00
|
|
|
checkClock(true);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_STRFTIME
|
2002-12-02 21:54:30 +00:00
|
|
|
} else if (re.button == 4) //mousewheel scroll up
|
2003-02-16 00:09:34 +00:00
|
|
|
screen().nextWorkspace(1);
|
2002-12-02 21:54:30 +00:00
|
|
|
else if (re.button == 5) //mousewheel scroll down
|
2003-02-16 00:09:34 +00:00
|
|
|
screen().prevWorkspace(1);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
void Toolbar::enterNotifyEvent(XCrossingEvent ¬_used) {
|
2003-06-23 13:17:57 +00:00
|
|
|
if (! doAutoHide())
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
if (isHidden()) {
|
2003-05-10 13:57:07 +00:00
|
|
|
if (! m_hide_timer.isTiming())
|
|
|
|
m_hide_timer.start();
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-05-10 13:57:07 +00:00
|
|
|
if (m_hide_timer.isTiming())
|
|
|
|
m_hide_timer.stop();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
void Toolbar::leaveNotifyEvent(XCrossingEvent ¬_used) {
|
2003-06-23 13:17:57 +00:00
|
|
|
if (! doAutoHide())
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
if (isHidden()) {
|
2003-05-10 13:57:07 +00:00
|
|
|
if (m_hide_timer.isTiming())
|
|
|
|
m_hide_timer.stop();
|
|
|
|
} else if (! m_toolbarmenu.isVisible() && ! m_hide_timer.isTiming())
|
|
|
|
m_hide_timer.start();
|
2002-11-27 12:20:23 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
void Toolbar::exposeEvent(XExposeEvent &ee) {
|
|
|
|
if (ee.window == frame.clock)
|
2002-12-01 13:42:15 +00:00
|
|
|
checkClock(true);
|
2003-06-23 13:17:57 +00:00
|
|
|
else if (ee.window == frame.workspace_label && (! isEditing()))
|
2002-12-01 13:42:15 +00:00
|
|
|
redrawWorkspaceLabel();
|
|
|
|
else if (m_iconbar.get() != 0)
|
2002-12-02 21:54:30 +00:00
|
|
|
m_iconbar->exposeEvent(&ee);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
void Toolbar::keyPressEvent(XKeyEvent &ke) {
|
2003-06-23 13:17:57 +00:00
|
|
|
if (ke.window != frame.workspace_label.window() || !isEditing())
|
2003-04-23 00:17:51 +00:00
|
|
|
return;
|
2002-04-09 23:16:28 +00:00
|
|
|
|
2003-04-23 00:17:51 +00:00
|
|
|
KeySym ks;
|
|
|
|
char keychar[1];
|
|
|
|
XLookupString(&ke, keychar, 1, &ks, 0);
|
|
|
|
|
|
|
|
if (ks == XK_Return || ks == XK_Escape) {
|
2003-06-23 13:17:57 +00:00
|
|
|
m_editing = false;
|
2003-04-23 00:17:51 +00:00
|
|
|
Fluxbox * const fluxbox = Fluxbox::instance();
|
2003-04-25 16:08:45 +00:00
|
|
|
|
2003-04-23 00:17:51 +00:00
|
|
|
if (fluxbox->getFocusedWindow()) {
|
|
|
|
fluxbox->getFocusedWindow()->setInputFocus();
|
|
|
|
fluxbox->getFocusedWindow()->setFocusFlag(true);
|
|
|
|
} else
|
2003-06-23 13:17:57 +00:00
|
|
|
XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime);
|
2002-01-21 00:53:02 +00:00
|
|
|
|
2003-04-23 00:17:51 +00:00
|
|
|
if (ks == XK_Return) //change workspace name if keypress = Return
|
2003-06-23 13:17:57 +00:00
|
|
|
screen().currentWorkspace()->setName(m_new_workspace_name.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
m_new_workspace_name.erase(); //erase temporary workspace name
|
2003-04-23 00:17:51 +00:00
|
|
|
reconfigure();
|
|
|
|
//save workspace names
|
|
|
|
Fluxbox::instance()->save_rc();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-04-23 00:17:51 +00:00
|
|
|
} else if (! IsModifierKey(ks) && !IsCursorKey(ks)) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
if (ks == XK_BackSpace && m_new_workspace_name.size())
|
|
|
|
m_new_workspace_name.erase(m_new_workspace_name.size() - 1);
|
2003-04-23 00:17:51 +00:00
|
|
|
else
|
2003-06-23 13:17:57 +00:00
|
|
|
m_new_workspace_name += keychar[0];
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
2003-04-23 00:17:51 +00:00
|
|
|
frame.workspace_label.clear();
|
2003-06-23 13:17:57 +00:00
|
|
|
int l = m_new_workspace_name.size(), tw, x;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
tw = m_theme.font().textWidth(m_new_workspace_name.c_str(), l);
|
2003-04-23 00:17:51 +00:00
|
|
|
x = (frame.workspace_label_w - tw) / 2;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-04-23 00:17:51 +00:00
|
|
|
if (x < (signed) frame.bevel_w)
|
|
|
|
x = frame.bevel_w;
|
|
|
|
int dy = 1 + m_theme.font().ascent();
|
|
|
|
if (m_theme.font().isRotated()) {
|
|
|
|
int tmp = dy;
|
|
|
|
dy = frame.workspace_label_w - x;
|
|
|
|
x = tmp;
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-04-25 11:19:45 +00:00
|
|
|
m_theme.font().drawText(frame.workspace_label.window(),
|
2003-05-15 12:00:46 +00:00
|
|
|
screen().screenNumber(),
|
2003-04-25 11:19:45 +00:00
|
|
|
screen().winFrameTheme().labelTextFocusGC(),
|
2003-06-23 13:17:57 +00:00
|
|
|
m_new_workspace_name.c_str(), l,
|
2003-04-23 00:17:51 +00:00
|
|
|
x, dy);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
frame.workspace_label.drawRectangle(screen().winFrameTheme().labelTextFocusGC(),
|
|
|
|
x + tw, 0, 1,
|
|
|
|
frame.label_h - 1);
|
2003-04-23 00:17:51 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::timeout() {
|
2002-12-01 13:42:15 +00:00
|
|
|
checkClock(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
timeval delay;
|
|
|
|
delay.tv_sec = 1;
|
|
|
|
delay.tv_usec = 0;
|
2003-05-10 13:57:07 +00:00
|
|
|
m_clock_timer.setTimeout(delay);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
void Toolbar::setPlacement(Toolbar::Placement where) {
|
2003-06-23 13:17:57 +00:00
|
|
|
*m_rc_placement = where;
|
2002-12-02 21:54:30 +00:00
|
|
|
int head_x = 0,
|
|
|
|
head_y = 0,
|
|
|
|
head_w,
|
|
|
|
head_h;
|
|
|
|
|
2003-05-19 14:26:30 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
if (screen().hasXinerama()) {
|
2003-06-23 13:17:57 +00:00
|
|
|
int head = *m_rc_on_head;
|
2003-05-19 14:26:30 +00:00
|
|
|
head_x = screen().getHeadX(head);
|
|
|
|
head_y = screen().getHeadY(head);
|
|
|
|
head_w = screen().getHeadWidth(head);
|
|
|
|
head_h = screen().getHeadHeight(head);
|
|
|
|
} else
|
|
|
|
#endif // XINERAMA
|
|
|
|
{
|
|
|
|
head_w = screen().width();
|
|
|
|
head_h = screen().height();
|
|
|
|
}
|
2002-12-02 21:54:30 +00:00
|
|
|
|
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
frame.width = head_w * (*m_rc_width_percent) / 100;
|
2002-12-02 21:54:30 +00:00
|
|
|
frame.height = m_theme.font().height();
|
|
|
|
|
|
|
|
frame.height += 2;
|
|
|
|
frame.height += (frame.bevel_w * 2);
|
|
|
|
|
2003-06-24 18:33:29 +00:00
|
|
|
int bevel_width = theme().bevelWidth();
|
|
|
|
int border_width = theme().borderWidth();
|
2002-12-02 21:54:30 +00:00
|
|
|
|
2002-12-03 17:02:53 +00:00
|
|
|
// should we flipp sizes?
|
|
|
|
if (isVertical()) {
|
|
|
|
frame.width = frame.height;
|
2003-06-23 13:17:57 +00:00
|
|
|
frame.height = head_h * (*m_rc_width_percent) / 100;
|
2002-12-03 17:02:53 +00:00
|
|
|
if (!m_theme.font().isRotated())
|
|
|
|
m_theme.font().rotate(90); // rotate to vertical text
|
|
|
|
|
|
|
|
frame.label_h = frame.width;
|
|
|
|
frame.button_w = frame.width;
|
|
|
|
} else { // horizontal toolbar
|
|
|
|
if (m_theme.font().isRotated())
|
|
|
|
m_theme.font().rotate(0); // rotate to horizontal text
|
|
|
|
frame.label_h = frame.height;
|
|
|
|
frame.button_w = frame.height;
|
|
|
|
}
|
|
|
|
|
2003-06-25 12:33:28 +00:00
|
|
|
// So we get at least one pixel visible in hidden mode
|
|
|
|
if (bevel_width <= border_width)
|
|
|
|
bevel_width = border_width + 1;
|
|
|
|
|
2002-12-02 21:54:30 +00:00
|
|
|
switch (where) {
|
|
|
|
case TOPLEFT:
|
|
|
|
frame.x = head_x;
|
|
|
|
frame.y = head_y;
|
|
|
|
frame.x_hidden = head_x;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.y_hidden = head_y + bevel_width - border_width - frame.height;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::BOTTOMRIGHT | Shape::BOTTOMLEFT);
|
2002-12-02 21:54:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BOTTOMLEFT:
|
|
|
|
frame.x = head_x;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
2002-12-02 21:54:30 +00:00
|
|
|
frame.x_hidden = head_x;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.y_hidden = head_y + head_h - bevel_width - border_width;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPRIGHT | Shape::TOPLEFT);
|
2002-12-02 21:54:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TOPCENTER:
|
2003-06-25 12:33:28 +00:00
|
|
|
frame.x = head_x + (head_w - frame.width) / 2;
|
2002-12-02 21:54:30 +00:00
|
|
|
frame.y = head_y;
|
|
|
|
frame.x_hidden = frame.x;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.y_hidden = head_y + bevel_width - border_width - frame.height;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::BOTTOMRIGHT | Shape::BOTTOMLEFT);
|
2002-12-02 21:54:30 +00:00
|
|
|
break;
|
|
|
|
case TOPRIGHT:
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
2002-12-02 21:54:30 +00:00
|
|
|
frame.y = head_y;
|
|
|
|
frame.x_hidden = frame.x;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::BOTTOMRIGHT | Shape::BOTTOMLEFT);
|
2002-12-02 21:54:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BOTTOMRIGHT:
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
2002-12-02 21:54:30 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.y_hidden = head_y + head_h - bevel_width - border_width;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPRIGHT | Shape::TOPLEFT);
|
2002-12-02 21:54:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BOTTOMCENTER: // default is BOTTOMCENTER
|
|
|
|
default:
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.x = head_x + (head_w - frame.width) / 2;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
2002-12-02 21:54:30 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.y_hidden = head_y + head_h - bevel_width - border_width;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPRIGHT | Shape::TOPLEFT);
|
2002-12-02 21:54:30 +00:00
|
|
|
break;
|
2002-12-03 17:02:53 +00:00
|
|
|
case LEFTCENTER:
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.x = head_x;
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.y = head_y + (head_h - frame.height)/2;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x_hidden = frame.x - frame.width + bevel_width + border_width;
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.y_hidden = frame.y;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPRIGHT | Shape::BOTTOMRIGHT);
|
2002-12-04 17:58:01 +00:00
|
|
|
break;
|
|
|
|
case LEFTTOP:
|
|
|
|
frame.x = head_x;
|
|
|
|
frame.y = head_y;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x_hidden = frame.x - frame.width + bevel_width + border_width;
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.y_hidden = frame.y;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPRIGHT | Shape::BOTTOMRIGHT);
|
2002-12-04 17:58:01 +00:00
|
|
|
break;
|
|
|
|
case LEFTBOTTOM:
|
|
|
|
frame.x = head_x;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
|
|
|
frame.x_hidden = frame.x - frame.width + bevel_width + border_width;
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.y_hidden = frame.y;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPRIGHT | Shape::BOTTOMRIGHT);
|
2002-12-04 17:58:01 +00:00
|
|
|
break;
|
|
|
|
case RIGHTCENTER:
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.y = head_y + (head_h - frame.height)/2;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x_hidden = frame.x + frame.width - bevel_width - border_width;
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.y_hidden = frame.y;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPLEFT | Shape::BOTTOMLEFT);
|
2002-12-04 17:58:01 +00:00
|
|
|
break;
|
|
|
|
case RIGHTTOP:
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.y = head_y;
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x_hidden = frame.x + frame.width - bevel_width - border_width;
|
2002-12-04 17:58:01 +00:00
|
|
|
frame.y_hidden = frame.y;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPLEFT | Shape::BOTTOMLEFT);
|
2002-12-04 17:58:01 +00:00
|
|
|
break;
|
|
|
|
case RIGHTBOTTOM:
|
2003-06-24 18:33:29 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
|
|
|
frame.x_hidden = frame.x + frame.width - bevel_width - border_width;
|
2002-12-03 17:02:53 +00:00
|
|
|
frame.y_hidden = frame.y;
|
2003-07-10 11:48:14 +00:00
|
|
|
if (m_shape.get())
|
|
|
|
m_shape->setPlaces(Shape::TOPLEFT | Shape::BOTTOMLEFT);
|
2002-12-03 17:02:53 +00:00
|
|
|
break;
|
2002-12-02 21:54:30 +00:00
|
|
|
}
|
|
|
|
}
|
2002-12-03 17:02:53 +00:00
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::HideHandler::timeout() {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (toolbar->isEditing()) { // don't hide if we're editing workspace label
|
2003-05-10 13:57:07 +00:00
|
|
|
toolbar->m_hide_timer.fireOnce(false);
|
|
|
|
toolbar->m_hide_timer.start(); // restart timer and try next timeout
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-02-22 23:07:23 +00:00
|
|
|
|
2003-05-10 13:57:07 +00:00
|
|
|
toolbar->m_hide_timer.fireOnce(true);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-23 13:17:57 +00:00
|
|
|
// toggle hidden
|
|
|
|
toolbar->m_hidden = ! toolbar->m_hidden;
|
|
|
|
if (toolbar->isHidden()) {
|
2002-12-03 17:02:53 +00:00
|
|
|
toolbar->frame.window.move(toolbar->frame.x_hidden, toolbar->frame.y_hidden);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2002-12-03 17:02:53 +00:00
|
|
|
toolbar->frame.window.move(toolbar->frame.x, toolbar->frame.y);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2003-04-16 13:43:50 +00:00
|
|
|
|
|
|
|
void Toolbar::moveToLayer(int layernum) {
|
|
|
|
m_layeritem.moveToLayer(layernum);
|
2003-06-23 13:17:57 +00:00
|
|
|
*m_rc_layernum = layernum;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::setupMenus() {
|
|
|
|
Toolbar &tbar = *this;
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
using namespace FBNLS;
|
|
|
|
using namespace FbTk;
|
|
|
|
|
|
|
|
FbTk::Menu &menu = tbar.menu();
|
|
|
|
|
|
|
|
RefCount<Command> start_edit(new SimpleCommand<Toolbar>(tbar, &Toolbar::edit));
|
|
|
|
menu.insert(i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarEditWkspcName,
|
|
|
|
"Edit current workspace name"),
|
|
|
|
start_edit);
|
|
|
|
|
|
|
|
menu.setLabel(i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarToolbarTitle,
|
|
|
|
"Toolbar"));
|
|
|
|
|
|
|
|
FbTk::MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent",
|
|
|
|
m_rc_width_percent,
|
|
|
|
0, 100); // min/max value
|
|
|
|
|
|
|
|
|
|
|
|
FbTk::RefCount<FbTk::Command> reconfig_toolbar(new FbTk::
|
|
|
|
SimpleCommand<Toolbar>
|
|
|
|
(tbar, &Toolbar::reconfigure));
|
|
|
|
FbTk::RefCount<FbTk::Command> save_resources(new FbCommands::SaveResources());
|
|
|
|
FbTk::MacroCommand *toolbar_menuitem_macro = new FbTk::MacroCommand();
|
|
|
|
toolbar_menuitem_macro->add(reconfig_toolbar);
|
|
|
|
toolbar_menuitem_macro->add(save_resources);
|
|
|
|
|
|
|
|
FbTk::RefCount<FbTk::Command> reconfig_toolbar_and_save_resource(toolbar_menuitem_macro);
|
|
|
|
toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource);
|
|
|
|
|
|
|
|
menu.insert(toolbar_menuitem);
|
|
|
|
|
|
|
|
menu.insert(new BoolMenuItem(i18n->getMessage(FBNLS::CommonSet, FBNLS::CommonAutoHide,
|
|
|
|
"Auto hide"),
|
|
|
|
*m_rc_auto_hide,
|
|
|
|
reconfig_toolbar_and_save_resource));
|
2003-07-10 15:52:58 +00:00
|
|
|
menu.insert(new BoolMenuItem("Maximize Over", *m_rc_maximize_over,
|
|
|
|
reconfig_toolbar_and_save_resource));
|
2003-06-23 13:17:57 +00:00
|
|
|
menu.insert("Layer...", &tbar.layermenu());
|
|
|
|
|
|
|
|
if (tbar.screen().hasXinerama()) {
|
|
|
|
menu.insert("On Head...", new XineramaHeadMenu<Toolbar>(
|
|
|
|
*tbar.screen().menuTheme(),
|
|
|
|
tbar.screen(),
|
|
|
|
tbar.screen().imageControl(),
|
|
|
|
*tbar.screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
|
|
|
|
&tbar
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup items in placement menu
|
|
|
|
struct {
|
|
|
|
int set;
|
|
|
|
int base;
|
|
|
|
const char *default_str;
|
|
|
|
Toolbar::Placement placement;
|
|
|
|
} place_menu[] = {
|
|
|
|
{0, 0, "Top Left", Toolbar::TOPLEFT},
|
|
|
|
{0, 0, "Left Top", Toolbar::LEFTTOP},
|
|
|
|
{0, 0, "Left Center", Toolbar::LEFTCENTER},
|
|
|
|
{0, 0, "Left Bottom", Toolbar::LEFTBOTTOM},
|
|
|
|
{0, 0, "Bottom Left", Toolbar::BOTTOMLEFT},
|
|
|
|
{0, 0, "Top Center", Toolbar::TOPCENTER},
|
|
|
|
{0, 0, 0, Toolbar::TOPCENTER},
|
|
|
|
{0, 0, 0, Toolbar::BOTTOMCENTER},
|
|
|
|
{0, 0, 0, Toolbar::BOTTOMCENTER},
|
|
|
|
{0, 0, "Bottom Center", Toolbar::BOTTOMCENTER},
|
|
|
|
{0, 0, "Top Right", Toolbar::TOPRIGHT},
|
|
|
|
{0, 0, "Right Top", Toolbar::RIGHTTOP},
|
|
|
|
{0, 0, "Right Center", Toolbar::RIGHTCENTER},
|
|
|
|
{0, 0, "Right Bottom", Toolbar::RIGHTBOTTOM},
|
|
|
|
{0, 0, "Bottom Right", Toolbar::BOTTOMRIGHT}
|
|
|
|
};
|
|
|
|
tbar.placementMenu().setMinimumSublevels(3);
|
|
|
|
// create items in sub menu
|
|
|
|
for (size_t i=0; i<15; ++i) {
|
|
|
|
if (place_menu[i].default_str == 0) {
|
|
|
|
tbar.placementMenu().insert("");
|
|
|
|
} else {
|
|
|
|
const char *i18n_str = i18n->getMessage(place_menu[i].set,
|
|
|
|
place_menu[i].base,
|
|
|
|
place_menu[i].default_str);
|
|
|
|
RefCount<FbTk::Command> setplace(new SetToolbarPlacementCmd(tbar, place_menu[i].placement));
|
|
|
|
tbar.placementMenu().insert(i18n_str, setplace);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menu.insert("Placement", &tbar.placementMenu());
|
|
|
|
tbar.placementMenu().update();
|
|
|
|
menu.update();
|
2003-04-16 13:43:50 +00:00
|
|
|
}
|