Merge branch 'check/next-cc'

Only compile-tested.
This commit is contained in:
Stefan Seyfried
2013-11-13 14:04:15 +01:00
56 changed files with 1278 additions and 203 deletions

View File

@@ -23,6 +23,7 @@ libneutrino_gui_components_a_SOURCES = \
cc_frm_clock.cpp \
cc_frm_footer.cpp \
cc_frm_header.cpp \
cc_frm_ext_text.cpp \
cc_frm_icons.cpp \
cc_frm_signalbars.cpp \
cc_frm_window.cpp \

View File

@@ -31,8 +31,8 @@ Basic attributes and member functions for component sub classes
#ifndef __N_COMPONENTS__
#define __N_COMPONENTS__
#include "cc_base.h"
#include "cc_types.h"
#include "cc_base.h"
#include "cc_item_infobox.h"
#include "cc_item_picture.h"

View File

@@ -56,8 +56,8 @@ void CComponents::clearSavedScreen()
void CComponents::initVarBasic()
{
x = saved_screen.x = 0;
y = saved_screen.y = 0;
x = saved_screen.x = 1;
y = saved_screen.y = 1;
cc_xr = x;
cc_yr = y;
height = saved_screen.dy = CC_HEIGHT_MIN;
@@ -77,6 +77,7 @@ void CComponents::initVarBasic()
firstPaint = true;
is_painted = false;
paint_bg = true;
cc_allow_paint = true;
frameBuffer = CFrameBuffer::getInstance();
v_fbdata.clear();
saved_screen.pixbuf = NULL;
@@ -106,8 +107,15 @@ void CComponents::paintFbItems(bool do_save_bg)
for(size_t i=0; i< v_fbdata.size() ;i++){
// Don't paint if dx or dy are 0
if ((v_fbdata[i].dx == 0) || (v_fbdata[i].dy == 0))
if ((v_fbdata[i].dx == 0) || (v_fbdata[i].dy == 0)){
// printf(" [CComponents] WARNING:\n [%s - %d], dx = %d\n dy = %d\n", __FUNCTION__, __LINE__, v_fbdata[i].dx, v_fbdata[i].dy);
continue;
}
#if 0
if ((v_fbdata[i].x == 0) || (v_fbdata[i].y == 0)){
printf(" [CComponents] WARNING:\n [%s - %d], x = %d\n y = %d\n", __FUNCTION__, __LINE__, v_fbdata[i].x, v_fbdata[i].y);
}
#endif
int fbtype = v_fbdata[i].fbdata_type;
#ifdef DEBUG_CC
@@ -130,7 +138,7 @@ void CComponents::paintFbItems(bool do_save_bg)
//paint all fb relevant basic parts (frame and body) with all specified properties, paint_bg must be true
if (fbtype != CC_FBDATA_TYPE_BGSCREEN && paint_bg){
if (fbtype == CC_FBDATA_TYPE_FRAME) {
if (v_fbdata[i].frame_thickness > 0)
if (v_fbdata[i].frame_thickness > 0 && cc_allow_paint)
frameBuffer->paintBoxFrame(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].frame_thickness, v_fbdata[i].color, v_fbdata[i].r, corner_type);
}
else if (fbtype == CC_FBDATA_TYPE_BACKGROUND)
@@ -148,14 +156,17 @@ void CComponents::paintFbItems(bool do_save_bg)
//calculate current shadow width depends of current corner_rad
sw_cur = max(2*v_fbdata[i].r, sw);
}
// shadow right
frameBuffer->paintBoxRel(x_sh, v_fbdata[i].y, sw_cur, v_fbdata[i].dy-sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_TOP_RIGHT);
// shadow bottom
frameBuffer->paintBoxRel(v_fbdata[i].x, y_sh, v_fbdata[i].dx, sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_BOTTOM);
if (cc_allow_paint){
// shadow right
frameBuffer->paintBoxRel(x_sh, v_fbdata[i].y, sw_cur, v_fbdata[i].dy-sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_TOP_RIGHT);
// shadow bottom
frameBuffer->paintBoxRel(v_fbdata[i].x, y_sh, v_fbdata[i].dx, sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_BOTTOM);
}
}
}
else
frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].color, v_fbdata[i].r, corner_type);
if(cc_allow_paint)
frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].color, v_fbdata[i].r, corner_type);
}
}

