mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
gui/components/cc_frm_clock: fix label widths for non-standard fonts
Origin commit data
------------------
Commit: c88ad39c67
Author: martii <m4rtii@gmx.de>
Date: 2013-11-29 (Fri, 29 Nov 2013)
This commit is contained in:
@@ -151,7 +151,21 @@ void CComponentsFrmClock::initCCLockItems()
|
||||
}
|
||||
}
|
||||
|
||||
//modifie available lable items with current segment chars
|
||||
int minNumWidth = 0, w_tmp;
|
||||
char b[2];
|
||||
b[1] = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
b[0] = '0' + i;
|
||||
w_tmp = (*getClockFont())->getRenderWidth(b, true);
|
||||
if (w_tmp > minNumWidth)
|
||||
minNumWidth = w_tmp;
|
||||
}
|
||||
int minSepWidth = (*getClockFont())->getRenderWidth(":", true);
|
||||
w_tmp = (*getClockFont())->getRenderWidth(".", true);
|
||||
if (w_tmp > minSepWidth)
|
||||
minSepWidth = w_tmp;
|
||||
|
||||
//modify available label items with current segment chars
|
||||
for (size_t i = 0; i < v_cc_items.size(); i++)
|
||||
{
|
||||
//v_cc_items are only available as CComponent-items here, so we must cast them before
|
||||
@@ -171,7 +185,20 @@ void CComponentsFrmClock::initCCLockItems()
|
||||
string stmp = s_time.substr(i, 1);
|
||||
|
||||
//get width of current segment
|
||||
int wtmp = (*getClockFont())->getRenderWidth(stmp, true);
|
||||
int wtmp;
|
||||
char c = stmp.at(0);
|
||||
switch (c) {
|
||||
case '0' ... '9':
|
||||
wtmp = minNumWidth;
|
||||
break;
|
||||
case '.':
|
||||
case ':':
|
||||
wtmp = minSepWidth;
|
||||
break;
|
||||
default:
|
||||
b[0] = c;
|
||||
wtmp = (*getClockFont())->getRenderWidth(stmp, true);
|
||||
}
|
||||
|
||||
//set size, text, color of current item
|
||||
lbl->setDimensionsAll(cl_x, cl_y, wtmp, cl_h);
|
||||
|
Reference in New Issue
Block a user