aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/MenuTheme.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/MenuTheme.cc')
-rw-r--r--src/FbTk/MenuTheme.cc135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/FbTk/MenuTheme.cc b/src/FbTk/MenuTheme.cc
new file mode 100644
index 0000000..1b7a187
--- /dev/null
+++ b/src/FbTk/MenuTheme.cc
@@ -0,0 +1,135 @@
1// MenuTheme.cc for FbTk
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: MenuTheme.cc,v 1.1 2002/12/25 11:42:05 fluxgen Exp $
23
24#include "MenuTheme.hh"
25
26#include "Color.hh"
27#include "Texture.hh"
28#include "Font.hh"
29#include "App.hh"
30//TODO change this
31#include "../StringUtil.hh"
32
33namespace FbTk {
34
35MenuTheme::MenuTheme(int screen_num):
36 FbTk::Theme(screen_num),
37 t_text(*this, "menu.title.textColor", "Menu.Title.TextColor"),
38 f_text(*this, "menu.frame.textColor", "Menu.Frame.TextColor"),
39 h_text(*this, "menu.hilite.textColor", "Menu.Hilite.TextColor"),
40 d_text(*this, "menu.frame.disableColor", "Menu.Frame.DisableColor"),
41 title(*this, "menu.title", "Menu.Title"),
42 frame(*this, "menu.frame", "Menu.Frame"),
43 hilite(*this, "menu.hilite", "Menu.Hilite"),
44 titlefont(*this, "menu.title.font", "Menu.Title.Font"),
45 framefont(*this, "menu.frame.font", "Menu.Frame.Font"),
46 framefont_justify(*this, "menu.frame.justify", "Menu.Frame.Justify"),
47 titlefont_justify(*this, "menu.title.justify", "Menu.Title.Justify"),
48 bullet_pos(*this, "menu.bulletPos", "Menu.BulletPos"),
49 m_bullet(*this, "menu.bullet", "Menu.Bullet"),
50 m_display(FbTk::App::instance()->display()) {
51
52 Window rootwindow = RootWindow(m_display, screen_num);
53
54 XGCValues gcv;
55 unsigned long gc_value_mask = GCForeground;
56 gcv.foreground = t_text->pixel();
57
58 t_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
59
60 gcv.foreground = f_text->pixel();
61
62 f_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
63
64 gcv.foreground = h_text->pixel();
65 h_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
66
67 gcv.foreground = d_text->pixel();
68 d_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
69
70 gcv.foreground = hilite->color().pixel();
71 hilite_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
72}
73
74MenuTheme::~MenuTheme() {
75 XFreeGC(m_display, t_text_gc);
76 XFreeGC(m_display, f_text_gc);
77 XFreeGC(m_display, h_text_gc);
78 XFreeGC(m_display, d_text_gc);
79 XFreeGC(m_display, hilite_gc);
80}
81
82void MenuTheme::reconfigTheme() {
83
84 XGCValues gcv;
85 unsigned long gc_value_mask = GCForeground;
86
87 gcv.foreground = t_text->pixel();
88
89 XChangeGC(m_display, t_text_gc,
90 gc_value_mask, &gcv);
91
92 gcv.foreground = f_text->pixel();
93
94 XChangeGC(m_display, f_text_gc,
95 gc_value_mask, &gcv);
96
97 gcv.foreground = h_text->pixel();
98 XChangeGC(m_display, h_text_gc,
99 gc_value_mask, &gcv);
100
101 gcv.foreground = d_text->pixel();
102 XChangeGC(m_display, d_text_gc,
103 gc_value_mask, &gcv);
104
105 gcv.foreground = hilite->color().pixel();
106 XChangeGC(m_display, hilite_gc,
107 gc_value_mask, &gcv);
108
109}
110
111
112template <>
113void ThemeItem<MenuTheme::BulletType>::setDefaultValue() {
114 m_value = MenuTheme::EMPTY;
115}
116
117template <>
118void ThemeItem<MenuTheme::BulletType>::setFromString(const char *str) {
119 // do nothing
120 if (StringUtil::strcasestr(str, "EMPTY") == 0)
121 m_value = MenuTheme::EMPTY;
122 else if (StringUtil::strcasestr(str, "SQUARE") == 0)
123 m_value = MenuTheme::SQUARE;
124 else if (StringUtil::strcasestr(str, "TRIANGLE") == 0)
125 m_value = MenuTheme::TRIANGLE;
126 else
127 setDefaultValue();
128}
129
130template <>
131void ThemeItem<MenuTheme::BulletType>::load() {
132 // do nothing, we don't have anything extra to load
133}
134
135}; // end namespace FbTk