aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorakir <akir>2004-09-10 16:12:01 (GMT)
committerakir <akir>2004-09-10 16:12:01 (GMT)
commit97d2577f1a2861113f9755260ef0225618056a06 (patch)
tree8a0ed387627152a6ef52142a317d8e81341d600e /src
parentb453d143bbc9445aa8e498bdbc73ed1d71040f09 (diff)
downloadfluxbox_pavel-97d2577f1a2861113f9755260ef0225618056a06.zip
fluxbox_pavel-97d2577f1a2861113f9755260ef0225618056a06.tar.bz2
cosmetic issues, removed unneeded strcasestr-code (is already in StringUtil),
tried to avoid App::instance()->display() calls again.
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/XmbFontImp.cc55
1 files changed, 19 insertions, 36 deletions
diff --git a/src/FbTk/XmbFontImp.cc b/src/FbTk/XmbFontImp.cc
index c8a6291..0f66802 100644
--- a/src/FbTk/XmbFontImp.cc
+++ b/src/FbTk/XmbFontImp.cc
@@ -1,6 +1,6 @@
1// XmbFontImp.cc for FbTk fluxbox toolkit 1// XmbFontImp.cc for FbTk fluxbox toolkit
2// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) 2// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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"),
6// to deal in the Software without restriction, including without limitation 6// to deal in the Software without restriction, including without limitation
@@ -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: XmbFontImp.cc,v 1.11 2004/09/03 17:05:35 rathnor Exp $ 22// $Id: XmbFontImp.cc,v 1.12 2004/09/10 16:12:01 akir Exp $
23 23
24#include "XmbFontImp.hh" 24#include "XmbFontImp.hh"
25 25
@@ -59,25 +59,6 @@ using namespace std;
59 59
60namespace { 60namespace {
61 61
62#ifndef HAVE_STRCASESTR
63//!! TODO this is moved to StringUtil
64// Tries to find a string in another and
65// ignoring the case of the characters
66// Returns 0 on success else pointer to str.
67const char *strcasestr(const char *str, const char *ptn) {
68 const char *s2, *p2;
69 for( ; *str; str++) {
70 for(s2=str, p2=ptn; ; s2++,p2++) {
71 // check if we reached the end of ptn, if so, return str
72 if (!*p2) return str;
73 // check if the chars match(ignoring case)
74 if (toupper(*s2) != toupper(*p2)) break;
75 }
76 }
77 return 0;
78}
79#endif //HAVE_STRCASESTR
80
81const char *getFontSize(const char *pattern, int *size) { 62const char *getFontSize(const char *pattern, int *size) {
82 const char *p; 63 const char *p;
83 const char *p2=0; 64 const char *p2=0;
@@ -178,13 +159,13 @@ XFontSet createFontSet(const char *fontname, bool utf8mode) {
178 "-r-", "-i-", "-o-", "-ri-", "-ro-", NULL); 159 "-r-", "-i-", "-o-", "-ri-", "-ro-", NULL);
179 getFontSize(fontname, &pixel_size); 160 getFontSize(fontname, &pixel_size);
180 161
181 if (! strcmp(weight, "*")) 162 if (! strcmp(weight, "*"))
182 strncpy(weight, "medium", FONT_ELEMENT_SIZE); 163 strncpy(weight, "medium", FONT_ELEMENT_SIZE);
183 if (! strcmp(slant, "*")) 164 if (! strcmp(slant, "*"))
184 strncpy(slant, "r", FONT_ELEMENT_SIZE); 165 strncpy(slant, "r", FONT_ELEMENT_SIZE);
185 if (pixel_size < 3) 166 if (pixel_size < 3)
186 pixel_size = 3; 167 pixel_size = 3;
187 else if (pixel_size > 97) 168 else if (pixel_size > 97)
188 pixel_size = 97; 169 pixel_size = 97;
189 170
190 buf_size = strlen(fontname) + (FONT_ELEMENT_SIZE * 2) + 64; 171 buf_size = strlen(fontname) + (FONT_ELEMENT_SIZE * 2) + 64;
@@ -240,26 +221,28 @@ bool XmbFontImp::load(const std::string &fontname) {
240 m_fontset = set; 221 m_fontset = set;
241 m_setextents = XExtentsOfFontSet(m_fontset); 222 m_setextents = XExtentsOfFontSet(m_fontset);
242 223
243 return true; 224 return true;
244} 225}
245 226
246void XmbFontImp::drawText(Drawable w, int screen, GC gc, const char *text, 227void XmbFontImp::drawText(Drawable w, int screen, GC gc, const char *text,
247 size_t len, int x, int y) const { 228 size_t len, int x, int y) const {
248 229
249 if (text == 0 || len == 0 || w == 0 || m_fontset == 0) 230 if (text == 0 || len == 0 || w == 0 || m_fontset == 0)
250 return; 231 return;
232
233 Display* disp = App::instance()->display();
251#ifdef X_HAVE_UTF8_STRING 234#ifdef X_HAVE_UTF8_STRING
252 if (m_utf8mode) { 235 if (m_utf8mode) {
253 Xutf8DrawString(App::instance()->display(), w, m_fontset, 236 Xutf8DrawString(disp, w, m_fontset,
254 gc, x, y, 237 gc, x, y,
255 text, len); 238 text, len);
256 } else 239 } else
257#endif //X_HAVE_UTF8_STRING 240#endif //X_HAVE_UTF8_STRING
258 { 241 {
259 XmbDrawString(App::instance()->display(), w, m_fontset, 242 XmbDrawString(disp, w, m_fontset,
260 gc, x, y, 243 gc, x, y,
261 text, len); 244 text, len);
262 } 245 }
263} 246}
264 247
265unsigned int XmbFontImp::textWidth(const char * const text, unsigned int len) const { 248unsigned int XmbFontImp::textWidth(const char * const text, unsigned int len) const {