diff options
author | fluxgen <fluxgen> | 2003-02-17 12:35:59 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-02-17 12:35:59 (GMT) |
commit | 2f8e99f9dfcb3212842e7c2b55203d36550a999c (patch) | |
tree | e916581c23cef4b563d047bc787e4371e63fe07f | |
parent | 24adaad3d5309597cb9ba27ec6197a4a2e194d39 (diff) | |
download | fluxbox_paul-2f8e99f9dfcb3212842e7c2b55203d36550a999c.zip fluxbox_paul-2f8e99f9dfcb3212842e7c2b55203d36550a999c.tar.bz2 |
added shade button option, fixed antialias for menus, added toolbar width percent menu item
-rw-r--r-- | src/Screen.cc | 84 |
1 files 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 @@ | |||
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: Screen.cc,v 1.109 2003/02/16 17:57:54 rathnor Exp $ | 25 | // $Id: Screen.cc,v 1.110 2003/02/17 12:35:59 fluxgen Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -41,7 +41,7 @@ | |||
41 | #include "MenuTheme.hh" | 41 | #include "MenuTheme.hh" |
42 | #include "FbCommands.hh" | 42 | #include "FbCommands.hh" |
43 | #include "BoolMenuItem.hh" | 43 | #include "BoolMenuItem.hh" |
44 | //#include "IntResMenuItem.hh" | 44 | #include "IntResMenuItem.hh" |
45 | #include "MacroCommand.hh" | 45 | #include "MacroCommand.hh" |
46 | #include "XLayerItem.hh" | 46 | #include "XLayerItem.hh" |
47 | #include "MultLayers.hh" | 47 | #include "MultLayers.hh" |
@@ -279,6 +279,14 @@ private: | |||
279 | BScreen &m_screen; | 279 | BScreen &m_screen; |
280 | }; | 280 | }; |
281 | 281 | ||
282 | class ReloadStyleCmd: public FbTk::Command { | ||
283 | public: | ||
284 | void execute() { | ||
285 | FbCommands::SetStyleCmd cmd(Fluxbox::instance()->getStyleFilename()); | ||
286 | cmd.execute(); | ||
287 | } | ||
288 | }; | ||
289 | |||
282 | void setupWorkspacemenu(BScreen &scr, FbTk::Menu &menu) { | 290 | void setupWorkspacemenu(BScreen &scr, FbTk::Menu &menu) { |
283 | menu.removeAll(); // clear all items | 291 | menu.removeAll(); // clear all items |
284 | using namespace FbTk; | 292 | using namespace FbTk; |
@@ -426,11 +434,16 @@ BScreen::BScreen(ResourceManager &rm, | |||
426 | 434 | ||
427 | image_control->setDither(*resource.image_dither); | 435 | image_control->setDither(*resource.image_dither); |
428 | theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(), | 436 | theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(), |
429 | fluxbox->getStyleFilename(), getRootCommand().c_str()); | 437 | fluxbox->getStyleFilename().c_str(), getRootCommand().c_str()); |
430 | 438 | ||
431 | theme->reconfigure(*resource.antialias); | 439 | theme->reconfigure(*resource.antialias); |
440 | // setup windowtheme, toolbartheme for antialias | ||
441 | m_windowtheme.font().setAntialias(*resource.antialias); | ||
442 | m_menutheme->titleFont().setAntialias(*resource.antialias); | ||
443 | m_menutheme->frameFont().setAntialias(*resource.antialias); | ||
444 | |||
432 | // set database for new Theme Engine | 445 | // set database for new Theme Engine |
433 | FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename()); | 446 | FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename().c_str()); |
434 | 447 | ||
435 | // special case for tab rotated | 448 | // special case for tab rotated |
436 | if (*resource.tab_rotate_vertical && | 449 | if (*resource.tab_rotate_vertical && |
@@ -482,7 +495,7 @@ BScreen::BScreen(ResourceManager &rm, | |||
482 | } else { | 495 | } else { |
483 | geom_pixmap = image_control->renderImage(geom_w, geom_h, | 496 | geom_pixmap = image_control->renderImage(geom_w, geom_h, |
484 | m_windowtheme.labelFocusTexture()); | 497 | m_windowtheme.labelFocusTexture()); |
485 | geom_window.setBackgroundPixmap(geom_pixmap); | 498 | geom_window.setBackgroundPixmap(geom_pixmap); |
486 | } | 499 | } |
487 | } | 500 | } |
488 | 501 | ||
@@ -493,12 +506,10 @@ BScreen::BScreen(ResourceManager &rm, | |||
493 | for (int i = 0; i < *resource.workspaces; ++i) { | 506 | for (int i = 0; i < *resource.workspaces; ++i) { |
494 | wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); | 507 | wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); |
495 | workspacesList.push_back(wkspc); | 508 | workspacesList.push_back(wkspc); |
496 | // workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); | ||
497 | } | 509 | } |
498 | } else { | 510 | } else { // create at least one workspace |
499 | wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); | 511 | wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); |
500 | workspacesList.push_back(wkspc); | 512 | workspacesList.push_back(wkspc); |
501 | // workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); | ||
502 | } | 513 | } |
503 | 514 | ||
504 | current_workspace = workspacesList.front(); | 515 | current_workspace = workspacesList.front(); |
@@ -508,7 +519,25 @@ BScreen::BScreen(ResourceManager &rm, | |||
508 | #endif // SLIT | 519 | #endif // SLIT |
509 | 520 | ||
510 | m_toolbar.reset(new Toolbar(*this)); | 521 | m_toolbar.reset(new Toolbar(*this)); |
511 | 522 | // setup toolbar width menu item | |
523 | FbTk::MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent", | ||
524 | resource.toolbar_width_percent, | ||
525 | 0, 100); // min/max value | ||
526 | FbTk::RefCount<FbTk::Command> reconfig_toolbar(new FbTk:: | ||
527 | SimpleCommand<Toolbar> | ||
528 | (*(m_toolbar.get()), &Toolbar::reconfigure)); | ||
529 | FbTk::RefCount<FbTk::Command> save_resources(new FbTk:: | ||
530 | SimpleCommand<Fluxbox> | ||
531 | (*Fluxbox::instance(), &Fluxbox::save_rc)); | ||
532 | FbTk::MacroCommand *toolbar_menuitem_macro = new FbTk::MacroCommand(); | ||
533 | toolbar_menuitem_macro->add(reconfig_toolbar); | ||
534 | toolbar_menuitem_macro->add(save_resources); | ||
535 | |||
536 | FbTk::RefCount<FbTk::Command> reconfig_toolbar_and_save_resource(toolbar_menuitem_macro); | ||
537 | |||
538 | toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource); | ||
539 | m_toolbar->menu().insert(toolbar_menuitem); | ||
540 | |||
512 | setupWorkspacemenu(*this, *workspacemenu); | 541 | setupWorkspacemenu(*this, *workspacemenu); |
513 | 542 | ||
514 | m_configmenu.reset(createMenuFromScreen(*this)); | 543 | m_configmenu.reset(createMenuFromScreen(*this)); |
@@ -661,7 +690,16 @@ void BScreen::reconfigure() { | |||
661 | theme->setRootCommand(getRootCommand()); | 690 | theme->setRootCommand(getRootCommand()); |
662 | const string &filename = Fluxbox::instance()->getStyleFilename(); | 691 | const string &filename = Fluxbox::instance()->getStyleFilename(); |
663 | theme->load(filename.c_str()); // old theme engine | 692 | theme->load(filename.c_str()); // old theme engine |
693 | // setup windowtheme, toolbartheme for antialias | ||
694 | m_windowtheme.font().setAntialias(*resource.antialias); | ||
695 | m_menutheme->titleFont().setAntialias(*resource.antialias); | ||
696 | m_menutheme->frameFont().setAntialias(*resource.antialias); | ||
697 | |||
664 | FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine | 698 | FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine |
699 | |||
700 | if (m_toolbar.get()) | ||
701 | m_toolbar->theme().font().setAntialias(*resource.antialias); | ||
702 | |||
665 | theme->reconfigure(*resource.antialias); | 703 | theme->reconfigure(*resource.antialias); |
666 | 704 | ||
667 | I18n *i18n = I18n::instance(); | 705 | I18n *i18n = I18n::instance(); |
@@ -1183,6 +1221,14 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { | |||
1183 | #ifdef DEBUG | 1221 | #ifdef DEBUG |
1184 | cerr<<__FILE__<<": Creating stick button"<<endl; | 1222 | cerr<<__FILE__<<": Creating stick button"<<endl; |
1185 | #endif // DEBUG | 1223 | #endif // DEBUG |
1224 | } else if ((*dir)[i] == Fluxbox::SHADE) { | ||
1225 | newbutton = new WinButton(WinButton::SHADE, | ||
1226 | frame.titlebar(), | ||
1227 | 0, 0, 10, 10); | ||
1228 | newbutton->setOnClick(shade_cmd); | ||
1229 | #ifdef DEBUG | ||
1230 | cerr<<__FILE__<<": Creating shade button"<<endl; | ||
1231 | #endif // DEBUG | ||
1186 | } | 1232 | } |
1187 | 1233 | ||
1188 | if (newbutton != 0) { | 1234 | if (newbutton != 0) { |
@@ -1207,8 +1253,9 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { | |||
1207 | menu.removeAll(); // clear old items | 1253 | menu.removeAll(); // clear old items |
1208 | menu.disableTitle(); // not titlebar | 1254 | menu.disableTitle(); // not titlebar |
1209 | 1255 | ||
1210 | // check and setup layer menu | 1256 | // check and setup layer menu as a submenu windowmenu |
1211 | FbTk::Menu &layer_menu = win.getLayermenu(); | 1257 | FbTk::Menu &layer_menu = win.getLayermenu(); |
1258 | layer_menu.disableTitle(); // no titlebar | ||
1212 | // if it hasn't already been setup (no need to reset it) | 1259 | // if it hasn't already been setup (no need to reset it) |
1213 | if (layer_menu.numberOfItems() == 0) { | 1260 | if (layer_menu.numberOfItems() == 0) { |
1214 | Fluxbox *fluxbox = Fluxbox::instance(); | 1261 | Fluxbox *fluxbox = Fluxbox::instance(); |
@@ -1528,6 +1575,8 @@ void BScreen::initMenu() { | |||
1528 | bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { | 1575 | bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { |
1529 | 1576 | ||
1530 | string line; | 1577 | string line; |
1578 | FbTk::RefCount<FbTk::Command> | ||
1579 | hide_menu(new FbTk::SimpleCommand<FbTk::Menu>(menu, &FbTk::Menu::hide)); | ||
1531 | 1580 | ||
1532 | while (! file.eof()) { | 1581 | while (! file.eof()) { |
1533 | 1582 | ||
@@ -1568,7 +1617,11 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { | |||
1568 | cerr<<"Row: "<<row<<endl; | 1617 | cerr<<"Row: "<<row<<endl; |
1569 | } else { | 1618 | } else { |
1570 | FbTk::RefCount<FbTk::Command> exec_cmd(new FbCommands::ExecuteCmd(str_cmd)); | 1619 | FbTk::RefCount<FbTk::Command> exec_cmd(new FbCommands::ExecuteCmd(str_cmd)); |
1571 | menu.insert(str_label.c_str(), exec_cmd); | 1620 | FbTk::MacroCommand *exec_and_hide = new FbTk::MacroCommand(); |
1621 | exec_and_hide->add(hide_menu); | ||
1622 | exec_and_hide->add(exec_cmd); | ||
1623 | FbTk::RefCount<FbTk::Command> exec_and_hide_cmd(exec_and_hide); | ||
1624 | menu.insert(str_label.c_str(), exec_and_hide_cmd); | ||
1572 | } | 1625 | } |
1573 | } else if (str_key == "exit") { // exit | 1626 | } else if (str_key == "exit") { // exit |
1574 | if (!str_label.size()) { | 1627 | if (!str_label.size()) { |
@@ -1711,7 +1764,8 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { | |||
1711 | "no menu label defined\n")); | 1764 | "no menu label defined\n")); |
1712 | cerr<<"Row: "<<row<<endl; | 1765 | cerr<<"Row: "<<row<<endl; |
1713 | } else { | 1766 | } else { |
1714 | FbTk::RefCount<FbTk::Command> reconfig_fb_cmd(new FbCommands::ReconfigureFluxboxCmd()); | 1767 | FbTk::RefCount<FbTk::Command> |
1768 | reconfig_fb_cmd(new FbCommands::ReconfigureFluxboxCmd()); | ||
1715 | menu.insert(str_label.c_str(), reconfig_fb_cmd); | 1769 | menu.insert(str_label.c_str(), reconfig_fb_cmd); |
1716 | } | 1770 | } |
1717 | } else if (str_key == "stylesdir" || str_key == "stylesmenu") { | 1771 | } else if (str_key == "stylesdir" || str_key == "stylesmenu") { |
@@ -1811,7 +1865,11 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { | |||
1811 | ConfigmenuSet, ConfigmenuDesktopWheeling, | 1865 | ConfigmenuSet, ConfigmenuDesktopWheeling, |
1812 | "Desktop MouseWheel Switching"), | 1866 | "Desktop MouseWheel Switching"), |
1813 | *resource.desktop_wheeling, save_and_reconfigure)); | 1867 | *resource.desktop_wheeling, save_and_reconfigure)); |
1814 | menu.insert(new BoolMenuItem("antialias", *resource.antialias, save_and_reconfigure)); | 1868 | |
1869 | // setup antialias cmd to reload style and save resource on toggle | ||
1870 | menu.insert(new BoolMenuItem("antialias", *resource.antialias, | ||
1871 | save_and_reconfigure)); | ||
1872 | |||
1815 | // finaly update menu | 1873 | // finaly update menu |
1816 | menu.update(); | 1874 | menu.update(); |
1817 | } | 1875 | } |