From 2f8e99f9dfcb3212842e7c2b55203d36550a999c Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 17 Feb 2003 12:35:59 +0000 Subject: added shade button option, fixed antialias for menus, added toolbar width percent menu item --- src/Screen.cc | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 13 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 85b2e12..178b2a4 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.109 2003/02/16 17:57:54 rathnor Exp $ +// $Id: Screen.cc,v 1.110 2003/02/17 12:35:59 fluxgen Exp $ #include "Screen.hh" @@ -41,7 +41,7 @@ #include "MenuTheme.hh" #include "FbCommands.hh" #include "BoolMenuItem.hh" -//#include "IntResMenuItem.hh" +#include "IntResMenuItem.hh" #include "MacroCommand.hh" #include "XLayerItem.hh" #include "MultLayers.hh" @@ -279,6 +279,14 @@ private: BScreen &m_screen; }; +class ReloadStyleCmd: public FbTk::Command { +public: + void execute() { + FbCommands::SetStyleCmd cmd(Fluxbox::instance()->getStyleFilename()); + cmd.execute(); + } +}; + void setupWorkspacemenu(BScreen &scr, FbTk::Menu &menu) { menu.removeAll(); // clear all items using namespace FbTk; @@ -426,11 +434,16 @@ BScreen::BScreen(ResourceManager &rm, image_control->setDither(*resource.image_dither); theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(), - fluxbox->getStyleFilename(), getRootCommand().c_str()); + fluxbox->getStyleFilename().c_str(), getRootCommand().c_str()); theme->reconfigure(*resource.antialias); + // setup windowtheme, toolbartheme for antialias + m_windowtheme.font().setAntialias(*resource.antialias); + m_menutheme->titleFont().setAntialias(*resource.antialias); + m_menutheme->frameFont().setAntialias(*resource.antialias); + // set database for new Theme Engine - FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename()); + FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename().c_str()); // special case for tab rotated if (*resource.tab_rotate_vertical && @@ -482,7 +495,7 @@ BScreen::BScreen(ResourceManager &rm, } else { geom_pixmap = image_control->renderImage(geom_w, geom_h, m_windowtheme.labelFocusTexture()); - geom_window.setBackgroundPixmap(geom_pixmap); + geom_window.setBackgroundPixmap(geom_pixmap); } } @@ -493,12 +506,10 @@ BScreen::BScreen(ResourceManager &rm, for (int i = 0; i < *resource.workspaces; ++i) { wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); workspacesList.push_back(wkspc); - // workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); } - } else { + } else { // create at least one workspace wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); workspacesList.push_back(wkspc); - // workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); } current_workspace = workspacesList.front(); @@ -508,7 +519,25 @@ BScreen::BScreen(ResourceManager &rm, #endif // SLIT m_toolbar.reset(new Toolbar(*this)); - + // setup toolbar width menu item + FbTk::MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent", + resource.toolbar_width_percent, + 0, 100); // min/max value + FbTk::RefCount reconfig_toolbar(new FbTk:: + SimpleCommand + (*(m_toolbar.get()), &Toolbar::reconfigure)); + FbTk::RefCount save_resources(new FbTk:: + SimpleCommand + (*Fluxbox::instance(), &Fluxbox::save_rc)); + FbTk::MacroCommand *toolbar_menuitem_macro = new FbTk::MacroCommand(); + toolbar_menuitem_macro->add(reconfig_toolbar); + toolbar_menuitem_macro->add(save_resources); + + FbTk::RefCount reconfig_toolbar_and_save_resource(toolbar_menuitem_macro); + + toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource); + m_toolbar->menu().insert(toolbar_menuitem); + setupWorkspacemenu(*this, *workspacemenu); m_configmenu.reset(createMenuFromScreen(*this)); @@ -661,7 +690,16 @@ void BScreen::reconfigure() { theme->setRootCommand(getRootCommand()); const string &filename = Fluxbox::instance()->getStyleFilename(); theme->load(filename.c_str()); // old theme engine + // setup windowtheme, toolbartheme for antialias + m_windowtheme.font().setAntialias(*resource.antialias); + m_menutheme->titleFont().setAntialias(*resource.antialias); + m_menutheme->frameFont().setAntialias(*resource.antialias); + FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine + + if (m_toolbar.get()) + m_toolbar->theme().font().setAntialias(*resource.antialias); + theme->reconfigure(*resource.antialias); I18n *i18n = I18n::instance(); @@ -1183,6 +1221,14 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { #ifdef DEBUG cerr<<__FILE__<<": Creating stick button"<setOnClick(shade_cmd); +#ifdef DEBUG + cerr<<__FILE__<<": Creating shade button"< + hide_menu(new FbTk::SimpleCommand(menu, &FbTk::Menu::hide)); while (! file.eof()) { @@ -1568,7 +1617,11 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { cerr<<"Row: "< exec_cmd(new FbCommands::ExecuteCmd(str_cmd)); - menu.insert(str_label.c_str(), exec_cmd); + FbTk::MacroCommand *exec_and_hide = new FbTk::MacroCommand(); + exec_and_hide->add(hide_menu); + exec_and_hide->add(exec_cmd); + FbTk::RefCount exec_and_hide_cmd(exec_and_hide); + menu.insert(str_label.c_str(), exec_and_hide_cmd); } } else if (str_key == "exit") { // exit if (!str_label.size()) { @@ -1711,7 +1764,8 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { "no menu label defined\n")); cerr<<"Row: "< reconfig_fb_cmd(new FbCommands::ReconfigureFluxboxCmd()); + FbTk::RefCount + reconfig_fb_cmd(new FbCommands::ReconfigureFluxboxCmd()); menu.insert(str_label.c_str(), reconfig_fb_cmd); } } else if (str_key == "stylesdir" || str_key == "stylesmenu") { @@ -1811,7 +1865,11 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { ConfigmenuSet, ConfigmenuDesktopWheeling, "Desktop MouseWheel Switching"), *resource.desktop_wheeling, save_and_reconfigure)); - menu.insert(new BoolMenuItem("antialias", *resource.antialias, save_and_reconfigure)); + + // setup antialias cmd to reload style and save resource on toggle + menu.insert(new BoolMenuItem("antialias", *resource.antialias, + save_and_reconfigure)); + // finaly update menu menu.update(); } -- cgit v0.11.2