From 58c6885c23e6d65ed478e7fda8fc167f3e695607 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 15 May 2002 09:35:49 +0000 Subject: changed menustyle.framefont/titlefont to nonpointer --- src/Basemenu.cc | 64 ++++++++++++++++++++++++++++++--------------------------- src/Theme.cc | 54 ++++++++++++------------------------------------ src/Theme.hh | 6 ++++-- 3 files changed, 51 insertions(+), 73 deletions(-) diff --git a/src/Basemenu.cc b/src/Basemenu.cc index 354f4e6..46a5735 100644 --- a/src/Basemenu.cc +++ b/src/Basemenu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Basemenu.cc,v 1.22 2002/04/28 15:54:59 fluxgen Exp $ +// $Id: Basemenu.cc,v 1.23 2002/05/15 09:35:49 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -95,12 +95,12 @@ m_alignment(ALIGNDONTCARE) { if (i18n->multibyte()) { menu.width = menu.title_h = menu.item_w = menu.frame_h = - m_screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.height + + m_screen->getMenuStyle()->titlefont.getFontSetExtents()->max_ink_extent.height + (menu.bevel_w * 2); } else { menu.width = menu.title_h = menu.item_w = menu.frame_h = - m_screen->getMenuStyle()->titlefont->getFontStruct()->ascent + - m_screen->getMenuStyle()->titlefont->getFontStruct()->descent + + m_screen->getMenuStyle()->titlefont.getFontStruct()->ascent + + m_screen->getMenuStyle()->titlefont.getFontStruct()->descent + (menu.bevel_w * 2); } @@ -109,11 +109,11 @@ m_alignment(ALIGNDONTCARE) { menu.minsub = 0; if (i18n->multibyte()) { - menu.item_h = m_screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.height + + menu.item_h = m_screen->getMenuStyle()->framefont.getFontSetExtents()->max_ink_extent.height + (menu.bevel_w); } else { - menu.item_h = m_screen->getMenuStyle()->framefont->getFontStruct()->ascent + - m_screen->getMenuStyle()->framefont->getFontStruct()->descent + + menu.item_h = m_screen->getMenuStyle()->framefont.getFontStruct()->ascent + + m_screen->getMenuStyle()->framefont.getFontStruct()->descent + (menu.bevel_w); } menu.height = menu.title_h + m_screen->getBorderWidth() + menu.frame_h; @@ -260,16 +260,16 @@ void Basemenu::update(void) { I18n *i18n = I18n::instance(); if (i18n->multibyte()) { - menu.item_h = m_screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.height + + menu.item_h = m_screen->getMenuStyle()->framefont.getFontSetExtents()->max_ink_extent.height + menu.bevel_w; - menu.title_h = m_screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.height + + menu.title_h = m_screen->getMenuStyle()->titlefont.getFontSetExtents()->max_ink_extent.height + (menu.bevel_w * 2); } else { - menu.item_h = m_screen->getMenuStyle()->framefont->getFontStruct()->ascent + - m_screen->getMenuStyle()->framefont->getFontStruct()->descent + + menu.item_h = m_screen->getMenuStyle()->framefont.getFontStruct()->ascent + + m_screen->getMenuStyle()->framefont.getFontStruct()->descent + menu.bevel_w; - menu.title_h = m_screen->getMenuStyle()->titlefont->getFontStruct()->ascent + - m_screen->getMenuStyle()->titlefont->getFontStruct()->descent + + menu.title_h = m_screen->getMenuStyle()->titlefont.getFontStruct()->ascent + + m_screen->getMenuStyle()->titlefont.getFontStruct()->descent + (menu.bevel_w * 2); } @@ -279,14 +279,15 @@ void Basemenu::update(void) { FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, "fluxbox Menu"); int l = strlen(s); - - + + /* if (i18n->multibyte()) { XRectangle ink, logical; - XmbTextExtents(m_screen->getMenuStyle()->titlefont->getFontSet(), s, l, &ink, &logical); + XmbTextExtents(m_screen->getMenuStyle()->titlefont.getFontSet(), s, l, &ink, &logical); menu.item_w = logical.width; - } else - menu.item_w = XTextWidth(m_screen->getMenuStyle()->titlefont->getFontStruct(), s, l); + } else*/ + menu.item_w = m_screen->getMenuStyle()->titlefont.getTextWidth(s, l); + //XTextWidth(m_screen->getMenuStyle()->titlefont.getFontStruct(), s, l); menu.item_w += (menu.bevel_w * 2); } else @@ -301,12 +302,15 @@ void Basemenu::update(void) { const char *s = itmp->label().c_str(); int l = itmp->label().size(); - if (i18n->multibyte()) { + /*if (i18n->multibyte()) { XRectangle ink, logical; - XmbTextExtents(m_screen->getMenuStyle()->framefont->getFontSet(), s, l, &ink, &logical); + XmbTextExtents(m_screen->getMenuStyle()->framefont.getFontSet(), s, l, &ink, &logical); ii = logical.width; } else - ii = XTextWidth(m_screen->getMenuStyle()->framefont->getFontStruct(), s, l); + ii = XTextWidth(m_screen->getMenuStyle()->framefont.getFontStruct(), s, l); + */ + ii = screen()->getMenuStyle()->framefont.getTextWidth(s, l); + ii += (menu.bevel_w * 2) + (menu.item_h * 2); @@ -485,7 +489,7 @@ void Basemenu::redrawTitle(void) { int dx = menu.bevel_w, len = strlen(text); unsigned int l; - l = m_screen->getMenuStyle()->titlefont->getTextWidth(text, len); + l = m_screen->getMenuStyle()->titlefont.getTextWidth(text, len); l += (menu.bevel_w * 2); @@ -503,13 +507,13 @@ void Basemenu::redrawTitle(void) { } if (i18n->multibyte()) - XmbDrawString(m_display, menu.title, m_screen->getMenuStyle()->titlefont->getFontSet(), + XmbDrawString(m_display, menu.title, m_screen->getMenuStyle()->titlefont.getFontSet(), m_screen->getMenuStyle()->t_text_gc, dx, menu.bevel_w - - m_screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.y, + m_screen->getMenuStyle()->titlefont.getFontSetExtents()->max_ink_extent.y, text, len); else XDrawString(m_display, menu.title, m_screen->getMenuStyle()->t_text_gc, dx, - m_screen->getMenuStyle()->titlefont->getFontStruct()->ascent + menu.bevel_w, + m_screen->getMenuStyle()->titlefont.getFontStruct()->ascent + menu.bevel_w, text, len); } @@ -654,14 +658,14 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear, I18n *i18n = I18n::instance(); if (text) { - text_w = m_screen->getMenuStyle()->framefont->getTextWidth(text, len); + text_w = m_screen->getMenuStyle()->framefont.getTextWidth(text, len); - if (m_screen->getMenuStyle()->framefont->multibyte()) { + if (m_screen->getMenuStyle()->framefont.multibyte()) { text_y = item_y + (menu.bevel_w / 2) - - m_screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.y; + m_screen->getMenuStyle()->framefont.getFontSetExtents()->max_ink_extent.y; } else { text_y = item_y + - m_screen->getMenuStyle()->framefont->getFontStruct()->ascent + + m_screen->getMenuStyle()->framefont.getFontStruct()->ascent + (menu.bevel_w / 2); } @@ -753,7 +757,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear, if (dotext && text) { if (i18n->multibyte()) { - XmbDrawString(m_display, menu.frame, m_screen->getMenuStyle()->framefont->getFontSet(), + XmbDrawString(m_display, menu.frame, m_screen->getMenuStyle()->framefont.getFontSet(), tgc, text_x, text_y, text, len); } else XDrawString(m_display, menu.frame, tgc, text_x, text_y, text, len); diff --git a/src/Theme.cc b/src/Theme.cc index 71a1b68..d0674f5 100644 --- a/src/Theme.cc +++ b/src/Theme.cc @@ -41,7 +41,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.cc,v 1.20 2002/04/20 10:33:10 fluxgen Exp $ +// $Id: Theme.cc,v 1.21 2002/05/15 09:35:49 fluxgen Exp $ #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -71,6 +71,7 @@ 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), @@ -81,8 +82,7 @@ m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointe cerr<<__FILE__<<"("<<__LINE__<<"): Creating."<getFontStruct()) - gcv.font = m_menustyle.titlefont->getFontStruct()->fid; + if (m_menustyle.titlefont.getFontStruct()) + gcv.font = m_menustyle.titlefont.getFontStruct()->fid; m_menustyle.t_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); gcv.foreground = m_menustyle.f_text.getPixel(); - if (m_menustyle.framefont->getFontStruct()) - gcv.font = m_menustyle.framefont->getFontStruct()->fid; + if (m_menustyle.framefont.getFontStruct()) + gcv.font = m_menustyle.framefont.getFontStruct()->fid; m_menustyle.f_text_gc = XCreateGC(m_display, rootwindow, @@ -213,10 +213,6 @@ Theme::~Theme() { // should only be called from ~Theme //-------------------- void Theme::freeMenuStyle() { - delete m_menustyle.framefont; - m_menustyle.framefont = 0; - delete m_menustyle.titlefont; - m_menustyle.titlefont = 0; XFreeGC(m_display, m_menustyle.t_text_gc); XFreeGC(m_display, m_menustyle.f_text_gc); @@ -300,8 +296,6 @@ void Theme::load(const char *filename){ } void Theme::loadMenuStyle() { - if (m_menustyle.titlefont==0) - m_menustyle.titlefont = new FbTk::Font(m_display); readDatabaseTexture("menu.title", "Menu.Title", &m_menustyle.title, @@ -381,30 +375,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"); - /* - if (I18n::instance()->multibyte()) { - - readDatabaseFontSet("menu.title.font", "Menu.Title.Font", - &m_menustyle.titlefont.set); - readDatabaseFontSet("menu.frame.font", "Menu.Frame.Font", - &m_menustyle.framefont.set); - - m_menustyle.titlefont.set_extents = - XExtentsOfFontSet(m_menustyle.titlefont.set); - m_menustyle.framefont.set_extents = - XExtentsOfFontSet(m_menustyle.framefont.set); - - - } else { - - readDatabaseFont("menu.title.font", "Menu.Title.Font", - &m_menustyle.titlefont.fontstruct); - - readDatabaseFont("menu.frame.font", "Menu.Frame.Font", - &m_menustyle.framefont.fontstruct); - }*/ + m_menustyle.framefont.loadFromDatabase(m_database, "menu.frame.font", "Menu.Frame.Font"); + m_menustyle.titlefont.loadFromDatabase(m_database, "menu.title.font", "Menu.Title.Font"); } @@ -990,14 +962,14 @@ void Theme::reconfigure() { GCForeground, &gcv); gcv.foreground = m_menustyle.t_text.getPixel(); - if (m_menustyle.titlefont->getFontStruct()) - gcv.font = m_menustyle.titlefont->getFontStruct()->fid; + if (m_menustyle.titlefont.getFontStruct()) + gcv.font = m_menustyle.titlefont.getFontStruct()->fid; XChangeGC(m_display, m_menustyle.t_text_gc, gc_value_mask, &gcv); gcv.foreground = m_menustyle.f_text.getPixel(); - if (m_menustyle.framefont->getFontStruct()) - gcv.font = m_menustyle.framefont->getFontStruct()->fid; + if (m_menustyle.framefont.getFontStruct()) + gcv.font = m_menustyle.framefont.getFontStruct()->fid; XChangeGC(m_display, m_menustyle.f_text_gc, gc_value_mask, &gcv); diff --git a/src/Theme.hh b/src/Theme.hh index c197469..1401716 100644 --- a/src/Theme.hh +++ b/src/Theme.hh @@ -42,7 +42,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.hh,v 1.8 2002/05/07 15:22:07 fluxgen Exp $ +// $Id: Theme.hh,v 1.9 2002/05/15 09:35:49 fluxgen Exp $ #ifndef THEME_HH #define THEME_HH @@ -66,10 +66,12 @@ public: typedef struct MenuStyle { + MenuStyle(Display *display):titlefont(display, "fixed"), + framefont(display, "fixed") { } BColor t_text, f_text, h_text, d_text; BTexture title, frame, hilite; GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; - FbTk::Font *titlefont, *framefont; + FbTk::Font titlefont, framefont; DrawUtil::Font::FontJustify framefont_justify; DrawUtil::Font::FontJustify titlefont_justify; int bullet, bullet_pos; -- cgit v0.11.2