aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r--src/Toolbar.cc142
1 files changed, 75 insertions, 67 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index b88abf2..856c8e6 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Toolbar.cc,v 1.55 2003/01/12 18:53:16 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.56 2003/02/15 02:00:29 fluxgen Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
@@ -181,7 +181,11 @@ Toolbar::Toolbar(BScreen *scrn, size_t width):
181 hide_timer(&hide_handler), 181 hide_timer(&hide_handler),
182 m_toolbarmenu(*scrn->menuTheme(), scrn->getScreenNumber(), *scrn->getImageControl()), 182 m_toolbarmenu(*scrn->menuTheme(), scrn->getScreenNumber(), *scrn->getImageControl()),
183 m_theme(scrn->getScreenNumber()), 183 m_theme(scrn->getScreenNumber()),
184 m_place(BOTTOMCENTER) { 184 m_place(BOTTOMCENTER),
185 m_themelistener(*this) {
186
187 // we need to get notified when the theme is reloaded
188 m_theme.addListener(m_themelistener);
185 189
186 setupMenus(*this); 190 setupMenus(*this);
187 191
@@ -412,7 +416,8 @@ void Toolbar::reconfigure() {
412 frame.base = None; 416 frame.base = None;
413 frame.window.setBackgroundColor(texture->color()); 417 frame.window.setBackgroundColor(texture->color());
414 } else { 418 } else {
415 frame.base = image_ctrl.renderImage(frame.window.width(), frame.window.height(), *texture); 419 frame.base = image_ctrl.renderImage(frame.window.width(),
420 frame.window.height(), *texture);
416 frame.window.setBackgroundPixmap(frame.base); 421 frame.window.setBackgroundPixmap(frame.base);
417 } 422 }
418 if (tmp) image_ctrl.removeImage(tmp); 423 if (tmp) image_ctrl.removeImage(tmp);
@@ -424,7 +429,8 @@ void Toolbar::reconfigure() {
424 frame.window_label.setBackgroundColor(texture->color()); 429 frame.window_label.setBackgroundColor(texture->color());
425 } else { 430 } else {
426 frame.label = 431 frame.label =
427 image_ctrl.renderImage(frame.window_label.width(), frame.window_label.height(), *texture); 432 image_ctrl.renderImage(frame.window_label.width(),
433 frame.window_label.height(), *texture);
428 frame.window_label.setBackgroundPixmap(frame.label); 434 frame.window_label.setBackgroundPixmap(frame.label);
429 } 435 }
430 if (tmp) image_ctrl.removeImage(tmp); 436 if (tmp) image_ctrl.removeImage(tmp);
@@ -562,75 +568,77 @@ void Toolbar::checkClock(bool redraw, bool date) {
562 cerr<<__FILE__<<"("<<__LINE__<<"): time(null)<0"<<endl; 568 cerr<<__FILE__<<"("<<__LINE__<<"): time(null)<0"<<endl;
563 569
564 570
565 if (redraw) { 571 if (!redraw)
566 frame.clock.clear(); 572 return;
573
574 frame.clock.clear();
567#ifdef HAVE_STRFTIME 575#ifdef HAVE_STRFTIME
568 char t[1024]; 576 char t[1024];
569 if (! strftime(t, 1024, screen()->getStrftimeFormat(), tt)) 577 if (! strftime(t, 1024, screen()->getStrftimeFormat(), tt))
570 return; 578 return;
571#else // !HAVE_STRFTIME 579#else // !HAVE_STRFTIME
572 char t[9]; 580 char t[9];
573 if (date) { 581 if (date) {
574 // format the date... with special consideration for y2k ;) 582 // format the date... with special consideration for y2k ;)
575 if (screen()->getDateFormat() == Blackbox::B_EuropeanDate) { 583 if (screen()->getDateFormat() == Blackbox::B_EuropeanDate) {
576 sprintf(t, 584 sprintf(t,
577 i18n->getMessage( 585 i18n->getMessage(
578 ToolbarSet, ToolbarNoStrftimeDateFormatEu, 586 ToolbarSet, ToolbarNoStrftimeDateFormatEu,
579 "%02d.%02d.%02d"), 587 "%02d.%02d.%02d"),
580 tt->tm_mday, tt->tm_mon + 1, 588 tt->tm_mday, tt->tm_mon + 1,
581 (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year); 589 (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
582 } else {
583 sprintf(t,
584 i18n->getMessage(
585 ToolbarSet, ToolbarNoStrftimeDateFormat,
586 "%02d/%02d/%02d"),
587 tt->tm_mon + 1, tt->tm_mday,
588 (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
589 }
590 } else { 590 } else {
591 if (screen()->isClock24Hour()) { 591 sprintf(t,
592 sprintf(t, 592 i18n->getMessage(
593 i18n->getMessage( 593 ToolbarSet, ToolbarNoStrftimeDateFormat,
594 ToolbarSet, ToolbarNoStrftimeTimeFormat24, 594 "%02d/%02d/%02d"),
595 " %02d:%02d "), 595 tt->tm_mon + 1, tt->tm_mday,
596 frame.hour, frame.minute); 596 (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
597 } else { 597 }
598 sprintf(t, 598 } else {
599 i18n->getMessage( 599 if (screen()->isClock24Hour()) {
600 ToolbarSet, ToolbarNoStrftimeTimeFormat12, 600 sprintf(t,
601 "%02d:%02d %sm"), 601 i18n->getMessage(
602 ((frame.hour > 12) ? frame.hour - 12 : 602 ToolbarSet, ToolbarNoStrftimeTimeFormat24,
603 ((frame.hour == 0) ? 12 : frame.hour)), frame.minute, 603 " %02d:%02d "),
604 ((frame.hour >= 12) ? 604 frame.hour, frame.minute);
605 i18n->getMessage( 605 } else {
606 ToolbarSet, ToolbarNoStrftimeTimeFormatP, 606 sprintf(t,
607 "p") : 607 i18n->getMessage(
608 i18n->getMessage( 608 ToolbarSet, ToolbarNoStrftimeTimeFormat12,
609 ToolbarSet, ToolbarNoStrftimeTimeFormatA, 609 "%02d:%02d %sm"),
610 "a"))); 610 ((frame.hour > 12) ? frame.hour - 12 :
611 } 611 ((frame.hour == 0) ? 12 : frame.hour)), frame.minute,
612 ((frame.hour >= 12) ?
613 i18n->getMessage(
614 ToolbarSet, ToolbarNoStrftimeTimeFormatP,
615 "p") :
616 i18n->getMessage(
617 ToolbarSet, ToolbarNoStrftimeTimeFormatA,
618 "a")));
612 } 619 }
620 }
613#endif // HAVE_STRFTIME 621#endif // HAVE_STRFTIME
614 622
615 size_t newlen = strlen(t); 623 size_t newlen = strlen(t);
616 int dx = FbTk::doAlignment(frame.clock_w, 624 int dx = FbTk::doAlignment(frame.clock_w,
617 frame.bevel_w*2, 625 frame.bevel_w*2,
618 m_theme.justify(), 626 m_theme.justify(),
619 m_theme.font(), 627 m_theme.font(),
620 t, strlen(t), newlen); 628 t, strlen(t), newlen);
621 int dy = 1 + m_theme.font().ascent(); 629 int dy = 1 + m_theme.font().ascent();
622 if (m_theme.font().isRotated()) { 630 if (m_theme.font().isRotated()) {
623 int tmp = dy; 631 int tmp = dy;
624 dy = frame.clock.height() - dx; 632 dy = frame.clock.height() - dx;
625 dx = tmp; 633 dx = tmp;
626 } 634 }
627 m_theme.font().drawText( 635 m_theme.font().drawText(
628 frame.clock.window(), 636 frame.clock.window(),
629 screen()->getScreenNumber(), 637 screen()->getScreenNumber(),
630 m_theme.clockTextGC(), 638 m_theme.clockTextGC(),
631 t, newlen, 639 t, newlen,
632 dx, dy); 640 dx, dy);
633 } 641
634} 642}
635 643
636 644