Merge remote-tracking branch 'check/next-cc'

Lightly tested only...
This commit is contained in:
Stefan Seyfried
2013-12-25 22:51:23 +01:00
90 changed files with 1583 additions and 1578 deletions

View File

@@ -20,12 +20,14 @@ libneutrino_gui_components_a_SOURCES = \
cc_detailsline.cpp \
cc_frm_button.cpp \
cc_frm.cpp \
cc_frm_chain.cpp \
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_slider.cpp \
cc_frm_window.cpp \
cc_item.cpp \
cc_item_infobox.cpp \

View File

@@ -44,8 +44,10 @@ Basic attributes and member functions for component sub classes
#include "cc_frm.h"
#include "cc_frm_button.h"
#include "cc_frm_chain.h"
#include "cc_frm_clock.h"
#include "cc_frm_signalbars.h"
#include "cc_frm_slider.h"

View File

@@ -177,6 +177,9 @@ void CComponents::paintFbItems(bool do_save_bg)
//screen area save
inline fb_pixel_t* CComponents::getScreen(int ax, int ay, int dx, int dy)
{
if (dx * dy == 0)
return NULL;
fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy];
frameBuffer->waitForIdle("CComponents::getScreen()");
frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf);
@@ -187,14 +190,13 @@ inline fb_pixel_t* CComponents::getScreen(int ax, int ay, int dx, int dy)
inline void CComponents::hide()
{
for(size_t i =0; i< v_fbdata.size() ;i++) {
if (v_fbdata[i].pixbuf != NULL){
if (v_fbdata[i].pixbuf){
frameBuffer->waitForIdle("CComponents::hide()");
frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf);
delete[] v_fbdata[i].pixbuf;
v_fbdata[i].pixbuf = NULL;
}
}
v_fbdata.clear();
clear();
is_painted = false;
}
@@ -212,7 +214,7 @@ void CComponents::kill()
inline void CComponents::clear()
{
for(size_t i =0; i< v_fbdata.size() ;i++)
if (v_fbdata[i].pixbuf != NULL)
if (v_fbdata[i].pixbuf)
delete[] v_fbdata[i].pixbuf;
v_fbdata.clear();
}

View File

