aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/XftFontImp.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-09-11 23:01:34 (GMT)
committerfluxgen <fluxgen>2004-09-11 23:01:34 (GMT)
commit049e40c9eb6e6e8651b171a2a78465398c87f6a1 (patch)
tree7aef9d57e82336221d6d953617c7a5d53ee95db0 /src/FbTk/XftFontImp.cc
parentacd2176355876a7bb7afe9d026f9780a3d1c2737 (diff)
downloadfluxbox-049e40c9eb6e6e8651b171a2a78465398c87f6a1.zip
fluxbox-049e40c9eb6e6e8651b171a2a78465398c87f6a1.tar.bz2
Font::drawText takes reference to FbDrawable instead of X Drawable + some code cleaning
Diffstat (limited to 'src/FbTk/XftFontImp.cc')
-rw-r--r--src/FbTk/XftFontImp.cc37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc
index bf0aaa1..3d79dcc 100644
--- a/src/FbTk/XftFontImp.cc
+++ b/src/FbTk/XftFontImp.cc
@@ -1,5 +1,5 @@
1// XftFontImp.cc Xft font implementation for FbTk 1// XftFontImp.cc Xft font implementation for FbTk
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen@linuxmail.org)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
@@ -19,10 +19,11 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: XftFontImp.cc,v 1.5 2004/09/10 16:12:49 akir Exp $ 22//$Id: XftFontImp.cc,v 1.6 2004/09/11 22:58:20 fluxgen Exp $
23 23
24#include "XftFontImp.hh" 24#include "XftFontImp.hh"
25#include "App.hh" 25#include "App.hh"
26#include "FbDrawable.hh"
26 27
27#ifdef HAVE_CONFIG_H 28#ifdef HAVE_CONFIG_H
28#include "config.h" 29#include "config.h"
@@ -32,6 +33,7 @@ namespace FbTk {
32 33
33XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0), 34XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0),
34 m_utf8mode(utf8) { 35 m_utf8mode(utf8) {
36
35 if (name != 0) 37 if (name != 0)
36 load(name); 38 load(name);
37} 39}
@@ -61,25 +63,24 @@ bool XftFontImp::load(const std::string &name) {
61 return true; 63 return true;
62} 64}
63 65
64void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { 66void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y) const {
65 if (m_xftfont == 0) 67 if (m_xftfont == 0)
66 return; 68 return;
67 Display *disp = App::instance()->display(); 69 XftDraw *draw = XftDrawCreate(w.display(),
68 XftDraw *draw = XftDrawCreate(disp, 70 w.drawable(),
69 w, 71 DefaultVisual(w.display(), screen),
70 DefaultVisual(disp, screen), 72 DefaultColormap(w.display(), screen));
71 DefaultColormap(disp, screen));
72 73
73 XGCValues gc_val; 74 XGCValues gc_val;
74 75
75 // get foreground pixel value and convert it to XRenderColor value 76 // get foreground pixel value and convert it to XRenderColor value
76 // TODO: we should probably check return status 77 // TODO: we should probably check return status
77 XGetGCValues(disp, gc, GCForeground, &gc_val); 78 XGetGCValues(w.display(), gc, GCForeground, &gc_val);
78 79
79 // get red, green, blue values 80 // get red, green, blue values
80 XColor xcol; 81 XColor xcol;
81 xcol.pixel = gc_val.foreground; 82 xcol.pixel = gc_val.foreground;
82 XQueryColor(disp, DefaultColormap(disp, screen), &xcol); 83 XQueryColor(w.display(), DefaultColormap(w.display(), screen), &xcol);
83 84
84 // convert xcolor to XftColor 85 // convert xcolor to XftColor
85 XRenderColor rendcol; 86 XRenderColor rendcol;
@@ -88,7 +89,9 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
88 rendcol.blue = xcol.blue; 89 rendcol.blue = xcol.blue;
89 rendcol.alpha = 0xFFFF; 90 rendcol.alpha = 0xFFFF;
90 XftColor xftcolor; 91 XftColor xftcolor;
91 XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), 92 XftColorAllocValue(w.display(),
93 DefaultVisual(w.display(), screen),
94 DefaultColormap(w.display(), screen),
92 &rendcol, &xftcolor); 95 &rendcol, &xftcolor);
93 96
94 // draw string 97 // draw string
@@ -97,7 +100,7 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
97 // check the string size, 100 // check the string size,
98 // if the size is zero we use the XftDrawString8 function instead. 101 // if the size is zero we use the XftDrawString8 function instead.
99 XGlyphInfo ginfo; 102 XGlyphInfo ginfo;
100 XftTextExtentsUtf8(App::instance()->display(), 103 XftTextExtentsUtf8(w.display(),
101 m_xftfont, 104 m_xftfont,
102 (XftChar8 *)text, len, 105 (XftChar8 *)text, len,
103 &ginfo); 106 &ginfo);
@@ -107,8 +110,9 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
107 m_xftfont, 110 m_xftfont,
108 x, y, 111 x, y,
109 (XftChar8 *)(text), len); 112 (XftChar8 *)(text), len);
110 XftColorFree(disp, DefaultVisual(disp, screen), 113 XftColorFree(w.display(),
111 DefaultColormap(disp, screen), &xftcolor); 114 DefaultVisual(w.display(), screen),
115 DefaultColormap(w.display(), screen), &xftcolor);
112 XftDrawDestroy(draw); 116 XftDrawDestroy(draw);
113 return; 117 return;
114 } 118 }
@@ -122,8 +126,9 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
122 (XftChar8 *)(text), len); 126 (XftChar8 *)(text), len);
123 127
124 128
125 XftColorFree(disp, DefaultVisual(disp, screen), 129 XftColorFree(w.display(),
126 DefaultColormap(disp, screen), &xftcolor); 130 DefaultVisual(w.display(), screen),
131 DefaultColormap(w.display(), screen), &xftcolor);
127 XftDrawDestroy(draw); 132 XftDrawDestroy(draw);
128} 133}
129 134