View File

@@ -94,6 +94,8 @@ class CComponents
bool is_painted;
///mode: true=activate rendering of basic elements (frame, shadow and body)
bool paint_bg;
///mode: true=allows painting of item, see also allowPaint()
bool cc_allow_paint;
///initialize of basic attributes, no parameters required
void initVarBasic();
@@ -205,6 +207,11 @@ class CComponents
///allows paint of elementary item parts (shadow, frame and body), similar as background, set it usually to false, if item used in a form
virtual void doPaintBg(bool do_paint){paint_bg = do_paint;};
///allow/disalows paint of item and its contents, but initialize of other properties are not touched
///this can be understood as a counterpart to isPainted(), but before paint
virtual void allowPaint(bool allow){cc_allow_paint = allow;};
///returns visibility mode
virtual bool paintAllowed(){return cc_allow_paint;};
};
class CComponentsItem : public CComponents

View File

@@ -361,8 +361,17 @@ void CComponentsForm::paintCCItems()
cc_item->setHeight(new_h);
}
//get current visibility mode from item, me must hold it and restore after paint
bool item_visible = cc_item->paintAllowed();
//set visibility mode
if (!this->cc_allow_paint)
cc_item->allowPaint(false);
//finally paint current item
cc_item->paint(CC_SAVE_SCREEN_NO);
//restore defined old visibility mode of item after paint
cc_item->allowPaint(item_visible);
}
}

View File

