diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index ad0d17d9f..9b960aae7 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -36,6 +36,7 @@ #include #include #include +#include using namespace std; @@ -151,10 +152,9 @@ void CComponentsFrmClock::initCCLockItems() } } + //calculate minimal separator width, we use a space char...should be enough int minSepWidth = 0; - minSepWidth = std::max((*getClockFont())->getRenderWidth(" ", true), minSepWidth); - minSepWidth = std::max((*getClockFont())->getRenderWidth(".", true), minSepWidth); - minSepWidth = std::max((*getClockFont())->getRenderWidth(":", true), minSepWidth); + minSepWidth = max((*getClockFont())->getRenderWidth("\x20", true), minSepWidth); //modify available label items with current segment chars for (size_t i = 0; i < v_cc_items.size(); i++) @@ -176,20 +176,11 @@ void CComponentsFrmClock::initCCLockItems() string stmp = s_time.substr(i, 1); //get width of current segment - int wtmp; - char c = stmp.at(0); - switch (c) { - case '0' ... '9': - wtmp = (*getClockFont())->getMaxDigitWidth(); - break; - case ' ': - case '.': - case ':': - wtmp = minSepWidth; - break; - default: - wtmp = (*getClockFont())->getRenderWidth(stmp, true); - } + int wtmp = 0; + if (isdigit(stmp.at(0)) ) //check for digits, if true, we use digit width + wtmp = (*getClockFont())->getMaxDigitWidth(); + else //not digit found, we use render width or minimal width + wtmp = max((*getClockFont())->getRenderWidth(stmp, true), minSepWidth); //set size, text, color of current item lbl->setDimensionsAll(cl_x, cl_y, wtmp, cl_h);