all repos — fluxbox @ 3e972e83bd2716f7e5941f4ef8edcb67f4f2a3b5

custom fork of the fluxbox windowmanager

using new font system for labelstyle, windowstyle
fluxgen fluxgen
commit

3e972e83bd2716f7e5941f4ef8edcb67f4f2a3b5

parent

715f363016995cbe188e7c47d9c389c8581b9fb1

5 files changed, 98 insertions(+), 132 deletions(-)

jump to
M src/IconBar.ccsrc/IconBar.cc

@@ -19,7 +19,7 @@ // 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: IconBar.cc,v 1.15 2002/08/04 15:23:24 fluxgen Exp $ +// $Id: IconBar.cc,v 1.16 2002/10/15 17:10:48 fluxgen Exp $ #include "IconBar.hh" #include "i18n.hh"

@@ -261,9 +261,9 @@

FluxboxWindow *fluxboxwin = obj->getFluxboxWin(); Window iconwin = obj->getIconWin(); unsigned int title_text_w; - + /* const int multibyte = I18n::instance()->multibyte(); - + if (multibyte) { XRectangle ink, logical; XmbTextExtents(m_screen->getWindowStyle()->font.set,

@@ -273,14 +273,16 @@ } else {

title_text_w = XTextWidth(m_screen->getWindowStyle()->font.fontstruct, fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size()); } - + */ + title_text_w = m_screen->getWindowStyle()->font.textWidth( + fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size()); int l = title_text_w; unsigned int dlen=fluxboxwin->getIconTitle().size(); unsigned int bevel_w = m_screen->getBevelWidth(); int dx=bevel_w*2; for (; dlen >= 0; dlen--) { - if (multibyte) { + /*if (multibyte) { XRectangle ink, logical; XmbTextExtents(m_screen->getWindowStyle()->tab.font.set, fluxboxwin->getIconTitle().c_str(), dlen,

@@ -289,13 +291,16 @@ l = logical.width;

} else l = XTextWidth(m_screen->getWindowStyle()->tab.font.fontstruct, fluxboxwin->getIconTitle().c_str(), dlen); - l += (bevel_w * 4); - + */ + l = m_screen->getWindowStyle()->tab.font.textWidth( + fluxboxwin->getIconTitle().c_str(), dlen); + l += (bevel_w * 4); + if (l < width) break; } - switch (m_screen->getWindowStyle()->tab.font.justify) { + switch (m_screen->getWindowStyle()->tab.justify) { case DrawUtil::Font::RIGHT: dx += width - l; break;

@@ -309,7 +314,7 @@

//Draw title to m_iconwin XClearWindow(m_display, iconwin); - + /* if (multibyte) { XmbDrawString(m_display, iconwin, m_screen->getWindowStyle()->tab.font.set,

@@ -322,6 +327,13 @@ m_screen->getWindowStyle()->tab.l_text_focus_gc, dx,

m_screen->getWindowStyle()->tab.font.fontstruct->ascent + 1, fluxboxwin->getIconTitle().c_str(), dlen); } + */ + m_screen->getWindowStyle()->tab.font.drawText( + iconwin, + m_screen->getScreenNumber(), + m_screen->getWindowStyle()->tab.l_text_focus_gc, + fluxboxwin->getIconTitle().c_str(), dlen, + dx, m_screen->getWindowStyle()->tab.font.height()); }
M src/Screen.ccsrc/Screen.cc

@@ -22,7 +22,7 @@ // 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: Screen.cc,v 1.73 2002/10/15 13:05:55 fluxgen Exp $ +// $Id: Screen.cc,v 1.74 2002/10/15 17:12:23 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE

@@ -288,7 +288,7 @@ FBNLS::ScreenSet, FBNLS::ScreenPositionLength,

"0: 0000 x 0: 0000"); int l = strlen(s); - + /* if (i18n->multibyte()) { XRectangle ink, logical; XmbTextExtents(theme->getWindowStyle().font.set, s, l, &ink, &logical);

@@ -301,7 +301,10 @@ theme->getWindowStyle().font.fontstruct->descent;

geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l); } - + */ + geom_h = theme->getWindowStyle().font.height(); + geom_w = theme->getWindowStyle().font.textWidth(s, l); + geom_w += getBevelWidth()*2; geom_h += getBevelWidth()*2;

