mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
CComponentsFrmClock: Rework font handling
- Use setClockFont(enum FONT_TYPES) for selection of neutrino fonts
- Use setClockFontSize(size) for Dynamic Font
Origin commit data
------------------
Commit: 1bfb6d2cd3
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-11-27 (Wed, 27 Nov 2013)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include <driver/neutrinofonts.h>
|
||||
|
||||
#include "cc_frm_clock.h"
|
||||
#include <time.h>
|
||||
@@ -70,16 +71,19 @@ CComponentsFrmClock::CComponentsFrmClock( const int x_pos, const int y_pos, cons
|
||||
void CComponentsFrmClock::initVarClock()
|
||||
{
|
||||
initVarForm();
|
||||
cc_item_type = CC_ITEMTYPE_FRM_CLOCK;
|
||||
corner_rad = RADIUS_SMALL;
|
||||
cc_item_type = CC_ITEMTYPE_FRM_CLOCK;
|
||||
corner_rad = RADIUS_SMALL;
|
||||
|
||||
cl_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO];
|
||||
cl_col_text = COL_MENUCONTENT_TEXT;
|
||||
cl_format_str = "%H:%M";
|
||||
cl_align = CC_ALIGN_VER_CENTER | CC_ALIGN_HOR_CENTER;
|
||||
cl_font_type = SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO;
|
||||
cl_font = &g_Font[cl_font_type];
|
||||
dyn_font_size = 0;
|
||||
|
||||
cl_thread = 0;
|
||||
cl_interval = 1;
|
||||
cl_col_text = COL_MENUCONTENT_TEXT;
|
||||
cl_format_str = "%H:%M";
|
||||
cl_align = CC_ALIGN_VER_CENTER | CC_ALIGN_HOR_CENTER;
|
||||
|
||||
cl_thread = 0;
|
||||
cl_interval = 1;
|
||||
}
|
||||
|
||||
CComponentsFrmClock::~CComponentsFrmClock()
|
||||
@@ -117,8 +121,8 @@ void CComponentsFrmClock::initCCLockItems()
|
||||
string s_time = cl_timestr;
|
||||
|
||||
//get minimal required height, width from raw text
|
||||
int min_text_w = cl_font->getRenderWidth(s_time, true);;
|
||||
int min_text_h = cl_font->getHeight();
|
||||
int min_text_w = (*getClockFont())->getRenderWidth(s_time, true);;
|
||||
int min_text_h = (*getClockFont())->getHeight();
|
||||
height = max(height, min_text_h);
|
||||
width = max(width, min_text_w);
|
||||
|
||||
@@ -169,13 +173,13 @@ void CComponentsFrmClock::initCCLockItems()
|
||||
string stmp = s_time.substr(i, 1);
|
||||
|
||||
//get width of current segment
|
||||
int wtmp = cl_font->getRenderWidth(stmp, true);
|
||||
int wtmp = (*getClockFont())->getRenderWidth(stmp, true);
|
||||
|
||||
//set size, text, color of current item
|
||||
lbl->setDimensionsAll(cl_x, cl_y, wtmp, cl_h);
|
||||
lbl->setTextColor(cl_col_text);
|
||||
lbl->setColorAll(col_frame, col_body, col_shadow);
|
||||
lbl->setText(stmp, CTextBox::CENTER, cl_font);
|
||||
lbl->setText(stmp, CTextBox::CENTER, *getClockFont());
|
||||
|
||||
//use matching height for digits for better vertical centerring into form
|
||||
CTextBox* ctb = lbl->getCTextBoxObject();
|
||||
@@ -333,3 +337,24 @@ void CComponentsFrmClock::paint(bool do_save_bg)
|
||||
//paint form contents
|
||||
paintForm(do_save_bg);
|
||||
}
|
||||
|
||||
void CComponentsFrmClock::setClockFontSize(int size)
|
||||
{
|
||||
int tmp_w = 0;
|
||||
dyn_font_size = size;
|
||||
cl_font = CNeutrinoFonts::getInstance()->getDynFont(tmp_w, dyn_font_size, "", CNeutrinoFonts::FONT_STYLE_BOLD, CNeutrinoFonts::FONT_ID_INFOCLOCK);
|
||||
}
|
||||
|
||||
void CComponentsFrmClock::setClockFont(int font)
|
||||
{
|
||||
cl_font_type = font;
|
||||
cl_font = &g_Font[cl_font_type];
|
||||
}
|
||||
|
||||
Font** CComponentsFrmClock::getClockFont()
|
||||
{
|
||||
if (dyn_font_size == 0)
|
||||
cl_font = &g_Font[cl_font_type];
|
||||
return cl_font;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user