menu.title_h = style->t_font->height() + menu.bevel_w * 2;
if (title_vis) {
- menu.item_w = screen->getMenuStyle()->t_font->measureString(menu.label) +
+ menu.item_w = screen->getMenuStyle()->t_font->measureString(menu.label,
+ false) +
menu.bevel_w * 2;
} else {
menu.item_w = 1;
unsigned int ii = 0;
MenuItems::iterator it = menuitems.begin(), end = menuitems.end();
for (; it != end; ++it) {
- ii = screen->getMenuStyle()->f_font->measureString((*it)->l) +
+ ii = screen->getMenuStyle()->f_font->measureString((*it)->l, false) +
(menu.bevel_w * 2) + (menu.item_h * 2);
menu.item_w = ((menu.item_w < ii) ? ii : menu.item_w);
unsigned int l;
const MenuStyle* const style = screen->getMenuStyle();
- l = style->t_font->measureString(text) + menu.bevel_w * 2;
+ l = style->t_font->measureString(text, false) + menu.bevel_w * 2;
switch (screen->getMenuStyle()->t_justify) {
case RightJustify:
XClearWindow(display, menu.title);
style->t_font->drawString(menu.title, dx, menu.bevel_w,
- style->t_text, text);
+ style->t_text, text, false);
}
void Basemenu::drawSubmenu(int index) {
text_h = 0;
if (text) {
- text_w = screen->getMenuStyle()->f_font->measureString(text);
+ text_w = screen->getMenuStyle()->f_font->measureString(text, false);
text_y = item_y + menu.bevel_w / 2;
switch(screen->getMenuStyle()->f_justify) {
(highlight ? style->h_text :
(item->isEnabled() ? style->f_text :
style->d_text)),
- text);
+ text, false);
}
if (dosel && item->submenu()) {
void BFont::drawString(Drawable d, int x, int y, const BColor &color,
- const string &string) const {
+ const string &string, bool utf) const {
assert(_valid);
#ifdef XFT
c.pixel = WhitePixel(_display, _screen->getScreenNumber());
}
-#ifdef XFT_UTF8
- XftDrawStringUtf8(
-#else
- XftDrawString8(
-#endif
- draw, &c, _xftfont, x + _offset,
- _xftfont->ascent + y + _offset,
- (XftChar8 *) string.c_str(),
- string.size());
+//#ifdef XFT_UTF8
+ if (utf)
+ XftDrawStringUtf8(draw, &c, _xftfont, x + _offset,
+ _xftfont->ascent + y + _offset,
+ (XftChar8 *) string.c_str(),
+ string.size());
+ else
+//#endif
+ XftDrawString8(draw, &c, _xftfont, x + _offset,
+ _xftfont->ascent + y + _offset,
+ (XftChar8 *) string.c_str(),
+ string.size());
}
XftColor c;
c.pixel = color.pixel();
c.color.alpha = 0xff | 0xff << 8; // no transparency in BColor yet
-#ifdef XFT_UTF8
- XftDrawStringUtf8(
-#else
- XftDrawString8(
-#endif
- draw, &c, _xftfont, x, _xftfont->ascent + y,
- (XftChar8 *) string.c_str(), string.size());
+//#ifdef XFT_UTF8
+ if (utf)
+ XftDrawStringUtf8(draw, &c, _xftfont, x, _xftfont->ascent + y,
+ (XftChar8 *) string.c_str(), string.size());
+ else
+//#endif
+ XftDrawString8(draw, &c, _xftfont, x, _xftfont->ascent + y,
+ (XftChar8 *) string.c_str(), string.size());
XftDrawDestroy(draw);
return;
}
-unsigned int BFont::measureString(const string &string) const {
+unsigned int BFont::measureString(const string &string, bool utf) const {
assert(_valid);
#ifdef XFT
if (_xftfont) {
XGlyphInfo info;
-#ifdef XFT_UTF8
- XftTextExtentsUtf8(
-#else
- XftTextExtents8(
-#endif
- _display, _xftfont, (XftChar8 *) string.c_str(),
- string.size(), &info);
+//#ifdef XFT_UTF8
+ if (utf)
+ XftTextExtentsUtf8(_display, _xftfont, (XftChar8 *) string.c_str(),
+ string.size(), &info);
+ else
+//#endif
+ XftTextExtents8(_display, _xftfont, (XftChar8 *) string.c_str(),
+ string.size(), &info);
return info.xOff + (_shadow ? std::abs(_offset) : 0);
}
unsigned int height(void) const;
unsigned int maxCharWidth(void) const;
- unsigned int measureString(const std::string &string) const;
+ unsigned int measureString(const std::string &string, bool utf) const;
void drawString(Drawable d, int x, int y, const BColor &color,
- const std::string &string) const;
+ const std::string &string, bool utf) const;
};
#endif // __Font_hh
const char *s = i18n(ScreenSet, ScreenPositionLength,
"0: 0000 x 0: 0000");
- geom_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2;
+ geom_w = resource.wstyle.font->measureString(s, false) +
+ resource.bevel_width * 2;
geom_h = resource.wstyle.font->height() + resource.bevel_width * 2;
XSetWindowAttributes attrib;
const char *s = i18n(ScreenSet, ScreenPositionLength,
"0: 0000 x 0: 0000");
- geom_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2;
+ geom_w = resource.wstyle.font->measureString(s, false) +
+ resource.bevel_width * 2;
geom_h = resource.wstyle.font->height() + resource.bevel_width * 2;
BTexture* texture = &(resource.wstyle.l_focus);
resource.wstyle.font->drawString(geom_window,
resource.bevel_width, resource.bevel_width,
resource.wstyle.l_text_focus,
- label);
+ label, false);
}
resource.wstyle.font->drawString(geom_window,
resource.bevel_width, resource.bevel_width,
resource.wstyle.l_text_focus,
- label);
+ label, false);
}
TextJustify justify;
void doJustify(const std::string &text, int &start_pos,
- unsigned int max_length, unsigned int modifier) const;
+ unsigned int max_length, unsigned int modifier,
+ bool utf) const;
};
struct ToolbarStyle {
TextJustify justify;
void doJustify(const std::string &text, int &start_pos,
- unsigned int max_length, unsigned int modifier) const;
+ unsigned int max_length, unsigned int modifier,
+ bool utf) const;
};
struct MenuStyle {
// find the length of the rendered string and add room for two extra
// characters to it. This allows for variable width output of the fonts
BFont *font = screen->getToolbarStyle()->font;
- frame.clock_w = font->measureString(t) + font->maxCharWidth() * 2;
+ frame.clock_w = font->measureString(t, false) + font->maxCharWidth() * 2;
}
}
#else // !HAVE_STRFTIME
for (unsigned int i = 0; i < screen->getWorkspaceCount(); i++) {
const string& workspace_name = screen->getWorkspace(i)->getName();
- width = screen->getToolbarStyle()->font->measureString(workspace_name);
+ width = screen->getToolbarStyle()->font->measureString(workspace_name,
+ false);
if (width > frame.workspace_label_w) frame.workspace_label_w = width;
}
ToolbarStyle *style = screen->getToolbarStyle();
int pos = frame.bevel_w * 2; // this is modified by doJustify()
- style->doJustify(t, pos, frame.clock_w, frame.bevel_w * 4);
+ style->doJustify(t, pos, frame.clock_w, frame.bevel_w * 4, false);
#ifdef XFT
XClearWindow(display, frame.clock);
#endif // XFT
- style->font->drawString(frame.clock, pos, 1, style->c_text, t);
+ style->font->drawString(frame.clock, pos, 1, style->c_text, t, false);
}
}
if (foc->getScreen() != screen) return;
const char *title = foc->getTitle();
+ bool utf = foc->getTitleUtf();
ToolbarStyle *style = screen->getToolbarStyle();
int pos = frame.bevel_w * 2; // modified by doJustify()
- style->doJustify(title, pos, frame.window_label_w, frame.bevel_w * 4);
- style->font->drawString(frame.window_label, pos, 1, style->w_text, title);
+ style->doJustify(title, pos, frame.window_label_w, frame.bevel_w * 4, utf);
+ style->font->drawString(frame.window_label, pos, 1, style->w_text, title,
+ utf);
}
int pos = frame.bevel_w * 2;
style->doJustify(name.c_str(), pos, frame.workspace_label_w,
- frame.bevel_w * 4);
- style->font->drawString(frame.workspace_label, pos, 1, style->l_text, name);
+ frame.bevel_w * 4, false);
+ style->font->drawString(frame.workspace_label, pos, 1, style->l_text, name,
+ false);
}
XClearWindow(display, frame.workspace_label);
unsigned int tw, x;
- tw = screen->getToolbarStyle()->font->measureString(new_workspace_name);
+ tw = screen->getToolbarStyle()->font->measureString(new_workspace_name,
+ false);
x = (frame.workspace_label_w - tw) / 2;
if (x < frame.bevel_w) x = frame.bevel_w;
ToolbarStyle *style = screen->getToolbarStyle();
style->font->drawString(frame.workspace_label, x, 1, style->l_text,
- new_workspace_name);
+ new_workspace_name, false);
BPen pen(style->l_text);
XDrawRectangle(display, frame.workspace_label, pen.gc(), x + tw, 0, 1,
frame.label_h - 1);
void ToolbarStyle::doJustify(const std::string &text, int &start_pos,
unsigned int max_length,
- unsigned int modifier) const {
+ unsigned int modifier, bool utf) const {
size_t text_len = text.size();
unsigned int length;
do {
- length = font->measureString(string(text, 0, text_len)) + modifier;
+ length = font->measureString(string(text, 0, text_len), utf) +
+ modifier;
} while (length > max_length && text_len-- > 0);
switch (justify) {
XAtom::utf8, client.title) &&
!client.title.empty()) {
xatom->eraseValue(client.window, XAtom::net_wm_visible_name);
+ client.title_utf = true;
return;
}
//fall through to using WM_NAME
if (xatom->getValue(client.window, XAtom::wm_name, XAtom::ansi, client.title)
&& !client.title.empty()) {
xatom->eraseValue(client.window, XAtom::net_wm_visible_name);
+ client.title_utf = false;
return;
}
// fall back to an internal default
client.title = i18n(WindowSet, WindowUnnamed, "Unnamed");
xatom->setValue(client.window, XAtom::net_wm_visible_name, XAtom::utf8,
client.title);
+ client.title_utf = false;
#ifdef DEBUG_WITH_ID
// the 16 is the 8 chars of the debug text plus the number
XAtom::utf8, client.icon_title) &&
!client.icon_title.empty()) {
xatom->eraseValue(client.window, XAtom::net_wm_visible_icon_name);
+ client.icon_title_utf = true;
return;
}
//fall through to using WM_ICON_NAME
client.icon_title) &&
!client.icon_title.empty()) {
xatom->eraseValue(client.window, XAtom::net_wm_visible_icon_name);
+ client.icon_title_utf = false;
return;
}
// fall back to using the main name
client.icon_title = client.title;
xatom->setValue(client.window, XAtom::net_wm_visible_icon_name, XAtom::utf8,
client.icon_title);
+ client.icon_title_utf = client.title_utf;
}
WindowStyle *style = screen->getWindowStyle();
int pos = frame.bevel_w * 2;
- style->doJustify(client.title.c_str(), pos, frame.label_w, frame.bevel_w * 4);
+ style->doJustify(client.title.c_str(), pos, frame.label_w, frame.bevel_w * 4,
+ client.title_utf);
style->font->drawString(frame.label, pos, 1,
(flags.focused ? style->l_text_focus :
style->l_text_unfocus),
- client.title);
+ client.title, client.title_utf);
}
void WindowStyle::doJustify(const std::string &text, int &start_pos,
unsigned int max_length,
- unsigned int modifier) const {
+ unsigned int modifier, bool utf) const {
size_t text_len = text.size();
unsigned int length;
do {
- length = font->measureString(string(text, 0, text_len)) + modifier;
+ length = font->measureString(string(text, 0, text_len), utf) + modifier;
} while (length > max_length && text_len-- > 0);
switch (justify) {
BlackboxWindowList transientList; // which windows are our transients?
std::string title, icon_title;
+ bool title_utf, icon_title_utf;
Rect rect;
Strut strut;
inline Windowmenu * getWindowmenu(void) const { return windowmenu; }
- inline const char *getTitle(void) const
- { return client.title.c_str(); }
+ inline const char *getTitle(void) const { return client.title.c_str(); }
+ inline bool getTitleUtf(void) const { return client.title_utf; }
inline const char *getIconTitle(void) const
- { return client.icon_title.c_str(); }
+ { return client.icon_title.c_str(); }
+ inline bool getIconTitleUtf(void) const { return client.icon_title_utf; }
inline unsigned int getWorkspaceNumber(void) const
{ return blackbox_attrib.workspace; }