diff options
author | fluxgen <fluxgen> | 2003-04-25 11:05:11 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-04-25 11:05:11 (GMT) |
commit | dc6fb9e55c7ed01dda217a682d505ee6267169b7 (patch) | |
tree | aa6a63a645bff6f8e56644a822abe34d98d3e085 /src | |
parent | eafc85bca73ed4132a6688a92f67a7d226875c22 (diff) | |
download | fluxbox-dc6fb9e55c7ed01dda217a682d505ee6267169b7.zip fluxbox-dc6fb9e55c7ed01dda217a682d505ee6267169b7.tar.bz2 |
removed old theme engine, fixed RootTheme and some deps
Diffstat (limited to 'src')
-rw-r--r-- | src/Screen.cc | 157 |
1 files changed, 77 insertions, 80 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index 08449a5..57ae7f0 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.131 2003/04/23 10:51:17 fluxgen Exp $ | 25 | // $Id: Screen.cc,v 1.132 2003/04/25 11:05:11 fluxgen Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -38,7 +38,9 @@ | |||
38 | #include "DirHelper.hh" | 38 | #include "DirHelper.hh" |
39 | #include "WinButton.hh" | 39 | #include "WinButton.hh" |
40 | #include "SimpleCommand.hh" | 40 | #include "SimpleCommand.hh" |
41 | #include "FbWinFrameTheme.hh" | ||
41 | #include "MenuTheme.hh" | 42 | #include "MenuTheme.hh" |
43 | #include "RootTheme.hh" | ||
42 | #include "FbCommands.hh" | 44 | #include "FbCommands.hh" |
43 | #include "BoolMenuItem.hh" | 45 | #include "BoolMenuItem.hh" |
44 | #include "IntResMenuItem.hh" | 46 | #include "IntResMenuItem.hh" |
@@ -50,6 +52,7 @@ | |||
50 | #include "WinClient.hh" | 52 | #include "WinClient.hh" |
51 | #include "Subject.hh" | 53 | #include "Subject.hh" |
52 | 54 | ||
55 | |||
53 | //use GNU extensions | 56 | //use GNU extensions |
54 | #ifndef _GNU_SOURCE | 57 | #ifndef _GNU_SOURCE |
55 | #define _GNU_SOURCE | 58 | #define _GNU_SOURCE |
@@ -417,27 +420,6 @@ void setupWorkspacemenu(BScreen &scr, FbTk::Menu &menu) { | |||
417 | 420 | ||
418 | }; | 421 | }; |
419 | 422 | ||
420 | /// for root command | ||
421 | class RootTheme: public FbTk::Theme { | ||
422 | public: | ||
423 | explicit RootTheme(BScreen &scr):FbTk::Theme(scr.getScreenNumber()), | ||
424 | m_root_command(*this, "rootCommand", "RootCommand"), | ||
425 | m_scr(scr) { } | ||
426 | void reconfigTheme() { | ||
427 | // override resource root command? | ||
428 | if (m_scr.getRootCommand() == "") { | ||
429 | // do root command | ||
430 | FbCommands::ExecuteCmd cmd(*m_root_command); | ||
431 | cmd.execute(); | ||
432 | } else { | ||
433 | FbCommands::ExecuteCmd cmd(m_scr.getRootCommand()); | ||
434 | cmd.execute(); | ||
435 | } | ||
436 | } | ||
437 | private: | ||
438 | FbTk::ThemeItem<std::string> m_root_command; | ||
439 | BScreen &m_scr; | ||
440 | }; | ||
441 | 423 | ||
442 | template <> | 424 | template <> |
443 | void FbTk::ThemeItem<std::string>::load() { } | 425 | void FbTk::ThemeItem<std::string>::load() { } |
@@ -452,6 +434,21 @@ void FbTk::ThemeItem<std::string>::setFromString(const char *str) { | |||
452 | *(*this) = (str ? str : ""); | 434 | *(*this) = (str ? str : ""); |
453 | } | 435 | } |
454 | 436 | ||
437 | template <> | ||
438 | void FbTk::ThemeItem<int>::load() { } | ||
439 | |||
440 | template <> | ||
441 | void FbTk::ThemeItem<int>::setDefaultValue() { | ||
442 | *(*this) = 0; | ||
443 | } | ||
444 | |||
445 | template <> | ||
446 | void FbTk::ThemeItem<int>::setFromString(const char *str) { | ||
447 | if (str == 0) | ||
448 | return; | ||
449 | sscanf(str, "%d", &m_value); | ||
450 | } | ||
451 | |||
455 | BScreen::ScreenResource::ScreenResource(ResourceManager &rm, | 452 | BScreen::ScreenResource::ScreenResource(ResourceManager &rm, |
456 | const std::string &scrname, | 453 | const std::string &scrname, |
457 | const std::string &altscrname): | 454 | const std::string &altscrname): |
@@ -503,12 +500,14 @@ BScreen::BScreen(ResourceManager &rm, | |||
503 | m_currentworkspace_sig(*this), // current workspace signal | 500 | m_currentworkspace_sig(*this), // current workspace signal |
504 | m_layermanager(num_layers), | 501 | m_layermanager(num_layers), |
505 | cycling_focus(false), | 502 | cycling_focus(false), |
506 | theme(0), m_windowtheme(scrn), | 503 | m_windowtheme(new FbWinFrameTheme(scrn)), |
507 | m_menutheme(new FbTk::MenuTheme(scrn)), | 504 | m_menutheme(new FbTk::MenuTheme(scrn)), |
508 | resource(rm, screenname, altscreenname), | 505 | resource(rm, screenname, altscreenname), |
509 | m_root_theme(new RootTheme(*this)), | 506 | m_root_theme(new |
510 | m_toolbarhandler(0) | 507 | RootTheme(scrn, |
511 | { | 508 | *resource.rootcommand)), |
509 | m_toolbarhandler(0) { | ||
510 | |||
512 | Display *disp = FbTk::App::instance()->display(); | 511 | Display *disp = FbTk::App::instance()->display(); |
513 | 512 | ||
514 | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | | 513 | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | |
@@ -573,15 +572,13 @@ BScreen::BScreen(ResourceManager &rm, | |||
573 | 572 | ||
574 | fluxbox->load_rc(*this); | 573 | fluxbox->load_rc(*this); |
575 | FbTk::Menu::setAlpha(*resource.menu_alpha); | 574 | FbTk::Menu::setAlpha(*resource.menu_alpha); |
575 | |||
576 | image_control->setDither(*resource.image_dither); | 576 | image_control->setDither(*resource.image_dither); |
577 | theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(), | ||
578 | fluxbox->getStyleFilename().c_str(), getRootCommand().c_str()); | ||
579 | 577 | ||
580 | theme->reconfigure(*resource.antialias); | ||
581 | // setup windowtheme, toolbartheme for antialias | 578 | // setup windowtheme, toolbartheme for antialias |
582 | m_windowtheme.font().setAntialias(*resource.antialias); | 579 | winFrameTheme().font().setAntialias(*resource.antialias); |
583 | m_menutheme->titleFont().setAntialias(*resource.antialias); | 580 | menuTheme()->titleFont().setAntialias(*resource.antialias); |
584 | m_menutheme->frameFont().setAntialias(*resource.antialias); | 581 | menuTheme()->frameFont().setAntialias(*resource.antialias); |
585 | 582 | ||
586 | // set database for new Theme Engine | 583 | // set database for new Theme Engine |
587 | FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename().c_str()); | 584 | FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename().c_str()); |
@@ -592,42 +589,42 @@ BScreen::BScreen(ResourceManager &rm, | |||
592 | 589 | ||
593 | int l = strlen(s); | 590 | int l = strlen(s); |
594 | 591 | ||
595 | geom_h = m_windowtheme.font().height(); | 592 | geom_h = winFrameTheme().font().height(); |
596 | geom_w = m_windowtheme.font().textWidth(s, l); | 593 | geom_w = winFrameTheme().font().textWidth(s, l); |
597 | 594 | ||
598 | geom_w += getBevelWidth()*2; | 595 | geom_w += m_root_theme->bevelWidth()*2; |
599 | geom_h += getBevelWidth()*2; | 596 | geom_h += m_root_theme->bevelWidth()*2; |
600 | 597 | ||
601 | XSetWindowAttributes attrib; | 598 | XSetWindowAttributes attrib; |
602 | unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder; | 599 | unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder; |
603 | attrib.border_pixel = getBorderColor()->pixel(); | 600 | attrib.border_pixel = m_root_theme->borderColor().pixel(); |
604 | attrib.colormap = colormap(); | 601 | attrib.colormap = colormap(); |
605 | attrib.save_under = true; | 602 | attrib.save_under = true; |
606 | 603 | //!! TODO border width | |
607 | geom_window = | 604 | geom_window = |
608 | XCreateWindow(disp, getRootWindow(), | 605 | XCreateWindow(disp, getRootWindow(), |
609 | 0, 0, geom_w, geom_h, theme->getBorderWidth(), getDepth(), | 606 | 0, 0, geom_w, geom_h, m_root_theme->borderWidth(), getDepth(), |
610 | InputOutput, getVisual(), mask, &attrib); | 607 | InputOutput, getVisual(), mask, &attrib); |
611 | geom_visible = false; | 608 | geom_visible = false; |
612 | 609 | ||
613 | if (m_windowtheme.labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) { | 610 | if (winFrameTheme().labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) { |
614 | if (m_windowtheme.titleFocusTexture().type() == | 611 | if (winFrameTheme().titleFocusTexture().type() == |
615 | (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { | 612 | (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { |
616 | geom_pixmap = None; | 613 | geom_pixmap = None; |
617 | geom_window.setBackgroundColor(m_windowtheme.titleFocusTexture().color()); | 614 | geom_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color()); |
618 | } else { | 615 | } else { |
619 | geom_pixmap = image_control->renderImage(geom_w, geom_h, | 616 | geom_pixmap = image_control->renderImage(geom_w, geom_h, |
620 | m_windowtheme.titleFocusTexture()); | 617 | winFrameTheme().titleFocusTexture()); |
621 | geom_window.setBackgroundPixmap(geom_pixmap); | 618 | geom_window.setBackgroundPixmap(geom_pixmap); |
622 | } | 619 | } |
623 | } else { | 620 | } else { |
624 | if (m_windowtheme.labelFocusTexture().type() == | 621 | if (winFrameTheme().labelFocusTexture().type() == |
625 | (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { | 622 | (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { |
626 | geom_pixmap = None; | 623 | geom_pixmap = None; |
627 | geom_window.setBackgroundColor(m_windowtheme.labelFocusTexture().color()); | 624 | geom_window.setBackgroundColor(winFrameTheme().labelFocusTexture().color()); |
628 | } else { | 625 | } else { |
629 | geom_pixmap = image_control->renderImage(geom_w, geom_h, | 626 | geom_pixmap = image_control->renderImage(geom_w, geom_h, |
630 | m_windowtheme.labelFocusTexture()); | 627 | winFrameTheme().labelFocusTexture()); |
631 | geom_window.setBackgroundPixmap(geom_pixmap); | 628 | geom_window.setBackgroundPixmap(geom_pixmap); |
632 | } | 629 | } |
633 | } | 630 | } |
@@ -774,8 +771,6 @@ BScreen::~BScreen() { | |||
774 | 771 | ||
775 | delete image_control; | 772 | delete image_control; |
776 | 773 | ||
777 | delete theme; | ||
778 | |||
779 | } | 774 | } |
780 | 775 | ||
781 | const FbTk::Menu &BScreen::getToolbarModemenu() const { | 776 | const FbTk::Menu &BScreen::getToolbarModemenu() const { |
@@ -786,6 +781,10 @@ FbTk::Menu &BScreen::getToolbarModemenu() { | |||
786 | return m_toolbarhandler->getModeMenu(); | 781 | return m_toolbarhandler->getModeMenu(); |
787 | } | 782 | } |
788 | 783 | ||
784 | unsigned int BScreen::getCurrentWorkspaceID() const { | ||
785 | return current_workspace->workspaceID(); | ||
786 | } | ||
787 | |||
789 | /// TODO | 788 | /// TODO |
790 | unsigned int BScreen::getMaxLeft() const { | 789 | unsigned int BScreen::getMaxLeft() const { |
791 | return 0; | 790 | return 0; |
@@ -811,18 +810,15 @@ void BScreen::reconfigure() { | |||
811 | #endif // DEBUG | 810 | #endif // DEBUG |
812 | FbTk::Menu::setAlpha(*resource.menu_alpha); | 811 | FbTk::Menu::setAlpha(*resource.menu_alpha); |
813 | Fluxbox::instance()->loadRootCommand(*this); | 812 | Fluxbox::instance()->loadRootCommand(*this); |
814 | theme->setRootCommand(getRootCommand()); | 813 | |
815 | const string &filename = Fluxbox::instance()->getStyleFilename(); | ||
816 | theme->load(filename.c_str()); // old theme engine | ||
817 | // setup windowtheme, toolbartheme for antialias | 814 | // setup windowtheme, toolbartheme for antialias |
818 | m_windowtheme.font().setAntialias(*resource.antialias); | 815 | winFrameTheme().font().setAntialias(*resource.antialias); |
819 | m_menutheme->titleFont().setAntialias(*resource.antialias); | 816 | m_menutheme->titleFont().setAntialias(*resource.antialias); |
820 | m_menutheme->frameFont().setAntialias(*resource.antialias); | 817 | m_menutheme->frameFont().setAntialias(*resource.antialias); |
818 | // load theme | ||
819 | std::string theme_filename(Fluxbox::instance()->getStyleFilename()); | ||
820 | FbTk::ThemeManager::instance().load(theme_filename.c_str()); | ||
821 | 821 | ||
822 | FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine | ||
823 | |||
824 | theme->reconfigure(*resource.antialias); | ||
825 | |||
826 | I18n *i18n = I18n::instance(); | 822 | I18n *i18n = I18n::instance(); |
827 | 823 | ||
828 | const char *s = i18n->getMessage( | 824 | const char *s = i18n->getMessage( |
@@ -832,38 +828,38 @@ void BScreen::reconfigure() { | |||
832 | int l = strlen(s); | 828 | int l = strlen(s); |
833 | 829 | ||
834 | //TODO: repeated from somewhere else? | 830 | //TODO: repeated from somewhere else? |
835 | geom_h = m_windowtheme.font().height(); | 831 | geom_h = winFrameTheme().font().height(); |
836 | geom_w = m_windowtheme.font().textWidth(s, l); | 832 | geom_w = winFrameTheme().font().textWidth(s, l); |
837 | geom_w += getBevelWidth()*2; | 833 | geom_w += m_root_theme->bevelWidth()*2; |
838 | geom_h += getBevelWidth()*2; | 834 | geom_h += m_root_theme->bevelWidth()*2; |
839 | 835 | ||
840 | Pixmap tmp = geom_pixmap; | 836 | Pixmap tmp = geom_pixmap; |
841 | if (m_windowtheme.labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) { | 837 | if (winFrameTheme().labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) { |
842 | if (m_windowtheme.titleFocusTexture().type() == | 838 | if (winFrameTheme().titleFocusTexture().type() == |
843 | (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { | 839 | (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { |
844 | geom_pixmap = None; | 840 | geom_pixmap = None; |
845 | geom_window.setBackgroundColor(m_windowtheme.titleFocusTexture().color()); | 841 | geom_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color()); |
846 | } else { | 842 | } else { |
847 | geom_pixmap = image_control->renderImage(geom_w, geom_h, | 843 | geom_pixmap = image_control->renderImage(geom_w, geom_h, |
848 | m_windowtheme.titleFocusTexture()); | 844 | winFrameTheme().titleFocusTexture()); |
849 | geom_window.setBackgroundPixmap(geom_pixmap); | 845 | geom_window.setBackgroundPixmap(geom_pixmap); |
850 | } | 846 | } |
851 | } else { | 847 | } else { |
852 | if (m_windowtheme.labelFocusTexture().type() == | 848 | if (winFrameTheme().labelFocusTexture().type() == |
853 | (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { | 849 | (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { |
854 | geom_pixmap = None; | 850 | geom_pixmap = None; |
855 | geom_window.setBackgroundColor(m_windowtheme.labelFocusTexture().color()); | 851 | geom_window.setBackgroundColor(winFrameTheme().labelFocusTexture().color()); |
856 | } else { | 852 | } else { |
857 | geom_pixmap = image_control->renderImage(geom_w, geom_h, | 853 | geom_pixmap = image_control->renderImage(geom_w, geom_h, |
858 | m_windowtheme.labelFocusTexture()); | 854 | winFrameTheme().labelFocusTexture()); |
859 | geom_window.setBackgroundPixmap(geom_pixmap); | 855 | geom_window.setBackgroundPixmap(geom_pixmap); |
860 | } | 856 | } |
861 | } | 857 | } |
862 | if (tmp) | 858 | if (tmp) |
863 | image_control->removeImage(tmp); | 859 | image_control->removeImage(tmp); |
864 | 860 | ||
865 | geom_window.setBorderWidth(theme->getBorderWidth()); | 861 | geom_window.setBorderWidth(m_root_theme->borderWidth()); |
866 | geom_window.setBorderColor(theme->getBorderColor()); | 862 | geom_window.setBorderColor(m_root_theme->borderColor()); |
867 | 863 | ||
868 | //reconfigure menus | 864 | //reconfigure menus |
869 | workspacemenu->reconfigure(); | 865 | workspacemenu->reconfigure(); |
@@ -1643,7 +1639,7 @@ void BScreen::dirFocus(FluxboxWindow &win, FocusDir dir) { | |||
1643 | 1639 | ||
1644 | FluxboxWindow *foundwin = 0; | 1640 | FluxboxWindow *foundwin = 0; |
1645 | int weight = 999999, exposure = 0; // extreme values | 1641 | int weight = 999999, exposure = 0; // extreme values |
1646 | int borderW = getBorderWidth(), | 1642 | int borderW = m_root_theme->borderWidth(), |
1647 | top = win.getYFrame(), | 1643 | top = win.getYFrame(), |
1648 | bottom = win.getYFrame() + win.getHeight() + 2*borderW, | 1644 | bottom = win.getYFrame() + win.getHeight() + 2*borderW, |
1649 | left = win.getXFrame(), | 1645 | left = win.getXFrame(), |
@@ -2269,13 +2265,14 @@ void BScreen::showPosition(int x, int y) { | |||
2269 | 2265 | ||
2270 | geom_window.clear(); | 2266 | geom_window.clear(); |
2271 | 2267 | ||
2272 | m_windowtheme.font().drawText( | 2268 | winFrameTheme().font().drawText( |
2273 | geom_window.window(), | 2269 | geom_window.window(), |
2274 | getScreenNumber(), | 2270 | getScreenNumber(), |
2275 | m_windowtheme.labelTextFocusGC(), | 2271 | winFrameTheme().labelTextFocusGC(), |
2276 | label, strlen(label), | 2272 | label, strlen(label), |
2277 | theme->getBevelWidth(), theme->getBevelWidth() + | 2273 | m_root_theme->bevelWidth(), |
2278 | m_windowtheme.font().ascent()); | 2274 | m_root_theme->bevelWidth() + |
2275 | winFrameTheme().font().ascent()); | ||
2279 | 2276 | ||
2280 | } | 2277 | } |
2281 | 2278 | ||
@@ -2308,13 +2305,13 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) { | |||
2308 | geom_window.clear(); | 2305 | geom_window.clear(); |
2309 | 2306 | ||
2310 | //TODO: geom window again?! repeated | 2307 | //TODO: geom window again?! repeated |
2311 | m_windowtheme.font().drawText( | 2308 | winFrameTheme().font().drawText(geom_window.window(), |
2312 | geom_window.window(), | ||
2313 | getScreenNumber(), | 2309 | getScreenNumber(), |
2314 | m_windowtheme.labelTextFocusGC(), | 2310 | winFrameTheme().labelTextFocusGC(), |
2315 | label, strlen(label), | 2311 | label, strlen(label), |
2316 | theme->getBevelWidth(), theme->getBevelWidth() + | 2312 | m_root_theme->bevelWidth(), |
2317 | m_windowtheme.font().ascent()); | 2313 | m_root_theme->bevelWidth() + |
2314 | winFrameTheme().font().ascent()); | ||
2318 | } | 2315 | } |
2319 | 2316 | ||
2320 | 2317 | ||