grow the clock if the text gets too big
simonb simonb
2 files changed,
12 insertions(+),
1 deletions(-)
M
ChangeLog
→
ChangeLog
@@ -1,6 +1,9 @@
(Format: Year/Month/Day) Changes for 0.9.16: *06/04/17: + * Resize the clock if the text gets too big, sf.net patch #1436406 + (thanks Geoff Lywood - glywood at users.sourceforge.net) + ClockTool.cc * Fix some rotated toolbar+textbutton issues (Simon) Toolbar.cc IconbarTool.cc FbTk/TextButton.cc * Fix /bin/sh portability for fbsetbg and startfluxbox (Simon)
M
src/ClockTool.cc
→
src/ClockTool.cc
@@ -249,14 +249,22 @@ time_t the_time = time(0);
if (the_time != -1) { char time_string[255]; + int time_string_len; struct tm *time_type = localtime(&the_time); if (time_type == 0) return; #ifdef HAVE_STRFTIME - if (!strftime(time_string, 255, m_timeformat->c_str(), time_type) || m_button.text() == time_string) + time_string_len = strftime(time_string, 255, m_timeformat->c_str(), time_type); + if( time_string_len == 0 || m_button.text() == time_string) return; m_button.setText(time_string); + + int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2; + if (new_width > m_button.width()) { + resize(new_width, m_button.height()); + resizeSig().notify(); + } #else // dont have strftime so we have to set it to hour:minut // sprintf(time_string, "%d:%d", ); #endif // HAVE_STRFTIME