aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-10-13 22:32:49 (GMT)
committerfluxgen <fluxgen>2002-10-13 22:32:49 (GMT)
commit25f7f0034524fea4fbd455b17fef8288ffd0aa54 (patch)
tree50350fe89aa5e31b0348c49796939827f3a6451a
parent4d1713cb87db91e691d54902f31fcd52e1dd0a7b (diff)
downloadfluxbox-25f7f0034524fea4fbd455b17fef8288ffd0aa54.zip
fluxbox-25f7f0034524fea4fbd455b17fef8288ffd0aa54.tar.bz2
setting font id in XFontImp now and reading font from database here
-rw-r--r--src/Theme.cc70
1 files changed, 33 insertions, 37 deletions
diff --git a/src/Theme.cc b/src/Theme.cc
index 120fffb..69f0963 100644
--- a/src/Theme.cc
+++ b/src/Theme.cc
@@ -1,5 +1,7 @@
1// Theme.cc for fluxbox 1// Theme.cc for fluxbox
2// Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3// Some code based on:
4// Screen.cc - Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3// 5//
4// Permission is hereby granted, free of charge, to any person obtaining a 6// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 7// copy of this software and associated documentation files (the "Software"),
@@ -13,35 +15,13 @@
13// 15//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18// 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 19// 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 20// 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 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 22// DEALINGS IN THE SOFTWARE.
21 23
22// A lot of the code base is taken from Screen.cc in Blackbox 0.61.1 24// $Id: Theme.cc,v 1.29 2002/10/13 22:32:49 fluxgen Exp $
23// and Brad Hughes (bhuges@tcac.net) should get alot of credit for it
24// Screen.cc - Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
25//
26// Permission is hereby granted, free of charge, to any person obtaining a
27// copy of this software and associated documentation files (the "Software"),
28// to deal in the Software without restriction, including without limitation
29// the rights to use, copy, modify, merge, publish, distribute, sublicense,
30// and/or sell copies of the Software, and to permit persons to whom the
31// Software is furnished to do so, subject to the following conditions:
32//
33// The above copyright notice and this permission notice shall be included in
34// all copies or substantial portions of the Software.
35//
36// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
39// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
41// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
42// DEALINGS IN THE SOFTWARE.
43
44// $Id: Theme.cc,v 1.28 2002/09/14 23:25:44 fluxgen Exp $
45 25
46#ifndef _GNU_SOURCE 26#ifndef _GNU_SOURCE
47#define _GNU_SOURCE 27#define _GNU_SOURCE
@@ -71,16 +51,15 @@ using namespace std;
71 51
72Theme::Theme(Display *display, Window rootwindow, Colormap colormap, 52Theme::Theme(Display *display, Window rootwindow, Colormap colormap,
73 int screennum, BImageControl *ic, const char *filename, const char *rootcommand): 53 int screennum, BImageControl *ic, const char *filename, const char *rootcommand):
74m_menustyle(display),
75m_imagecontrol(ic), 54m_imagecontrol(ic),
76m_display(display), 55m_display(display),
77m_colormap(colormap), 56m_colormap(colormap),
78m_screennum(screennum), 57m_screennum(screennum),
79m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointer to std::string 58m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointer to std::string
80{ 59{
81 #ifdef DEBUG 60#ifdef DEBUG
82 cerr<<__FILE__<<"("<<__LINE__<<"): Creating."<<endl; 61 cerr<<__FILE__<<"("<<__LINE__<<"): Creating."<<endl;
83 #endif //DEBUG 62#endif //DEBUG
84 //default settings 63 //default settings
85 64
86 m_windowstyle.font.set = m_toolbarstyle.font.set = m_windowstyle.tab.font.set = 0; 65 m_windowstyle.font.set = m_toolbarstyle.font.set = m_windowstyle.tab.font.set = 0;
@@ -147,15 +126,15 @@ m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointe
147 GCForeground, &gcv); 126 GCForeground, &gcv);
148 127
149 gcv.foreground = m_menustyle.t_text.pixel(); 128 gcv.foreground = m_menustyle.t_text.pixel();
150 if (m_menustyle.titlefont.fontStruct()) 129 //if (m_menustyle.titlefont.fontStruct())
151 gcv.font = m_menustyle.titlefont.fontStruct()->fid; 130 // gcv.font = m_menustyle.titlefont.fontStruct()->fid;
152 m_menustyle.t_text_gc = 131 m_menustyle.t_text_gc =
153 XCreateGC(m_display, rootwindow, 132 XCreateGC(m_display, rootwindow,
154 gc_value_mask, &gcv); 133 gc_value_mask, &gcv);
155 134
156 gcv.foreground = m_menustyle.f_text.pixel(); 135 gcv.foreground = m_menustyle.f_text.pixel();
157 if (m_menustyle.framefont.fontStruct()) 136 //if (m_menustyle.framefont.fontStruct())
158 gcv.font = m_menustyle.framefont.fontStruct()->fid; 137 // gcv.font = m_menustyle.framefont.fontStruct()->fid;
159 138
160 m_menustyle.f_text_gc = 139 m_menustyle.f_text_gc =
161 XCreateGC(m_display, rootwindow, 140 XCreateGC(m_display, rootwindow,
@@ -375,8 +354,8 @@ void Theme::loadMenuStyle() {
375 m_menustyle.bullet_pos = Basemenu::LEFT; 354 m_menustyle.bullet_pos = Basemenu::LEFT;
376 355
377 //---------- font 356 //---------- font
378 m_menustyle.framefont.loadFromDatabase(m_database, "menu.frame.font", "Menu.Frame.Font"); 357 loadFontFromDatabase(m_menustyle.framefont, "menu.frame.font", "Menu.Frame.Font");
379 m_menustyle.titlefont.loadFromDatabase(m_database, "menu.title.font", "Menu.Title.Font"); 358 loadFontFromDatabase(m_menustyle.titlefont, "menu.title.font", "Menu.Title.Font");
380 359
381} 360}
382 361
@@ -987,14 +966,14 @@ void Theme::reconfigure() {
987 GCForeground, &gcv); 966 GCForeground, &gcv);
988 967
989 gcv.foreground = m_menustyle.t_text.pixel(); 968 gcv.foreground = m_menustyle.t_text.pixel();
990 if (m_menustyle.titlefont.fontStruct()) 969// if (m_menustyle.titlefont.fontStruct())
991 gcv.font = m_menustyle.titlefont.fontStruct()->fid; 970// gcv.font = m_menustyle.titlefont.fontStruct()->fid;
992 XChangeGC(m_display, m_menustyle.t_text_gc, 971 XChangeGC(m_display, m_menustyle.t_text_gc,
993 gc_value_mask, &gcv); 972 gc_value_mask, &gcv);
994 973
995 gcv.foreground = m_menustyle.f_text.pixel(); 974 gcv.foreground = m_menustyle.f_text.pixel();
996 if (m_menustyle.framefont.fontStruct()) 975// if (m_menustyle.framefont.fontStruct())
997 gcv.font = m_menustyle.framefont.fontStruct()->fid; 976// gcv.font = m_menustyle.framefont.fontStruct()->fid;
998 977
999 XChangeGC(m_display, m_menustyle.f_text_gc, 978 XChangeGC(m_display, m_menustyle.f_text_gc,
1000 gc_value_mask, &gcv); 979 gc_value_mask, &gcv);
@@ -1146,3 +1125,20 @@ const char *Theme::getFontElement(const char *pattern, char *buf, int bufsiz, ..
1146 strncpy(buf, "*", bufsiz); 1125 strncpy(buf, "*", bufsiz);
1147 return 0; 1126 return 0;
1148} 1127}
1128
1129void Theme::loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname) {
1130 assert(name);
1131 assert(altname);
1132
1133 XrmValue value;
1134 char *value_type;
1135
1136 if (XrmGetResource(m_database, name, altname, &value_type, &value)) {
1137#ifdef DEBUG
1138 std::cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<<value.addr<<std::endl;
1139#endif // DEBUG
1140 dest.load(value.addr);
1141 }
1142
1143
1144}