mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
CComponentsFrmClock: use only space char for minimal separator width
Calculate of minimal separator width by a space char should be enough
in all cases.
A switch statement should be also unnecessary, if we check for digits.
Origin commit data
------------------
Commit: 08fed0f5d6
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-12-03 (Tue, 03 Dec 2013)
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user