mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 01:11:12 +02:00
Merge branch 'master' into pu/mp
This commit is contained in:
@@ -18,6 +18,7 @@ noinst_LIBRARIES = libneutrino_gui_components.a
|
||||
|
||||
libneutrino_gui_components_a_SOURCES = \
|
||||
cc_base.cpp \
|
||||
cc_button_select.cpp \
|
||||
cc_detailsline.cpp \
|
||||
cc_draw.cpp \
|
||||
cc_extra.cpp \
|
||||
|
82
src/gui/components/cc_button_select.cpp
Normal file
82
src/gui/components/cc_button_select.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2017, 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "cc_button_select.h"
|
||||
#include <system/debug.h>
|
||||
|
||||
CCButtonSelect::CCButtonSelect()
|
||||
{
|
||||
btn_container = NULL;
|
||||
}
|
||||
|
||||
CComponentsFrmChain* CCButtonSelect::getButtonChainObject()
|
||||
{
|
||||
return btn_container;
|
||||
}
|
||||
|
||||
CComponentsButton* CCButtonSelect::getSelectedButtonObject()
|
||||
{
|
||||
CComponentsButton* ret = static_cast<CComponentsButton*>(btn_container->getSelectedItemObject());
|
||||
return ret;
|
||||
}
|
||||
|
||||
int CCButtonSelect::getSelectedButton()
|
||||
{
|
||||
if (btn_container)
|
||||
return btn_container->getSelectedItem();
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CCButtonSelect::setSelectedButton(size_t item_id,
|
||||
const fb_pixel_t& fr_col,
|
||||
const fb_pixel_t& sel_fr_col,
|
||||
const fb_pixel_t& bg_col,
|
||||
const fb_pixel_t& sel_bg_col,
|
||||
const fb_pixel_t& text_col,
|
||||
const fb_pixel_t& sel_text_col,
|
||||
const int& frame_width,
|
||||
const int& sel_frame_width)
|
||||
{
|
||||
CComponentsButton *btn = NULL;
|
||||
if (btn_container){
|
||||
for (size_t i= 0; i< btn_container->size(); i++){
|
||||
CComponentsItem *item = btn_container->getCCItem(i);
|
||||
if (item->getItemType() >= CC_ITEMTYPE_BUTTON && item->getItemType() <= CC_ITEMTYPE_BUTTON_BLUE){
|
||||
btn = static_cast<CComponentsButton*>(item);
|
||||
btn->setButtonTextColor(text_col);
|
||||
}
|
||||
}
|
||||
if (!btn)
|
||||
dprintf(DEBUG_NORMAL, "\033[33m[CCButtonSelect]\t[%s - %d], no button object found...\033[0m\n", __func__, __LINE__);
|
||||
|
||||
fb_pixel_t sel_col = fr_col;
|
||||
if (btn_container->size() > 1)
|
||||
sel_col = sel_fr_col; //TODO: make it configurable
|
||||
btn_container->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width);
|
||||
|
||||
getSelectedButtonObject()->setButtonTextColor(sel_text_col);
|
||||
}
|
||||
}
|
||||
|
||||
|
81
src/gui/components/cc_button_select.h
Normal file
81
src/gui/components/cc_button_select.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2017, 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CC_BTN_SEL_H__
|
||||
#define __CC_BTN_SEL_H__
|
||||
|
||||
|
||||
#include "cc_frm_button.h"
|
||||
|
||||
/*!
|
||||
Class for inheritation of button select handling inside other CComponentsForm objects and their derivations
|
||||
*/
|
||||
class CCButtonSelect
|
||||
{
|
||||
protected:
|
||||
CComponentsFrmChain *btn_container;
|
||||
|
||||
public:
|
||||
CCButtonSelect();
|
||||
|
||||
///returns selected button object, return value as pointer to object, NULL means nothing is selected
|
||||
CComponentsButton* getSelectedButtonObject();
|
||||
|
||||
///returns pointer to internal button container
|
||||
CComponentsFrmChain* getButtonChainObject();
|
||||
|
||||
///returns id of select button, return value as int, -1 = nothing is selected
|
||||
int getSelectedButton();
|
||||
|
||||
/**Select a definied button inside button chain object
|
||||
* @param[in] item_id
|
||||
* @li optional: expects type size_t
|
||||
* @param[in] fr_col
|
||||
* @li optional: expects type fb_pixel_t, as default frame color
|
||||
* @param[in] sel_fr_col
|
||||
* @li optional: expects type fb_pixel_t, as selected frame color
|
||||
* @param[in] bg_col
|
||||
* @li optional: expects type fb_pixel_t, as default background color
|
||||
* @param[in] sel_bg_col
|
||||
* @li optional: expects type fb_pixel_t, as selected background color
|
||||
* @param[in] text_col
|
||||
* @li optional: expects type fb_pixel_t, as default text color
|
||||
* @param[in] sel_text_col
|
||||
* @li optional: expects type fb_pixel_t, as selected text color
|
||||
* @param[in] frame_width
|
||||
* @li optional: expects type int, default = 1
|
||||
* @param[in] sel_frame_width
|
||||
* @li optional: expects type int, default = 1
|
||||
*/
|
||||
void setSelectedButton(size_t item_id,
|
||||
const fb_pixel_t& fr_col = COL_MENUCONTENTSELECTED_PLUS_2,
|
||||
const fb_pixel_t& sel_fr_col = COL_MENUCONTENTSELECTED_PLUS_0,
|
||||
const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0,
|
||||
const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0,
|
||||
const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT,
|
||||
const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT,
|
||||
const int& frame_width = 1,
|
||||
const int& sel_frame_width = 1);
|
||||
};
|
||||
|
||||
#endif //__CC_BTN_SEL_H__
|
@@ -440,11 +440,13 @@ bool CCDraw::CheckFbData(const cc_fbdata_t& fbdata, const char* func, const int
|
||||
//screen area save
|
||||
fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy)
|
||||
{
|
||||
fb_pixel_t* pixbuf = NULL;
|
||||
|
||||
if (dx < 1 || dy < 1 || dx * dy == 0)
|
||||
return NULL;
|
||||
else
|
||||
pixbuf = new fb_pixel_t[dx * dy];
|
||||
|
||||
dprintf(DEBUG_INFO, "[CCDraw] INFO! [%s - %d], ax = %d, ay = %d, dx = %d, dy = %d\n", __func__, __LINE__, ax, ay, dx, dy);
|
||||
fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy];
|
||||
frameBuffer->waitForIdle("CCDraw::getScreen()");
|
||||
frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf);
|
||||
return pixbuf;
|
||||
@@ -453,8 +455,14 @@ fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy)
|
||||
cc_screen_data_t CCDraw::getScreenData(const int& ax, const int& ay, const int& dx, const int& dy)
|
||||
{
|
||||
cc_screen_data_t res;
|
||||
res.x = res.y = res.dx = res.dy = 0;
|
||||
res.pixbuf = getScreen(ax, ay, dx, dy);
|
||||
res.x = ax; res.y = ay; res.dx = dx; res.dy = dy;
|
||||
|
||||
if (res.pixbuf){
|
||||
res.x = ax; res.y = ay; res.dx = dx; res.dy = dy;
|
||||
}
|
||||
else
|
||||
dprintf(DEBUG_NORMAL, "\033[33m[CCDraw]\[%s - %d], Warning: initialize of screen buffer failed!\033[0m\n", __func__, __LINE__);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@@ -185,11 +185,10 @@ void CComponentsForm::clear()
|
||||
return;
|
||||
|
||||
for(size_t i=0; i<v_cc_items.size(); i++) {
|
||||
CComponentsItem *item = v_cc_items[i];
|
||||
if (item){
|
||||
dprintf(DEBUG_DEBUG, "[CComponentsForm] %s... delete form cc-item %d of %d (type=%d)\taddress = %p\n", __func__, (int)i+1, (int)v_cc_items.size(), item->getItemType(), item);
|
||||
delete item;
|
||||
item = NULL;
|
||||
if (v_cc_items[i]){
|
||||
dprintf(DEBUG_DEBUG, "[CComponentsForm] %s... delete form cc-item %d of %d (type=%d)\taddress = %p\n", __func__, (int)i+1, (int)v_cc_items.size(), v_cc_items[i]->getItemType(), v_cc_items[i]);
|
||||
delete v_cc_items[i];
|
||||
v_cc_items[i] = NULL;
|
||||
}
|
||||
}
|
||||
v_cc_items.clear();
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "config.h"
|
||||
#include "cc_base.h"
|
||||
#include "cc_item.h"
|
||||
#include "cc_frm_scrollbar.h"
|
||||
|
||||
|
||||
class CComponentsForm : public CComponentsItem
|
||||
{
|
||||
|
@@ -112,8 +112,9 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos,
|
||||
|
||||
CComponentsFrmClock::~CComponentsFrmClock()
|
||||
{
|
||||
if (cl_timer)
|
||||
delete cl_timer;
|
||||
if (cl_timer){
|
||||
delete cl_timer; cl_timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsFrmClock::initClockFont(int dx, int dy)
|
||||
|
@@ -35,7 +35,7 @@ using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//sub class CComponentsFooter inherit from CComponentsHeader
|
||||
CComponentsFooter::CComponentsFooter(CComponentsForm* parent)
|
||||
CComponentsFooter::CComponentsFooter(CComponentsForm* parent):CCButtonSelect()
|
||||
{
|
||||
//CComponentsFooter
|
||||
initVarFooter(1, 1, 0, 0, 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUFOOT_PLUS_0, COL_SHADOW_PLUS_0);
|
||||
@@ -47,7 +47,7 @@ CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const
|
||||
int shadow_mode,
|
||||
fb_pixel_t color_frame,
|
||||
fb_pixel_t color_body,
|
||||
fb_pixel_t color_shadow )
|
||||
fb_pixel_t color_shadow ):CCButtonSelect()
|
||||
{
|
||||
//CComponentsFooter
|
||||
initVarFooter(x_pos, y_pos, w, h, buttons, parent, shadow_mode, color_frame, color_body, color_shadow);
|
||||
@@ -95,7 +95,6 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
|
||||
corner_type = CORNER_BOTTOM;
|
||||
|
||||
ccf_enable_button_bg = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment
|
||||
chain = NULL;
|
||||
|
||||
addContextButton(buttons);
|
||||
initCCItems();
|
||||
@@ -108,8 +107,8 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
|
||||
void CComponentsFooter::setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width, const int& label_width)
|
||||
{
|
||||
/* clean up before init*/
|
||||
if (chain)
|
||||
chain->clear();
|
||||
if (btn_container)
|
||||
btn_container->clear();
|
||||
|
||||
if (label_count == 0)
|
||||
return;
|
||||
@@ -150,11 +149,11 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
||||
int y_chain = height/2 - h_chain/2;
|
||||
if (cch_icon_obj)
|
||||
x_chain = cch_offset+cch_icon_obj->getWidth()+cch_offset;
|
||||
if (chain == NULL){
|
||||
chain = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body);
|
||||
chain->setAppendOffset(0, 0);
|
||||
chain->setCorner(this->corner_rad, this->corner_type);
|
||||
chain->doPaintBg(false);
|
||||
if (btn_container == NULL){
|
||||
btn_container = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body);
|
||||
btn_container->setAppendOffset(0, 0);
|
||||
btn_container->setCorner(this->corner_rad, this->corner_type);
|
||||
btn_container->doPaintBg(false);
|
||||
}
|
||||
|
||||
/* Calculate usable width of button labels inside button object container
|
||||
@@ -166,11 +165,11 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
||||
* button objects itself.
|
||||
*/
|
||||
int w_offset = int((label_count-1)*cch_offset);
|
||||
int w_btn = chain->getWidth()/label_count - w_offset;
|
||||
int w_btn = btn_container->getWidth()/label_count - w_offset;
|
||||
if (label_width){
|
||||
int w_label = label_width;
|
||||
int w_defined = int(label_width*label_count);
|
||||
int w_max = chain->getWidth() - w_offset;
|
||||
int w_max = btn_container->getWidth() - w_offset;
|
||||
while (w_defined > w_max){
|
||||
w_label--;
|
||||
w_defined = int(w_label*label_count) - w_offset;
|
||||
@@ -182,7 +181,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
||||
* with default width to chain object.
|
||||
*/
|
||||
vector<CComponentsItem*> v_btns;
|
||||
int h_btn = /*(ccf_enable_button_bg ? */chain->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width;
|
||||
int h_btn = /*(ccf_enable_button_bg ? */btn_container->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width;
|
||||
for (size_t i= 0; i< label_count; i++){
|
||||
string txt = content[i].locale == NONEXISTANT_LOCALE ? content[i].text : g_Locale->getText(content[i].locale);
|
||||
string icon_name = string(content[i].button);
|
||||
@@ -193,7 +192,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
||||
continue;
|
||||
}
|
||||
|
||||
int y_btn = chain->getHeight()/2 - h_btn/2;
|
||||
int y_btn = btn_container->getHeight()/2 - h_btn/2;
|
||||
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] y_btn [%d] ccf_button_shadow_width [%d]\n", __func__, __LINE__, y_btn, ccf_button_shadow_width);
|
||||
CComponentsButton *btn = new CComponentsButton(0, y_btn, w_btn, h_btn, txt, icon_name, NULL, false, true, ccf_enable_button_shadow);
|
||||
|
||||
@@ -224,27 +223,27 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con
|
||||
btn->setButtonFont(NULL);
|
||||
}
|
||||
|
||||
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%zu] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, chain->getWidth());
|
||||
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%u] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, btn_container->getWidth());
|
||||
}
|
||||
|
||||
/* add generated button objects to chain object.
|
||||
*/
|
||||
if (!v_btns.empty()){
|
||||
/*add all buttons into button container*/
|
||||
chain->addCCItem(v_btns);
|
||||
btn_container->addCCItem(v_btns);
|
||||
|
||||
/* set position of labels, as centered inside button container*/
|
||||
int w_chain_used = 0;
|
||||
for (size_t a= 0; a< chain->size(); a++)
|
||||
w_chain_used += chain->getCCItem(a)->getWidth();
|
||||
w_chain_used += (chain->size()-1)*cch_offset;
|
||||
for (size_t a= 0; a< btn_container->size(); a++)
|
||||
w_chain_used += btn_container->getCCItem(a)->getWidth();
|
||||
w_chain_used += (btn_container->size()-1)*cch_offset;
|
||||
|
||||
int x_btn = chain->getWidth()/2 - w_chain_used/2;
|
||||
chain->getCCItem(0)->setXPos(x_btn);
|
||||
int x_btn = btn_container->getWidth()/2 - w_chain_used/2;
|
||||
btn_container->getCCItem(0)->setXPos(x_btn);
|
||||
|
||||
for (size_t c= 1; c< chain->size(); c++){
|
||||
x_btn += chain->getCCItem(c-1)->getWidth()+ cch_offset;
|
||||
chain->getCCItem(c)->setXPos(x_btn);
|
||||
for (size_t c= 1; c< btn_container->size(); c++){
|
||||
x_btn += btn_container->getCCItem(c-1)->getWidth()+ cch_offset;
|
||||
btn_container->getCCItem(c)->setXPos(x_btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,49 +316,12 @@ void CComponentsFooter::setButtonLabel( const char *button_icon,
|
||||
void CComponentsFooter::enableButtonBg(bool enable)
|
||||
{
|
||||
ccf_enable_button_bg = enable;
|
||||
if (chain) {
|
||||
for (size_t i= 0; i< chain->size(); i++)
|
||||
chain->getCCItem(i)->doPaintBg(ccf_enable_button_bg);
|
||||
if (btn_container) {
|
||||
for (size_t i= 0; i< btn_container->size(); i++)
|
||||
btn_container->getCCItem(i)->doPaintBg(ccf_enable_button_bg);
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsFooter::setSelectedButton(size_t item_id,
|
||||
const fb_pixel_t& fr_col, const fb_pixel_t& sel_fr_col,
|
||||
const fb_pixel_t& bg_col, const fb_pixel_t& sel_bg_col,
|
||||
const fb_pixel_t& text_col, const fb_pixel_t& sel_text_col,
|
||||
const int& frame_width,
|
||||
const int& sel_frame_width)
|
||||
{
|
||||
if (chain){
|
||||
for (size_t i= 0; i< chain->size(); i++){
|
||||
CComponentsButton *btn = static_cast<CComponentsButton*>(chain->getCCItem(i));
|
||||
btn->setButtonTextColor(text_col);
|
||||
}
|
||||
fb_pixel_t sel_col = fr_col;
|
||||
if (chain->size() > 1)
|
||||
sel_col = sel_fr_col; //TODO: make it configurable
|
||||
chain->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width);
|
||||
|
||||
getSelectedButtonObject()->setButtonTextColor(sel_text_col);
|
||||
}
|
||||
}
|
||||
|
||||
int CComponentsFooter::getSelectedButton()
|
||||
{
|
||||
int ret = -1;
|
||||
if (chain)
|
||||
ret = chain->getSelectedItem();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CComponentsButton* CComponentsFooter::getSelectedButtonObject()
|
||||
{
|
||||
CComponentsButton* ret = static_cast<CComponentsButton*>(chain->getSelectedItemObject());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void CComponentsFooter::paintButtons(const int& x_pos,
|
||||
const int& y_pos,
|
||||
const int& w,
|
||||
@@ -395,12 +357,12 @@ void CComponentsFooter::enableButtonShadow(int mode, const int& shadow_width, bo
|
||||
ccf_enable_button_shadow = mode;
|
||||
ccf_button_shadow_width = shadow_width;
|
||||
ccf_button_shadow_force_paint = force_paint;
|
||||
if (chain){
|
||||
for(size_t i=0; i<chain->size(); i++){
|
||||
chain->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint);
|
||||
if (btn_container){
|
||||
for(size_t i=0; i<btn_container->size(); i++){
|
||||
btn_container->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint);
|
||||
//int y_btn = ccf_enable_button_shadow == CC_SHADOW_OFF ? CC_CENTERED : chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2 - ccf_button_shadow_width;
|
||||
int y_btn = chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2;
|
||||
chain->getCCItem(i)->setYPos(y_btn);
|
||||
int y_btn = btn_container->getHeight()/2 - btn_container->getCCItem(i)->getHeight()/2;
|
||||
btn_container->getCCItem(i)->setYPos(y_btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,8 @@
|
||||
|
||||
#include "cc_frm_header.h"
|
||||
#include "cc_frm_button.h"
|
||||
#include "cc_button_select.h"
|
||||
|
||||
#include <global.h>
|
||||
#include <gui/widget/buttons.h> //for compatibility with 'button_label' type
|
||||
|
||||
@@ -39,7 +41,7 @@ to add button labels known by older button handler, to find in gui/widget/button
|
||||
functionality. Why limited ?: old parameter 'struct button_label' doesn't provide newer parameters.
|
||||
Missing parameters are filled with default values and must be assigned afterward, if required.
|
||||
*/
|
||||
class CComponentsFooter : public CComponentsHeader
|
||||
class CComponentsFooter : public CComponentsHeader, public CCButtonSelect
|
||||
{
|
||||
private:
|
||||
void initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||
@@ -67,9 +69,6 @@ class CComponentsFooter : public CComponentsHeader
|
||||
///init default fonts for size modes
|
||||
virtual void initDefaultFonts();
|
||||
|
||||
///container for button objects
|
||||
CComponentsFrmChain *chain;
|
||||
|
||||
public:
|
||||
CComponentsFooter(CComponentsForm *parent = NULL);
|
||||
CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
|
||||
@@ -114,40 +113,6 @@ class CComponentsFooter : public CComponentsHeader
|
||||
///disables background of buttons
|
||||
void disableButtonBg(){enableButtonBg(false);}
|
||||
|
||||
/**Select a definied button inside button chain object
|
||||
* @param[in] item_id
|
||||
* @li optional: exepts type size_t
|
||||
* @param[in] fr_col
|
||||
* @li optional: exepts type fb_pixel_t, as default frame color
|
||||
* @param[in] sel_fr_col
|
||||
* @li optional: exepts type fb_pixel_t, as selected frame color
|
||||
* @param[in] bg_col
|
||||
* @li optional: exepts type fb_pixel_t, as default background color
|
||||
* @param[in] sel_bg_col
|
||||
* @li optional: exepts type fb_pixel_t, as selected background color
|
||||
* @param[in] text_col
|
||||
* @li optional: exepts type fb_pixel_t, as default text color
|
||||
* @param[in] sel_text_col
|
||||
* @li optional: exepts type fb_pixel_t, as selected text color
|
||||
* @param[in] frame_width
|
||||
* @li optional: exepts type int, default = 1
|
||||
* @param[in] sel_frame_width
|
||||
* @li optional: exepts type int, default = 2
|
||||
*/
|
||||
void setSelectedButton(size_t item_id,
|
||||
const fb_pixel_t& fr_col = COL_MENUCONTENTSELECTED_PLUS_2,
|
||||
const fb_pixel_t& sel_fr_col = COL_MENUCONTENTSELECTED_PLUS_0,
|
||||
const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0,
|
||||
const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0,
|
||||
const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT,
|
||||
const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT,
|
||||
const int& frame_width = 1,
|
||||
const int& sel_frame_width = 1);
|
||||
///returns id of select button, return value as int, -1 = nothing is selected
|
||||
int getSelectedButton();
|
||||
///returns selected button object, return value as pointer to object, NULL means nothing is selected
|
||||
CComponentsButton* getSelectedButtonObject();
|
||||
|
||||
/*!
|
||||
Sets a new text to an already predefined button.
|
||||
1st parameter 'btn_id' accepts current id of an already defined button. 2nd parameter sets the new text as std::string
|
||||
@@ -164,10 +129,6 @@ class CComponentsFooter : public CComponentsHeader
|
||||
///property: set font for label caption, parameter as font object, value NULL causes usage of dynamic font
|
||||
void setButtonFont(Font* font){ccf_btn_font = font;};
|
||||
|
||||
///returns pointer to internal button container
|
||||
CComponentsFrmChain* getButtonChainObject(){return chain;};
|
||||
|
||||
|
||||
///this is a nearly methode similar with the older button handler find in gui/widget/buttons.h, some parameters are different, but require minimalized input
|
||||
///this member sets some basic parameters and will paint concurrently on execute, explicit call of paint() is not required
|
||||
void paintButtons( const int& x_pos,
|
||||
@@ -196,4 +157,6 @@ class CComponentsFooter : public CComponentsHeader
|
||||
void disbaleButtonShadow(){enableButtonShadow(CC_SHADOW_OFF);}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -302,7 +302,7 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
|
||||
}
|
||||
|
||||
///returns the clock object
|
||||
virtual CComponentsFrmClock* getClockObject(){return cch_cl_obj;}
|
||||
CComponentsFrmClock* getClockObject(){return cch_cl_obj;}
|
||||
|
||||
///enable display of clock, parameter bool enable, const char* format, bool run
|
||||
virtual void enableClock(bool enable = true, const char* format = "%H:%M", const char* sec_format_str = NULL, bool run = false);
|
||||
|
@@ -220,6 +220,16 @@ void CComponentsScrollBar::initSegments()
|
||||
}
|
||||
}
|
||||
|
||||
void getScrollBarData(int *total_pages, int *current_page, int total_items, int items_per_page, int selected_item)
|
||||
{
|
||||
// avoid divison by zero and fix wrong values
|
||||
total_items = std::max(total_items, 1);
|
||||
items_per_page = std::max(items_per_page, 1);
|
||||
selected_item = std::max(selected_item, 0);
|
||||
|
||||
*total_pages = ((total_items - 1) / items_per_page) + 1;
|
||||
*current_page = selected_item / items_per_page;
|
||||
}
|
||||
|
||||
void paintScrollBar( const int &x_pos,
|
||||
const int &y_pos,
|
||||
|
@@ -145,6 +145,8 @@ class CComponentsScrollBar : public CComponentsFrmChain
|
||||
void disableVisualize(){enableVisualize(false);}
|
||||
};
|
||||
|
||||
void getScrollBarData(int *total_pages, int *current_page, int total_items, int items_per_page, int selected_item);
|
||||
|
||||
/**Small and easy to apply scrollbar paint methode without expilcit object declaration
|
||||
* @return void
|
||||
*
|
||||
|
@@ -51,10 +51,10 @@ CComponentsInfoBox::CComponentsInfoBox( const int& x_pos,
|
||||
{
|
||||
cc_item_type = CC_ITEMTYPE_TEXT_INFOBOX;
|
||||
|
||||
x = x_pos;
|
||||
y = y_pos;
|
||||
width = w;
|
||||
height = h;
|
||||
x = x_old = x_pos;
|
||||
y = y_old = y_pos;
|
||||
width = width_old = w;
|
||||
height = height_old = h;
|
||||
shadow = shadow_mode;
|
||||
col_frame = color_frame;
|
||||
cc_enable_frame = true;
|
||||
@@ -124,7 +124,7 @@ void CComponentsInfoBox::paintPicture()
|
||||
pic->doPaintBg(false);
|
||||
|
||||
//fit icon into frame
|
||||
pic->setYPos(y_pic+(height/2-pic->getHeight()/2));
|
||||
pic->setYPos(y_pic+(height-2*fr_thickness)/2-pic->getHeight()/2);
|
||||
|
||||
//paint, but set visibility mode
|
||||
pic->allowPaint(cc_allow_paint);
|
||||
|
@@ -57,10 +57,10 @@ CProgressBar::CProgressBar( const int x_pos,
|
||||
cc_item_type = CC_ITEMTYPE_PROGRESSBAR;
|
||||
|
||||
//CComponents
|
||||
x = x_pos;
|
||||
y = y_pos;
|
||||
width = w;
|
||||
height = h;
|
||||
x = x_old = x_pos;
|
||||
y = y_old = y_pos;
|
||||
width = width_old = w;
|
||||
height = height_old = h;
|
||||
|
||||
col_frame = color_frame;
|
||||
col_body = color_body;
|
||||
@@ -198,6 +198,7 @@ void CProgressBarCache::pbcClear()
|
||||
if ((*it)->pbc_passive)
|
||||
free((*it)->pbc_passive);
|
||||
delete (*it);
|
||||
(*it) = NULL;
|
||||
}
|
||||
pbCache.clear();
|
||||
}
|
||||
|
@@ -95,8 +95,6 @@ class CComponentsText : public CCTextScreen, public CComponentsItem
|
||||
///destroy current CTextBox and CBox objects
|
||||
void clearCCText();
|
||||
|
||||
///initialize all required attributes for text and send to the CTextBox object
|
||||
void initCCText();
|
||||
///init internal CBox object required by CTextBox object
|
||||
void initCBox();
|
||||
|
||||
@@ -164,6 +162,9 @@ class CComponentsText : public CCTextScreen, public CComponentsItem
|
||||
///send option to CTextBox object to paint background box behind text or not
|
||||
virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;};
|
||||
|
||||
///initialize all required attributes for text and send to the CTextBox object
|
||||
void initCCText();
|
||||
|
||||
///set text as string also possible with overloades members for loacales, const char and text file, returns true if text was changed
|
||||
virtual bool setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR);
|
||||
///set text with const char*, returns true if text was changed
|
||||
|
@@ -34,6 +34,7 @@ struct gradientData_t;
|
||||
class Font;
|
||||
class CComponentsForm;
|
||||
class CComponentsScrollBar;
|
||||
class CCButtonSelect;
|
||||
|
||||
///cc item types
|
||||
typedef enum
|
||||
|
Reference in New Issue
Block a user