@@ -285,16 +285,13 @@ class CComponentsWindow : public CComponentsForm
~CComponentsWindow();
///paint window
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///add item to body object, also usable is addCCItem() to add items to the windo object
void addWindowItem(CComponentsItem* cc_Item);
///allow/disallow paint a footer, default true, see also ccw_show_footer, showHeader()
void showFooter(bool show = true){ccw_show_footer = show;};
void showFooter(bool show = true){ccw_show_footer = show; initCCWItems();};
///allow/disallow paint a header, default true, see also ccw_show_header, showFooter()
void showHeader(bool show = true){ccw_show_header = show;};
void showHeader(bool show = true){ccw_show_header = show; initCCWItems();};
///set caption in header with string, see also getHeaderObject()
void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;};
@@ -322,4 +319,100 @@ class CComponentsWindow : public CComponentsForm
void Refresh(){initCCWItems();};
};
class CComponentsExtTextForm : public CComponentsForm
{
private:
///property: content of label, see also setLabelAndText()
std::string ccx_label_text;
///property: content of text, see also setLabelAndText()
std::string ccx_text;
///property: color of label text, see also setLabelAndTextColor()
fb_pixel_t ccx_label_color;
///property: color of text, see also setLabelAndTextColor()
fb_pixel_t ccx_text_color;
///property: mode of label text, see also setTextModes()
int ccx_label_align;
///property: mode of text, see also setTextModes()
int ccx_text_align;
///property: width of label, see also setLabelWidthPercent()
int ccx_label_width;
///property: width of text, see also setLabelWidthPercent()
int ccx_text_width;
///property: font type of both items (label and text), see also setLabelAndText()
Font* ccx_font;
///property: percentage val of label width related to full width, causes fit of text automatically into the available remaining size of item, see also setLabelWidthPercent()
uint8_t ccx_percent_label_w;
///object: label object
CComponentsLabel *ccx_label_obj;
///object: text object
CComponentsText *ccx_text_obj;
///initialize of properties for all objects
void initCCTextItems();
///initialize the label object
void initLabel();
///initialize the text object
void initText();
protected:
///initialize basic variables
void initVarExtTextForm(const int x_pos = 1, const int y_pos = 1, const int w = 300, const int h = 27,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT,
fb_pixel_t text_color = COL_MENUCONTENT_TEXT,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
public:
///simple constructor for CComponentsExtTextForm
CComponentsExtTextForm();
///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as string
CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h,
const std::string& label_text, const std::string& text,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT,
fb_pixel_t text_color = COL_MENUCONTENT_TEXT,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales
CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h,
const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT,
fb_pixel_t text_color = COL_MENUCONTENT_TEXT,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
// ~CComponentsExtTextForm(); //inherited from CComponentsForm
///assigns texts for label and text, parameter as string, parameter Font is optional for required font type, default font is dependently from defined item height
void setLabelAndText(const std::string& label_text, const std::string& text, Font* font_text = NULL);
///assigns texts for label and text, parameter as neutrino_locale_t, parameter Font is optional for required font type, default font is dependently from defined item height
void setLabelAndText(const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, Font* font_text = NULL);
///assigns text Font type
void setLabelAndTextFont(Font* font);
///assigns texts for label and text, parameter as struct (locale_ext_txt_t), parameters provide the same properties like setLabelAndText()
void setLabelAndTexts(const locale_ext_txt_t& texts);
///assigns texts for label and text, parameter as struct (string_ext_txt_t), parameters provide the same properties like setLabelAndText()
void setLabelAndTexts(const string_ext_txt_t& locale_texts);
///assigns colors for text for label text, parameter as fb_pixel_t
void setLabelAndTextColor(const fb_pixel_t label_color , const fb_pixel_t text_color);
///assigns width of label and text related to width, parameter as uint8_t in percent of width, fits text automatically into the available remaining size of item
void setLabelWidthPercent(const uint8_t& percent_val);
///returns a pointer to the internal label object, use this to get access to its most properties
CComponentsLabel*getLabelObject(){return ccx_label_obj;};
///returns a pointer to the internal text object, use this to get access to its most properties
CComponentsText*getTextObject(){return ccx_text_obj;};
///sets the text modes (mainly text alignment) to the label and text object, see /gui/widget/textbox.h for possible modes
void setTextModes(const int& label_mode, const int& text_mode);
///paint this item/form
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
#endif

View File

@@ -68,7 +68,8 @@ CComponentsButton::CComponentsButton( const int x_pos, const int y_pos, const i
{
initVarButton();
cc_btn_icon = icon_name;
cc_btn_capt = g_Locale->getText(caption_locale);;
cc_btn_capt_locale = caption_locale;
cc_btn_capt = g_Locale->getText(cc_btn_capt_locale);
cc_btn_capt_col = COL_MENUCONTENT_TEXT;
x = x_pos;
@@ -95,6 +96,7 @@ void CComponentsButton::initVarButton()
cc_btn_font = NULL;
cc_btn_icon = "";
cc_btn_capt = "";
cc_btn_capt_locale = NONEXISTANT_LOCALE;
}
void CComponentsButton::initIcon()
@@ -194,7 +196,8 @@ void CComponentsButton::setCaption(const std::string& text)
void CComponentsButton::setCaption(const neutrino_locale_t locale_text)
{
cc_btn_capt = g_Locale->getText(locale_text);
cc_btn_capt_locale = locale_text;
cc_btn_capt = g_Locale->getText(cc_btn_capt_locale);
}
void CComponentsButton::initCCBtnItems()

View File

@@ -47,8 +47,11 @@ class CComponentsButton : public CComponentsForm
///initialize all required attributes and objects
void initVarButton();
///property: button text
///property: button text as string, see also setCaption() and getCaptionString()
std::string cc_btn_capt;
///property: button text as locale, see also setCaption() and getCaptionLocale()
neutrino_locale_t cc_btn_capt_locale;
///property: icon name, only icons supported, to find in gui/widget/icons.h
std::string cc_btn_icon;
@@ -86,6 +89,11 @@ class CComponentsButton : public CComponentsForm
///set caption: parameter as locale
virtual void setCaption(const neutrino_locale_t locale_text);
///get caption, type as std::string
virtual std::string getCaptionString(){return cc_btn_capt;};
///get loacalized caption id, type = neutrino_locale_t
virtual neutrino_locale_t getCaptionLocale(){return cc_btn_capt_locale;};
///reinitialize items
virtual void Refresh(){initCCBtnItems();};
@@ -108,6 +116,14 @@ class CComponentsButtonRed : public CComponentsButton
{
cc_item_type = CC_ITEMTYPE_BUTTON_RED;
};
CComponentsButtonRed( const int x_pos, const int y_pos, const int w, const int h,
const neutrino_locale_t& caption_locale,
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_RED, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_RED;
};
};
//! Sub class of CComponentsButton.
@@ -125,6 +141,14 @@ class CComponentsButtonGreen : public CComponentsButton
{
cc_item_type = CC_ITEMTYPE_BUTTON_GREEN;
};
CComponentsButtonGreen( const int x_pos, const int y_pos, const int w, const int h,
const neutrino_locale_t& caption_locale,
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_GREEN, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_GREEN;
};
};
//! Sub class of CComponentsButton.
@@ -142,6 +166,14 @@ class CComponentsButtonYellow : public CComponentsButton
{
cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW;
};
CComponentsButtonYellow( const int x_pos, const int y_pos, const int w, const int h,
const neutrino_locale_t& caption_locale,
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_YELLOW, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW;
};
};
//! Sub class of CComponentsButton.
@@ -159,6 +191,14 @@ class CComponentsButtonBlue : public CComponentsButton
{
cc_item_type = CC_ITEMTYPE_BUTTON_BLUE;
};
CComponentsButtonBlue( const int x_pos, const int y_pos, const int w, const int h,
const neutrino_locale_t& caption_locale,
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_BLUE, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_BLUE;
};
};
#endif /*__CC_BUTTONS_H__*/

