2002-12-25 11:42:05 +00:00
|
|
|
// MenuTheme.cc for FbTk
|
2003-04-26 22:10:53 +00:00
|
|
|
// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
2002-12-25 11:42:05 +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,
|
|
|
|
// 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.
|
|
|
|
|
2003-07-19 03:59:56 +00:00
|
|
|
// $Id: MenuTheme.cc,v 1.8 2003/07/19 03:59:56 rathnor Exp $
|
2002-12-25 11:42:05 +00:00
|
|
|
|
|
|
|
#include "MenuTheme.hh"
|
|
|
|
|
|
|
|
#include "Color.hh"
|
|
|
|
#include "Texture.hh"
|
|
|
|
#include "Font.hh"
|
|
|
|
#include "App.hh"
|
2003-04-26 22:10:53 +00:00
|
|
|
#include "StringUtil.hh"
|
|
|
|
|
2003-01-10 00:54:12 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
2002-12-25 11:42:05 +00:00
|
|
|
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"),
|
2003-02-23 01:00:48 +00:00
|
|
|
bullet_pos(*this, "menu.bullet.position", "Menu.Bullet.Position"),
|
2002-12-25 11:42:05 +00:00
|
|
|
m_bullet(*this, "menu.bullet", "Menu.Bullet"),
|
2003-01-09 16:51:52 +00:00
|
|
|
m_border_width(*this, "borderWidth", "BorderWidth"),
|
|
|
|
m_bevel_width(*this, "bevelWidth", "BevelWidth"),
|
|
|
|
m_border_color(*this, "borderColor", "BorderColor"),
|
2003-07-19 03:59:56 +00:00
|
|
|
m_display(FbTk::App::instance()->display()),
|
|
|
|
m_alpha(255)
|
|
|
|
{
|
2002-12-25 11:42:05 +00:00
|
|
|
|
|
|
|
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;
|
2003-02-22 19:08:28 +00:00
|
|
|
|
2002-12-25 11:42:05 +00:00
|
|
|
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);
|
|
|
|
|
2003-02-15 01:49:43 +00:00
|
|
|
// notify any listeners
|
|
|
|
m_theme_change_sig.notify();
|
2002-12-25 11:42:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void ThemeItem<MenuTheme::BulletType>::setDefaultValue() {
|
|
|
|
m_value = MenuTheme::EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void ThemeItem<MenuTheme::BulletType>::setFromString(const char *str) {
|
2003-02-22 19:08:28 +00:00
|
|
|
|
2002-12-25 11:42:05 +00:00
|
|
|
// do nothing
|
2003-02-22 19:08:28 +00:00
|
|
|
if (StringUtil::strcasestr(str, "empty") != 0)
|
2002-12-25 11:42:05 +00:00
|
|
|
m_value = MenuTheme::EMPTY;
|
2003-02-22 19:08:28 +00:00
|
|
|
else if (StringUtil::strcasestr(str, "square") != 0)
|
2002-12-25 11:42:05 +00:00
|
|
|
m_value = MenuTheme::SQUARE;
|
2003-02-22 19:08:28 +00:00
|
|
|
else if (StringUtil::strcasestr(str, "triangle") != 0)
|
2002-12-25 11:42:05 +00:00
|
|
|
m_value = MenuTheme::TRIANGLE;
|
2003-02-22 19:08:28 +00:00
|
|
|
else if (StringUtil::strcasestr(str, "diamond") != 0)
|
|
|
|
m_value = MenuTheme::DIAMOND;
|
2002-12-25 11:42:05 +00:00
|
|
|
else
|
|
|
|
setDefaultValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void ThemeItem<MenuTheme::BulletType>::load() {
|
|
|
|
// do nothing, we don't have anything extra to load
|
|
|
|
}
|
|
|
|
|
2003-01-09 16:51:52 +00:00
|
|
|
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() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-25 11:42:05 +00:00
|
|
|
}; // end namespace FbTk
|