@@ -527,7 +530,7 @@ const char *s = i18n->getMessage(

FBNLS::ScreenSet, FBNLS::ScreenPositionLength, "0: 0000 x 0: 0000"); int l = strlen(s); - + /* if (i18n->multibyte()) { XRectangle ink, logical; XmbTextExtents(theme->getWindowStyle().font.set, s, l, &ink, &logical);

@@ -540,7 +543,10 @@

geom_h = theme->getWindowStyle().font.fontstruct->ascent + theme->getWindowStyle().font.fontstruct->descent; } - + */ + //TODO: repeat from somewhere else? + geom_h = theme->getWindowStyle().font.height(); + geom_w = theme->getWindowStyle().font.textWidth(s, l); geom_w += getBevelWidth()*2; geom_h += getBevelWidth()*2;

@@ -1620,7 +1626,7 @@ FBNLS::ScreenSet, FBNLS::ScreenPositionFormat,

"X: %4d x Y: %4d"), x, y); XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); - + /* if (I18n::instance()->multibyte()) XmbDrawString(getBaseDisplay()->getXDisplay(), geom_window, theme->getWindowStyle().font.set, theme->getWindowStyle().l_text_focus_gc,

@@ -1633,7 +1639,15 @@ theme->getWindowStyle().l_text_focus_gc,

theme->getBevelWidth(), theme->getWindowStyle().font.fontstruct->ascent + theme->getBevelWidth(), label, strlen(label)); - + */ + theme->getWindowStyle().font.drawText( + geom_window, + getScreenNumber(), + theme->getWindowStyle().l_text_focus_gc, + label, strlen(label), + theme->getBevelWidth(), theme->getBevelWidth() + + theme->getWindowStyle().font.height()); + }

@@ -1664,7 +1678,7 @@ FBNLS::ScreenSet, FBNLS::ScreenGeometryFormat,

"W: %4d x H: %4d"), gx, gy); XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); - + /* if (I18n::instance()->multibyte()) XmbDrawString(getBaseDisplay()->getXDisplay(), geom_window, theme->getWindowStyle().font.set, theme->getWindowStyle().l_text_focus_gc,

@@ -1677,6 +1691,15 @@ theme->getWindowStyle().l_text_focus_gc,

theme->getBevelWidth(), theme->getWindowStyle().font.fontstruct->ascent + theme->getBevelWidth(), label, strlen(label)); + */ + //TODO: geom window again?! repeat + theme->getWindowStyle().font.drawText( + geom_window, + getScreenNumber(), + theme->getWindowStyle().l_text_focus_gc, + label, strlen(label), + theme->getBevelWidth(), theme->getBevelWidth() + + theme->getWindowStyle().font.height()); }
M src/Theme.ccsrc/Theme.cc

@@ -21,7 +21,7 @@ // 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.30 2002/10/15 10:53:01 fluxgen Exp $ +// $Id: Theme.cc,v 1.31 2002/10/15 17:08:45 fluxgen Exp $ #ifndef _GNU_SOURCE #define _GNU_SOURCE

@@ -62,10 +62,8 @@ cerr<<__FILE__<<"("<<__LINE__<<"): Creating."<<endl;

#endif //DEBUG //default settings - m_windowstyle.font.set = m_toolbarstyle.font.set = m_windowstyle.tab.font.set = 0; - - m_toolbarstyle.font.fontstruct = m_windowstyle.font.fontstruct = m_windowstyle.tab.font.fontstruct = 0; - m_windowstyle.tab.rot_font = 0; + m_toolbarstyle.font.set = 0; + m_toolbarstyle.font.fontstruct = 0; load(filename); //-------- create gc for the styles ------------

@@ -74,9 +72,6 @@

XGCValues gcv; unsigned long gc_value_mask = GCForeground; - if (! I18n::instance()->multibyte()) - gc_value_mask |= GCFont; - gcv.foreground = WhitePixel(m_display, screennum)^BlackPixel(m_display, screennum); gcv.function = GXxor; gcv.subwindow_mode = IncludeInferiors;

