From 25f7f0034524fea4fbd455b17fef8288ffd0aa54 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 13 Oct 2002 22:32:49 +0000 Subject: setting font id in XFontImp now and reading font from database here --- src/Theme.cc | 70 ++++++++++++++++++++++++++++-------------------------------- 1 file 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 @@ // Theme.cc for fluxbox // Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org) +// Some code based on: +// Screen.cc - Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -13,35 +15,13 @@ // // 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 +// 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. -// A lot of the code base is taken from Screen.cc in Blackbox 0.61.1 -// and Brad Hughes (bhuges@tcac.net) should get alot of credit for it -// Screen.cc - Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.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: Theme.cc,v 1.28 2002/09/14 23:25:44 fluxgen Exp $ +// $Id: Theme.cc,v 1.29 2002/10/13 22:32:49 fluxgen Exp $ #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -71,16 +51,15 @@ using namespace std; Theme::Theme(Display *display, Window rootwindow, Colormap colormap, int screennum, BImageControl *ic, const char *filename, const char *rootcommand): -m_menustyle(display), m_imagecontrol(ic), m_display(display), m_colormap(colormap), m_screennum(screennum), m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointer to std::string { - #ifdef DEBUG +#ifdef DEBUG cerr<<__FILE__<<"("<<__LINE__<<"): Creating."<fid; + //if (m_menustyle.titlefont.fontStruct()) + // gcv.font = m_menustyle.titlefont.fontStruct()->fid; m_menustyle.t_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); gcv.foreground = m_menustyle.f_text.pixel(); - if (m_menustyle.framefont.fontStruct()) - gcv.font = m_menustyle.framefont.fontStruct()->fid; + //if (m_menustyle.framefont.fontStruct()) + // gcv.font = m_menustyle.framefont.fontStruct()->fid; m_menustyle.f_text_gc = XCreateGC(m_display, rootwindow, @@ -375,8 +354,8 @@ void Theme::loadMenuStyle() { m_menustyle.bullet_pos = Basemenu::LEFT; //---------- font - m_menustyle.framefont.loadFromDatabase(m_database, "menu.frame.font", "Menu.Frame.Font"); - m_menustyle.titlefont.loadFromDatabase(m_database, "menu.title.font", "Menu.Title.Font"); + loadFontFromDatabase(m_menustyle.framefont, "menu.frame.font", "Menu.Frame.Font"); + loadFontFromDatabase(m_menustyle.titlefont, "menu.title.font", "Menu.Title.Font"); } @@ -987,14 +966,14 @@ void Theme::reconfigure() { GCForeground, &gcv); gcv.foreground = m_menustyle.t_text.pixel(); - if (m_menustyle.titlefont.fontStruct()) - gcv.font = m_menustyle.titlefont.fontStruct()->fid; +// if (m_menustyle.titlefont.fontStruct()) +// gcv.font = m_menustyle.titlefont.fontStruct()->fid; XChangeGC(m_display, m_menustyle.t_text_gc, gc_value_mask, &gcv); gcv.foreground = m_menustyle.f_text.pixel(); - if (m_menustyle.framefont.fontStruct()) - gcv.font = m_menustyle.framefont.fontStruct()->fid; +// if (m_menustyle.framefont.fontStruct()) +// gcv.font = m_menustyle.framefont.fontStruct()->fid; XChangeGC(m_display, m_menustyle.f_text_gc, gc_value_mask, &gcv); @@ -1146,3 +1125,20 @@ const char *Theme::getFontElement(const char *pattern, char *buf, int bufsiz, .. strncpy(buf, "*", bufsiz); return 0; } + +void Theme::loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname) { + assert(name); + assert(altname); + + XrmValue value; + char *value_type; + + if (XrmGetResource(m_database, name, altname, &value_type, &value)) { +#ifdef DEBUG + std::cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<