From 2566f7014db4dc1dc42ea19b28f945bf018cdd51 Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 8 Apr 2007 18:12:08 +0000 Subject: fix for determining the width of clock (copied from Simon's commit to trunk) --- ChangeLog | 4 ++++ src/ClockTool.cc | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d77590b..4ed32dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,10 @@ Changes for 1.1: * Buttons with different textures when pressed weren't getting reset properly (Mark) FbTk/Button.cc + * Only replace numbers with zeros when calculating clock width (Simon) + Otherwise width of things in proportional fonts can be way out. + sf.net bug #1545066. + ClockTool.cc *07/04/06: * More changes to theme handling (Mark) - introduced window.label.(un)focused.{justify,border{Color,Width}}, diff --git a/src/ClockTool.cc b/src/ClockTool.cc index 6e06ed6..0bfa136 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -220,7 +220,17 @@ void ClockTool::update(FbTk::Subject *subj) { updateTime(); // + 2 to make the entire text fit inside - std::string text(m_button.text().size() + 2, '0'); + // we only replace numbers with zeros because everything else should be + // relatively static. If we replace all text with zeros then widths of + // proportional fonts with some strftime formats will be considerably off. + std::string text(m_button.text()); + + int textlen = text.size(); + for (int i=0; i < textlen; ++i) { + if (isdigit(text[i])) // don't bother replacing zeros + text[i] = '0'; + } + text.append("00"); // pad unsigned int new_width = m_button.width(); unsigned int new_height = m_button.height(); -- cgit v0.11.2