aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/XmbFontImp.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2006-04-04 14:07:07 (GMT)
committersimonb <simonb>2006-04-04 14:07:07 (GMT)
commit42719701dc17b5acef41223fe0237b9154cb3f0a (patch)
treedc2c5567e071fa6d445003439800ba03b328ce20 /src/FbTk/XmbFontImp.cc
parentc243fa897f37dabeade187ac74ea5cd175e80a22 (diff)
downloadfluxbox_pavel-42719701dc17b5acef41223fe0237b9154cb3f0a.zip
fluxbox_pavel-42719701dc17b5acef41223fe0237b9154cb3f0a.tar.bz2
rotated Xmb Fonts, by rotating as we draw
Diffstat (limited to 'src/FbTk/XmbFontImp.cc')
-rw-r--r--src/FbTk/XmbFontImp.cc82
1 files changed, 74 insertions, 8 deletions
diff --git a/src/FbTk/XmbFontImp.cc b/src/FbTk/XmbFontImp.cc
index e923040..f33942a 100644
--- a/src/FbTk/XmbFontImp.cc
+++ b/src/FbTk/XmbFontImp.cc
@@ -25,7 +25,8 @@
25 25
26#include "App.hh" 26#include "App.hh"
27#include "StringUtil.hh" 27#include "StringUtil.hh"
28#include "FbDrawable.hh" 28#include "FbPixmap.hh"
29#include "GContext.hh"
29 30
30#ifdef HAVE_CONFIG_H 31#ifdef HAVE_CONFIG_H
31#include "config.h" 32#include "config.h"
@@ -56,6 +57,8 @@
56 #include <string.h> 57 #include <string.h>
57#endif 58#endif
58 59
60#include <X11/Xlib.h>
61
59using namespace std; 62using namespace std;
60 63
61namespace { 64namespace {
@@ -183,24 +186,87 @@ bool XmbFontImp::load(const std::string &fontname) {
183 return true; 186 return true;
184} 187}
185 188
186void XmbFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *text, 189void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const char *text,
187 size_t len, int x, int y, FbTk::Orientation orient) const { 190 size_t len, int x, int y, FbTk::Orientation orient) const {
188 191
189 if (m_fontset == 0) 192 if (m_fontset == 0)
190 return; 193 return;
191 194
195 if (orient == ROT0) {
196#ifdef X_HAVE_UTF8_STRING
197 if (m_utf8mode) {
198 Xutf8DrawString(d.display(), d.drawable(), m_fontset,
199 main_gc, x, y,
200 text, len);
201 } else
202#endif //X_HAVE_UTF8_STRING
203 {
204 XmbDrawString(d.display(), d.drawable(), m_fontset,
205 main_gc, x, y,
206 text, len);
207 }
208 return;
209 }
210
211 Display *dpy = App::instance()->display();
212 Window rootwin = DefaultRootWindow(dpy);
213
214 int xpos = x, ypos = y;
215 unsigned int w = d.width();
216 unsigned int h = d.height();
217
218 translateSize(orient, w, h);
219 untranslateCoords(orient, xpos, ypos, w, h);
220
221 // not straight forward, we actually draw it elsewhere, then rotate it
222 FbTk::FbPixmap canvas(rootwin, w, h, 1);
223
224 // create graphic context for our canvas
225 FbTk::GContext font_gc(canvas);
226 font_gc.setBackground(None);
227 font_gc.setForeground(None);
228
229 XFillRectangle(dpy, canvas.drawable(), font_gc.gc(), 0, 0, canvas.width(), canvas.height());
230 font_gc.setForeground(1);
231
232
192#ifdef X_HAVE_UTF8_STRING 233#ifdef X_HAVE_UTF8_STRING
193 if (m_utf8mode) { 234 if (m_utf8mode) {
194 Xutf8DrawString(w.display(), w.drawable(), m_fontset, 235 Xutf8DrawString(dpy, canvas.drawable(), m_fontset,
195 gc, x, y, 236 font_gc.gc(), xpos, ypos,
196 text, len); 237 text, len);
197 } else 238 } else
198#endif //X_HAVE_UTF8_STRING 239#endif //X_HAVE_UTF8_STRING
199 { 240 {
200 XmbDrawString(w.display(), w.drawable(), m_fontset, 241 XmbDrawString(dpy, canvas.drawable(), m_fontset,
201 gc, x, y, 242 font_gc.gc(), xpos, ypos,
202 text, len); 243 text, len);
203 } 244 }
245
246 canvas.rotate(orient);
247
248 GC my_gc = XCreateGC(dpy, d.drawable(), 0, 0);
249
250 XCopyGC(dpy, main_gc, GCForeground|GCBackground, my_gc);
251
252 // vertical or upside down
253
254 XSetFillStyle(dpy, my_gc, FillStippled);
255
256 // vertical or upside down
257
258 XSetFillStyle(dpy, my_gc, FillStippled);
259
260 XSetStipple(dpy, my_gc, canvas.drawable());
261
262 XSetTSOrigin(dpy, my_gc, 0, 0);
263
264 XFillRectangle(dpy, d.drawable(), my_gc, 0, 0,
265 canvas.width(),
266 canvas.height());
267
268 XFreeGC(dpy, my_gc);
269
204} 270}
205 271
206unsigned int XmbFontImp::textWidth(const char * const text, unsigned int len) const { 272unsigned int XmbFontImp::textWidth(const char * const text, unsigned int len) const {