@@ -84,24 +79,17 @@ m_opgc = XCreateGC(m_display, rootwindow,

GCForeground | GCFunction | GCSubwindowMode, &gcv); gcv.foreground = m_windowstyle.l_text_focus.pixel(); - if (m_windowstyle.font.fontstruct) - gcv.font = m_windowstyle.font.fontstruct->fid; - m_windowstyle.l_text_focus_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); gcv.foreground = m_windowstyle.l_text_unfocus.pixel(); - if (m_windowstyle.font.fontstruct) - gcv.font = m_windowstyle.font.fontstruct->fid; m_windowstyle.l_text_unfocus_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); //---- Tab gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); - if (m_windowstyle.tab.font.fontstruct) - gcv.font = m_windowstyle.tab.font.fontstruct->fid; m_windowstyle.tab.l_text_focus_gc = XCreateGC(m_display, rootwindow,

@@ -202,15 +190,8 @@ }

//----- freeWindowStyle ----- // free memory allocated for m_windowstyle -// should only be called from ~Theme //-------------------- void Theme::freeWindowStyle() { - if (m_windowstyle.font.set) - XFreeFontSet(m_display, m_windowstyle.font.set); - - if (m_windowstyle.font.fontstruct) - XFreeFont(m_display, m_windowstyle.font.fontstruct); - XFreeGC(m_display, m_windowstyle.l_text_focus_gc); XFreeGC(m_display, m_windowstyle.l_text_unfocus_gc); XFreeGC(m_display, m_windowstyle.b_pic_focus_gc);

@@ -219,20 +200,8 @@ }

//----- freeTabStyle ----- // free memory allocated for m_windowstyle.tab -// should only be called from ~Theme //-------------------- void Theme::freeTabStyle() { - - if (m_windowstyle.tab.font.set) - XFreeFontSet(m_display, m_windowstyle.tab.font.set); - - if (m_windowstyle.tab.font.fontstruct) - XFreeFont(m_display, m_windowstyle.tab.font.fontstruct); - - if (m_windowstyle.tab.rot_font) - DrawUtil::XRotUnloadFont(m_display, m_windowstyle.tab.rot_font); - - XFreeGC(m_display, m_windowstyle.tab.l_text_focus_gc); XFreeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc); }

@@ -445,17 +414,7 @@ &m_windowstyle.b_pic_unfocus,

WhitePixel(m_display, m_screennum)); //----- font - - if (I18n::instance()->multibyte()) { - readDatabaseFontSet("window.font", "Window.Font", - &m_windowstyle.font.set); - - m_windowstyle.font.set_extents = - XExtentsOfFontSet(m_windowstyle.font.set); - } else { - readDatabaseFont("window.font", "Window.Font", - &m_windowstyle.font.fontstruct); - } + loadFontFromDatabase(m_windowstyle.font, "window.font", "Window.Font"); XrmValue value; char *value_type;

@@ -463,13 +422,13 @@

if (XrmGetResource(m_database, "window.justify", "Window.Justify", &value_type, &value)) { if (strstr(value.addr, "right") || strstr(value.addr, "Right")) - m_windowstyle.font.justify = DrawUtil::Font::RIGHT; + m_windowstyle.justify = DrawUtil::Font::RIGHT; else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) - m_windowstyle.font.justify = DrawUtil::Font::CENTER; + m_windowstyle.justify = DrawUtil::Font::CENTER; else - m_windowstyle.font.justify = DrawUtil::Font::LEFT; + m_windowstyle.justify = DrawUtil::Font::LEFT; } else - m_windowstyle.font.justify = DrawUtil::Font::LEFT; + m_windowstyle.justify = DrawUtil::Font::LEFT; }

@@ -523,38 +482,29 @@ m_windowstyle.tab.border_width = 1;