@@ -35,26 +35,17 @@
using namespace std;
//sub class CComponentsDetailLine from CComponents
CComponentsDetailLine::CComponentsDetailLine()
CComponentsDetailLine::CComponentsDetailLine( const int& x_pos, const int& y_pos_top,
const int& y_pos_down, const int& h_mark_top_, const int& h_mark_down_,
fb_pixel_t color_line, fb_pixel_t color_shadow)
{
initVarDline();
//CComponents
x = 0;
y = 0;
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
col_body = COL_MENUCONTENT_PLUS_6;
//CComponentsDetailLine
y_down = 0;
h_mark_top = CC_HEIGHT_MIN;
h_mark_down = CC_HEIGHT_MIN;
initVarDline(x_pos, y_pos_top, y_pos_down, h_mark_top_, h_mark_down_, color_line, color_shadow);
}
CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_top, const int y_pos_down, const int h_mark_top_, const int h_mark_down_, fb_pixel_t color_line, fb_pixel_t color_shadow)
void CComponentsDetailLine::initVarDline( const int& x_pos, const int& y_pos_top,
const int& y_pos_down, const int& h_mark_top_, const int& h_mark_down_,
fb_pixel_t color_line, fb_pixel_t color_shadow)
{
initVarDline();
//CComponents
x = x_pos;
y = y_pos_top;
@@ -65,10 +56,7 @@ CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_to
y_down = y_pos_down;
h_mark_top = h_mark_top_;
h_mark_down = h_mark_down_;
}
void CComponentsDetailLine::initVarDline()
{
shadow_w = 1;
//CComponentsDetailLine

View File

@@ -50,12 +50,13 @@ class CComponentsDetailLine : public CComponents
int h_mark_down;
///initialize all internal attributes
void initVarDline();
void initVarDline( const int& x_pos, const int& y_pos_top, const int& y_pos_down,
const int& h_mark_top_, const int& h_mark_down_,
fb_pixel_t color_line, fb_pixel_t color_shadow);
public:
CComponentsDetailLine();
CComponentsDetailLine( const int x_pos,const int y_pos_top, const int y_pos_down,
const int h_mark_up = CC_HEIGHT_MIN , const int h_mark_down = CC_HEIGHT_MIN,
CComponentsDetailLine( const int& x_pos = 1,const int& y_pos_top = 1, const int& y_pos_down = 1,
const int& h_mark_top_ = CC_HEIGHT_MIN , const int& h_mark_down_ = CC_HEIGHT_MIN,
fb_pixel_t color_line = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
~CComponentsDetailLine();

View File

@@ -151,6 +151,12 @@ void CComponentsForm::addCCItem(CComponentsItem* cc_Item)
#endif
}
void CComponentsForm::addCCItem(const std::vector<CComponentsItem*> &cc_Items)
{
for (size_t i= 0; i< cc_Items.size(); i++)
addCCItem(cc_Items[i]);
}
int CComponentsForm::getCCItemId(CComponentsItem* cc_Item)
{
if (cc_Item){
@@ -297,6 +303,15 @@ void CComponentsForm::paintCCItems()
int xpos = cc_item->getXPos();
int ypos = cc_item->getYPos();
//check item for corrupt position, skip current item if found problems
//TODO: need a solution with possibility for scrolling
if (ypos > height || xpos > width){
printf("[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined width=%d \ndefinied y=%d, defined height=%d \n",
__func__, cc_item_index, cc_item->getIndex(), cc_item->getItemType(), xpos, width, ypos, height);
if (this->cc_item_type != CC_ITEMTYPE_FRM_CHAIN)
continue;
}
//set required x-position to item:
//append vertical
if (xpos == CC_APPEND){

View File

@@ -57,6 +57,7 @@ class CComponentsForm : public CComponentsItem
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void hide(bool no_restore = false);
virtual void addCCItem(CComponentsItem* cc_Item);
virtual void addCCItem(const std::vector<CComponentsItem*> &cc_items);
virtual void insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item);
virtual void removeCCItem(const uint& cc_item_id);
virtual void removeCCItem(CComponentsItem* cc_Item);

View File

@@ -136,14 +136,13 @@ void CComponentsButton::initCaption()
//if we have an icon, we must calculate positions for booth items together
//also the icon width and left position = 0
int face_w = 0;
int face_x = 0;
//calculate width and left position of icon, if available, picture position is default centered
if (cc_btn_icon_obj){
//if found a picture object, then get width from it...
face_w = cc_btn_icon_obj->getWidth();
//...and set position as centered
face_x = width/2 - face_w/2;
int face_x = width/2 - face_w/2;
cc_btn_icon_obj->setXPos(face_x);
}

View File

@@ -0,0 +1,126 @@
/*
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, see <http://www.gnu.org/licenses/>.
*/
#include <global.h>
#include <neutrino.h>
#include "cc_frm_chain.h"
using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsFrmChain
CComponentsFrmChain::CComponentsFrmChain( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::vector<CComponentsItem*> *v_items,
bool horizontal,
bool dynamic_width,
bool dynamic_height,
bool has_shadow,
fb_pixel_t& color_frame,
fb_pixel_t& color_body,
fb_pixel_t& color_shadow)
{
initVarChain(x_pos, y_pos, w, h, v_items, horizontal, dynamic_width, dynamic_height, has_shadow, color_frame, color_body, color_shadow);
}
void CComponentsFrmChain::initVarChain( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::vector<CComponentsItem*> *v_items,
bool horizontal,
bool dynamic_width,
bool dynamic_height,
bool has_shadow,
fb_pixel_t& color_frame,
fb_pixel_t& color_body,
fb_pixel_t& color_shadow)
{
cc_item_type = CC_ITEMTYPE_FRM_CHAIN;
corner_rad = 0;
x = x_pos;
y = y_pos;
width = w;
height = h;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
chn_horizontal = horizontal;
chn_dyn_height = dynamic_height;
chn_dyn_width = dynamic_width;
if (v_items){
addCCItem(*v_items);
initCChainItems();
}
}
void CComponentsFrmChain::initCChainItems()
{
if (!v_cc_items.empty()){
if (chn_dyn_height)
height = 0;
if (chn_dyn_width)
width = 0;
}
for (size_t i= 0; i< v_cc_items.size(); i++){
//set general start position for all items
if (i == 0)
v_cc_items[i]->setPos(0, 0);
//set arrangement with required direction
if (chn_horizontal){
if (i > 0)
v_cc_items[i]->setPos(CC_APPEND, 0);
}
else{
if (i > 0)
v_cc_items[i]->setPos(0, CC_APPEND);
}
//assign size
if (chn_horizontal){
//assign dynamic width
if (chn_dyn_width)
width += v_cc_items[i]->getWidth();
//assign dynamic height
if (chn_dyn_height)
height = max(v_cc_items[i]->getHeight(), height);
else
v_cc_items[i]->setHeight(height);
}
else{
//assign dynamic height
if (chn_dyn_height)
height += v_cc_items[i]->getHeight();
//assign dynamic width
if (chn_dyn_width)
width = max(v_cc_items[i]->getWidth(), width);
else
v_cc_items[i]->setWidth(width);
}
}
}

View File

@@ -0,0 +1,78 @@
/*
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CC_FORM_CHAIN_H__
#define __CC_FORM_CHAIN_H__
#include <config.h>
#include "cc_frm.h"
//! Sub class of CComponentsForm. Creates a dynamic form with chained items.
/*!
Paint chained cc-items on screen.
You can set default form parameters like position, size, colors etc. and additional values
to display with defined direction.
*/
class CComponentsFrmChain : public CComponentsForm
{
private:
///property: defined arrangement mode of items, can be vertical or horizontal
int chn_horizontal;
///property: defines height from sum of all contained items
bool chn_dyn_height;
///property: defines width from sum of all contained items
bool chn_dyn_width;
///init all required variables
void initVarChain( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::vector<CComponentsItem*> *v_items,
bool horizontal,
bool dynamic_width,
bool dynamic_height,
bool has_shadow,
fb_pixel_t& color_frame,
fb_pixel_t& color_body,
fb_pixel_t& color_shadow);
void initCChainItems();
protected:
public:
CComponentsFrmChain( const int& x_pos = 1, const int& y_pos = 1, const int& w = 720, const int& h = 32,
const std::vector<CComponentsItem*> *v_items = NULL,
bool horizontal = true,
bool dynamic_width = false,
bool dynamic_height = false,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t& color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t& color_body = COL_MENUHEAD_PLUS_0,
fb_pixel_t& color_shadow = COL_MENUCONTENTDARK_PLUS_0);
// ~CComponentsSlider(); //inherited from CComponentsForm
};
#endif

View File

@@ -41,18 +41,19 @@
using namespace std;
CComponentsFrmClock::CComponentsFrmClock()
{
initVarClock();
}
CComponentsFrmClock::CComponentsFrmClock( const int x_pos, const int y_pos, const int w, const int h,
CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, const int& y_pos, const int& w, const int& h,
const char* format_str, bool activ, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarClock();
initVarClock(x_pos, y_pos, w, h, format_str, activ, has_shadow, color_frame, color_body, color_shadow);
}
void CComponentsFrmClock::initVarClock( const int& x_pos, const int& y_pos, const int& w, const int& h,
const char* format_str, bool activ, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
x = x_pos;
y = y_pos;
width = w;
@@ -63,15 +64,6 @@ CComponentsFrmClock::CComponentsFrmClock( const int x_pos, const int y_pos, cons
col_body = color_body;
col_shadow = color_shadow;
cl_format_str = format_str;
paintClock = false;
activeClock = activ;
if (activeClock)
startThread();
}
void CComponentsFrmClock::initVarClock()
{
cc_item_type = CC_ITEMTYPE_FRM_CLOCK;
corner_rad = RADIUS_SMALL;
@@ -80,7 +72,7 @@ void CComponentsFrmClock::initVarClock()
dyn_font_size = 0;
cl_col_text = COL_MENUCONTENT_TEXT;
cl_format_str = "%H:%M";
cl_format_str = format_str;
cl_align = CC_ALIGN_VER_CENTER | CC_ALIGN_HOR_CENTER;
cl_thread = 0;
@@ -88,6 +80,11 @@ void CComponentsFrmClock::initVarClock()
activeClock = true;
cl_blink_str = "";
paintClock = false;
activeClock = activ;
if (activeClock)
startThread();
}
CComponentsFrmClock::~CComponentsFrmClock()

View File

@@ -78,7 +78,9 @@ class CComponentsFrmClock : public CComponentsForm
int cl_align;
///initialize all attributes and required objects
void initVarClock();
void initVarClock( const int& x_pos, const int& y_pos, const int& w, const int& h,
const char* format_str, bool activ, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow);
///initialize clock contents
void initCCLockItems();
@@ -91,8 +93,7 @@ class CComponentsFrmClock : public CComponentsForm
inline Font** getClockFont();
public:
CComponentsFrmClock();
CComponentsFrmClock( const int x_pos, const int y_pos, const int w, const int h,
CComponentsFrmClock( const int& x_pos = 1, const int& y_pos = 1, const int& w = 200, const int& h = 48,
const char* format_str = "%H:%M", bool activ=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);
virtual ~CComponentsFrmClock();

View File

@@ -0,0 +1,168 @@
/*
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, see <http://www.gnu.org/licenses/>.
*/
#include <global.h>
#include <neutrino.h>
#include "cc_frm_slider.h"
using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsSlider
CComponentsSlider::CComponentsSlider( const int& x_pos, const int& y_pos, const int& w, const int& h,
const int& current_value,
const int& min_value,
const int& max_value,
bool has_shadow,
fb_pixel_t& color_frame,
fb_pixel_t& color_body,
fb_pixel_t& color_shadow)
{
initVarSlider(x_pos, y_pos, w, h, current_value, min_value, max_value, has_shadow, color_frame, color_body, color_shadow);
initCCSlItems();
}
void CComponentsSlider::initVarSlider( const int& x_pos, const int& y_pos, const int& w, const int& h,
const int& current_value,
const int& min_value,
const int& max_value,
bool has_shadow,
fb_pixel_t& color_frame,
fb_pixel_t& color_body,
fb_pixel_t& color_shadow)
{
cc_item_type = CC_ITEMTYPE_SLIDER;
corner_rad = 0;
x = x_pos;
y = y_pos;
width = w;
height = h;
csl_current_value = current_value;
csl_min_value = min_value;
csl_max_value = max_value;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
csl_body_obj = NULL;
csl_slider_obj = NULL;
csl_body_icon = NEUTRINO_ICON_VOLUMEBODY;
csl_slider_icon =NEUTRINO_ICON_VOLUMESLIDER2;
}
//set current value
void CComponentsSlider::setValuePos(const int& current_value)
{
csl_current_value = current_value;
if (csl_slider_obj->isPicPainted())
csl_slider_obj->hide();
initCCSlItems();
}
//set current scale values
void CComponentsSlider::setValueScale(const int& min_value, const int& max_value)
{
csl_min_value = min_value;
csl_max_value = max_value;
initCCSlItems();
}
//init slider body object and add to container
void CComponentsSlider::initCCSlBody()
{
if (!csl_body_icon.empty()){
printf("[CComponentsSlider] [%s] missing or undefinied slider body icon %s\n", __func__, csl_body_icon.c_str());
if (csl_body_obj == NULL){
csl_body_obj = new CComponentsPicture(0, 0, 0, height, csl_body_icon);
csl_body_obj->doPaintBg(false);
addCCItem(csl_body_obj);
}
else
csl_body_obj->setPicture(csl_body_icon);
}
else
return;
//get first icon dimensions
int icon_w = csl_body_obj->getWidth();
int icon_h = csl_body_obj->getHeight();
//position of icon default centered
int icon_x = width/2-icon_w/2;
int icon_y = height/2-icon_h/2;
if (csl_body_obj){
csl_body_obj->setDimensionsAll(icon_x, icon_y, icon_w, icon_h);
csl_body_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
}
}
//init slider caption object and add to container
void CComponentsSlider::initCCSlSlider()
{
if (!csl_slider_icon.empty()){
printf("[CComponentsSlider] [%s] missing or undefinied slider icon %s\n", __func__, csl_slider_icon.c_str());
if (csl_slider_obj == NULL){
csl_slider_obj = new CComponentsPicture(0, 0, 0, 0, csl_slider_icon);
csl_slider_obj->doPaintBg(false);
addCCItem(csl_slider_obj);
}
else
csl_slider_obj->setPicture(csl_slider_icon);
}
else
return;
//get first icon dimensions
int slider_w = csl_slider_obj->getWidth();
int slider_h = csl_slider_obj->getHeight();
//position of slider icon
int slider_x = csl_body_obj->getXPos() - slider_w/2 + csl_body_obj->getWidth() * (abs(csl_min_value) + csl_current_value) / (abs(csl_min_value) + abs(csl_max_value));
int slider_y = height/2-slider_h/2;
if (csl_slider_obj)
csl_slider_obj->setDimensionsAll(slider_x, slider_y, slider_w, slider_h);
}
void CComponentsSlider::initCCSlItems()
{
initCCSlBody();
initCCSlSlider();
}
// void CComponentsSlider::paint(bool do_save_bg)
// {
// //prepare items before paint
// initCCSlItems();
//
// //paint form contents
// paintForm(do_save_bg);
// }

View File

@@ -0,0 +1,92 @@
/*
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CC_FORM_SLIDER_H__
#define __CC_FORM_SLIDER_H__
#include <config.h>
#include "cc_frm.h"
//! Sub class of CComponentsForm. Shows a slider.
/*!
Paint a simple slider on screen.
You can set default form parameters like position, size, colors etc. and additional values
to display current values with a slider icon.
*/
class CComponentsSlider : public CComponentsForm
{
private:
///names of slider icons
std::string csl_body_icon, csl_slider_icon;
///property: current value that should be displayed by slider button, see also setValuePos()
int csl_current_value;
///property: minimal scale value, see also setValueScale()
int csl_min_value;
///property: maximal scale value, see also setValueScale()
int csl_max_value;
///object: image objects for slider button and body
CComponentsPicture *csl_body_obj, *csl_slider_obj;
///init body image object
void initCCSlBody();
///init slider image object
void initCCSlSlider();
///init all items at once
void initCCSlItems();
///init all required variables
void initVarSlider( const int& x_pos, const int& y_pos, const int& w, const int& h,
const int& current_value,
const int& min_value,
const int& max_value,
bool has_shadow,
fb_pixel_t& color_frame,
fb_pixel_t& color_body,
fb_pixel_t& color_shadow);
protected:
public:
CComponentsSlider( const int& x_pos = 1, const int& y_pos = 1, const int& w = 120+16, const int& h = 32,
const int& current_value = 0,
const int& min_value = 0,
const int& max_value = 100,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t& color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t& color_body = COL_MENUHEAD_PLUS_0,
fb_pixel_t& color_shadow = COL_MENUCONTENTDARK_PLUS_0);
// ~CComponentsSlider(); //inherited from CComponentsForm
void setValuePos(const int& current_value);
void setValueScale(const int& min_value, const int& max_value);
// void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
#endif

View File

@@ -43,6 +43,7 @@ typedef enum
CC_ITEMTYPE_SHAPE_CIRCLE,
CC_ITEMTYPE_PIP,
CC_ITEMTYPE_FRM,
CC_ITEMTYPE_FRM_CHAIN,
CC_ITEMTYPE_FRM_CLOCK,
CC_ITEMTYPE_FRM_HEADER,
CC_ITEMTYPE_FOOTER,
@@ -56,6 +57,7 @@ typedef enum
CC_ITEMTYPE_BUTTON_GREEN,
CC_ITEMTYPE_BUTTON_YELLOW,
CC_ITEMTYPE_BUTTON_BLUE,
CC_ITEMTYPE_SLIDER,
CC_ITEMTYPES
}CC_ITEMTYPES_T;

View File

@@ -1,615 +0,0 @@
/*
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
Copyright (C) 2012, 2013, Thilo Graf 'dbt'
Copyright (C) 2012, Michael Liebmann 'micha-bbg'
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_misc.h"
using namespace std;
//sub class CComponentsItemBox from CComponentsItem
CComponentsItemBox::CComponentsItemBox()
{
//CComponentsItemBox
initVarItemBox();
}
CComponentsItemBox::~CComponentsItemBox()
{
hide();
clearElements();
clearSavedScreen();
clear();
}
void CComponentsItemBox::initVarItemBox()
{
//CComponents, CComponentsItem
initVarItem();
//CComponentsItemBox
it_col_text = COL_MENUCONTENT_TEXT;
hSpacer = 2;
hOffset = 4;
vOffset = 1;
digit_h = 0;
digit_offset = 0;
font_text = NULL;
paintElements = true;
hMax = 0;
has_TextElement = false;
firstElementLeft = FIRST_ELEMENT_INIT;
firstElementRight = FIRST_ELEMENT_INIT;
prevElementLeft = 0;
prevElementRight = 0;
onlyOneTextElement = false;
isCalculated = false;
v_element_data.clear();
}
int CComponentsItemBox::getHeight()
{
if (!isCalculated)
calculateElements();
return height;
}
void CComponentsItemBox::clearElements()
{
for(size_t i = 0; i < v_element_data.size(); i++) {
switch (v_element_data[i].type) {
case CC_ITEMBOX_ICON:
case CC_ITEMBOX_PICTURE:
if (v_element_data[i].handler1 != NULL)
delete static_cast<CComponentsPicture*>(v_element_data[i].handler1);
break;
case CC_ITEMBOX_TEXT:
if (v_element_data[i].handler1 != NULL)
delete static_cast<CBox*>(v_element_data[i].handler1);
if (v_element_data[i].handler2 != NULL)
delete static_cast<CTextBox*>(v_element_data[i].handler2);
break;
default:
break;
}
}
isCalculated = false;
v_element_data.clear();
}
extern CPictureViewer * g_PicViewer;
bool CComponentsItemBox::addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index)
{
comp_element_data_t data;
int dx=0, dy=0;
data.align = align;
data.x = x;
data.y = y;
data.width = 0;
data.height = 0;
data.handler1 = NULL;
data.handler2 = NULL;
g_PicViewer->getSize(logo.c_str(), &dx, &dy);
if ((dx != 0) && (dy != 0)) {
// logo OK
data.type = CC_ITEMBOX_PICTURE;
data.element = logo;
}
else {
// no logo
if ((text == "") || ((onlyOneTextElement) && (has_TextElement)))
return false;
else
has_TextElement = true;
if (font_text != NULL)
data.height = font_text->getHeight();
data.type = CC_ITEMBOX_TEXT;
data.element = text;
}
v_element_data.push_back(data);
if (index != NULL)
*index = v_element_data.size()-1;
isCalculated = false;
return true;
}
void CComponentsItemBox::addText(const std::string& s_text, const int align, size_t *index)
{
addElement(align, CC_ITEMBOX_TEXT, s_text, index);
}
void CComponentsItemBox::addText(neutrino_locale_t locale_text, const int align, size_t *index)
{
addElement(align, CC_ITEMBOX_TEXT, g_Locale->getText(locale_text), index);
}
void CComponentsItemBox::addIcon(const std::string& s_icon_name, const int align, size_t *index)
{
addElement(align, CC_ITEMBOX_ICON, s_icon_name, index);
}
void CComponentsItemBox::addPicture(const std::string& s_picture_path, const int align, size_t *index)
{
addElement(align, CC_ITEMBOX_PICTURE, s_picture_path, index);
}
void CComponentsItemBox::addClock(const int align, size_t *index)
{
addElement(align, CC_ITEMBOX_CLOCK, "", index);
}
bool CComponentsItemBox::addElement(int align, int type, const std::string& element, size_t *index)
{
comp_element_data_t data;
int dx=0, dy=0;
switch (type)
{
case CC_ITEMBOX_ICON:
frameBuffer->getIconSize(element.c_str(), &dx, &dy);
if ((dx == 0) || (dy == 0))
return false;
break;
case CC_ITEMBOX_TEXT:
if ((element == "") || ((onlyOneTextElement) && (has_TextElement)))
return false;
else
has_TextElement = true;
break;
default:
break;
}
data.type = type;
data.align = align;
data.element = element;
data.x = x;
data.y = y;
data.width = 0;
data.height = 0;
data.handler1 = NULL;
data.handler2 = NULL;
v_element_data.push_back(data);
if (index != NULL)
*index = v_element_data.size()-1;
isCalculated = false;
return true;
}
void CComponentsItemBox::refreshElement(size_t index, const std::string& element)
{
CComponentsPicture* pic = NULL;
switch (v_element_data[index].type) {
case CC_ITEMBOX_PICTURE:
pic = static_cast<CComponentsPicture*>(v_element_data[index].handler1);
if (pic != NULL) {
pic->hide();
delete pic;
}
v_element_data[index].element = element;
v_element_data[index].x = x;
v_element_data[index].y = y;
v_element_data[index].width = 0;
v_element_data[index].height = 0;
v_element_data[index].handler1 = NULL;
v_element_data[index].handler2 = NULL;
break;
default:
break;
}
calculateElements();
}
//paint image into item box
void CComponentsItemBox::paintImage(size_t index, bool newElement)
{
CComponentsPicture* pic = NULL;
pic = static_cast<CComponentsPicture*>(v_element_data[index].handler1);
int pw = 0, ph = 0;
if ((newElement) || (pic == NULL)) {
if (pic != NULL) {
pic->hide();
delete pic;
pic = NULL;
}
if ((v_element_data[index].type) == CC_ITEMBOX_PICTURE)
pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, v_element_data[index].width,
v_element_data[index].height, v_element_data[index].element);
else
pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, 0, 0, v_element_data[index].element);
v_element_data[index].handler1 = (void*)pic;
}
pic->getPictureSize(&pw, &ph);
pic->setHeight(ph);
pic->setWidth(pw);
pic->setColorBody(col_body);
pic->paint();
}
//paint text into item box
void CComponentsItemBox::paintText(size_t index, bool newElement)
{
//prepare textbox dimension instances
CBox* box = NULL;
box = static_cast<CBox*>(v_element_data[index].handler1);
if ((newElement) || (box == NULL)) {
if (box != NULL) {
delete box;
box = NULL;
}
box = new CBox();
v_element_data[index].handler1 = (void*)box;
}
box->iX = v_element_data[index].x;
box->iY = v_element_data[index].y;
box->iWidth = v_element_data[index].width;
box->iHeight = v_element_data[index].height;
//prepare text
CTextBox* textbox = NULL;
textbox = static_cast<CTextBox*>(v_element_data[index].handler2);
if ((newElement) || (textbox == NULL)) {
if (textbox != NULL) {
textbox->hide();
delete textbox;
textbox = NULL;
}
textbox = new CTextBox(v_element_data[index].element.c_str(), font_text, CTextBox::AUTO_WIDTH|CTextBox::AUTO_HIGH, box, col_body);
v_element_data[index].handler2 = (void*)textbox;
}
textbox->setTextBorderWidth(0,0);
textbox->enableBackgroundPaint(false);
textbox->setTextFont(font_text);
textbox->movePosition(box->iX, box->iY);
textbox->setTextColor(it_col_text);
if (textbox->setText(&v_element_data[index].element))
textbox->paint();
}
//paint available elements at one task
void CComponentsItemBox::paintElement(size_t index, bool newElement)
{
switch (v_element_data[index].type) {
case CC_ITEMBOX_ICON:
case CC_ITEMBOX_PICTURE:
paintImage(index,newElement);
break;
case CC_ITEMBOX_TEXT:
paintText(index,newElement);
break;
case CC_ITEMBOX_CLOCK:
font_text->RenderString(v_element_data[index].x, v_element_data[index].y, v_element_data[index].width,
v_element_data[index].element.c_str(), it_col_text);
break;
default:
break;
}
}
void CComponentsItemBox::calSizeOfElements()
{
size_t i;
// Set element size
for (i = 0; i < v_element_data.size(); i++) {
switch (v_element_data[i].type)
{
case CC_ITEMBOX_ICON:
frameBuffer->getIconSize(v_element_data[i].element.c_str(), &v_element_data[i].width, &v_element_data[i].height);
break;
case CC_ITEMBOX_PICTURE:
g_PicViewer->getSize(v_element_data[i].element.c_str(), &v_element_data[i].width, &v_element_data[i].height);
break;
case CC_ITEMBOX_TEXT:
if (font_text != NULL)
v_element_data[i].height = font_text->getHeight();
break;
case CC_ITEMBOX_CLOCK: {
if (!g_Sectionsd->getIsTimeSet())
break;
if (font_text != NULL) {
char timestr[10] = {0};
time_t now = time(NULL);
struct tm *tm = localtime(&now);
strftime(timestr, sizeof(timestr)-1, "%H:%M", tm);
digit_h = font_text->getDigitHeight();
digit_offset = font_text->getDigitOffset();
v_element_data[i].height = digit_h + (int)((float)digit_offset*1.5);
// v_element_data[i].width = font_text->getMaxDigitWidth() + font->getRenderWidth(":");
v_element_data[i].width = font_text->getRenderWidth(timestr);
v_element_data[i].element = timestr;
}
}
break;
default:
break;
}
}
// Calculate largest height without CC_ITEMBOX_PICTURE
firstElementLeft = FIRST_ELEMENT_INIT;
firstElementRight = FIRST_ELEMENT_INIT;
for (i = 0; i < v_element_data.size(); i++) {
if ((firstElementLeft == FIRST_ELEMENT_INIT) && (v_element_data[i].align == CC_ALIGN_LEFT))
firstElementLeft = i;
if ((firstElementRight == FIRST_ELEMENT_INIT) && (v_element_data[i].align == CC_ALIGN_RIGHT))
firstElementRight = i;
if (v_element_data[i].type != CC_ITEMBOX_PICTURE)
hMax = max(v_element_data[i].height, hMax);
}
}
void CComponentsItemBox::calPositionOfElements()
{
size_t i;
// Calculate y-positions
height = hMax + 2*vOffset;
for (i = 0; i < v_element_data.size(); i++) {
v_element_data[i].y = y + (height - v_element_data[i].height) / 2;
if (v_element_data[i].type == CC_ITEMBOX_CLOCK)
v_element_data[i].y += v_element_data[i].height + digit_offset/4;
}
// Calculate x-positions
for (i = 0; i < v_element_data.size(); i++) {
if (firstElementLeft == i){
prevElementLeft = i;
v_element_data[i].x = x + hOffset + corner_rad/2;
}
else if (firstElementRight == i){
prevElementRight = i;
v_element_data[i].x = x + width - v_element_data[i].width - hOffset - corner_rad/2;
}
else {
if (v_element_data[i].align == CC_ALIGN_LEFT) {
// left elements
v_element_data[i].x = v_element_data[prevElementLeft].x + v_element_data[prevElementLeft].width + hSpacer;
prevElementLeft = i;
}
else {
// right elements
v_element_data[i].x = v_element_data[prevElementRight].x - v_element_data[i].width - hSpacer;
prevElementRight = i;
}
}
}
}
void CComponentsItemBox::calculateElements()
{
if (v_element_data.empty())
return;
size_t i;
calSizeOfElements();
// hMax correction if no text element.
if (!has_TextElement)
hMax = max(font_text->getHeight(), hMax);
// Calculate logo
for (i = 0; i < v_element_data.size(); i++) {
if (v_element_data[i].type == CC_ITEMBOX_PICTURE) {
if ((v_element_data[i].width > LOGO_MAX_WIDTH) || (v_element_data[i].height > hMax))
g_PicViewer->rescaleImageDimensions(&v_element_data[i].width, &v_element_data[i].height, LOGO_MAX_WIDTH, hMax);
}
}
// Calculate text width
int allWidth = 0;
for (i = 0; i < v_element_data.size(); i++) {
if (v_element_data[i].type != CC_ITEMBOX_TEXT)
allWidth += v_element_data[i].width + hSpacer;
}
for (i = 0; i < v_element_data.size(); i++) {
if (v_element_data[i].type == CC_ITEMBOX_TEXT) {
v_element_data[i].width = width - (allWidth + 2*hSpacer);
// If text is too long, number of rows = 2
if (font_text->getRenderWidth(v_element_data[i].element) > v_element_data[i].width) {
v_element_data[i].height = font_text->getHeight() * 2;
hMax = max(v_element_data[i].height, hMax);
}
break;
}
}
calPositionOfElements();
isCalculated = true;
}
void CComponentsItemBox::paintItemBox(bool do_save_bg)
{
// paint background
paintInit(do_save_bg);
if ((v_element_data.empty()) || (!paintElements))
return;
// paint elements
for (size_t i = 0; i < v_element_data.size(); i++)
paintElement(i);
}
void CComponentsItemBox::clearTitlebar()
{
clearElements();
paintElements = false;
paint(false);
paintElements = true;
}
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsTitleBar from CComponentsItemBox
CComponentsTitleBar::CComponentsTitleBar()
{
//CComponentsTitleBar
initVarTitleBar();
}
void CComponentsTitleBar::initVarTitleBar()
{
//CComponentsItemBox
initVarItemBox();
onlyOneTextElement = true;
font_text = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
it_col_text = COL_MENUHEAD_TEXT;
//CComponents
x = 0;
y = 0;
height = font_text->getHeight() + 2*hSpacer;
width = frameBuffer->getScreenWidth(true);;
col_body = COL_MENUHEAD_PLUS_0;
corner_type = CORNER_TOP;
corner_rad = RADIUS_LARGE;
//CComponentsTitleBar
tb_text_align = CC_ALIGN_LEFT;
tb_icon_align = CC_ALIGN_LEFT;
tb_c_text = NULL;
tb_s_text = "";
tb_locale_text = NONEXISTANT_LOCALE;
tb_icon_name = "";
}
CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, const char* c_text, const std::string& s_icon,
fb_pixel_t color_text, fb_pixel_t color_body)
{
//CComponentsItemBox
initVarTitleBar();
it_col_text = color_text;
//CComponents
x = x_pos;
y = y_pos;
height = h;
width = w;
col_body = color_body;
//CComponentsTitleBar
tb_c_text = c_text;
tb_icon_name = s_icon;
initElements();
}
CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, const string& s_text, const std::string& s_icon,
fb_pixel_t color_text, fb_pixel_t color_body)
{
//CComponentsItemBox
initVarTitleBar();
it_col_text = color_text;
//CComponents
x = x_pos;
y = y_pos;
height = h;
width = w;
col_body = color_body;
//CComponentsTitleBar
tb_s_text = s_text;
tb_icon_name = s_icon;
initElements();
}
CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t locale_text, const std::string& s_icon,
fb_pixel_t color_text, fb_pixel_t color_body)
{
//CComponentsItemBox
initVarTitleBar();
it_col_text = color_text;
//CComponents
x = x_pos;
y = y_pos;
height = h;
width = w;
col_body = color_body;
//CComponentsTitleBar
tb_locale_text = locale_text;
tb_s_text = g_Locale->getText(tb_locale_text);
tb_icon_name = s_icon;
initElements();
}
///basic init methodes for constructors ***************************************
void CComponentsTitleBar::initIcon()
{
if (!tb_icon_name.empty())
addElement (tb_icon_align, CC_ITEMBOX_ICON, tb_icon_name);
}
void CComponentsTitleBar::initText()
{
if (tb_c_text){
addElement (tb_text_align, CC_ITEMBOX_TEXT, tb_c_text);
return;
}
else if (!tb_s_text.empty()){
addElement (tb_text_align, CC_ITEMBOX_TEXT, tb_s_text);
return;
}
}
void CComponentsTitleBar::initElements()
{
initIcon();
initText();
}
///*****************************************************************************
void CComponentsTitleBar::paint(bool do_save_bg)
{
calculateElements();
paintItemBox(do_save_bg);
}

View File

@@ -1,113 +0,0 @@
/*
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Experimental Classes for generic GUI-related components. Not really used.
Copyright (C) 2012, Michael Liebmann 'micha-bbg
Copyright (C) 2012, 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.
*/
#ifndef __CC_MISC__
#define __CC_MISC__
#include "config.h"
#include <gui/components/cc_base.h>
#include <vector>
#include <string>
#define FIRST_ELEMENT_INIT 10000
#define LOGO_MAX_WIDTH width/4
class CComponentsItemBox : public CComponentsItem
{
protected:
int hSpacer;
int hOffset;
int vOffset;
int digit_offset, digit_h;
bool paintElements;
bool onlyOneTextElement;
fb_pixel_t it_col_text;
Font* font_text;
int hMax;
bool has_TextElement;
size_t firstElementLeft;
size_t firstElementRight;
size_t prevElementLeft;
size_t prevElementRight;
std::vector<comp_element_data_t> v_element_data;
bool isCalculated;
void clearElements();
void initVarItemBox();
void calSizeOfElements();
void calPositionOfElements();
void paintItemBox(bool do_save_bg = CC_SAVE_SCREEN_YES);
void calculateElements();
bool addElement(int align, int type, const std::string& element="", size_t *index=NULL);
void paintImage(size_t index, bool newElement);
void paintText(size_t index, bool newElement);
public:
CComponentsItemBox();
virtual ~CComponentsItemBox();
inline virtual void setTextFont(Font* font){font_text = font;};
inline virtual void setTextColor(fb_pixel_t color_text){ it_col_text = color_text;};
virtual void refreshElement(size_t index, const std::string& element);
virtual void paintElement(size_t index, bool newElement= false);
virtual bool addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index=NULL);
virtual void clearTitlebar();
virtual void addText(const std::string& s_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
virtual void addText(neutrino_locale_t locale_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
virtual void addIcon(const std::string& s_icon_name, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
virtual void addPicture(const std::string& s_picture_path, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
virtual void addClock(const int align=CC_ALIGN_RIGHT, size_t *index=NULL);
virtual int getHeight();
};
class CComponentsTitleBar : public CComponentsItemBox
{
private:
const char* tb_c_text;
std::string tb_s_text, tb_icon_name;
neutrino_locale_t tb_locale_text;
int tb_text_align, tb_icon_align;
void initText();
void initIcon();
void initElements();
void initVarTitleBar();
public:
CComponentsTitleBar();
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const char* c_text = NULL, const std::string& s_icon ="",
fb_pixel_t color_text = COL_MENUHEAD_TEXT, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0);
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const std::string& s_text ="", const std::string& s_icon ="",
fb_pixel_t color_text = COL_MENUHEAD_TEXT, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0);
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t locale_text = NONEXISTANT_LOCALE, const std::string& s_icon ="",
fb_pixel_t color_text = COL_MENUHEAD_TEXT, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
#endif /*__CC_MISC__*/