all repos — fluxbox @ 42719701dc17b5acef41223fe0237b9154cb3f0a

custom fork of the fluxbox windowmanager

rotated Xmb Fonts, by rotating as we draw
simonb simonb
commit

42719701dc17b5acef41223fe0237b9154cb3f0a

parent

c243fa897f37dabeade187ac74ea5cd175e80a22

4 files changed, 107 insertions(+), 8 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,11 @@

(Format: Year/Month/Day) Changes for 0.9.16: *06/04/04: + * Rotated Xmb Fonts (Simon) + - rotated when drawn. Probably not very efficient for + parentrelative backgrounds. If it proves an issue, we should + probably cache recently-drawn strings so we can just re-stipple. + XmbFontImp.hh/cc Text.hh * Rotated X Fonts again, plus minor external tab alignment fixes (Simon) - Still need to do XmbFonts. Most people probably load those instead of XFont these days. Will need yet another approach...
M src/FbTk/Text.hhsrc/FbTk/Text.hh

@@ -75,6 +75,31 @@ }

} +// still require w and h in ROT0 coords +inline void untranslateCoords(Orientation orient, int &orig_x, int &orig_y, unsigned int w, unsigned int h) { + + int x = orig_x; + int y = orig_y; + + switch(orient) { + case ROT0: + break; + case ROT90: + orig_y = h - x; + orig_x = y; + break; + case ROT180: + orig_x = w - x; + orig_y = h - y; + break; + case ROT270: + orig_y = x; + orig_x = w - y; + break; + } + +} + // When positioning an X11 box inside another area, we need to // relocate the x,y coordinates inline void translatePosition(Orientation orient, int &x, int &y, unsigned int w, unsigned int h, unsigned int bw) {
M src/FbTk/XmbFontImp.ccsrc/FbTk/XmbFontImp.cc

@@ -25,7 +25,8 @@ #include "XmbFontImp.hh"

#include "App.hh" #include "StringUtil.hh" -#include "FbDrawable.hh" +#include "FbPixmap.hh" +#include "GContext.hh" #ifdef HAVE_CONFIG_H #include "config.h"

@@ -55,6 +56,8 @@ #include <cstring>

#else #include <string.h> #endif + +#include <X11/Xlib.h> using namespace std;

@@ -183,24 +186,87 @@

return true; } -void XmbFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *text, +void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const char *text, size_t len, int x, int y, FbTk::Orientation orient) const { if (m_fontset == 0) return; + if (orient == ROT0) { +#ifdef X_HAVE_UTF8_STRING + if (m_utf8mode) { + Xutf8DrawString(d.display(), d.drawable(), m_fontset, + main_gc, x, y, + text, len); + } else +#endif //X_HAVE_UTF8_STRING + { + XmbDrawString(d.display(), d.drawable(), m_fontset, + main_gc, x, y, + text, len); + } + return; + } + + Display *dpy = App::instance()->display(); + Window rootwin = DefaultRootWindow(dpy); + + int xpos = x, ypos = y; + unsigned int w = d.width(); + unsigned int h = d.height(); + + translateSize(orient, w, h); + untranslateCoords(orient, xpos, ypos, w, h); + + // not straight forward, we actually draw it elsewhere, then rotate it + FbTk::FbPixmap canvas(rootwin, w, h, 1); + + // create graphic context for our canvas + FbTk::GContext font_gc(canvas); + font_gc.setBackground(None); + font_gc.setForeground(None); + + XFillRectangle(dpy, canvas.drawable(), font_gc.gc(), 0, 0, canvas.width(), canvas.height()); + font_gc.setForeground(1); + + #ifdef X_HAVE_UTF8_STRING if (m_utf8mode) { - Xutf8DrawString(w.display(), w.drawable(), m_fontset, - gc, x, y, - text, len); + Xutf8DrawString(dpy, canvas.drawable(), m_fontset, + font_gc.gc(), xpos, ypos, + text, len); } else #endif //X_HAVE_UTF8_STRING { - XmbDrawString(w.display(), w.drawable(), m_fontset, - gc, x, y, - text, len); + XmbDrawString(dpy, canvas.drawable(), m_fontset, + font_gc.gc(), xpos, ypos, + text, len); } + + canvas.rotate(orient); + + GC my_gc = XCreateGC(dpy, d.drawable(), 0, 0); + + XCopyGC(dpy, main_gc, GCForeground|GCBackground, my_gc); + + // vertical or upside down + + XSetFillStyle(dpy, my_gc, FillStippled); + + // vertical or upside down + + XSetFillStyle(dpy, my_gc, FillStippled); + + XSetStipple(dpy, my_gc, canvas.drawable()); + + XSetTSOrigin(dpy, my_gc, 0, 0); + + XFillRectangle(dpy, d.drawable(), my_gc, 0, 0, + canvas.width(), + canvas.height()); + + XFreeGC(dpy, my_gc); + } unsigned int XmbFontImp::textWidth(const char * const text, unsigned int len) const {
M src/FbTk/XmbFontImp.hhsrc/FbTk/XmbFontImp.hh

@@ -43,6 +43,9 @@ int ascent() const { return m_setextents ? -m_setextents->max_ink_extent.y : 0; }

int descent() const { return m_setextents ? m_setextents->max_ink_extent.height + m_setextents->max_ink_extent.y : 0; } bool loaded() const { return m_fontset != 0; } bool utf8() const { return m_utf8mode; } + + bool validOrientation(FbTk::Orientation orient) { return true; }; // rotated on demand + private: XFontSet m_fontset; XFontSetExtents *m_setextents;