aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Font.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2006-03-26 04:02:30 (GMT)
committersimonb <simonb>2006-03-26 04:02:30 (GMT)
commitaf74a2284551c8511b66d77112c7bf32831c1522 (patch)
tree35a8830352f5facc1fc9c58b82c0c6dce8fc921e /src/FbTk/Font.cc
parent872f6a0e1e4230f702ad69fa2d7e10a2fa78b7a3 (diff)
downloadfluxbox_pavel-af74a2284551c8511b66d77112c7bf32831c1522.zip
fluxbox_pavel-af74a2284551c8511b66d77112c7bf32831c1522.tar.bz2
rotated fonts, buttons, containers. Used for tabs for now
Diffstat (limited to 'src/FbTk/Font.cc')
-rw-r--r--src/FbTk/Font.cc62
1 files changed, 11 insertions, 51 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc
index 2fff39c..a946915 100644
--- a/src/FbTk/Font.cc
+++ b/src/FbTk/Font.cc
@@ -201,7 +201,6 @@ void Font::shutdown() {
201 201
202Font::Font(const char *name): 202Font::Font(const char *name):
203 m_fontimp(0), 203 m_fontimp(0),
204 m_rotated(false),
205 m_shadow(false), m_shadow_color("black", DefaultScreen(App::instance()->display())), 204 m_shadow(false), m_shadow_color("black", DefaultScreen(App::instance()->display())),
206 m_shadow_offx(2), m_shadow_offy(2), 205 m_shadow_offx(2), m_shadow_offy(2),
207 m_halo(false), m_halo_color("white", DefaultScreen(App::instance()->display())), 206 m_halo(false), m_halo_color("white", DefaultScreen(App::instance()->display())),
@@ -361,9 +360,13 @@ int Font::descent() const {
361 return m_fontimp->descent(); 360 return m_fontimp->descent();
362} 361}
363 362
363bool Font::validOrientation(FbTk::Orientation orient) {
364 return m_fontimp->validOrientation(orient);
365}
366
364void Font::drawText(const FbDrawable &w, int screen, GC gc, 367void Font::drawText(const FbDrawable &w, int screen, GC gc,
365 const char *text, size_t len, int x, int y, 368 const char *text, size_t len, int x, int y,
366 bool rotate) const { 369 Orientation orient) const {
367 if (text == 0 || len == 0) 370 if (text == 0 || len == 0)
368 return; 371 return;
369 372
@@ -391,69 +394,26 @@ void Font::drawText(const FbDrawable &w, int screen, GC gc,
391 shadow_gc.setForeground(m_shadow_color); 394 shadow_gc.setForeground(m_shadow_color);
392 first_run = false; 395 first_run = false;
393 drawText(w, screen, shadow_gc.gc(), real_text, len, 396 drawText(w, screen, shadow_gc.gc(), real_text, len,
394 x + m_shadow_offx, y + m_shadow_offy, rotate); 397 x + m_shadow_offx, y + m_shadow_offy, orient);
395 first_run = true; 398 first_run = true;
396 } else if (m_halo) { 399 } else if (m_halo) {
397 FbTk::GContext halo_gc(w); 400 FbTk::GContext halo_gc(w);
398 halo_gc.setForeground(m_halo_color); 401 halo_gc.setForeground(m_halo_color);
399 first_run = false; 402 first_run = false;
400 drawText(w, screen, halo_gc.gc(), real_text, len, x + 1, y + 1, rotate); 403 drawText(w, screen, halo_gc.gc(), real_text, len, x + 1, y + 1, orient);
401 drawText(w, screen, halo_gc.gc(), real_text, len, x - 1, y + 1, rotate); 404 drawText(w, screen, halo_gc.gc(), real_text, len, x - 1, y + 1, orient);
402 drawText(w, screen, halo_gc.gc(), real_text, len, x - 1, y - 1, rotate); 405 drawText(w, screen, halo_gc.gc(), real_text, len, x - 1, y - 1, orient);
403 drawText(w, screen, halo_gc.gc(), real_text, len, x + 1, y - 1, rotate); 406 drawText(w, screen, halo_gc.gc(), real_text, len, x + 1, y - 1, orient);
404 first_run = true; 407 first_run = true;
405 } 408 }
406 } 409 }
407 410
408 if (!rotate && isRotated()) { 411 m_fontimp->drawText(w, screen, gc, real_text, len, x, y, orient);
409 // if this was called with request to not rotated the text
410 // we just forward it to the implementation that handles rotation
411 // currently just XFontImp
412 // Using dynamic_cast just temporarly until there's a better solution
413 // to put in FontImp
414 try {
415 XFontImp *font = dynamic_cast<XFontImp *>(m_fontimp);
416 font->setRotate(false); // disable rotation temporarly
417
418 font->drawText(w, screen, gc, real_text, len, x, y);
419 font->setRotate(true); // enable rotation
420 } catch (std::bad_cast &bc) {
421 // draw normal...
422 m_fontimp->drawText(w, screen, gc, real_text, len, x, y);
423 }
424
425 } else
426 m_fontimp->drawText(w, screen, gc, real_text, len, x, y);
427 412
428 if (rtext != 0) 413 if (rtext != 0)
429 delete[] rtext; 414 delete[] rtext;
430 415
431} 416}
432 417
433void Font::rotate(float angle) {
434/* TODO: reimplement rotated text
435#ifdef USE_XFT
436 // if we are rotated and we are changing to horiz text
437 // and we were antialiased before we rotated then change to XftFontImp
438 if (isRotated() && angle == 0 && !m_xftfontstr.empty())
439 m_fontimp.reset(new XftFontImp(m_fontstr.c_str(),s_utf8mode));
440#endif // USE_XFT
441 // change to a font imp that handles rotated fonts (i.e just XFontImp at the moment)
442 // if we're going to rotate this font
443 if (angle != 0 && !isRotated()) {
444 m_fontimp.reset(new XFontImp(m_fontstr.c_str()));
445 if (!m_fontimp->loaded()) // if it failed to load font, try default font fixed
446 m_fontimp->load("fixed");
447 }
448
449 //Note: only XFontImp implements FontImp::rotate
450 m_fontimp->rotate(angle);
451
452 m_rotated = (angle == 0 ? false : true);
453 m_angle = angle;
454 */
455}
456
457
458}; 418};
459 419