aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-08 18:48:01 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-08 18:48:01 (GMT)
commit26c1cd0ceeb289abdf9ddfecdc699a27db8b0339 (patch)
tree8c71509d438106a831526645d418c889d1ce54ad
parent08bd29d0d83756944b35a312497fbadcde9d74fe (diff)
downloadfluxbox-26c1cd0ceeb289abdf9ddfecdc699a27db8b0339.zip
fluxbox-26c1cd0ceeb289abdf9ddfecdc699a27db8b0339.tar.bz2
code simplification
-rw-r--r--src/FbTk/XFontImp.cc23
-rw-r--r--src/FbTk/XFontImp.hh2
-rw-r--r--src/FbTk/XmbFontImp.cc4
3 files changed, 11 insertions, 18 deletions
diff --git a/src/FbTk/XFontImp.cc b/src/FbTk/XFontImp.cc
index fa88593..73ae384 100644
--- a/src/FbTk/XFontImp.cc
+++ b/src/FbTk/XFontImp.cc
@@ -102,14 +102,14 @@ void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char* text
102 if (!text || !*text || m_fontstruct == 0) 102 if (!text || !*text || m_fontstruct == 0)
103 return; 103 return;
104 104
105 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, len));
106
105 // use roated font functions? 107 // use roated font functions?
106 if (orient != ROT0 && validOrientation(orient)) { 108 if (orient != ROT0 && validOrientation(orient)) {
107 drawRotText(w.drawable(), screen, gc, text, len, x, y, orient); 109 drawRotText(w.drawable(), screen, gc, localestr.c_str(), localestr.size(), x, y, orient);
108 return; 110 return;
109 } 111 }
110 112
111 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, 0, len));
112
113 XSetFont(w.display(), gc, m_fontstruct->fid); 113 XSetFont(w.display(), gc, m_fontstruct->fid);
114 XDrawString(w.display(), w.drawable(), gc, x, y, localestr.data(), localestr.size()); 114 XDrawString(w.display(), w.drawable(), gc, x, y, localestr.data(), localestr.size());
115} 115}
@@ -330,7 +330,10 @@ void XFontImp::freeRotFont(XRotFontStruct *rotfont) {
330 rotfont = 0; 330 rotfont = 0;
331} 331}
332 332
333void XFontImp::drawRotText(Drawable w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { 333void XFontImp::drawRotText(Drawable w, int screen, GC gc, const char* text, size_t len, int x, int y, FbTk::Orientation orient) const {
334
335 if (!text || !*text || len<1)
336 return;
334 337
335 Display *dpy = App::instance()->display(); 338 Display *dpy = App::instance()->display();
336 static GC my_gc = 0; 339 static GC my_gc = 0;
@@ -338,27 +341,17 @@ void XFontImp::drawRotText(Drawable w, int screen, GC gc, const FbString &text,
338 341
339 XRotFontStruct *rotfont = m_rotfonts[orient]; 342 XRotFontStruct *rotfont = m_rotfonts[orient];
340 343
341 if (text.empty() || len<1)
342 return;
343
344 if (my_gc == 0) 344 if (my_gc == 0)
345 my_gc = XCreateGC(dpy, w, 0, 0); 345 my_gc = XCreateGC(dpy, w, 0, 0);
346 346
347 XCopyGC(dpy, gc, GCForeground|GCBackground, my_gc); 347 XCopyGC(dpy, gc, GCForeground|GCBackground, my_gc);
348 348
349 // vertical or upside down 349 // vertical or upside down
350
351 XSetFillStyle(dpy, my_gc, FillStippled); 350 XSetFillStyle(dpy, my_gc, FillStippled);
352 string localestr = text;
353 localestr.erase(len, string::npos);
354 localestr = FbStringUtil::FbStrToLocale(localestr);
355 const char *ctext = localestr.data();
356 len = localestr.size();
357
358 351
359 // loop through each character in texting 352 // loop through each character in texting
360 for (size_t i = 0; i<len; i++) { 353 for (size_t i = 0; i<len; i++) {
361 ichar = ctext[i]-32; 354 ichar = text[i]-32;
362 355
363 // make sure it's a printing character 356 // make sure it's a printing character
364 if (ichar >= 0 && ichar<95) { 357 if (ichar >= 0 && ichar<95) {
diff --git a/src/FbTk/XFontImp.hh b/src/FbTk/XFontImp.hh
index ccebbb7..600bb68 100644
--- a/src/FbTk/XFontImp.hh
+++ b/src/FbTk/XFontImp.hh
@@ -72,7 +72,7 @@ private:
72 void rotate(FbTk::Orientation orient); 72 void rotate(FbTk::Orientation orient);
73 73
74 void freeRotFont(XRotFontStruct * rotfont); 74 void freeRotFont(XRotFontStruct * rotfont);
75 void drawRotText(Drawable w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const; 75 void drawRotText(Drawable w, int screen, GC gc, const char* text, size_t len, int x, int y, FbTk::Orientation orient) const;
76 76
77 XRotFontStruct *m_rotfonts[4]; ///< rotated font structure (only 3 used) 77 XRotFontStruct *m_rotfonts[4]; ///< rotated font structure (only 3 used)
78 bool m_rotfonts_loaded[4]; // whether we've tried yet 78 bool m_rotfonts_loaded[4]; // whether we've tried yet
diff --git a/src/FbTk/XmbFontImp.cc b/src/FbTk/XmbFontImp.cc
index 7613a40..8f2bdf9 100644
--- a/src/FbTk/XmbFontImp.cc
+++ b/src/FbTk/XmbFontImp.cc
@@ -204,7 +204,7 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const cha
204 } else 204 } else
205#endif //X_HAVE_UTF8_STRING 205#endif //X_HAVE_UTF8_STRING
206 { 206 {
207 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, 0, len)); 207 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, len));
208 XmbDrawString(d.display(), d.drawable(), m_fontset, 208 XmbDrawString(d.display(), d.drawable(), m_fontset,
209 main_gc, x, y, 209 main_gc, x, y,
210 localestr.data(), localestr.size()); 210 localestr.data(), localestr.size());
@@ -241,7 +241,7 @@ void XmbFontImp::drawText(const FbDrawable &d, int screen, GC main_gc, const cha
241 } else 241 } else
242#endif //X_HAVE_UTF8_STRING 242#endif //X_HAVE_UTF8_STRING
243 { 243 {
244 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, 0, len)); 244 std::string localestr = FbStringUtil::FbStrToLocale(FbString(text, len));
245 XmbDrawString(dpy, canvas.drawable(), m_fontset, 245 XmbDrawString(dpy, canvas.drawable(), m_fontset,
246 font_gc.gc(), xpos, ypos, 246 font_gc.gc(), xpos, ypos,
247 localestr.data(), localestr.size()); 247 localestr.data(), localestr.size());