src/FbTk/MenuTheme.cc (raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
// MenuTheme.cc for FbTk // Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) // // 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, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // 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. // $Id: MenuTheme.cc,v 1.7 2003/04/26 22:10:53 fluxgen Exp $ #include "MenuTheme.hh" #include "Color.hh" #include "Texture.hh" #include "Font.hh" #include "App.hh" #include "StringUtil.hh" #include <cstdio> namespace FbTk { MenuTheme::MenuTheme(int screen_num): FbTk::Theme(screen_num), t_text(*this, "menu.title.textColor", "Menu.Title.TextColor"), f_text(*this, "menu.frame.textColor", "Menu.Frame.TextColor"), h_text(*this, "menu.hilite.textColor", "Menu.Hilite.TextColor"), d_text(*this, "menu.frame.disableColor", "Menu.Frame.DisableColor"), title(*this, "menu.title", "Menu.Title"), frame(*this, "menu.frame", "Menu.Frame"), hilite(*this, "menu.hilite", "Menu.Hilite"), titlefont(*this, "menu.title.font", "Menu.Title.Font"), framefont(*this, "menu.frame.font", "Menu.Frame.Font"), framefont_justify(*this, "menu.frame.justify", "Menu.Frame.Justify"), titlefont_justify(*this, "menu.title.justify", "Menu.Title.Justify"), bullet_pos(*this, "menu.bullet.position", "Menu.Bullet.Position"), m_bullet(*this, "menu.bullet", "Menu.Bullet"), m_border_width(*this, "borderWidth", "BorderWidth"), m_bevel_width(*this, "bevelWidth", "BevelWidth"), m_border_color(*this, "borderColor", "BorderColor"), m_display(FbTk::App::instance()->display()) { Window rootwindow = RootWindow(m_display, screen_num); XGCValues gcv; unsigned long gc_value_mask = GCForeground; gcv.foreground = t_text->pixel(); t_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); gcv.foreground = f_text->pixel(); f_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); gcv.foreground = h_text->pixel(); h_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); gcv.foreground = d_text->pixel(); d_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); gcv.foreground = hilite->color().pixel(); hilite_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); } MenuTheme::~MenuTheme() { XFreeGC(m_display, t_text_gc); XFreeGC(m_display, f_text_gc); XFreeGC(m_display, h_text_gc); XFreeGC(m_display, d_text_gc); XFreeGC(m_display, hilite_gc); } void MenuTheme::reconfigTheme() { XGCValues gcv; unsigned long gc_value_mask = GCForeground; gcv.foreground = t_text->pixel(); XChangeGC(m_display, t_text_gc, gc_value_mask, &gcv); gcv.foreground = f_text->pixel(); XChangeGC(m_display, f_text_gc, gc_value_mask, &gcv); gcv.foreground = h_text->pixel(); XChangeGC(m_display, h_text_gc, gc_value_mask, &gcv); gcv.foreground = d_text->pixel(); XChangeGC(m_display, d_text_gc, gc_value_mask, &gcv); gcv.foreground = hilite->color().pixel(); XChangeGC(m_display, hilite_gc, gc_value_mask, &gcv); // notify any listeners m_theme_change_sig.notify(); } template <> void ThemeItem<MenuTheme::BulletType>::setDefaultValue() { m_value = MenuTheme::EMPTY; } template <> void ThemeItem<MenuTheme::BulletType>::setFromString(const char *str) { // do nothing if (StringUtil::strcasestr(str, "empty") != 0) m_value = MenuTheme::EMPTY; else if (StringUtil::strcasestr(str, "square") != 0) m_value = MenuTheme::SQUARE; else if (StringUtil::strcasestr(str, "triangle") != 0) m_value = MenuTheme::TRIANGLE; else if (StringUtil::strcasestr(str, "diamond") != 0) m_value = MenuTheme::DIAMOND; else setDefaultValue(); } template <> void ThemeItem<MenuTheme::BulletType>::load() { // do nothing, we don't have anything extra to load } template <> void ThemeItem<unsigned int>::setDefaultValue() { m_value = 0; } template <> void ThemeItem<unsigned int>::setFromString(const char *str) { sscanf(str, "%d", &m_value); } template <> void ThemeItem<unsigned int>::load() { } }; // end namespace FbTk |