diff options
author | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
commit | 28b5c604490094e187494dcc566bd3d7a05a2c25 (patch) | |
tree | 8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/FbTk/XftFontImp.cc | |
parent | b9134162f9633784d9097df18769a699a62650fe (diff) | |
download | fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.zip fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2 |
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/FbTk/XftFontImp.cc')
-rw-r--r-- | src/FbTk/XftFontImp.cc | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc index 0a68518..59f8440 100644 --- a/src/FbTk/XftFontImp.cc +++ b/src/FbTk/XftFontImp.cc | |||
@@ -19,7 +19,7 @@ | |||
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.1 2002/11/26 16:01:27 fluxgen Exp $ | 22 | //$Id: XftFontImp.cc,v 1.2 2002/12/01 13:42:15 rathnor Exp $ |
23 | 23 | ||
24 | #include "XftFontImp.hh" | 24 | #include "XftFontImp.hh" |
25 | #include "App.hh" | 25 | #include "App.hh" |
@@ -30,114 +30,114 @@ | |||
30 | namespace FbTk { | 30 | namespace FbTk { |
31 | 31 | ||
32 | XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0), | 32 | XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0), |
33 | m_utf8mode(utf8) { | 33 | m_utf8mode(utf8) { |
34 | if (name != 0) | 34 | if (name != 0) |
35 | load(name); | 35 | load(name); |
36 | } | 36 | } |
37 | 37 | ||
38 | XftFontImp::~XftFontImp() { | 38 | XftFontImp::~XftFontImp() { |
39 | if (m_xftfont != 0) | 39 | if (m_xftfont != 0) |
40 | XftFontClose(App::instance()->display(), m_xftfont); | 40 | XftFontClose(App::instance()->display(), m_xftfont); |
41 | } | 41 | } |
42 | 42 | ||
43 | bool XftFontImp::load(const std::string &name) { | 43 | bool XftFontImp::load(const std::string &name) { |
44 | //Note: assumes screen 0 for now, changes on draw if needed | 44 | //Note: assumes screen 0 for now, changes on draw if needed |
45 | 45 | ||
46 | Display *disp = App::instance()->display(); | 46 | Display *disp = App::instance()->display(); |
47 | XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str()); | 47 | XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str()); |
48 | 48 | ||
49 | if (newxftfont == 0) { // failed to open font, lets test with XLFD | 49 | if (newxftfont == 0) { // failed to open font, lets test with XLFD |
50 | newxftfont = XftFontOpenXlfd(disp, 0, name.c_str()); | 50 | newxftfont = XftFontOpenXlfd(disp, 0, name.c_str()); |
51 | if (newxftfont == 0) | 51 | if (newxftfont == 0) |
52 | return false; | 52 | return false; |
53 | } | 53 | } |
54 | // destroy old font and set new | 54 | // destroy old font and set new |
55 | if (m_xftfont != 0) | 55 | if (m_xftfont != 0) |
56 | XftFontClose(disp, m_xftfont); | 56 | XftFontClose(disp, m_xftfont); |
57 | 57 | ||
58 | m_xftfont = newxftfont; | 58 | m_xftfont = newxftfont; |
59 | 59 | ||
60 | return true; | 60 | return true; |
61 | } | 61 | } |
62 | 62 | ||
63 | void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { | 63 | void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { |
64 | if (m_xftfont == 0) | 64 | if (m_xftfont == 0) |
65 | return; | 65 | return; |
66 | Display *disp = App::instance()->display(); | 66 | Display *disp = App::instance()->display(); |
67 | XftDraw *draw = XftDrawCreate(disp, | 67 | XftDraw *draw = XftDrawCreate(disp, |
68 | w, | 68 | w, |
69 | DefaultVisual(disp, screen), | 69 | DefaultVisual(disp, screen), |
70 | DefaultColormap(disp, screen)); | 70 | DefaultColormap(disp, screen)); |
71 | 71 | ||
72 | XGCValues gc_val; | 72 | XGCValues gc_val; |
73 | 73 | ||
74 | // get foreground pixel value and convert it to XRenderColor value | 74 | // get foreground pixel value and convert it to XRenderColor value |
75 | // TODO: we should probably check return status | 75 | // TODO: we should probably check return status |
76 | XGetGCValues(disp, gc, GCForeground, &gc_val); | 76 | XGetGCValues(disp, gc, GCForeground, &gc_val); |
77 | 77 | ||
78 | // get red, green, blue values | 78 | // get red, green, blue values |
79 | XColor xcol; | 79 | XColor xcol; |
80 | xcol.pixel = gc_val.foreground; | 80 | xcol.pixel = gc_val.foreground; |
81 | XQueryColor(disp, DefaultColormap(disp, screen), &xcol); | 81 | XQueryColor(disp, DefaultColormap(disp, screen), &xcol); |
82 | 82 | ||
83 | // convert xcolor to XftColor | 83 | // convert xcolor to XftColor |
84 | XRenderColor rendcol; | 84 | XRenderColor rendcol; |
85 | rendcol.red = xcol.red; | 85 | rendcol.red = xcol.red; |
86 | rendcol.green = xcol.green; | 86 | rendcol.green = xcol.green; |
87 | rendcol.blue = xcol.blue; | 87 | rendcol.blue = xcol.blue; |
88 | rendcol.alpha = 0xFFFF; | 88 | rendcol.alpha = 0xFFFF; |
89 | XftColor xftcolor; | 89 | XftColor xftcolor; |
90 | XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), | 90 | XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), |
91 | &rendcol, &xftcolor); | 91 | &rendcol, &xftcolor); |
92 | 92 | ||
93 | // draw string | 93 | // draw string |
94 | #ifdef HAVE_XFT_UTF8_STRING | 94 | #ifdef HAVE_XFT_UTF8_STRING |
95 | if (m_utf8mode) { | 95 | if (m_utf8mode) { |
96 | XftDrawStringUtf8(draw, | 96 | XftDrawStringUtf8(draw, |
97 | &xftcolor, | 97 | &xftcolor, |
98 | m_xftfont, | 98 | m_xftfont, |
99 | x, y, | 99 | x, y, |
100 | (XftChar8 *)(text), len); | 100 | (XftChar8 *)(text), len); |
101 | } else | 101 | } else |
102 | #endif // HAVE_XFT_UTF8_STRING | 102 | #endif // HAVE_XFT_UTF8_STRING |
103 | { | 103 | { |
104 | XftDrawString8(draw, | 104 | XftDrawString8(draw, |
105 | &xftcolor, | 105 | &xftcolor, |
106 | m_xftfont, | 106 | m_xftfont, |
107 | x, y, | 107 | x, y, |
108 | (XftChar8 *)(text), len); | 108 | (XftChar8 *)(text), len); |
109 | } | 109 | } |
110 | 110 | ||
111 | XftColorFree(disp, DefaultVisual(disp, screen), | 111 | XftColorFree(disp, DefaultVisual(disp, screen), |
112 | DefaultColormap(disp, screen), &xftcolor); | 112 | DefaultColormap(disp, screen), &xftcolor); |
113 | XftDrawDestroy(draw); | 113 | XftDrawDestroy(draw); |
114 | } | 114 | } |
115 | 115 | ||
116 | unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const { | 116 | unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const { |
117 | if (m_xftfont == 0) | 117 | if (m_xftfont == 0) |
118 | return 0; | 118 | return 0; |
119 | XGlyphInfo ginfo; | 119 | XGlyphInfo ginfo; |
120 | #ifdef HAVE_XFT_UTF8_STRING | 120 | #ifdef HAVE_XFT_UTF8_STRING |
121 | if (m_utf8mode) { | 121 | if (m_utf8mode) { |
122 | XftTextExtentsUtf8(App::instance()->display(), | 122 | XftTextExtentsUtf8(App::instance()->display(), |
123 | m_xftfont, | 123 | m_xftfont, |
124 | (XftChar8 *)text, len, | 124 | (XftChar8 *)text, len, |
125 | &ginfo); | 125 | &ginfo); |
126 | } else | 126 | } else |
127 | #endif //HAVE_XFT_UTF8_STRING | 127 | #endif //HAVE_XFT_UTF8_STRING |
128 | { | 128 | { |
129 | XftTextExtents8(App::instance()->display(), | 129 | XftTextExtents8(App::instance()->display(), |
130 | m_xftfont, | 130 | m_xftfont, |
131 | (XftChar8 *)text, len, | 131 | (XftChar8 *)text, len, |
132 | &ginfo); | 132 | &ginfo); |
133 | } | 133 | } |
134 | return ginfo.xOff; | 134 | return ginfo.xOff; |
135 | } | 135 | } |
136 | 136 | ||
137 | unsigned int XftFontImp::height() const { | 137 | unsigned int XftFontImp::height() const { |
138 | if (m_xftfont == 0) | 138 | if (m_xftfont == 0) |
139 | return 0; | 139 | return 0; |
140 | return m_xftfont->height; | 140 | return m_xftfont->height; |
141 | } | 141 | } |
142 | 142 | ||
143 | }; // end namespace FbTk | 143 | }; // end namespace FbTk |