aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Theme.cc156
-rw-r--r--src/Theme.hh22
2 files changed, 4 insertions, 174 deletions
diff --git a/src/Theme.cc b/src/Theme.cc
index 5306b91..ae32045 100644
--- a/src/Theme.cc
+++ b/src/Theme.cc
@@ -21,13 +21,12 @@
21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22// DEALINGS IN THE SOFTWARE. 22// DEALINGS IN THE SOFTWARE.
23 23
24// $Id: Theme.cc,v 1.40 2003/01/09 22:09:19 fluxgen Exp $ 24// $Id: Theme.cc,v 1.41 2003/01/12 18:48:14 fluxgen Exp $
25 25
26 26
27#include "Theme.hh" 27#include "Theme.hh"
28 28
29#include "i18n.hh" 29#include "i18n.hh"
30#include "Basemenu.hh"
31#include "StringUtil.hh" 30#include "StringUtil.hh"
32 31
33#ifndef _GNU_SOURCE 32#ifndef _GNU_SOURCE
@@ -108,54 +107,13 @@ Theme::Theme(Display *display, Window rootwindow, Colormap colormap,
108 XCreateGC(m_display, rootwindow, 107 XCreateGC(m_display, rootwindow,
109 GCForeground, &gcv); 108 GCForeground, &gcv);
110 109
111 gcv.foreground = m_menustyle.t_text.pixel();
112
113 m_menustyle.t_text_gc =
114 XCreateGC(m_display, rootwindow,
115 gc_value_mask, &gcv);
116
117 gcv.foreground = m_menustyle.f_text.pixel();
118
119 m_menustyle.f_text_gc =
120 XCreateGC(m_display, rootwindow,
121 gc_value_mask, &gcv);
122
123 gcv.foreground = m_menustyle.h_text.pixel();
124 m_menustyle.h_text_gc =
125 XCreateGC(m_display, rootwindow,
126 gc_value_mask, &gcv);
127
128 gcv.foreground = m_menustyle.d_text.pixel();
129 m_menustyle.d_text_gc =
130 XCreateGC(m_display, rootwindow,
131 gc_value_mask, &gcv);
132
133 gcv.foreground = m_menustyle.hilite.color().pixel();
134 m_menustyle.hilite_gc =
135 XCreateGC(m_display, rootwindow,
136 gc_value_mask, &gcv);
137} 110}
138 111
139Theme::~Theme() { 112Theme::~Theme() {
140
141 freeMenuStyle();
142 freeWindowStyle(); 113 freeWindowStyle();
143 freeTabStyle(); 114 freeTabStyle();
144} 115}
145 116
146//----- freeMenuStyle -----
147// free memory allocated for m_menustyle
148// should only be called from ~Theme
149//--------------------
150void Theme::freeMenuStyle() {
151
152 XFreeGC(m_display, m_menustyle.t_text_gc);
153 XFreeGC(m_display, m_menustyle.f_text_gc);
154 XFreeGC(m_display, m_menustyle.h_text_gc);
155 XFreeGC(m_display, m_menustyle.d_text_gc);
156 XFreeGC(m_display, m_menustyle.hilite_gc);
157}
158
159//----- freeWindowStyle ----- 117//----- freeWindowStyle -----
160// free memory allocated for m_windowstyle 118// free memory allocated for m_windowstyle
161//-------------------- 119//--------------------
@@ -182,7 +140,6 @@ void Theme::load(const char *filename){
182 if (!m_database) 140 if (!m_database)
183 m_database = XrmGetFileDatabase(DEFAULTSTYLE); 141 m_database = XrmGetFileDatabase(DEFAULTSTYLE);
184 142
185 loadMenuStyle();
186 loadWindowStyle(); 143 loadWindowStyle();
187 loadTabStyle(); 144 loadTabStyle();
188 loadRootCommand(); 145 loadRootCommand();
@@ -191,91 +148,6 @@ void Theme::load(const char *filename){
191 XrmDestroyDatabase(m_database); 148 XrmDestroyDatabase(m_database);
192} 149}
193 150
194void Theme::loadMenuStyle() {
195
196 readDatabaseTexture("menu.title", "Menu.Title",
197 &m_menustyle.title,
198 WhitePixel(m_display, m_screennum));
199 readDatabaseTexture("menu.frame", "Menu.Frame",
200 &m_menustyle.frame,
201 BlackPixel(m_display, m_screennum));
202 readDatabaseTexture("menu.hilite", "Menu.Hilite",
203 &m_menustyle.hilite,
204 WhitePixel(m_display, m_screennum));
205 readDatabaseColor("menu.title.textColor", "Menu.Title.TextColor",
206 &m_menustyle.t_text,
207 BlackPixel(m_display, m_screennum));
208 readDatabaseColor("menu.frame.textColor", "Menu.Frame.TextColor",
209 &m_menustyle.f_text,
210 WhitePixel(m_display, m_screennum));
211 readDatabaseColor("menu.frame.disableColor", "Menu.Frame.DisableColor",
212 &m_menustyle.d_text,
213 BlackPixel(m_display, m_screennum));
214 readDatabaseColor("menu.hilite.textColor", "Menu.Hilite.TextColor",
215 &m_menustyle.h_text,
216 BlackPixel(m_display, m_screennum));
217
218 XrmValue value;
219 char *value_type=0;
220
221 if (XrmGetResource(m_database, "menu.title.justify",
222 "Menu.Title.Justify", &value_type, &value)) {
223
224 if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
225 m_menustyle.titlefont_justify = DrawUtil::Font::RIGHT;
226 else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
227 m_menustyle.titlefont_justify = DrawUtil::Font::CENTER;
228 else
229 m_menustyle.titlefont_justify = DrawUtil::Font::LEFT;
230
231 } else
232 m_menustyle.titlefont_justify = DrawUtil::Font::LEFT;
233
234 if (XrmGetResource(m_database, "menu.frame.justify",
235 "Menu.Frame.Justify", &value_type, &value)) {
236
237 if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
238 m_menustyle.framefont_justify = DrawUtil::Font::RIGHT;
239 else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
240 m_menustyle.framefont_justify = DrawUtil::Font::CENTER;
241 else
242 m_menustyle.framefont_justify = DrawUtil::Font::LEFT;
243
244 } else
245 m_menustyle.framefont_justify = DrawUtil::Font::LEFT;
246
247 if (XrmGetResource(m_database, "menu.bullet", "Menu.Bullet",
248 &value_type, &value)) {
249
250 if (! strncasecmp(value.addr, "empty", value.size))
251 m_menustyle.bullet = Basemenu::EMPTY;
252 else if (! strncasecmp(value.addr, "square", value.size))
253 m_menustyle.bullet = Basemenu::SQUARE;
254 else if (! strncasecmp(value.addr, "diamond", value.size))
255 m_menustyle.bullet = Basemenu::DIAMOND;
256 else
257 m_menustyle.bullet = Basemenu::TRIANGLE;
258
259 } else
260 m_menustyle.bullet = Basemenu::TRIANGLE;
261
262 if (XrmGetResource(m_database, "menu.bullet.position",
263 "Menu.Bullet.Position", &value_type, &value)) {
264
265 if (! strncasecmp(value.addr, "right", value.size))
266 m_menustyle.bullet_pos = Basemenu::RIGHT;
267 else
268 m_menustyle.bullet_pos = Basemenu::LEFT;
269
270 } else
271 m_menustyle.bullet_pos = Basemenu::LEFT;
272
273 //---------- font
274 loadFontFromDatabase(m_menustyle.framefont, "menu.frame.font", "Menu.Frame.Font");
275 loadFontFromDatabase(m_menustyle.titlefont, "menu.title.font", "Menu.Title.Font");
276
277}
278
279void Theme::loadWindowStyle() { 151void Theme::loadWindowStyle() {
280 152
281 //read textures 153 //read textures
@@ -743,32 +615,6 @@ void Theme::reconfigure(bool antialias) {
743 XChangeGC(m_display, m_windowstyle.b_pic_unfocus_gc, 615 XChangeGC(m_display, m_windowstyle.b_pic_unfocus_gc,
744 GCForeground, &gcv); 616 GCForeground, &gcv);
745 617
746 gcv.foreground = m_menustyle.t_text.pixel();
747 if (m_menustyle.titlefont.isAntialias() != antialias)
748 m_menustyle.titlefont.setAntialias(antialias);
749
750 XChangeGC(m_display, m_menustyle.t_text_gc,
751 gc_value_mask|GCForeground, &gcv);
752
753 gcv.foreground = m_menustyle.f_text.pixel();
754 if (m_menustyle.framefont.isAntialias() != antialias)
755 m_menustyle.framefont.setAntialias(antialias);
756
757 XChangeGC(m_display, m_menustyle.f_text_gc,
758 gc_value_mask, &gcv);
759
760 gcv.foreground = m_menustyle.h_text.pixel();
761 XChangeGC(m_display, m_menustyle.h_text_gc,
762 gc_value_mask, &gcv);
763
764 gcv.foreground = m_menustyle.d_text.pixel();
765 XChangeGC(m_display, m_menustyle.d_text_gc,
766 gc_value_mask, &gcv);
767
768 gcv.foreground = m_menustyle.hilite.color().pixel();
769 XChangeGC(m_display, m_menustyle.hilite_gc,
770 gc_value_mask, &gcv);
771
772} 618}
773 619
774XFontSet Theme::createFontSet(char *fontname) { 620XFontSet Theme::createFontSet(char *fontname) {
diff --git a/src/Theme.hh b/src/Theme.hh
index e31e5a5..810365b 100644
--- a/src/Theme.hh
+++ b/src/Theme.hh
@@ -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: Theme.hh,v 1.22 2002/12/02 20:52:50 fluxgen Exp $ 25// $Id: Theme.hh,v 1.23 2003/01/12 18:47:56 fluxgen Exp $
26 26
27#ifndef THEME_HH 27#ifndef THEME_HH
28#define THEME_HH 28#define THEME_HH
@@ -37,9 +37,10 @@
37 37
38#include <string> 38#include <string>
39 39
40/// OBSOLETE
40/** 41/**
41 Main theme class, holds themes for 42 Main theme class, holds themes for
42 Window, toolbar, slit, menu and the rootCommand, for a specific screen. 43 Window, slit, and the rootCommand, for a specific screen.
43*/ 44*/
44class Theme { 45class Theme {
45public: 46public:
@@ -48,19 +49,6 @@ public:
48 int screennum, const char *filename, const char *rootcommand); 49 int screennum, const char *filename, const char *rootcommand);
49 ~Theme(); 50 ~Theme();
50 51
51
52 typedef struct MenuStyle {
53 MenuStyle():titlefont("fixed"),
54 framefont("fixed") { }
55 FbTk::Color t_text, f_text, h_text, d_text;
56 FbTk::Texture title, frame, hilite;
57 GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc;
58 FbTk::Font titlefont, framefont;
59 DrawUtil::Font::FontJustify framefont_justify;
60 DrawUtil::Font::FontJustify titlefont_justify;
61 int bullet, bullet_pos;
62 } MenuStyle;
63
64 typedef struct LabelStyle { 52 typedef struct LabelStyle {
65 LabelStyle(const char *fontname="fixed"):font(fontname) { } 53 LabelStyle(const char *fontname="fixed"):font(fontname) { }
66 54
@@ -89,7 +77,6 @@ public:
89 } WindowStyle; 77 } WindowStyle;
90 78
91 inline WindowStyle &getWindowStyle() { return m_windowstyle; } 79 inline WindowStyle &getWindowStyle() { return m_windowstyle; }
92 inline MenuStyle &getMenuStyle() { return m_menustyle; }
93 inline const FbTk::Texture &getSlitTexture() const { return m_slit_texture; } 80 inline const FbTk::Texture &getSlitTexture() const { return m_slit_texture; }
94 inline unsigned int getBevelWidth() const { return m_bevel_width; } 81 inline unsigned int getBevelWidth() const { return m_bevel_width; }
95 inline unsigned int getBorderWidth() const { return m_border_width; } 82 inline unsigned int getBorderWidth() const { return m_border_width; }
@@ -106,12 +93,10 @@ public:
106 93
107private: 94private:
108 95
109 void loadMenuStyle();
110 void loadWindowStyle(); 96 void loadWindowStyle();
111 void loadTabStyle(); 97 void loadTabStyle();
112 void loadRootCommand(); 98 void loadRootCommand();
113 void loadMisc(); 99 void loadMisc();
114 void freeMenuStyle();
115 void freeWindowStyle(); 100 void freeWindowStyle();
116 void freeTabStyle(); 101 void freeTabStyle();
117 102
@@ -128,7 +113,6 @@ private:
128 113
129 114
130 WindowStyle m_windowstyle; 115 WindowStyle m_windowstyle;
131 MenuStyle m_menustyle;
132 116
133 unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width; 117 unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width;
134 FbTk::Color m_border_color; 118 FbTk::Color m_border_color;