m_windowstyle.tab.border_width_2x = m_windowstyle.tab.border_width*2; - //---------- font + loadFontFromDatabase(m_windowstyle.tab.font, "window.tab.font", "Window.Tab.Font"); - if (I18n::instance()->multibyte()) { - readDatabaseFontSet("window.tab.font", "Window.Tab.Font", - &m_windowstyle.tab.font.set); - - m_windowstyle.tab.font.set_extents = - XExtentsOfFontSet(m_windowstyle.tab.font.set); - } else { - readDatabaseFont("window.tab.font", "Window.Tab.Font", - &m_windowstyle.tab.font.fontstruct); - } - + //TODO: fix rotated font //--------- rotated font for left and right tabs // TODO: add extra checking - if (XrmGetResource(m_database, "window.tab.font", "Window.Tab.Font", + /*if (XrmGetResource(m_database, "window.tab.font", "Window.Tab.Font", &value_type, &value)) { if (! (m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, value.addr, 90.0)) ) m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, "fixed", 90); } else m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, "fixed", 90); + */ if (XrmGetResource(m_database, "window.tab.justify", "Window.Tab.Justify", &value_type, &value)) { if (strstr(value.addr, "right") || strstr(value.addr, "Right")) - m_windowstyle.tab.font.justify = DrawUtil::Font::RIGHT; + m_windowstyle.tab.justify = DrawUtil::Font::RIGHT; else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) - m_windowstyle.tab.font.justify = DrawUtil::Font::CENTER; + m_windowstyle.tab.justify = DrawUtil::Font::CENTER; else - m_windowstyle.tab.font.justify = DrawUtil::Font::LEFT; + m_windowstyle.tab.justify = DrawUtil::Font::LEFT; } else - m_windowstyle.tab.font.justify = DrawUtil::Font::LEFT; + m_windowstyle.tab.justify = DrawUtil::Font::LEFT; }

@@ -920,8 +870,6 @@ void Theme::reconfigure(bool antialias) {

XGCValues gcv; unsigned long gc_value_mask = GCForeground; - if (! I18n::instance()->multibyte()) - gc_value_mask |= GCFont; XChangeGC(m_display, m_opgc, GCForeground | GCFunction | GCSubwindowMode, &gcv);

@@ -933,8 +881,8 @@ XChangeGC(m_display, m_opgc,

GCForeground | GCFunction | GCSubwindowMode, &gcv); gcv.foreground = m_windowstyle.l_text_focus.pixel(); - if (m_windowstyle.font.fontstruct) - gcv.font = m_windowstyle.font.fontstruct->fid; + if (m_windowstyle.font.isAntialias() != antialias) + m_windowstyle.font.setAntialias(antialias); XChangeGC(m_display, m_windowstyle.l_text_focus_gc, gc_value_mask, &gcv);

@@ -945,9 +893,8 @@ gc_value_mask, &gcv);

//---- Tab gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); - if (m_windowstyle.tab.font.fontstruct) - gcv.font = m_windowstyle.tab.font.fontstruct->fid; - + if (m_windowstyle.tab.font.isAntialias() != antialias) + m_windowstyle.tab.font.setAntialias(antialias); XChangeGC(m_display, m_windowstyle.tab.l_text_focus_gc, gc_value_mask, &gcv);

@@ -970,7 +917,7 @@ if (m_menustyle.titlefont.isAntialias() != antialias)

m_menustyle.titlefont.setAntialias(antialias); XChangeGC(m_display, m_menustyle.t_text_gc, - gc_value_mask, &gcv); + gc_value_mask|GCForeground, &gcv); gcv.foreground = m_menustyle.f_text.pixel(); if (m_menustyle.framefont.isAntialias() != antialias)

@@ -994,7 +941,8 @@

gcv.foreground = m_toolbarstyle.l_text.pixel(); if (m_toolbarstyle.font.fontstruct) gcv.font = m_toolbarstyle.font.fontstruct->fid; - + + gc_value_mask |= GCFont; XChangeGC(m_display, m_toolbarstyle.l_text_gc, gc_value_mask, &gcv);