View File

@@ -0,0 +1,222 @@
/*
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
Copyright (C) 2013, Thilo Graf 'dbt'
License: GPL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <global.h>
#include <neutrino.h>
#include "cc_frm.h"
#define DEF_HEIGHT 27
#define DEF_LABEL_WIDTH_PERCENT 30
#define DEF_WIDTH 300
using namespace std;
CComponentsExtTextForm::CComponentsExtTextForm()
{
initVarExtTextForm();
initCCTextItems();
}
CComponentsExtTextForm::CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h,
const std::string& label_text, const std::string& text,
bool has_shadow,
fb_pixel_t label_color,
fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarExtTextForm(x_pos, y_pos, w, h, has_shadow, label_color, text_color, color_frame, color_body, color_shadow);
ccx_label_text = label_text;
ccx_text = text;
initCCTextItems();
}
CComponentsExtTextForm::CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h,
const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text,
bool has_shadow,
fb_pixel_t label_color,
fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarExtTextForm(x_pos, y_pos, w, h, has_shadow, label_color, text_color, color_frame, color_body, color_shadow);
ccx_label_text = g_Locale->getText(locale_label_text);
ccx_text = g_Locale->getText(locale_text);
initCCTextItems();
}
void CComponentsExtTextForm::initVarExtTextForm(const int x_pos, const int y_pos, const int w, const int h,
bool has_shadow,
fb_pixel_t label_color,
fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarForm();
cc_item_type = CC_ITEMTYPE_FRM_EXT_TEXT;
x = x_pos;
y = y_pos;
width = w;
//init ccx_label_width and ccx_text_width
//default ccx_label_width = 30% of form width
ccx_percent_label_w = DEF_LABEL_WIDTH_PERCENT;
ccx_label_width = ccx_percent_label_w * width/100;
ccx_text_width = width-ccx_label_width;
height = h;
ccx_label_text = "";
ccx_text = "";
shadow = has_shadow;
ccx_label_color = label_color;
ccx_text_color = text_color;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
ccx_label_obj = NULL;
ccx_text_obj = NULL;
corner_type = 0;
int dx = 0, dy = DEF_HEIGHT;
ccx_font = *(CNeutrinoFonts::getInstance()->getDynFont(dx, dy));
ccx_label_align = ccx_text_align = CTextBox::NO_AUTO_LINEBREAK;
}
void CComponentsExtTextForm::initLabel()
{
//initialize label object
if (ccx_label_obj == NULL){
ccx_label_obj = new CComponentsLabel();
ccx_label_obj->doPaintBg(false);
}
//add label object
if (!ccx_label_obj->isAdded())
addCCItem(ccx_label_obj);
//set properties
if (ccx_label_obj){
ccx_label_width = (ccx_percent_label_w * width/100);
ccx_label_obj->setText(ccx_label_text, ccx_label_align, ccx_font);
ccx_label_obj->setTextColor(ccx_label_color);
ccx_label_obj->setDimensionsAll(fr_thickness, 0, ccx_label_width-fr_thickness, height-2*fr_thickness);
ccx_label_obj->setCorner(this->corner_rad, CORNER_LEFT);
}
}
void CComponentsExtTextForm::initText()
{
//initialize text object
if (ccx_text_obj == NULL){
ccx_text_obj = new CComponentsLabel();
ccx_text_obj->doPaintBg(false);
}
//add text object
if (!ccx_text_obj->isAdded())
addCCItem(ccx_text_obj);
//set properties
if (ccx_text_obj){
ccx_text_width = width-ccx_label_obj->getWidth();
ccx_text_obj->setText(ccx_text, ccx_text_align, ccx_font);
ccx_text_obj->setTextColor(ccx_text_color);
ccx_text_obj->setDimensionsAll(CC_APPEND, 0, ccx_text_width-2*fr_thickness, height-2*fr_thickness);
ccx_text_obj->setCorner(this->corner_rad, CORNER_RIGHT);
}
}
void CComponentsExtTextForm::setLabelAndText(const std::string& label_text, const std::string& text, Font* font_text)
{
ccx_label_text = label_text;
ccx_text = text;
if (font_text)
ccx_font = font_text;
initCCTextItems();
}
void CComponentsExtTextForm::setLabelAndText(const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, Font* font_text)
{
setLabelAndText(g_Locale->getText(locale_label_text), g_Locale->getText(locale_text), font_text);
}
void CComponentsExtTextForm::setLabelAndTexts(const string_ext_txt_t& texts)
{
setLabelAndText(texts.label_text, texts.text, texts.font);
}
void CComponentsExtTextForm::setLabelAndTexts(const locale_ext_txt_t& locale_texts)
{
setLabelAndText(g_Locale->getText(locale_texts.label_text), g_Locale->getText(locale_texts.text), locale_texts.font);
}
void CComponentsExtTextForm::setLabelAndTextFont(Font* font)
{
if (font == NULL)
return;
setLabelAndText(ccx_label_text, ccx_text, font);
}
void CComponentsExtTextForm::setTextModes(const int& label_mode, const int& text_mode)
{
ccx_label_align = label_mode;
ccx_text_align = text_mode;
initCCTextItems();
}
void CComponentsExtTextForm::setLabelAndTextColor(const fb_pixel_t label_color , const fb_pixel_t text_color)
{
ccx_label_color = label_color;
ccx_text_color = text_color;
initCCTextItems();
}
void CComponentsExtTextForm::initCCTextItems()
{
initLabel();
initText();
}
void CComponentsExtTextForm::setLabelWidthPercent(const uint8_t& percent_val)
{
ccx_percent_label_w = (int)percent_val;
initCCTextItems();
}
void CComponentsExtTextForm::paint(bool do_save_bg)
{
//prepare items before paint
initCCTextItems();
//paint form contents
paintForm(do_save_bg);
}

View File

@@ -254,11 +254,3 @@ void CComponentsWindow::initCCWItems()
addCCItem(ccw_footer);
}
void CComponentsWindow::paint(bool do_save_bg)
{
//prepare items before paint
initCCWItems();
//paint form contents
paintForm(do_save_bg);
}

View File

@@ -107,21 +107,25 @@ void CComponentsItem::paintInit(bool do_save_bg)
}
//restore last saved screen behind form box,
//Do use parameter 'no restore' to override temporarly the restore funtionality.
//This could help to avoid ugly flicker efffects if it is necessary e.g. on often repaints, without changed contents.
//Do use parameter 'no restore' to override the restore funtionality.
//For embedded items is it mostly not required to restore saved screens, so no_resore=true also is default parameter
//for such items.
//This member ensures demage of already existing screen buffer too, if parameter no_restore was changed while runtime.
void CComponentsItem::hideCCItem(bool no_restore)
{
is_painted = false;
//restore saved screen if available
if (saved_screen.pixbuf) {
frameBuffer->waitForIdle("CComponentsItem::hideCCItem()");
frameBuffer->RestoreScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy, saved_screen.pixbuf);
if (no_restore) {
delete[] saved_screen.pixbuf;
saved_screen.pixbuf = NULL;
firstPaint = true;
}
if (no_restore) { //on parameter no restore=true delete saved screen if available
delete[] saved_screen.pixbuf;
saved_screen.pixbuf = NULL;
firstPaint = true;
}
}
is_painted = false;
}
void CComponentsItem::hide(bool no_restore)

View File

@@ -97,16 +97,19 @@ void CComponentsInfoBox::paintPicture()
//exit if no image definied
if (pic_name == "")
return;
//init pic object and set icon paint position
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, 0, 0, "");
//define icon
pic->setPicture(pic_name);
//fit icon into infobox
pic->setHeight(height-2*fr_thickness);
pic->setColorBody(col_body);
//paint, but set visibility mode
pic->allowPaint(cc_allow_paint);
pic->paint(CC_SAVE_SCREEN_NO);
}
@@ -119,7 +122,7 @@ void CComponentsInfoBox::paint(bool do_save_bg)
//NOTE: real values are reqiured, if we paint this item within a form as embedded cc-item
int x_text = (cc_parent ? cc_xr : x) + fr_thickness;
int y_text = (cc_parent ? cc_yr : y) + fr_thickness;
//set text to the left border if picture is not painted
int pic_w = 0;
if ((pic) && (pic->isPicPainted()))
@@ -141,7 +144,9 @@ void CComponentsInfoBox::paint(bool do_save_bg)
int tw = width - x_offset - pic_w - 2*fr_thickness;
int th = height-2*fr_thickness;
cctext->setDimensionsAll(tx, y_text, tw, th);
cctext->paint(CC_SAVE_SCREEN_NO);
//paint, but set visibility mode
cctext->allowPaint(cc_allow_paint);
cctext->paint(CC_SAVE_SCREEN_NO);
}
}

View File

@@ -180,7 +180,7 @@ void CComponentsPicture::paintPicture()
{
pic_painted = false;
if (do_paint){
if (do_paint && cc_allow_paint){
#ifdef DEBUG_CC
printf(" [CComponentsPicture] %s: paint image: %s (do_paint=%d)\n", __FUNCTION__, pic_name.c_str(), do_paint);
#endif

View File

@@ -141,6 +141,7 @@ void CProgressBar::paintShapes(int &shx, int &shy, int &shw, int &shh, fb_pixel_
{
CComponentsShapeSquare shape(shx, shy, shw, shh, false);
shape.setColorBody(col);
shape.allowPaint(cc_allow_paint);
shape.paint(false);
}

View File

@@ -92,7 +92,7 @@ class CProgressBar : public CComponentsItem
///paint version of progressbar with color and advanced display modifications
void paintAdvanced();
///painting of activ/passive bars via shape object
static void paintShapes(int &shx, int &shy, int &shw, int &shh, fb_pixel_t &col);
void paintShapes(int &shx, int &shy, int &shw, int &shh, fb_pixel_t &col);
void initDimensions();

View File

@@ -109,7 +109,7 @@ void CComponentsText::initVarText()
ct_text_Vborder = 0;
ct_col_text = COL_MENUCONTENT_TEXT;
ct_old_col_text = ct_col_text;
ct_old_col_text = 0;
ct_text_sent = false;
ct_paint_textbg = false;
ct_force_text_paint = false;
@@ -153,11 +153,24 @@ void CComponentsText::initCCText()
ct_textbox->setWindowMaxDimensions(width, height);
ct_textbox->setWindowMinDimensions(width, height);
//send text to CTextBox object, but paint text only if text or text coloer has changed or force option is enabled
if ((ct_old_text != ct_text) || ct_old_col_text != ct_col_text || ct_force_text_paint)
ct_text_sent = ct_textbox->setText(&ct_text, this->iWidth);
ct_old_text = ct_text;
ct_old_col_text = ct_col_text;
//observe behavior of parent form if available
bool force_text_paint = ct_force_text_paint;
if (cc_parent){
//if any embedded text item was hided because of hided parent form,
//we must ensure repaint of text, otherwise text item is not visible
if (cc_parent->isPainted())
force_text_paint = true;
}
//send text to CTextBox object, but force text paint text if force_text_paint option is enabled
//this is managed by CTextBox object itself
ct_text_sent = ct_textbox->setText(&ct_text, this->iWidth, force_text_paint);
//set current text status, needed by textChanged()
if (ct_text_sent){
ct_old_text = ct_text;
ct_old_col_text = ct_col_text;
}
#ifdef DEBUG_CC
printf(" [CComponentsText] [%s - %d] init text: %s [x %d, y %d, w %d, h %d]\n", __FUNCTION__, __LINE__, ct_text.c_str(), this->iX, this->iY, this->iWidth, this->iHeight);
#endif
@@ -170,7 +183,6 @@ void CComponentsText::clearCCText()
ct_textbox = NULL;
}
void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text)
{
ct_old_text = ct_text;
@@ -236,7 +248,7 @@ void CComponentsText::paintText(bool do_save_bg)
{
paintInit(do_save_bg);
initCCText();
if (ct_text_sent)
if (ct_text_sent && cc_allow_paint)
ct_textbox->paint();
ct_text_sent = false;
}

View File

@@ -150,7 +150,7 @@ CComponentsLbel provides a interface to the embedded CTextBox object.
class CComponentsLabel : public CComponentsText
{
public:
CComponentsLabel( const int x_pos, const int y_pos, const int w, const int h,
CComponentsLabel( const int x_pos = 10, const int y_pos = 10, const int w = 150, const int h = 50,
std::string text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_text = COL_MENUCONTENTINACTIVE_TEXT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
@@ -158,12 +158,6 @@ class CComponentsLabel : public CComponentsText
{
cc_item_type = CC_ITEMTYPE_LABEL;
};
CComponentsLabel():CComponentsText()
{
initVarText();
cc_item_type = CC_ITEMTYPE_LABEL;
ct_col_text = COL_MENUCONTENTINACTIVE_TEXT;
};
};
#endif

View File

@@ -87,6 +87,9 @@ void CComponentsPIP::paint(bool do_save_bg)
pig_w -= pig_w*25/100;
pig_x += tmpw/2-pig_w/2;
}
if (!cc_allow_paint)
return;
if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_tv){
videoDecoder->Pig(pig_x, pig_y, pig_w, pig_h, screen_w, screen_h);
@@ -95,7 +98,6 @@ void CComponentsPIP::paint(bool do_save_bg)
CComponentsPicture pic = CComponentsPicture (pig_x, pig_y, pig_w, pig_h, pic_name, CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
pic.paint(CC_SAVE_SCREEN_NO);
}
}

View File

@@ -28,6 +28,7 @@
#include <driver/framebuffer.h>
#include <system/localize.h>
#include <driver/fontrenderer.h>
///cc item types
typedef enum
@@ -45,6 +46,7 @@ typedef enum
CC_ITEMTYPE_FOOTER,
CC_ITEMTYPE_FRM_ICONFORM,
CC_ITEMTYPE_FRM_WINDOW,
CC_ITEMTYPE_FRM_EXT_TEXT,
CC_ITEMTYPE_LABEL,
CC_ITEMTYPE_PROGRESSBAR,
CC_ITEMTYPE_BUTTON,
@@ -125,6 +127,20 @@ typedef struct comp_element_data_t
void* handler2;
}comp_element_data_struct_t;
//text lebel types
typedef struct locale_ext_txt_t
{
neutrino_locale_t label_text;
neutrino_locale_t text;
Font* font;
} locale_ext_txt_struct_t;
typedef struct string_ext_txt_t
{
std::string label_text;
std::string text;
Font* font;
} string_ext_txt_struct_t;
#define CC_WIDTH_MIN 16
#define CC_HEIGHT_MIN 16