@@ -1138,7 +1086,8 @@ if (XrmGetResource(m_database, name, altname, &value_type, &value)) {

#ifdef DEBUG std::cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<<value.addr<<std::endl; #endif // DEBUG - dest.load(value.addr); + if (!dest.load(value.addr)) + cerr<<"Failed to load font: "<<value.addr<<endl; }
M src/Theme.hhsrc/Theme.hh

@@ -22,7 +22,7 @@ // 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.hh,v 1.15 2002/10/15 10:52:18 fluxgen Exp $ +// $Id: Theme.hh,v 1.16 2002/10/15 17:07:32 fluxgen Exp $ #ifndef THEME_HH #define THEME_HH

@@ -59,12 +59,14 @@ DrawUtil::Font::FontJustify titlefont_justify;

int bullet, bullet_pos; } MenuStyle; - typedef struct LabelStyle - { + typedef struct LabelStyle { + LabelStyle(const char *fontname="fixed"):font(fontname) { } + FbTk::Texture l_focus, l_unfocus, t_focus, t_unfocus; GC l_text_focus_gc, l_text_unfocus_gc; - DrawUtil::Font font; + FbTk::Font font; + DrawUtil::Font::FontJustify justify; FbTk::Color l_text_focus, l_text_unfocus; } LabelStyle;
M src/Window.ccsrc/Window.cc

@@ -22,7 +22,7 @@ // 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: Window.cc,v 1.88 2002/10/13 21:54:36 fluxgen Exp $ +// $Id: Window.cc,v 1.89 2002/10/15 17:17:00 fluxgen Exp $ #include "Window.hh"

@@ -1014,15 +1014,7 @@ client.y = frame.y + frame.y_border + frame.mwm_border_w +

screen->getBorderWidth(); if (getTitle().size() > 0) { - if (I18n::instance()->multibyte()) { - XRectangle ink, logical; - XmbTextExtents(screen->getWindowStyle()->font.set, - getTitle().c_str(), getTitle().size(), &ink, &logical); - client.title_text_w = logical.width; - } else { - client.title_text_w = XTextWidth(screen->getWindowStyle()->font.fontstruct, - getTitle().c_str(), getTitle().size()); - } + client.title_text_w = screen->getWindowStyle()->font.textWidth(getTitle().c_str(), getTitle().size()); client.title_text_w += (frame.bevel_w * 4); }

@@ -1121,17 +1113,8 @@ client.title = i18n->getMessage(

FBNLS::WindowSet, FBNLS::WindowUnnamed, "Unnamed"); } - - if (i18n->multibyte()) { - XRectangle ink, logical; - XmbTextExtents(screen->getWindowStyle()->font.set, - getTitle().c_str(), getTitle().size(), &ink, &logical); - client.title_text_w = logical.width; - } else { - client.title_text_w = XTextWidth(screen->getWindowStyle()->font.fontstruct, - getTitle().c_str(), getTitle().size()); - } - + //Note: repeated? + client.title_text_w = screen->getWindowStyle()->font.textWidth(getTitle().c_str(), getTitle().size()); client.title_text_w += (frame.bevel_w * 4); }

@@ -2445,15 +2428,18 @@ else

XSetWindowBackground(display, frame.label, frame.ulabel_pixel); } + XClearWindow(display, frame.label); + //no need to draw the title if we don't have any - if (getTitle().size()!=0) { + if (getTitle().size() != 0) { GC gc = ((focused) ? screen->getWindowStyle()->l_text_focus_gc : screen->getWindowStyle()->l_text_unfocus_gc); - - DrawUtil::DrawString(display, frame.label, gc, - &screen->getWindowStyle()->font, - client.title_text_w, frame.label_w, - frame.bevel_w, getTitle().c_str()); + screen->getWindowStyle()->font.drawText( + frame.label, + screen->getScreenNumber(), + gc, + getTitle().c_str(), getTitle().size(), + frame.bevel_w, frame.bevel_w + screen->getWindowStyle()->font.height()); } }

@@ -3633,14 +3619,8 @@

frame.bevel_w = screen->getBevelWidth(); frame.mwm_border_w = screen->getFrameWidth() * decorations.border; - if (I18n::instance()->multibyte()) { - frame.title_h = (screen->getWindowStyle()->font.set_extents-> - max_ink_extent.height + - (frame.bevel_w * 2) + 2) * decorations.titlebar; - } else - frame.title_h = (screen->getWindowStyle()->font.fontstruct->ascent + - screen->getWindowStyle()->font.fontstruct->descent + - (frame.bevel_w * 2) + 2) * decorations.titlebar; + frame.title_h = screen->getWindowStyle()->font.height() + + (frame.bevel_w*2 + 2)*decorations.titlebar; frame.label_h = (frame.title_h - (frame.bevel_w * 2)) * decorations.titlebar; frame.button_w = frame.button_h = frame.label_h - 2;