Merge branch 'check/next-cc'

it compiles, but is not really tested...

Conflicts:
	src/driver/netfile.cpp
	src/driver/volume.cpp
	src/eitd/sectionsd.cpp
	src/gui/audioplayer.cpp
	src/gui/bedit/bouqueteditor_bouquets.cpp
	src/gui/bedit/bouqueteditor_channels.cpp
	src/gui/bookmarkmanager.cpp
	src/gui/bouquetlist.cpp
	src/gui/eventlist.cpp
	src/gui/movieplayer.cpp
	src/gui/pictureviewer.cpp
	src/gui/scan.cpp
	src/gui/test_menu.h
	src/gui/timerlist.cpp
	src/gui/update.cpp
	src/gui/widget/listbox.cpp
	src/neutrino.cpp
	src/system/flashtool.cpp
	src/zapit/src/Makefile.am
	src/zapit/src/femanager.cpp
This commit is contained in:
Stefan Seyfried
2013-06-16 21:22:14 +02:00
160 changed files with 6251 additions and 2072 deletions

View File

@@ -31,11 +31,12 @@ libneutrino_gui_components_a_SOURCES = \
cc_detailsline.cpp \
cc_frm_button.cpp \
cc_frm.cpp \
cc_frm_clock.cpp \
cc_frm_footer.cpp \
cc_frm_header.cpp \
cc_frm_icons.cpp \
cc_frm_window.cpp \
cc_item.cpp \
cc_item_box.cpp \
cc_item_infobox.cpp \
cc_item_picture.cpp \
cc_item_progressbar.cpp \

View File

@@ -34,68 +34,174 @@
//#define DEBUG_CC
/// Basic component class.
/*!
Basic attributes and member functions for component sub classes
*/
class CComponents
{
protected:
int x, y, height, width, corner_type, shadow_w;
int corner_rad, fr_thickness, fr_thickness_sel;
CFrameBuffer * frameBuffer;
std::vector<comp_fbdata_t> v_fbdata;
fb_pixel_t col_body, col_shadow, col_frame, col_frame_sel;
bool firstPaint, shadow, is_painted, paint_bg;
private:
///pixel buffer handling, returns pixel buffer depends of given parameters
fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
void initVarBasic();
void paintFbItems(bool do_save_bg = true);
virtual fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
comp_screen_data_t saved_screen;
protected:
///object: framebuffer object, usable in all sub classes
CFrameBuffer * frameBuffer;
///container: for frambuffer properties and pixel buffer
std::vector<comp_fbdata_t> v_fbdata;
void clearSavedScreen();
///property: x-position on screen
int x;
///property: y-position on screen
int y;
///property: contains real x-position on screen
int cc_xr;
///property: contains real y-position on screen
int cc_yr;
///property: height-dimension on screen
int height;
///property: width-dimension on screen
int width;
///property: has corners with definied type, types are defined in /driver/frambuffer.h, without effect, if corner_radius=0
int corner_type;
///property: defined radius of corner, without effect, if corner_type=0
int corner_rad;
///property: color of body
fb_pixel_t col_body;
///property: color of shadow
fb_pixel_t col_shadow;
///property: color of frame
fb_pixel_t col_frame;
///property: color of frame if component is selected, Note: fr_thickness_sel must be set
fb_pixel_t col_frame_sel;
///property: true=component has shadow
bool shadow;
///property: width of shadow
int shadow_w;
///property: frame thickness
int fr_thickness;
///property: frame thickness of selected component
int fr_thickness_sel;
///status: true=component was painted for 1st time
bool firstPaint;
///status: true=component was rendered
bool is_painted;
///mode: true=activate rendering of basic elements (frame, shadow and body)
bool paint_bg;
///initialize of basic attributes, no parameters required
void initVarBasic();
///rendering of framebuffer elements at once,
///elements are contained in v_fbdata, presumes added frambuffer elements with paintInit(),
///parameter do_save_bg=true, saves background of element to pixel buffer, this can be restore with hide()
void paintFbItems(bool do_save_bg = true);
///clean up old screen buffer saved in v_fbdata
virtual void clear();
///container: contains saved pixel buffer with position and dimensions
comp_screen_data_t saved_screen;
///cleans saved pixel buffer
void clearSavedScreen();
public:
///basic component class constructor.
CComponents();
virtual~CComponents();
///set screen x-position
inline virtual void setXPos(const int& xpos){x = xpos;};
///set screen y-position,
inline virtual void setYPos(const int& ypos){y = ypos;};
///set x and y position
///Note: position of bound components (items) means position related within parent form, not for screen!
///to set the real screen position, look at setRealPos()
inline virtual void setPos(const int& xpos, const int& ypos){x = xpos; y = ypos;};
inline virtual void setHeight(const int& h){height = h;};
inline virtual void setWidth(const int& w){width = w;};
inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;};
///sets real x position on screen. Use this, if item is added to a parent form
virtual void setRealXPos(const int& xr){cc_xr = xr;};
///sets real y position on screen. Use this, if item is added to a parent form
virtual void setRealYPos(const int& yr){cc_yr = yr;};
///sets real x and y position on screen at once. Use this, if item is added to a parent form
virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;};
///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form
virtual int getRealXPos(){return cc_xr;};
///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form
virtual int getRealYPos(){return cc_yr;};
///set height of component on screen
inline virtual void setHeight(const int& h){height = h;};
///set width of component on screen
inline virtual void setWidth(const int& w){width = w;};
///set all positions and dimensions of component at once
inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;};
///return screen x-position of component
///Note: position of bound components (items) means position related within parent form, not for screen!
///to get the real screen position, use getRealXPos(), to find in CComponentsItem sub classes
inline virtual int getXPos(){return x;};
///return screen y-position of component
///Note: position of bound components (items) means position related within parent form, not for screen!
///to get the real screen position, use getRealYPos(), to find in CComponentsItem sub classes
inline virtual int getYPos(){return y;};
///return height of component
inline virtual int getHeight(){return height;};
///return width of component
inline virtual int getWidth(){return width;};
///return of frame thickness
inline virtual int getFrameThickness(){return fr_thickness;};
///return/set (pass through) width and height of component
inline virtual void getSize(int* w, int* h){*w=width; *h=height;};
///return/set (pass through) position and dimensions of component at once
inline virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;};
///set colors: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
///set frame color
inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
///set body color
inline virtual void setColorBody(fb_pixel_t color){col_body = color;};
///set shadow color
inline virtual void setColorShadow(fb_pixel_t color){col_shadow = color;};
///set all basic framebuffer element colors at once
///Note: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;};
///get colors
///get frame color
inline virtual fb_pixel_t getColorFrame(){return col_frame;};
///get body color
inline virtual fb_pixel_t getColorBody(){return col_body;};
///get shadow color
inline virtual fb_pixel_t getColorShadow(){return col_shadow;};
///set corner types: Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h).
///set corner types
///Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h)
///Note: default values are given from settings
inline virtual void setCornerType(const int& type){corner_type = type;};
///set corner radius
inline virtual void setCornerRadius(const int& radius){corner_rad = radius;};
///get corner types:
///get corner types
inline virtual int getCornerType(){return corner_type;};
///get corner radius
inline virtual int getCornerRadius(){return corner_rad;};
///set frame thickness
inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;};
///switch shadow on/off
///Note: it's recommended to use #defines: CC_SHADOW_ON=true or CC_SHADOW_OFF=false as parameter, see also cc_types.h
inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;};
///hide current screen and restore background
virtual void hide();
///erase current screen without restore of background, as similar to paintBackgroundBoxRel() from CFrameBuffer
///erase current screen without restore of background, it's similar to paintBackgroundBoxRel() from CFrameBuffer
virtual void kill();
///returns paint mode, true=item was painted
virtual bool isPainted(){return is_painted;}
///allows paint of elemetary item parts (shadow, frame and body), similar as background, set it usually to false, if item used in a form
///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;};
};
@@ -103,254 +209,64 @@ class CComponents
class CComponentsItem : public CComponents
{
protected:
///property: define of item type, see cc_types.h for possible types
int cc_item_type;
///property: define of item index, all bound items get an index,
///default: CC_NO_INDEX as identifer for not embedded item and default index=0 for form as main parent
///see also getIndex(), setIndex()
int cc_item_index;
bool cc_item_enabled, cc_item_selected;
///property: default enabled
bool cc_item_enabled;
///property: default not selected
bool cc_item_selected;
///Pointer to the form object in which this item is embedded.
///Is typically the type CComponentsForm or derived classes, default intialized with NULL
CComponents *cc_parent;
CComponentsItem *cc_parent;
///contains real position and dimensions on screen,
int cc_item_xr, cc_item_yr;
///hides item, arg: no_restore=true causes no restore of background, but clean up pixel buffer if required
void hideCCItem(bool no_restore = false);
///initialze of basic framebuffer elements with shadow, background and frame.
///must be called first in all paint() members before paint any item,
///If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this!
///arg do_save_bg=false avoids using of unnecessary pixel memory, eg. if no hide with restore is provided. This is mostly the case whenever
///an item will be hide or overpainted with other methods, or it's embedded (bound) in a parent form.
void paintInit(bool do_save_bg);
///initialize all required attributes
void initVarItem();
public:
CComponentsItem();
///sets pointer to the form object in which this item is embedded.
virtual void setParent(CComponents *parent){cc_parent = parent;};
virtual void setParent(CComponentsItem *parent){cc_parent = parent;};
///sets real position on screen. Use this, if item contains own render methods and item is added to a form
virtual void setRealPos(const int& xr, const int& yr){cc_item_xr = xr; cc_item_yr = yr;};
virtual int getRealXPos(){return cc_item_xr;};
virtual int getRealYPos(){return cc_item_yr;};
///abstract: paint item, arg: do_save_bg see paintInit() above
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
///hides item, arg: no_restore see hideCCItem() above
virtual void hide(bool no_restore = false);
///get the current item type, see attribute cc_item_type above
virtual int getItemType();
///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
virtual void syncSysColors();
///setters for item select stats
///set select mode, see also col_frame_sel
virtual void setSelected(bool selected){cc_item_selected = selected;};
///set enable mode, see also cc_item_enabled
virtual void setEnable(bool enabled){cc_item_enabled = enabled;};
///getters for item enable stats
///get select mode, see also setSelected() above
virtual bool isSelected(){return cc_item_selected;};
///get enable mode, see also setEnable() above
virtual bool isEnabled(){return cc_item_enabled;};
};
class CComponentsPicture : public CComponentsItem
{
protected:
void initVarPicture();
enum
{
CC_PIC_IMAGE_MODE_OFF = 0, //paint pictures in icon mode, mainly not scaled
CC_PIC_IMAGE_MODE_ON = 1, //paint pictures in image mode, paint scaled if required
CC_PIC_IMAGE_MODE_AUTO = 2
};
std::string pic_name;
unsigned char pic_offset;
bool pic_paint, pic_paintBg, pic_painted, do_paint;
int pic_align, pic_x, pic_y, pic_width, pic_height;
int pic_max_w, pic_max_h, pic_paint_mode;
void init( const int x_pos, const int y_pos, const std::string& image_name, const int alignment, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow);
public:
CComponentsPicture( const int x_pos, const int y_pos, const int w, const int h,
const std::string& image_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
virtual inline void setPictureOffset(const unsigned char offset){pic_offset = offset;};
virtual inline void setPicturePaint(bool paint_p){pic_paint = paint_p;};
virtual inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;};
virtual void setPicture(const std::string& picture_name);
virtual void setPictureAlign(const int alignment);
virtual inline bool isPicPainted(){return pic_painted;};
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
virtual void hide(bool no_restore = false);
virtual inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;};
virtual void setMaxWidth(const int w_max){pic_max_w = w_max;};
virtual void setMaxHeight(const int h_max){pic_max_h = h_max;};
};
class CComponentsText : public CComponentsItem
{
protected:
CTextBox * ct_textbox;
CBox * ct_box;
Font * ct_font;
fb_pixel_t ct_col_text;
int ct_text_mode; //see textbox.h for possible modes
std::string ct_text, ct_old_text;
bool ct_text_sent, ct_paint_textbg, ct_force_text_paint;
static std::string iToString(int int_val); //helper to convert int to string
void initVarText();
void clearCCText();
void initCCText();
void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES);
public:
CComponentsText();
CComponentsText( const int x_pos, const int y_pos, const int w, const int h,
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_MENUCONTENT, 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);
virtual ~CComponentsText();
//default members to paint a text box and hide painted text
//hide textbox
void hide(bool no_restore = false);
//paint text box, parameter do_save_bg: default = true, causes fill of backckrond pixel buffer
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
//send options for text font (size and type), color and mode (allignment)
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
//see textbox.h for possible allignment modes
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};
//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;};
//sets text mainly with string also possible with overloades members for loacales, const char and text file
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
//helper to remove linebreak chars from a string if needed
virtual void removeLineBreaks(std::string& str);
//returns true, if text was changed
virtual bool textChanged(){return ct_old_text != ct_text;};
//force paint of text even if text was changed or not
virtual void forceTextPaint(bool force_text_paint = true){ct_force_text_paint = force_text_paint;};
//gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties
virtual CTextBox* getCTextBoxObject() { return ct_textbox; };
};
class CComponentsLabel : public CComponentsText
{
public:
CComponentsLabel( const int x_pos, const int y_pos, const int w, const int h,
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, 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)
:CComponentsText(x_pos, y_pos, w, h, text, mode, font_text, has_shadow, color_text, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_LABEL;
};
CComponentsLabel():CComponentsText()
{
initVarText();
cc_item_type = CC_ITEMTYPE_LABEL;
ct_col_text = COL_MENUCONTENTINACTIVE;
};
};
#define INFO_BOX_Y_OFFSET 2
class CComponentsInfoBox : public CComponentsText
{
private:
int x_text, x_offset;
CComponentsPicture * pic;
std::string pic_default_name;
void paintPicture();
void initVarInfobox();
std::string pic_name;
public:
CComponentsText * cctext;
CComponentsInfoBox();
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h,
std::string info_text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_text = COL_MENUCONTENT, 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);
~CComponentsInfoBox();
inline void setSpaceOffset(const int offset){x_offset = offset;};
inline void setPicture(const std::string& picture_name){pic_name = picture_name;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsShapeCircle : public CComponentsItem
{
private:
int d;
public:
CComponentsShapeCircle( const int x_pos, const int y_pos, const int diam, bool has_shadow = CC_SHADOW_ON,
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);
inline void setDiam(const int& diam){d=width=height=diam, corner_rad=d/2;};
inline int getDiam(){return d;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsShapeSquare : public CComponentsItem
{
public:
CComponentsShapeSquare( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON,
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);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsPIP : public CComponentsItem
{
private:
int screen_w, screen_h;
std::string pic_name; //alternate picture if is no tv picture available
public:
CComponentsPIP( const int x_pos, const int y_pos, const int percent = 30, bool has_shadow = CC_SHADOW_OFF);
~CComponentsPIP();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void hide(bool no_restore = false);
void setScreenWidth(int screen_width){screen_w = screen_width;};
void setScreenHeight(int screen_heigth){screen_h = screen_heigth;};
void setPicture(const std::string& image){pic_name = image;};
};
class CComponentsDetailLine : public CComponents
{
private:
int thickness, y_down, h_mark_top, h_mark_down;
void initVarDline();
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,
fb_pixel_t color_line = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
~CComponentsDetailLine();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
inline void setColors(fb_pixel_t color_line, fb_pixel_t color_shadow){col_body = color_line; col_shadow = color_shadow;};
void syncSysColors();
inline void setYPosDown(const int& y_pos_down){y_down = y_pos_down;};
inline void setHMarkTop(const int& h_mark_top_){h_mark_top = h_mark_top_;};
inline void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
///get current index of item, see also attribut cc_item_index
virtual int getIndex(){return cc_item_index;};
///set index to item, see also attribut cc_item_index
virtual void setIndex(const int& index){cc_item_index = index;};
};
#endif

View File

@@ -58,6 +58,8 @@ void CComponents::initVarBasic()
{
x = saved_screen.x = 0;
y = saved_screen.y = 0;
cc_xr = x;
cc_yr = y;
height = saved_screen.dy = CC_HEIGHT_MIN;
width = saved_screen.dx = CC_WIDTH_MIN;
@@ -133,6 +135,25 @@ void CComponents::paintFbItems(bool do_save_bg)
}
else if (fbtype == CC_FBDATA_TYPE_BACKGROUND)
frameBuffer->paintBackgroundBoxRel(x, y, v_fbdata[i].dx, v_fbdata[i].dy);
else if (fbtype == CC_FBDATA_TYPE_SHADOW_BOX) {
if (shadow) {
int sw = shadow_w;
int sw_cur = sw;
int x_sh = v_fbdata[i].x + v_fbdata[i].dx - sw;
int y_sh = v_fbdata[i].y + v_fbdata[i].dy - sw;
if (corner_type && v_fbdata[i].r) {
//calculate positon of shadow areas
x_sh += sw - 2*v_fbdata[i].r;
y_sh += sw - 2*v_fbdata[i].r;
//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);
}
}
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);
}

View File

@@ -30,7 +30,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include "cc_detailsline.h"
using namespace std;

View File

@@ -0,0 +1,77 @@
/*
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'
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_DETAIL_LINE_H__
#define __CC_DETAIL_LINE_H__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "cc.h"
//! Sub class of CComponents. Shows a connectline with given dimensions and color on screen.
/*!
Not usable as CCItem!
*/
class CComponentsDetailLine : public CComponents
{
private:
///property: line thickness
int thickness;
///property: lowest y position
int y_down;
///property: height of top marker
int h_mark_top;
///property: height of bottom marker
int h_mark_down;
///initialize all internal attributes
void initVarDline();
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,
fb_pixel_t color_line = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
~CComponentsDetailLine();
///set colors
inline void setColors(fb_pixel_t color_line, fb_pixel_t color_shadow){col_body = color_line; col_shadow = color_shadow;};
///set colors with system settings
void syncSysColors();
///set property: lowest y position
inline void setYPosDown(const int& y_pos_down){y_down = y_pos_down;};
///set property: height of top marker
inline void setHMarkTop(const int& h_mark_top_){h_mark_top = h_mark_top_;};
///property: height of bottom marker
inline void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
///paint all to screen
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
#endif

View File

@@ -31,6 +31,8 @@
#include <global.h>
#include <neutrino.h>
#include "cc_frm.h"
#include <stdlib.h>
#include <algorithm>
using namespace std;
@@ -51,6 +53,8 @@ CComponentsForm::CComponentsForm(const int x_pos, const int y_pos, const int w,
//CComponents
x = x_pos;
y = y_pos;
cc_xr = x;
cc_yr = y;
width = w;
height = h;
@@ -70,7 +74,7 @@ void CComponentsForm::cleanCCForm()
#ifdef DEBUG_CC
printf("[CComponentsForm] [%s - %d] clean up...\n", __FUNCTION__, __LINE__);
#endif
// hide();
clearCCItems();
clearSavedScreen();
clear();
@@ -117,20 +121,37 @@ void CComponentsForm::initVarForm()
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
corner_rad = RADIUS_LARGE;
corner_type = CORNER_ALL;
cc_item_index = 0;
//CComponentsForm
v_cc_items.clear();
cc_item_type = CC_ITEMTYPE_FRM;
append_h_offset = 0;
append_v_offset = 0;
}
void CComponentsForm::addCCItem(CComponentsItem* cc_Item)
{
if (cc_Item){
#ifdef DEBUG_CC
printf(" [CComponentsForm] %s-%d add cc_Item [type %d] [current count %d] \n", __FUNCTION__, __LINE__, cc_Item->getItemType(), v_cc_items.size());
printf(" [CComponentsForm] %s-%d try to add cc_Item [type %d] to form [current index=%d] \n", __FUNCTION__, __LINE__, cc_Item->getItemType(), cc_item_index);
#endif
cc_Item->setParent(this);
v_cc_items.push_back(cc_Item);
#ifdef DEBUG_CC
printf(" added cc_Item [type %d] to form [current index=%d] \n", cc_Item->getItemType(), cc_item_index);
#endif
//assign item index
int count = v_cc_items.size();
char buf[64];
snprintf(buf, sizeof(buf), "%d%d", cc_item_index, count);
buf[63] = '\0';
int new_index = atoi(buf);
cc_Item->setIndex(new_index);
#ifdef DEBUG_CC
printf(" %s-%d parent index = %d, assigned index ======> %d\n", __FUNCTION__, __LINE__, cc_item_index, new_index);
#endif
}
#ifdef DEBUG_CC
else
@@ -140,12 +161,23 @@ void CComponentsForm::addCCItem(CComponentsItem* cc_Item)
int CComponentsForm::getCCItemId(CComponentsItem* cc_Item)
{
for (size_t i= 0; i< v_cc_items.size(); i++)
if (v_cc_items[i] == cc_Item)
return i;
if (cc_Item){
for (size_t i= 0; i< v_cc_items.size(); i++)
if (v_cc_items[i] == cc_Item)
return i;
}
return -1;
}
bool CComponentsForm::isAdded(CComponentsItem* cc_item)
{
bool ret = false;
if (getCCItemId(cc_item) != -1)
ret = true;
return ret;
}
CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id)
{
if (v_cc_items[cc_item_id])
@@ -208,6 +240,17 @@ void CComponentsForm::removeCCItem(const uint& cc_item_id)
#endif
}
void CComponentsForm::exchangeCCItem(const uint& cc_item_id_a, const uint& cc_item_id_b)
{
if (!v_cc_items.empty())
swap(v_cc_items[cc_item_id_a], v_cc_items[cc_item_id_b]);
}
void CComponentsForm::exchangeCCItem(CComponentsItem* item_a, CComponentsItem* item_b)
{
exchangeCCItem(getCCItemId(item_a), getCCItemId(item_b));
}
void CComponentsForm::paintForm(bool do_save_bg)
{
//paint body
@@ -222,65 +265,78 @@ void CComponentsForm::paint(bool do_save_bg)
paintForm(do_save_bg);
}
void CComponentsForm::paintCCItems()
{
size_t items_count = v_cc_items.size();
int x_frm_left = x+fr_thickness; //left form border
int y_frm_top = y+fr_thickness; //top form border
int x_frm_right = x+width-fr_thickness; //right form border
int y_frm_bottom = y+height-fr_thickness; //bottom form border
for(size_t i=0; i<items_count; i++) {
//cache original item position and dimensions
int x_item, y_item, w_item, h_item;
v_cc_items[i]->getDimensions(&x_item, &y_item, &w_item, &h_item);
{
size_t items_count = v_cc_items.size();
int xy_ref = 0+fr_thickness; //allowed minimal x and y start position
if (x_item < xy_ref){
#ifdef DEBUG_CC
printf("[CComponentsForm] %s: item %d position is out of form dimensions\ndefinied x=%d\nallowed x>=%d\n", __FUNCTION__, i, x_item, xy_ref);
#endif
x_item = xy_ref;
}
if (y_item < xy_ref){
#ifdef DEBUG_CC
printf("[CComponentsForm] %s: item %d position is out of form dimensions\ndefinied y=%d\nallowed y>=%d\n", __FUNCTION__, i, y_item, xy_ref);
#endif
y_item = xy_ref;
}
//set adapted position onto form
v_cc_items[i]->setXPos(x_frm_left+x_item);
v_cc_items[i]->setYPos(y_frm_top+y_item);
//using of real x/y values to paint items if this text object is bound in a parent form
int this_x = x, auto_x = x, this_y = y, auto_y = y;
if (cc_parent){
this_x = auto_x = cc_xr;
this_y = auto_y = cc_yr;
}
//watch horizontal x dimensions of items
int x_item_right = v_cc_items[i]->getXPos()+w_item; //right item border
if (x_item_right > x_frm_right){
v_cc_items[i]->setWidth(w_item-(x_item_right-x_frm_right));
#ifdef DEBUG_CC
printf("[CComponentsForm] %s: item %d too large, definied width=%d, possible width=%d \n", __FUNCTION__, i, w_item, v_cc_items[i]->getWidth());
#endif
for(size_t i=0; i<items_count; i++){
//assign item object
CComponentsItem *cc_item = v_cc_items[i];
//get current dimension of item
int w_item = cc_item->getWidth();
int h_item = cc_item->getHeight();
//get current position of item
int xpos = cc_item->getXPos();
int ypos = cc_item->getYPos();
//set required x-position to item
if (xpos == CC_APPEND){
auto_x += append_h_offset;
cc_item->setRealXPos(auto_x + xpos + 1);
auto_x += w_item;
}
else{
cc_item->setRealXPos(this_x + xpos);
auto_x = (cc_item->getRealXPos() + w_item);
}
//set required y-position to item
if (ypos == CC_APPEND){
auto_y += append_v_offset;
cc_item->setRealYPos(auto_y + ypos + 1);
auto_y += h_item;
}
else{
cc_item->setRealYPos(this_y + ypos);
auto_y = (cc_item->getRealYPos() + h_item);
}
//These steps check whether the element can be painted into the container.
//Is it too wide or too high, it will be shortened and displayed in the log.
//This should be avoid!
//checkwidth and adapt if required
int right_frm = (cc_parent ? cc_xr : x) + width - 2*fr_thickness;
int right_item = cc_item->getRealXPos() + w_item;
int w_diff = right_item - right_frm;
int new_w = w_item - w_diff;
if (right_item > right_frm){
printf("[CComponentsForm] %s: item %d width is too large, definied width=%d, possible width=%d \n", __FUNCTION__, i, w_item, new_w);
cc_item->setWidth(new_w);
}
//watch vertical y dimensions
int y_item_bottom = v_cc_items[i]->getYPos()+h_item; //bottom item border
if (y_item_bottom > y_frm_bottom){
v_cc_items[i]->setHeight(h_item-(y_item_bottom-y_frm_bottom));
#ifdef DEBUG_CC
printf("[CComponentsForm] %s: item %d too large, definied height=%d, possible height=%d \n", __FUNCTION__, i, h_item, v_cc_items[i]->getHeight());
#endif
//check height and adapt if required
int bottom_frm = (cc_parent ? cc_yr : y) + height - 2*fr_thickness;
int bottom_item = cc_item->getRealYPos() + h_item;
int h_diff = bottom_item - bottom_frm;
int new_h = h_item - h_diff;
if (bottom_item > bottom_frm){
printf("[CComponentsForm] %s: item %d height is too large, definied height=%d, possible height=%d \n", __FUNCTION__, i, h_item, new_h);
cc_item->setHeight(new_h);
}
//set real position dimension to item
int real_x = v_cc_items[i]->getXPos();
int real_y = v_cc_items[i]->getYPos();
v_cc_items[i]->setRealPos(real_x, real_y);
//paint element without saved screen!
v_cc_items[i]->paint(CC_SAVE_SCREEN_NO);
//restore dimensions and position
v_cc_items[i]->setDimensionsAll(x_item, y_item, w_item, h_item);
//finally paint current item
cc_item->paint(CC_SAVE_SCREEN_NO);
}
}

View File

@@ -29,6 +29,8 @@
#include "config.h"
#include <gui/components/cc.h>
#include <gui/components/cc_item_text.h>
#include <gui/components/cc_item_picture.h>
#include <vector>
#include <string>
@@ -39,6 +41,9 @@ class CComponentsForm : public CComponentsItem
std::vector<CComponentsItem*> v_cc_items;
void initVarForm();
void paintForm(bool do_save_bg);
int append_h_offset;
int append_v_offset;
public:
CComponentsForm();
@@ -53,11 +58,16 @@ class CComponentsForm : public CComponentsItem
virtual void removeCCItem(const uint& cc_item_id);
virtual void replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item);
virtual void replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item);
virtual void exchangeCCItem(const uint& item_id_a, const uint& item_id_b);
virtual void exchangeCCItem(CComponentsItem* item_a, CComponentsItem* item_b);
virtual int getCCItemId(CComponentsItem* cc_Item);
virtual CComponentsItem* getCCItem(const uint& cc_item_id);
virtual void paintCCItems();
virtual void clearCCItems();
virtual void cleanCCForm();
virtual void setAppendOffset(const int &h_offset, const int& v_offset){append_h_offset = h_offset; append_v_offset = v_offset;};
///property: returns true, if item already added to form
virtual bool isAdded(CComponentsItem *cc_item);
};
class CComponentsIconForm : public CComponentsForm
@@ -101,25 +111,23 @@ class CComponentsIconForm : public CComponentsForm
class CComponentsHeader : public CComponentsForm
{
private:
protected:
CComponentsPicture * cch_icon_obj;
CComponentsText * cch_text_obj;
CComponentsIconForm * cch_btn_obj;
std::string cch_text;
const char* cch_icon_name;
neutrino_locale_t cch_locale_text;
fb_pixel_t cch_col_text;
Font* cch_font;
int cch_icon_x, cch_items_y, cch_text_x, ccif_width, cch_icon_w, cch_buttons, cch_btn_offset;
int cch_items_y, cch_icon_x, cch_icon_w, cch_text_x, cch_buttons, cch_buttons_w, cch_buttons_h, cch_buttons_space, cch_offset;
std::vector<std::string> v_cch_btn;
void initCCHeaderIcon();
void initCCHeaderText();
void initCCHeaderButtons();
void initCCHDefaultButtons();
void initCCButtonFormSize();
void initIcon();
void initCaption();
void initButtons();
void initDefaultButtons();
void initButtonFormSize();
protected:
void initVarHeader();
public:
@@ -143,33 +151,87 @@ class CComponentsHeader : public CComponentsForm
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);
CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, neutrino_locale_t caption_locale = NONEXISTANT_LOCALE, const char* icon_name = NULL, const int buttons = 0,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);
~CComponentsHeader();
virtual ~CComponentsHeader();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void setHeaderText(const std::string& caption);
void setHeaderText(neutrino_locale_t caption_locale);
void setColorHeaderBody(fb_pixel_t text_color){cch_col_text = text_color;};
void setHeaderButtonOffset(const int offset){cch_btn_offset = offset;};
void setHeaderIcon(const char* icon_name);
void addHeaderButton(const std::string& button_name);
void removeHeaderButtons();
void setHeaderDefaultButtons(const int buttons);
void initCCHeaderItems();
virtual void setCaption(const std::string& caption);
virtual void setCaption(neutrino_locale_t caption_locale);
virtual void setCaptionFont(Font* font_name);
virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;};
virtual void setOffset(const int offset){cch_offset = offset;};
virtual void setIcon(const char* icon_name);
virtual void addButtonIcon(const std::string& button_name);
virtual void removeButtonIcons();
virtual void setDefaultButtons(const int buttons);
virtual void setButtonsSpace(const int buttons_space){cch_buttons_space = buttons_space;};
virtual void initCCItems();
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsFooter : public CComponentsHeader
{
protected:
void initVarFooter();
public:
CComponentsFooter();
CComponentsFooter( const int x_pos, const int y_pos, const int w, const int h = 0,
const int buttons = 0,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_INFOBAR_SHADOW_PLUS_1, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
};
//! Sub class of CComponentsForm. Shows a window with prepared items.
/*!
CComponentsWindow provides prepared items like header, footer and a container for
items like text, labels, pictures ...
*/
/*
x
y+-------------------------------------------------------+
|icon caption buttons |header (ccw_head)
+-x-----------------------------------------------------+
|cc_item0 |
|cc_item1 |body (ccw_body)
| add items here directly with |
| addWindowItem() or |
y with ccw_body->addCCItem() |
| Note: x/y related to body object |
| |
+-------------------------------------------------------+
| add cc_items with ccw_footer->addCCItem() |footer(ccw_footer)
+-------------------------------------------------------+
*/
class CComponentsWindow : public CComponentsForm
{
private:
///object: header object, to get access to header properties see also getHeaderObject()
CComponentsHeader * ccw_head;
///object: body object, this is the container for all needed items, to add with addWindowItem()
CComponentsForm * ccw_body;
///object: footer object, to get access to header properties see also getFooterObject(
CComponentsForm * ccw_footer;
///property: caption in header, see also getHeaderObject()
std::string ccw_caption;
///property: icon name in header, see also getHeaderObject()
const char* ccw_icon_name;
int ccw_start_y;
///property: assigned default icon buttons in header, see also getHeaderObject()
int ccw_buttons;
///initialze header object
void initHeader();
///initialze body object
void initBody();
///initialze footer object
void initFooter();
///initialze all window objects at once
void initCCWItems();
protected:
///initialize all attributes
void initVarWindow();
public:
@@ -177,17 +239,64 @@ class CComponentsWindow : public CComponentsForm
{
CC_WINDOW_ITEM_HEADER = 0
};
///simple constructor for CComponentsWindow
CComponentsWindow();
///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string
CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
const std::string& caption,
const char* iconname = NULL,
bool has_shadow = CC_SHADOW_OFF,
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 CComponentsWindow, provides parameters for the most required properties, and caption from locales
CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
neutrino_locale_t locale_caption,
const char* iconname = NULL,
bool has_shadow = CC_SHADOW_OFF,
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);
///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, position of window is general centered and bound
///to current screen settings, this shows a window over full screen
CComponentsWindow(const std::string& caption, const char* iconname = NULL);
///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, position of window is general centered and bound
///to current screen settings, this shows a window over full screen
CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname = NULL);
~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);
///set caption in header with string, see also getHeaderObject()
void setWindowCaption(const std::string& text){ccw_caption = text;};
///set caption in header from locales, see also getHeaderObject()
void setWindowCaption(neutrino_locale_t locale_text);
///set icon name in header, see also getHeaderObject()
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
///set default header icon buttons, see also getHeaderObject()
void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;};
///returns a pointer to the internal header object, use this to get access to header properities
CComponentsHeader* getHeaderObject(){return ccw_head;};
///returns a pointer to the internal body object, use this to get access to body properities
CComponentsForm* getBodyObject(){return ccw_body;};
///returns a pointer to the internal footer object, use this to get access to footer properities
CComponentsForm* getFooterObject(){return ccw_footer;};
int getStartY(); //y value for start of the area below header
};

View File

@@ -33,6 +33,7 @@
#include "cc_frm_button.h"
#define FRAME_TH 3
#define H_SPACE 4
using namespace std;
@@ -84,18 +85,28 @@ void CComponentsButton::initIcon()
cc_btn_icon_obj = NULL;
return;
}
//initialize icon object
if (cc_btn_icon_obj == NULL){
cc_btn_icon_obj = new CComponentsPicture(0, 0, 0, 0, cc_btn_icon);
addCCItem(cc_btn_icon_obj);
}
//get first icon dimensions
int icon_w = cc_btn_icon_obj->getWidth();
int icon_h = cc_btn_icon_obj->getHeight();
//position of icon default centered
int icon_x = width/2-icon_w/2;
int icon_y = height/2-icon_h/2;
//set properties to picture object
if (cc_btn_icon_obj){
cc_btn_icon_obj->setDimensionsAll(this->getRealXPos(), this->getRealYPos(), height/*-2*fr_thickness*/, height-2*fr_thickness);
cc_btn_icon_obj->setPos(icon_x, icon_y);
cc_btn_icon_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
cc_btn_icon_obj->doPaintBg(false);
}
}
void CComponentsButton::initCaption()
@@ -105,16 +116,22 @@ void CComponentsButton::initCaption()
addCCItem(cc_btn_capt_obj);
}
int cap_x = this->getRealXPos()+(width/2)-(cc_btn_text_w/2);
int cap_h = height/*-2*fr_thickness*/;
int cap_y = this->getRealYPos();
if (cc_btn_icon_obj)
cap_x = this->getRealXPos()+cc_btn_icon_obj->getWidth();
//text position is default centere
int cap_x = (width/2)-(cc_btn_text_w/2);
int cap_y = (height/2)-(cc_btn_text_h/2);
//if we have a icon, then we must calculate centered position for booth items together
if (cc_btn_icon_obj){
int face_w = cc_btn_icon_obj->getWidth() + H_SPACE + cc_btn_text_w + 2*fr_thickness;
int face_x = width/2 - face_w/2;
cc_btn_icon_obj->setXPos(face_x);
cap_x = face_x + cc_btn_icon_obj->getWidth() + H_SPACE;
}
//set properties to label object
if (cc_btn_capt_obj){
cc_btn_capt_obj->setDimensionsAll(cap_x, cap_y, width-cap_x, cap_h);
cc_btn_capt_obj->setDimensionsAll(cap_x, cap_y, width-cap_x, height);
cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? COL_MENUCONTENT : COL_MENUCONTENTINACTIVE);
cc_btn_capt_obj->setText(cc_btn_capt, CTextBox::NO_AUTO_LINEBREAK, cc_btn_font);
cc_btn_capt_obj->forceTextPaint(); //here required;

View File

@@ -31,26 +31,42 @@
#include "cc_frm.h"
#include <string>
//! Sub class of CComponentsForm.
/*!
Shows a button box with caption and optional icon.
*/
class CComponentsButton : public CComponentsForm
{
protected:
void initVarButton();
///caption and icon properties
std::string cc_btn_capt; //text
std::string cc_btn_icon; //icon name, only icons supported, to find in gui/widget/icons.h
fb_pixel_t cc_btn_capt_col; //text color
Font* cc_btn_font; //text font
int cc_btn_text_w, cc_btn_text_h; //width and height of text, too long text will be truncated
///icon and text objects
///object: picture object
CComponentsPicture *cc_btn_icon_obj;
///object: label object
CComponentsLabel *cc_btn_capt_obj;
///initialize of objects
///initialize all required attributes and objects
void initVarButton();
///property: button text
std::string cc_btn_capt;
///property: icon name, only icons supported, to find in gui/widget/icons.h
std::string cc_btn_icon;
///property: text color
fb_pixel_t cc_btn_capt_col;
///object: text font
Font* cc_btn_font;
///property: label object width, too long text will be truncated
int cc_btn_text_w;
///property: label object heigth
int cc_btn_text_h;
///initialize picture object
void initIcon();
///initialize label object
void initCaption();
///initialize picture and label object
void initCCBtnItems();
public:
@@ -59,12 +75,18 @@ class CComponentsButton : public CComponentsForm
const std::string& caption, const std::string& icon_name,
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);
///set text color
virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_color;};
///paint button object
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
///sub classes for button objects with most needed params, and predefined color buttons, but functionality is the same as in CComponentsButton
//! Sub class of CComponentsButton.
/*!
Shows a button box with caption and prepared red icon.
*/
class CComponentsButtonRed : public CComponentsButton
{
public:
@@ -78,6 +100,10 @@ class CComponentsButtonRed : public CComponentsButton
};
};
//! Sub class of CComponentsButton.
/*!
Shows a button box with caption and prepared green icon.
*/
class CComponentsButtonGreen : public CComponentsButton
{
public:
@@ -91,6 +117,10 @@ class CComponentsButtonGreen : public CComponentsButton
};
};
//! Sub class of CComponentsButton.
/*!
Shows a button box with caption and prepared yellow icon.
*/
class CComponentsButtonYellow : public CComponentsButton
{
public:
@@ -104,6 +134,10 @@ class CComponentsButtonYellow : public CComponentsButton
};
};
//! Sub class of CComponentsButton.
/*!
Shows a button box with caption and prepared blue icon.
*/
class CComponentsButtonBlue : public CComponentsButton
{
public:

View File

@@ -0,0 +1,333 @@
/*
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Generic GUI-related component.
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_clock.h"
#include <time.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
using namespace std;
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();
x = x_pos;
y = y_pos;
width = w;
height = h;
shadow = has_shadow;
shadow_w = SHADOW_OFFSET;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
paintClock = false;
activeClock = activ;
if (activeClock)
startThread();
cl_format_str = format_str;
}
void CComponentsFrmClock::initVarClock()
{
initVarForm();
cc_item_type = CC_ITEMTYPE_FRM_CLOCK;
corner_rad = RADIUS_SMALL;
cl_font_type = SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO;
cl_font = NULL;
cl_col_text = COL_MENUCONTENT;
cl_format_str = "%H:%M";
cl_align = CC_ALIGN_VER_CENTER | CC_ALIGN_HOR_CENTER;
// cl_force_segment_paint = false;
cl_thread = 0;
cl_interval = 1;
}
CComponentsFrmClock::~CComponentsFrmClock()
{
cleanCCForm();
if (activeClock)
stopThread();
}
void CComponentsFrmClock::initTimeString()
{
time_t tm = time(0);
strftime((char*) &cl_timestr, sizeof(cl_timestr), cl_format_str, localtime(&tm));
}
// How does it works?
// We don't paint complete date or time string at once, because of individual possible formats,
// so we split timestring and assign only one char to one lable (segment)
// x/y width
// +--------------------------+
// ||lbl0|lbl1|lbl2|lbl3|lbl4||
// || | | | | ||height
// || | | | | ||
// +--------------------------+
// So every item (lable or segment) contains only one char depending on specified format. eg: format %H:%M gives 5 items.
// The effort is slightly greater and it's necessary to avoid flicker effect, but it's more flexible.
void CComponentsFrmClock::initCCLockItems()
{
initTimeString();
string s_time = cl_timestr;
cl_font = g_Font[cl_font_type];
//get minimal required height, width from raw text
int min_text_w = cl_font->getRenderWidth(s_time, true);;
int min_text_h = cl_font->getHeight();
height = max(height, min_text_h);
width = max(width, min_text_w);
int cl_x = 0;
int cl_h = min_text_h;
int cl_y = 0;
int w_lbl_tmp = 0;
//create label objects and add to container, ensure count of items = count of chars (one char = one segment)
if (v_cc_items.size() != s_time.size()){
//clean up possible old items before add new items
clearCCItems();
//create new empty label objects, set some general properties and add to container
for (size_t i = 0; i < s_time.size(); i++){
CComponentsLabel * lbl = new CComponentsLabel();
addCCItem(lbl);
//background paint of item is not required
lbl->doPaintBg(false);
//set corner properties of label item
lbl->setCornerRadius(corner_rad-fr_thickness);
lbl->setCornerType(corner_type);
//set text border to 0
lbl->setTextBorderWidth(0);
}
}
//modifie available lable items with current segment chars
for (size_t i = 0; i < v_cc_items.size(); i++)
{
//v_cc_items are only available as CComponent-items here, so we must cast them before
CComponentsLabel *lbl = static_cast <CComponentsLabel*> (v_cc_items[i]);
//add rounded corners only to 1st and last segment
if (corner_type) {
if (i == 0)
lbl->setCornerType(corner_type & CORNER_LEFT);// 1st label item
else if (i == v_cc_items.size()-1)
lbl->setCornerType(corner_type & CORNER_RIGHT);// last label item
else
lbl->setCornerType(0);// inner items
}
//extract timestring segment (char)
string stmp = s_time.substr(i, 1);
//get width of current segment
int wtmp = cl_font->getRenderWidth(stmp, true);
//set size, text, color of current item
lbl->setDimensionsAll(cl_x, cl_y, wtmp, cl_h);
lbl->setTextColor(cl_col_text);
lbl->setColorAll(col_frame, col_body, col_shadow);
lbl->setText(stmp, CTextBox::CENTER, cl_font);
//use matching height for digits for better vertical centerring into form
CTextBox* ctb = lbl->getCTextBoxObject();
if (ctb)
ctb->setFontUseDigitHeight();
//ensure paint of text and label bg on changed text or painted form background
bool force_txt_and_bg = (lbl->textChanged() || this->paint_bg);
lbl->forceTextPaint(force_txt_and_bg);
lbl->doPaintTextBoxBg(force_txt_and_bg);
//set xpos of item
cl_x += wtmp;
lbl->setWidth(wtmp);
//set current width for form
w_lbl_tmp += wtmp;
}
//set required width
width = max(width, w_lbl_tmp);
initSegmentAlign(&w_lbl_tmp, &min_text_h);
}
//handle alignment
void CComponentsFrmClock::initSegmentAlign(int* segment_width, int* segment_height)
{
int wadd = 0;
int hadd = 0;
int* w_lbl_tmp = segment_width;
int* min_text_h = segment_height;
//use first item as reference and set x and y position to the 1st segement item with definied alignment
if (cl_align & CC_ALIGN_RIGHT){
wadd = width-*w_lbl_tmp;
v_cc_items[0]->setXPos(wadd);
}
else if (cl_align & CC_ALIGN_LEFT){
v_cc_items[0]->setXPos(wadd);
}
else if (cl_align & CC_ALIGN_HOR_CENTER){
hadd = height/2-*min_text_h/2;
v_cc_items[0]->setYPos(hadd);
}
if (cl_align & CC_ALIGN_TOP){
v_cc_items[0]->setYPos(hadd);
}
else if (cl_align & CC_ALIGN_BOTTOM){
hadd = height-*min_text_h;
v_cc_items[0]->setYPos(hadd);
}
else if (cl_align & CC_ALIGN_VER_CENTER){
wadd = width/2-*w_lbl_tmp/2;
v_cc_items[0]->setXPos(wadd);
}
//set all evaluated position values to all other segement items
for (size_t i = 1; i < v_cc_items.size(); i++){
wadd += v_cc_items[i-1]->getWidth();
v_cc_items[i]->setPos(wadd, hadd);
}
}
//thread handle
void* CComponentsFrmClock::initClockThread(void *arg)
{
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0);
CComponentsFrmClock *clock = static_cast<CComponentsFrmClock*>(arg);
time_t count = time(0);
//start loop for paint
while(1) {
sleep(clock->cl_interval);
if (clock->paintClock) {
//paint segements, but wihtout saved backgrounds
clock->paint(CC_SAVE_SCREEN_NO);
count = time(0);
}
if (time(0) >= count+30) {
clock->cl_thread = 0;
break;
}
}
return 0;
}
//start up ticking clock with own thread, return true on succses
bool CComponentsFrmClock::startThread()
{
void *ptr = static_cast<void*>(this);
if(!cl_thread) {
int res = pthread_create (&cl_thread, NULL, initClockThread, ptr) ;
if (res != 0){
printf("[CComponentsFrmClock] [%s] pthread_create %s\n", __FUNCTION__, strerror(errno));
return false;
}
}
return true;
}
//stop ticking clock and kill thread, return true on succses
bool CComponentsFrmClock::stopThread()
{
if(cl_thread) {
int res = pthread_cancel(cl_thread);
if (res != 0){
printf("[CComponentsFrmClock] [%s] pthread_cancel %s\n", __FUNCTION__, strerror(errno));
return false;
}
res = pthread_join(cl_thread, NULL);
if (res != 0){
printf("[CComponentsFrmClock] [%s] pthread_join %s\n", __FUNCTION__, strerror(errno));
return false;
}
}
cl_thread = 0;
return true;
}
bool CComponentsFrmClock::Start()
{
if (!activeClock)
return false;
if (!cl_thread)
startThread();
if (cl_thread) {
//ensure paint of segements on first paint
paint();
paintClock = true;
}
return cl_thread == 0 ? false : true;
}
bool CComponentsFrmClock::Stop()
{
if (!activeClock)
return false;
paintClock = false;
return cl_thread == 0 ? false : true;
}
void CComponentsFrmClock::paint(bool do_save_bg)
{
//prepare items before paint
initCCLockItems();
//paint form contents
paintForm(do_save_bg);
}

View File

@@ -0,0 +1,122 @@
/*
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'
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_CLOCK__
#define __CC_CLOCK__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "cc.h"
#include "cc_frm.h"
//! Sub class of CComponents. Show clock with digits on screen.
/*!
Usable as simple fixed display or as ticking clock.
*/
class CComponentsFrmClock : public CComponentsForm
{
private:
// bool cl_force_segment_paint;
protected:
///thread
pthread_t cl_thread;
///refresh interval in seconds
int cl_interval;
///init function to start clock in own thread
static void* initClockThread(void *arg);
///raw time chars
char cl_timestr[20];
bool paintClock;
bool activeClock;
///font
int cl_font_type;
///fontrenderer object
Font *cl_font;
///text color
int cl_col_text;
///time format
const char* cl_format_str;
///time string align, default allign is ver and hor centered
int cl_align;
///initialize all attributes and required objects
void initVarClock();
///initialize clock contents
void initCCLockItems();
///initialize timestring, called in initCCLockItems()
void initTimeString();
///initialize of general alignment of timestring segments within form area
void initSegmentAlign(int* segment_width, int* segment_height);
public:
CComponentsFrmClock( const int x_pos, const int y_pos, const int w, const int h,
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);
~CComponentsFrmClock();
///set font type for segments
void setClockFontType(const int& font_type){cl_font_type = font_type;};
///set text color
void setTextColor(fb_pixel_t color_text){ cl_col_text = color_text;};
///set alignment of timestring, possible modes see align types in cc_types.h
void setClockAlignment(int align_type){cl_align = align_type;};
///use string expession: "%H:%M" = 12:22, "%H:%M:%S" = 12:22:12
void setClockFormat(const char* format_str){cl_format_str = format_str;};
///start ticking clock thread, returns true on success, if false causes log output
bool startThread();
///stop ticking clock thread, returns true on success, if false causes log output
bool stopThread();
bool Start();
bool Stop();
///returns true, if clock is running in thread
bool isClockRun() const {return cl_thread == 0 ? false:true;};
///set refresh interval in seconds, default value=1 (=1 sec)
void setClockIntervall(const int& seconds){cl_interval = seconds;};
///show clock on screen
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///reinitialize clock contents
void refresh() { initCCLockItems(); }
};
#endif

View File

@@ -0,0 +1,74 @@
/*
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"
using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsFooter inherit from CComponentsHeader
CComponentsFooter::CComponentsFooter()
{
//CComponentsFooter
initVarFooter();
}
CComponentsFooter::CComponentsFooter( const int x_pos, const int y_pos, const int w, const int h, const int buttons, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow )
{
//CComponentsFooter
initVarFooter();
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;
cch_buttons = buttons;
initDefaultButtons();
initCCItems();
}
void CComponentsFooter::initVarFooter()
{
//CComponentsHeader
initVarHeader();
cc_item_type = CC_ITEMTYPE_FOOTER;
corner_rad = RADIUS_LARGE;
corner_type = CORNER_BOTTOM;
}

View File

@@ -51,7 +51,7 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in
x = x_pos;
y = y_pos;
width = w;
height = h > 0 ? h : g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
height = h > 0 ? h : height;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
@@ -60,8 +60,9 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in
cch_text = caption;
cch_icon_name = icon_name;
cch_buttons = buttons;
initCCHDefaultButtons();
initCCHeaderItems();
initDefaultButtons();
initCCItems();
}
CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t caption_locale, const char* icon_name, const int buttons, bool has_shadow,
@@ -73,18 +74,18 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in
x = x_pos;
y = y_pos;
width = w;
height = h;
height = h > 0 ? h : height;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
cch_locale_text = caption_locale;
cch_text = g_Locale->getText(caption_locale);
cch_icon_name = icon_name;
cch_buttons = buttons;
initCCHDefaultButtons();
initCCHeaderItems();
initDefaultButtons();
initCCItems();
}
void CComponentsHeader::initVarHeader()
@@ -105,19 +106,18 @@ void CComponentsHeader::initVarHeader()
cch_text_obj = NULL;
cch_icon_name = NULL;
cch_btn_obj = NULL;
cch_text = "header";
cch_locale_text = NONEXISTANT_LOCALE;
cch_text = "";
cch_col_text = COL_MENUHEAD;
cch_items_y = 0;
cch_icon_x = 0;
cch_icon_w = 5;
cch_text_x = 0;
ccif_width = 0;
cch_offset = 8;
cch_icon_x = cch_offset;
cch_icon_w = 0;
cch_text_x = cch_offset;
cch_buttons = 0;
cch_btn_offset = 8;
cch_buttons_w = 0;
cch_buttons_h = 0;
cch_buttons_space = cch_offset;
v_cch_btn.clear();
}
CComponentsHeader::~CComponentsHeader()
@@ -129,29 +129,32 @@ CComponentsHeader::~CComponentsHeader()
cleanCCForm();
}
void CComponentsHeader::setHeaderText(const std::string& caption)
void CComponentsHeader::setCaption(const std::string& caption)
{
cch_text = caption;
}
void CComponentsHeader::setHeaderText(neutrino_locale_t caption_locale)
void CComponentsHeader::setCaption(neutrino_locale_t caption_locale)
{
cch_text = g_Locale->getText(caption_locale);
}
void CComponentsHeader::setHeaderIcon(const char* icon_name)
void CComponentsHeader::setCaptionFont(Font* font_name)
{
cch_font = font_name;
height = std::max(height, cch_font->getHeight());
}
void CComponentsHeader::setIcon(const char* icon_name)
{
cch_icon_name = icon_name;
}
void CComponentsHeader::initCCHeaderIcon()
void CComponentsHeader::initIcon()
{
//reset cch_icon_w
cch_icon_w = cch_btn_offset;
//init cch_icon_obj only if an icon available
if (cch_icon_name == NULL) {
cch_icon_w = cch_btn_offset;
cch_icon_w = 0;
if (cch_icon_obj)
delete cch_icon_obj;
cch_icon_obj = NULL;
@@ -163,17 +166,21 @@ void CComponentsHeader::initCCHeaderIcon()
#ifdef DEBUG_CC
printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __FUNCTION__, __LINE__, cch_icon_name);
#endif
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name);
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name);
//add item only one time
addCCItem(cch_icon_obj); //icon
}
//get dimensions of header icon
int iw, ih;
frameBuffer->getIconSize(cch_icon_name, &iw, &ih);
//set properties for icon object
if (cch_icon_obj){
cch_icon_obj->setWidth(height-2*fr_thickness);
cch_icon_obj->setHeight(height);
cch_icon_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
cch_icon_obj->setWidth(iw);
cch_icon_obj->setHeight(ih);
cch_icon_obj->doPaintBg(false);
cch_icon_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
//set corner mode of icon item
cch_icon_obj->setCornerRadius(corner_rad-fr_thickness);
@@ -184,29 +191,31 @@ void CComponentsHeader::initCCHeaderIcon()
cc_icon_corner_type = CORNER_LEFT;
cch_icon_obj->setCornerType(cc_icon_corner_type);
//set width of icon object
//global set width of icon object
cch_icon_w = cch_icon_obj->getWidth();
//adapt height
height = max(height, cch_icon_obj->getHeight());
//global adapt height
height = max(height, cch_icon_obj->getHeight());
//re-align height of icon object
cch_icon_obj->setHeight(height);
}
}
void CComponentsHeader::addHeaderButton(const std::string& button_name)
void CComponentsHeader::addButtonIcon(const std::string& button_name)
{
v_cch_btn.push_back(button_name);
initCCHeaderButtons();
initButtons();
}
void CComponentsHeader::removeHeaderButtons()
void CComponentsHeader::removeButtonIcons()
{
v_cch_btn.clear();
cch_btn_obj->removeAllIcons();
initCCHeaderButtons();
initButtons();
}
void CComponentsHeader::initCCHDefaultButtons()
void CComponentsHeader::initDefaultButtons()
{
if (cch_buttons & CC_BTN_EXIT)
v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_HOME);
@@ -221,31 +230,34 @@ void CComponentsHeader::initCCHDefaultButtons()
#endif
}
void CComponentsHeader::setHeaderDefaultButtons(const int buttons)
void CComponentsHeader::setDefaultButtons(const int buttons)
{
cch_buttons = buttons;
v_cch_btn.clear();
initCCHDefaultButtons();
initDefaultButtons();
}
// calculate minimal width of icon form
void CComponentsHeader::initCCButtonFormSize()
void CComponentsHeader::initButtonFormSize()
{
ccif_width = 0;
cch_buttons_w = 0;
cch_buttons_h = 0;
for(size_t i=0; i<v_cch_btn.size(); i++){
int bw, bh;
frameBuffer->getIconSize(v_cch_btn[i].c_str(), &bw, &bh);
ccif_width += (bw + cch_btn_offset);
cch_buttons_w += (bw + cch_buttons_space);
cch_buttons_h = std::max(cch_buttons_h, bh);
}
cch_buttons_w -= cch_buttons_space;
}
void CComponentsHeader::initCCHeaderButtons()
void CComponentsHeader::initButtons()
{
//exit if no button defined
if (v_cch_btn.empty())
return;
initCCButtonFormSize();
initButtonFormSize();
if (cch_btn_obj == NULL){
cch_btn_obj = new CComponentsIconForm();
@@ -258,25 +270,50 @@ void CComponentsHeader::initCCHeaderButtons()
//set button form properties
if (cch_btn_obj){
cch_btn_obj->setDimensionsAll(0+width-ccif_width, 0, ccif_width-cch_btn_offset, height);
cch_btn_obj->setDimensionsAll(width-cch_offset-cch_buttons_w, cch_items_y, cch_buttons_w, cch_buttons_h);
cch_btn_obj->doPaintBg(false);
cch_btn_obj->setIconOffset(cch_btn_offset);
cch_btn_obj->setIconOffset(cch_buttons_space);
cch_btn_obj->setIconAlign(CComponentsIconForm::CC_ICONS_FRM_ALIGN_RIGHT);
cch_btn_obj->removeAllIcons();
cch_btn_obj->addIcon(v_cch_btn);
height = max(height, cch_btn_obj->getHeight());
//set corner mode of button item
cch_btn_obj->setCornerRadius(corner_rad-fr_thickness);
int cc_btn_corner_type = corner_type;
if (corner_type == CORNER_TOP_RIGHT || corner_type == CORNER_TOP)
cc_btn_corner_type = CORNER_TOP_RIGHT;
else
cc_btn_corner_type = CORNER_RIGHT;
cch_btn_obj->setCornerType(cc_btn_corner_type);
//global adapt height
height = max(height, cch_btn_obj->getHeight());
//re-align height of button object
cch_btn_obj->setHeight(height);
//re-align height of icon object
if (cch_icon_obj)
cch_icon_obj->setHeight(height);
}
}
void CComponentsHeader::initCCHeaderText()
void CComponentsHeader::initCaption()
{
//reset header text position first
cch_text_x = cch_icon_x+cch_icon_w;
//recalc header text position if header icon is defined
if (cch_icon_name != NULL){
cch_text_x = cch_icon_x+cch_icon_w+cch_offset;
}
//calc width of text object in header
int cc_text_w = width-cch_text_x-cch_offset;
if (cch_buttons_w)
cc_text_w -= cch_buttons_w-cch_offset;
//create cch_text_obj and add to collection
if (cch_text_obj == NULL){
#ifdef DEBUG_CC
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s\n", __FUNCTION__, __LINE__, cch_text.c_str());
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s [ x %d w %d ]\n", __FUNCTION__, __LINE__, cch_text.c_str(), cch_text_x, cc_text_w);
#endif
cch_text_obj = new CComponentsText();
//add text item
@@ -285,38 +322,41 @@ void CComponentsHeader::initCCHeaderText()
//set header text properties
if (cch_text_obj){
cch_text_obj->setText(cch_text, CTextBox::AUTO_WIDTH, cch_font);
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height);
cch_text_obj->doPaintBg(false);
cch_text_obj->setText(cch_text, CTextBox::TOP | CTextBox::NO_AUTO_LINEBREAK, cch_font);
cch_text_obj->forceTextPaint(); //here required
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, width-cch_icon_w-fr_thickness, height-2*fr_thickness);
cch_text_obj->setTextColor(cch_col_text);
cch_text_obj->setColorBody(col_body);
cch_text_obj->doPaintBg(false);
//corner of text item
cch_text_obj->setCornerRadius(corner_rad-fr_thickness);
cch_text_obj->setCornerType(corner_type);
//get height
height = max(height, cch_text_obj->getHeight());
/*
global adapt height not needed here again
because this object is initialized at last
*/
//height = max(height, cch_text_obj->getHeight());
}
}
void CComponentsHeader::initCCHeaderItems()
void CComponentsHeader::initCCItems()
{
//init icon
initCCHeaderIcon();
//init text
initCCHeaderText();
initIcon();
//init buttons
initCCHeaderButtons();
initButtons();
//init text
initCaption();
}
void CComponentsHeader::paint(bool do_save_bg)
{
//prepare items
initCCHeaderItems();
initCCItems();
//paint form contents
paintForm(do_save_bg);

View File

@@ -40,6 +40,8 @@ using namespace std;
CComponentsWindow::CComponentsWindow()
{
initVarWindow();
initCCWItems();
}
CComponentsWindow::CComponentsWindow(const std::string& caption, const char* iconname)
@@ -48,6 +50,9 @@ CComponentsWindow::CComponentsWindow(const std::string& caption, const char* ico
ccw_caption = caption;
ccw_icon_name = iconname;
initHeader();
initBody();
}
CComponentsWindow::CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname)
@@ -56,6 +61,58 @@ CComponentsWindow::CComponentsWindow(neutrino_locale_t locale_caption, const cha
ccw_caption = g_Locale->getText(locale_caption);
ccw_icon_name = iconname;
initCCWItems();
}
CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
neutrino_locale_t locale_caption,
const char* iconname,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
{
initVarWindow();
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;
ccw_caption = g_Locale->getText(locale_caption);
ccw_icon_name = iconname;
initCCWItems();
}
CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h,
const std::string& caption,
const char* iconname,
bool has_shadow,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
{
initVarWindow();
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;
ccw_caption = caption;;
ccw_icon_name = iconname;
initCCWItems();
}
CComponentsWindow::~CComponentsWindow()
@@ -79,9 +136,10 @@ void CComponentsWindow::initVarWindow()
y=getScreenStartY(height);
ccw_head = NULL;
ccw_body = NULL;
ccw_footer = NULL;
ccw_caption = "";
ccw_icon_name = NULL;
ccw_start_y = 0;
ccw_buttons = 0; //no header buttons
setShadowOnOff(true);
@@ -97,27 +155,68 @@ void CComponentsWindow::initHeader()
if (ccw_head == NULL){
ccw_head = new CComponentsHeader();
initHeader();
//add header item only one time
addCCItem(ccw_head);
//add of header item happens initCCWItems()
}
//set header properties
if (ccw_head){
ccw_head->setXPos(0);
ccw_head->setYPos(0);
ccw_head->setPos(0, 0);
ccw_head->setWidth(width);
ccw_head->setHeaderIcon(ccw_icon_name);
ccw_head->setHeaderText(ccw_caption);
ccw_head->initCCHeaderItems();
ccw_start_y = ccw_head->getHeight();
ccw_head->setHeaderDefaultButtons(ccw_buttons);
ccw_head->setIcon(ccw_icon_name);
ccw_head->setCaption(ccw_caption);
ccw_head->initCCItems();
ccw_head->setDefaultButtons(ccw_buttons);
}
}
void CComponentsWindow::initBody()
{
if (ccw_body== NULL){
ccw_body = new CComponentsForm();
initBody();
//add of body item happens initCCWItems()
}
//set body properties
if (ccw_body){
ccw_body->setCornerType(0);
int fh = ccw_footer->getHeight();
int hh = ccw_head->getHeight();
int h_body = height - hh - fh;
ccw_body->setDimensionsAll(0, CC_APPEND, width, h_body);
ccw_body->doPaintBg(false);
}
}
void CComponentsWindow::initFooter()
{
if (ccw_footer== NULL){
ccw_footer= new CComponentsFooter();
initFooter();
//add of footer item happens initCCWItems()
}
//set footer properties
if (ccw_footer){
ccw_footer->setPos(0, CC_APPEND);
ccw_footer->setWidth(width);
ccw_footer->setShadowOnOff(shadow);
}
}
void CComponentsWindow::addWindowItem(CComponentsItem* cc_Item)
{
if (ccw_body)
ccw_body->addCCItem(cc_Item);
}
int CComponentsWindow::getStartY()
{
initHeader();
return ccw_start_y;
if (ccw_head)
return ccw_head->getHeight();
return 0;
}
void CComponentsWindow::initCCWItems()
@@ -126,6 +225,16 @@ void CComponentsWindow::initCCWItems()
printf("[CComponentsWindow] [%s - %d] init items...\n", __FUNCTION__, __LINE__);
#endif
initHeader();
initFooter();
initBody();
//add header, body and footer items only one time
if (!isAdded(ccw_head))
addCCItem(ccw_head);
if (!isAdded(ccw_body))
addCCItem(ccw_body);
if (!isAdded(ccw_footer))
addCCItem(ccw_footer);
}
void CComponentsWindow::paint(bool do_save_bg)

View File

@@ -54,7 +54,6 @@ void CComponentsItem::initVarItem()
//CComponents
initVarBasic();
cc_item_index = CC_NO_INDEX;
cc_item_xr = cc_item_yr = -1;
cc_item_enabled = true;
cc_item_selected = false;
cc_parent = NULL;
@@ -78,33 +77,29 @@ void CComponentsItem::paintInit(bool do_save_bg)
//calculate current needed corner radius for body box, depends of frame thickness
int rad = (corner_rad>th) ? corner_rad-th : corner_rad;
int sw = (shadow) ? shadow_w : 0;
int sw = 0, sw_cur = 0;
int x_sh = x + width;
int y_sh = y + height;
if (shadow) {
sw = shadow_w;
sw_cur = sw;
if (corner_type && corner_rad) {
//calculate positon of shadow areas
x_sh += sw - 2*corner_rad;
y_sh += sw - 2*corner_rad;
//calculate current shadow width depends of current corner_rad
sw_cur = max(2*corner_rad, sw);
}
//if item is bound on a parent form, we must use real x/y values and from parent form as reference
int ix = x, iy = y;
if (cc_parent){
ix = cc_xr + cc_parent->getFrameThickness();
iy = cc_yr + cc_parent->getFrameThickness();
}
comp_fbdata_t fbdata[] =
{
{CC_FBDATA_TYPE_BGSCREEN, x, y, width+sw, height+sw, 0, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_BOX, x_sh, y+sw, sw_cur, height, col_shadow, corner_rad, 0, NULL, NULL},//shadow right
{CC_FBDATA_TYPE_BOX, x+sw, y_sh, width, sw_cur, col_shadow, corner_rad, 0, NULL, NULL},//shadow bottom
{CC_FBDATA_TYPE_FRAME, x, y, width, height, col_frame_cur, corner_rad, th, NULL, NULL},//frame
{CC_FBDATA_TYPE_BOX, x+th, y+th, width-2*th, height-2*th, col_body, rad, 0, NULL, NULL},//body
{CC_FBDATA_TYPE_BGSCREEN, ix, iy, width+sw, height+sw, 0, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_SHADOW_BOX, ix+sw, iy+sw, width, height, col_shadow, corner_rad, 0, NULL, NULL},//shadow
{CC_FBDATA_TYPE_FRAME, ix, iy, width, height, col_frame_cur, corner_rad, th, NULL, NULL},//frame
{CC_FBDATA_TYPE_BOX, ix+th, iy+th, width-2*th, height-2*th, col_body, rad, 0, NULL, NULL},//body
};
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++)
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) {
if (((fbdata[i].fbdata_type == CC_FBDATA_TYPE_SHADOW_BOX) && !shadow) ||
((fbdata[i].fbdata_type == CC_FBDATA_TYPE_FRAME) && !fr_thickness))
continue;
v_fbdata.push_back(fbdata[i]);
}
#ifdef DEBUG_CC
printf("[CComponentsItem] %s:\ncc_item_type: %d\ncc_item_index = %d\nheight = %d\nwidth = %d\n", __FUNCTION__, cc_item_type, cc_item_index, height, width);
#endif

View File

@@ -30,7 +30,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include "cc_item_infobox.h"
using namespace std;
@@ -85,8 +85,6 @@ void CComponentsInfoBox::initVarInfobox()
cctext = NULL;
pic_name = "";
x_offset = 10;
x_text = x+fr_thickness+x_offset;;
}
void CComponentsInfoBox::paintPicture()
@@ -101,7 +99,7 @@ void CComponentsInfoBox::paintPicture()
return;
//init pic object and set icon paint position
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness/*+y_offset*/, 0, 0, "");
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, 0, 0, "");
//define icon
pic->setPicture(pic_name);
@@ -109,7 +107,6 @@ void CComponentsInfoBox::paintPicture()
//fit icon into infobox
pic->setHeight(height-2*fr_thickness);
pic->setColorBody(col_body);
pic->paint(CC_SAVE_SCREEN_NO);
}
@@ -119,15 +116,16 @@ void CComponentsInfoBox::paint(bool do_save_bg)
paintPicture();
//define text x position
x_text = x+fr_thickness+x_offset;
//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
if ((pic) && (pic->isPicPainted())){
int pic_w = pic->getWidth();
x_text += pic_w+x_offset;
}
int pic_w = 0;
if ((pic) && (pic->isPicPainted()))
pic_w = pic->getWidth() + x_offset;
//set text and paint text lines
//set text properties and paint text lines
if (!ct_text.empty()){
if (cctext)
delete cctext;
@@ -137,7 +135,13 @@ void CComponentsInfoBox::paint(bool do_save_bg)
cctext->doPaintTextBoxBg(ct_paint_textbg);
cctext->doPaintBg(false);
cctext->setTextColor(ct_col_text);
cctext->setDimensionsAll(x_text, y+fr_thickness, width-(x_text-x+x_offset+fr_thickness), height-2*fr_thickness);
//calculate vars for x-position and dimensions
int tx = x_offset + x_text + pic_w;
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);
}
}

View File

@@ -0,0 +1,83 @@
/*
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'
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_ITEM_INFOBOX__
#define __CC_ITEM_INFOBOX__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "cc_item_text.h"
#include "cc_item_picture.h"
#include <string>
//! Sub class of CComponentsItem. Shows box with text and optional icon on screen.
/*!
InfoBox has been originally intended for displaying text information or menue hints,
but is also usable like each other CCItems.
*/
#define INFO_BOX_Y_OFFSET 2
class CComponentsInfoBox : public CComponentsText
{
private:
///property: property: space around fram and beetween picture and textbox, see also setSpaceOffset()
int x_offset;
///object: picture object
CComponentsPicture * pic;
///property: path or default name of displayed image
std::string pic_default_name;
///initialize all needed default attributes
void initVarInfobox();
///paint picture, used in initVarInfobox()
void paintPicture();
///property: path or name of displayed image
std::string pic_name;
public:
///object: internal used CTextBox object
CComponentsText * cctext;
CComponentsInfoBox();
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h,
std::string info_text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_text = COL_MENUCONTENT, 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);
~CComponentsInfoBox();
///set property: space around fram and beetween picture and textbox
inline void setSpaceOffset(const int offset){x_offset = offset;};
///set property: path or name of displayed image
inline void setPicture(const std::string& picture_name){pic_name = picture_name;};
///paint item
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
#endif

View File

@@ -30,7 +30,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include "cc_item_picture.h"
#include <unistd.h>
extern CPictureViewer * g_PicViewer;
@@ -142,48 +142,63 @@ void CComponentsPicture::initVarPicture()
printf("[CComponentsPicture] %s file: %s, no icon dimensions found! width = %d, height = %d\n", __FUNCTION__, pic_name.c_str(), pic_width, pic_height);
#endif
pic_x += fr_thickness;
pic_y += fr_thickness;
if (pic_height>0 && pic_width>0){
if (pic_align & CC_ALIGN_LEFT)
pic_x = x+fr_thickness;
if (pic_align & CC_ALIGN_RIGHT)
pic_x = x+width-pic_width-fr_thickness;
if (pic_align & CC_ALIGN_TOP)
pic_y = y+fr_thickness;
if (pic_align & CC_ALIGN_BOTTOM)
pic_y = y+height-pic_height-fr_thickness;
if (pic_align & CC_ALIGN_HOR_CENTER)
pic_x = x+width/2-pic_width/2;
if (pic_align & CC_ALIGN_VER_CENTER)
pic_y = y+height/2-pic_height/2;
do_paint = true;
}
initPosition();
int sw = (shadow ? shadow_w :0);
width = max(max(pic_width, pic_max_w), width) + sw ;
height = max(max(pic_height, pic_max_h), height) + sw ;
}
void CComponentsPicture::paint(bool do_save_bg)
void CComponentsPicture::initPosition()
{
//using of real x/y values to paint images if this picture object is bound in a parent form
int px = x, py = y;
if (cc_parent){
px = cc_xr;
py = cc_yr;
}
if (pic_height>0 && pic_width>0){
if (pic_align & CC_ALIGN_LEFT)
pic_x = px+fr_thickness;
if (pic_align & CC_ALIGN_RIGHT)
pic_x = px+width-pic_width-fr_thickness;
if (pic_align & CC_ALIGN_TOP)
pic_y = py+fr_thickness;
if (pic_align & CC_ALIGN_BOTTOM)
pic_y = py+height-pic_height-fr_thickness;
if (pic_align & CC_ALIGN_HOR_CENTER)
pic_x = px+width/2-pic_width/2;
if (pic_align & CC_ALIGN_VER_CENTER)
pic_y = py+height/2-pic_height/2;
do_paint = true;
}
}
void CComponentsPicture::paintPicture()
{
initVarPicture();
paintInit(do_save_bg);
pic_painted = false;
if (do_paint){
#ifdef DEBUG_CC
printf(" [CComponentsPicture] %s: paint image: %s (do_paint=%d)\n", __FUNCTION__, pic_name.c_str(), do_paint);
#endif
if (do_paint){
if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF)
pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0 /*pic_max_h*/, pic_offset, pic_paint, pic_paintBg, col_body);
else if (pic_paint_mode == CC_PIC_IMAGE_MODE_ON)
pic_painted = g_PicViewer->DisplayImage(pic_name, pic_x, pic_y, pic_width, pic_height);
do_paint = false;
}
if (pic_painted)
do_paint = false;
}
void CComponentsPicture::paint(bool do_save_bg)
{
initVarPicture();
paintInit(do_save_bg);
paintPicture();
}
void CComponentsPicture::hide(bool no_restore)

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) 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.
*/
#ifndef __CC_ITEM_PICTURE_H__
#define __CC_ITEM_PICTURE_H__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "cc.h"
#include <string>
#include <driver/pictureviewer/pictureviewer.h>
//! Sub class of CComponentsItem. Shows box with image with assigned attributes.
/*!
Picture is usable like each other CCItems.
*/
class CComponentsPicture : public CComponentsItem
{
protected:
///initialize all required attributes
void initVarPicture();
///some internal modes for icon and image handling
enum
{
CC_PIC_IMAGE_MODE_OFF = 0, //paint pictures in icon mode, mainly not scaled
CC_PIC_IMAGE_MODE_ON = 1, //paint pictures in image mode, paint scaled if required
CC_PIC_IMAGE_MODE_AUTO = 2
};
///property: path or name of image, icon names to find in /widget/icons.h, icons will paint never scaled
std::string pic_name;
///property: interface to CFrameBuffer::paintIcon() arg 5
unsigned char pic_offset;
bool pic_paint, pic_paintBg, pic_painted, do_paint;
int pic_align, pic_x, pic_y, pic_width, pic_height;
int pic_max_w, pic_max_h, pic_paint_mode;
void init( const int x_pos, const int y_pos, const std::string& image_name, const int alignment, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow);
///initialize position of picture object dependendly from settings
void initPosition();
void paintPicture();
public:
CComponentsPicture( const int x_pos, const int y_pos, const int w, const int h,
const std::string& image_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
virtual inline void setPictureOffset(const unsigned char offset){pic_offset = offset;};
virtual inline void setPicturePaint(bool paint_p){pic_paint = paint_p;};
virtual inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;};
virtual void setPicture(const std::string& picture_name);
virtual void setPictureAlign(const int alignment);
virtual inline bool isPicPainted(){return pic_painted;};
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
virtual void hide(bool no_restore = false);
virtual inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;};
virtual void setMaxWidth(const int w_max){pic_max_w = w_max;};
virtual void setMaxHeight(const int h_max){pic_max_h = h_max;};
};
#endif

View File

@@ -31,7 +31,7 @@
#include <neutrino.h>
#include "cc_item_progressbar.h"
#include "cc_item_shapes.h"
#define ITEMW 4
#define POINT 2
@@ -112,9 +112,10 @@ void CProgressBar::initDimensions()
if (pb_value > pb_max_value)
pb_max_value = pb_value;
// start positions x/y active bar
pb_x = (cc_item_xr > -1 ? cc_item_xr : x) + fr_thickness;
pb_y = (cc_item_yr > -1 ? cc_item_yr : y) + fr_thickness;
//assign start positions x/y active bar
//NOTE: real values are only reqiured, if we paint active/passive bar with own render methodes or not embedded cc-items
pb_x = (cc_parent ? cc_xr : x) + fr_thickness;
pb_y = (cc_parent ? cc_yr : y) + fr_thickness;
// width for active bar with current value
pb_active_width = max(0, pb_last_width);
@@ -136,16 +137,23 @@ void CProgressBar::initDimensions()
col_frame = pb_active_col;
}
void CProgressBar::paintShapes(int &shx, int &shy, int &shw, int &shh, fb_pixel_t &col)
{
CComponentsShapeSquare shape(shx, shy, shw, shh, false);
shape.setColorBody(col);
shape.paint(false);
}
void CProgressBar::paintSimple()
{
// progress value
if (pb_active_width != pb_last_width){
frameBuffer->paintBoxRel(pb_x, pb_y, pb_active_width, pb_height, pb_active_col); // active bar
frameBuffer->paintBoxRel(pb_start_x_passive, pb_y, pb_passive_width, pb_height, pb_passive_col); // passive bar
paintShapes(pb_x, pb_y, pb_active_width, pb_height, pb_active_col); // active bar
paintShapes(pb_start_x_passive, pb_y, pb_passive_width, pb_height, pb_passive_col); // passive bar
}
if (pb_paint_zero && pb_value == 0)
if (pb_paint_zero && pb_value == 0) //TODO: use shape cc-item, not available for lines yet
frameBuffer->paintLine(pb_x , pb_y, pb_x+width-3, pb_y+height-3, pb_active_col); // zero line
}
@@ -202,8 +210,11 @@ void CProgressBar::paintAdvanced()
else
rgb = RED + (diff << 8); // adding green
color = make16color(rgb);
for (j = 0; j < hcnt; j++)
frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color);
for (j = 0; j < hcnt; j++) {
int sh_x = pb_x + i * itemw;
int sh_y = py + j * itemh;
paintShapes(sh_x, sh_y, pointx, pointy, color);
}
}
step = yw - rd - 1;
if (step < 1)
@@ -215,8 +226,11 @@ void CProgressBar::paintAdvanced()
else
rgb = YELLOW - (diff << 16); // removing red
color = make16color(rgb);
for (j = 0; j < hcnt; j++)
frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color);
for (j = 0; j < hcnt; j++) {
int sh_x = pb_x + i * itemw;
int sh_y = py + j * itemh;
paintShapes(sh_x, sh_y, pointx, pointy, color);
}
}
off = diff;
b = 0;
@@ -230,13 +244,19 @@ void CProgressBar::paintAdvanced()
else
rgb = YELLOW - (diff << 16); // removing red
color = make16color(rgb);
for (j = 0; j < hcnt; j++)
frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, color);
for (j = 0; j < hcnt; j++) {
int sh_x = pb_x + i * itemw;
int sh_y = py + j * itemh;
paintShapes(sh_x, sh_y, pointx, pointy, color);
}
}
}
for(i = maxi; i < total; i++) {
for (j = 0; j < hcnt; j++)
frameBuffer->paintBoxRel(pb_x + i * itemw, py + j * itemh, pointx, pointy, pb_passive_col); //fill passive
for (j = 0; j < hcnt; j++) {//TODO: use shape cc-item
int sh_x = pb_x + i * itemw;
int sh_y = py + j * itemh;
paintShapes(sh_x, sh_y, pointx, pointy, pb_passive_col); //fill passive
}
}
}
}

View File

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

View File

@@ -30,7 +30,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include "cc_item_shapes.h"
using namespace std;

View File

@@ -0,0 +1,67 @@
/*
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'
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_ITEM_SHAPES_H__
#define __CC_ITEM_SHAPES_H__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "cc.h"
//! Sub class of CComponentsItem. Shows a shape with given dimensions and color on screen.
/*!
Paint of simple shapes on screen.
*/
class CComponentsShapeCircle : public CComponentsItem
{
private:
///property: diam
int d;
public:
CComponentsShapeCircle( const int x_pos, const int y_pos, const int diam, bool has_shadow = CC_SHADOW_ON,
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);
///set property: diam
inline void setDiam(const int& diam){d=width=height=diam, corner_rad=d/2;};
///get property: diam
inline int getDiam(){return d;};
///paint item
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsShapeSquare : public CComponentsItem
{
public:
CComponentsShapeSquare( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON,
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);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
#endif

View File

@@ -30,7 +30,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include "cc_item_text.h"
#include <sstream>
#include <fstream>
#include <errno.h>
@@ -67,6 +67,8 @@ CComponentsText::CComponentsText( const int x_pos, const int y_pos, const int w,
ct_text = text;
ct_text_mode = mode;
ct_col_text = color_text;
initCCText();
}
@@ -93,6 +95,12 @@ void CComponentsText::initVarText()
ct_text = "";
ct_old_text = ct_text;
ct_text_mode = CTextBox::AUTO_WIDTH;
/* we need a minimal borderwith of 1px because the edge-smoothing
(or fontrenderer?) otherwise will paint single pixels outside the
defined area. e.g. 'j' is leaving such residues */
ct_text_border = 1;
ct_col_text = COL_MENUCONTENT;
ct_text_sent = false;
ct_paint_textbg = false;
@@ -115,9 +123,16 @@ void CComponentsText::initCCText()
delete ct_box;
ct_box = NULL;
}
//using of real x/y values to paint images if this text object is bound in a parent form
int tx = x, ty = y;
if (cc_parent){
tx = cc_xr;
ty = cc_yr;
}
ct_box = new CBox();
ct_box->iX = x+fr_thickness;
ct_box->iY = y+fr_thickness;
ct_box->iX = tx+fr_thickness;
ct_box->iY = ty+fr_thickness;
ct_box->iWidth = width-2*fr_thickness;
ct_box->iHeight = height-2*fr_thickness;
@@ -129,7 +144,7 @@ void CComponentsText::initCCText()
ct_textbox->setTextFont(ct_font);
ct_textbox->setTextMode(ct_text_mode);
ct_textbox->setWindowPos(ct_box);
ct_textbox->setTextBorderWidth(0);
ct_textbox->setTextBorderWidth(ct_text_border);
ct_textbox->enableBackgroundPaint(ct_paint_textbg);
ct_textbox->setBackGroundColor(col_body);
ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type);
@@ -142,7 +157,7 @@ void CComponentsText::initCCText()
ct_text_sent = ct_textbox->setText(&ct_text, ct_box->iWidth);
ct_old_text = ct_text;
#ifdef DEBUG_CC
printf(" [CComponentsText] [%s - %d] init text: %s [x %d, y %d, h %d, w %d]\n", __FUNCTION__, __LINE__, ct_text.c_str(), ct_box->iX, ct_box->iY, height, width);
printf(" [CComponentsText] [%s - %d] init text: %s [x %d, y %d, w %d, h %d]\n", __FUNCTION__, __LINE__, ct_text.c_str(), ct_box->iX, ct_box->iY, ct_box->iWidth, ct_box->iHeight);
#endif
}

View File

@@ -0,0 +1,160 @@
/*
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'
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_ITEM_TEXT_H__
#define __CC_ITEM_TEXT_H__
#include "cc.h"
#include <gui/widget/textbox.h>
#include <string>
//! Sub class of CComponentsItem. Shows a text box.
/*!
Usable like all other CCItems and provides paint of text with different properties for format, alignment, color, fonts etc.
The basic background of textboxes based on frame, body and shadow, known from othe CCItems.
Handling of text parts based up CTextBox attributes and methodes.
CComponentsText provides a interface to the embedded CTextBox object.
*/
class CComponentsText : public CComponentsItem
{
protected:
///object: CTextBox object
CTextBox * ct_textbox;
///object: CBox object
CBox * ct_box;
///object: Fontrenderer object
Font * ct_font;
///property: CTextBox object
fb_pixel_t ct_col_text;
///property: text display modes, see textbox.h for possible modes
int ct_text_mode;
///property: text border width
int ct_text_border;
///property: current text string
std::string ct_text;
///status: cached text string, mainly required to compare with current text
std::string ct_old_text;
///status: current text string is sent to CTextBox object
bool ct_text_sent;
///property: send to CTextBox object enableBackgroundPaint(true)
bool ct_paint_textbg;
///property: force sending text to the CTextBox object, false= text only sended, if text was changed, see also textChanged()
bool ct_force_text_paint;
///helper: convert int to string
static std::string iToString(int int_val); //helper to convert int to string
///initialize all required default attributes
void initVarText();
///destroy current CTextBox and CBox objects
void clearCCText();
///initialize all required attributes for text and send to the CTextBox object
void initCCText();
///paint CCItem backckrond (if paint_bg=true), apply initCCText() and send paint() to the CTextBox object
void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES);
public:
CComponentsText();
CComponentsText( const int x_pos, const int y_pos, const int w, const int h,
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_MENUCONTENT, 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);
virtual ~CComponentsText();
///default members to paint a text box and hide painted text
///hide textbox
void hide(bool no_restore = false);
///paint text box, parameter do_save_bg: default = true, causes fill of backckrond pixel buffer
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///send options for text font (size and type), color and mode (allignment)
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
///set text color
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
///set text alignment, also see textbox.h for possible alignment modes
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};
///set text border width
virtual inline void setTextBorderWidth(const int border){ct_text_border = border;};
///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;};
///set text as string also possible with overloades members for loacales, const char and text file
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
///set text with const char*
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
///set text from locale
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
///set text from digit, digit is integer
virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
///set text directly from a textfile, path as string is required
virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
///helper to remove linebreak chars from a string if needed
virtual void removeLineBreaks(std::string& str);
///returns true, if text was changed
virtual bool textChanged(){return ct_old_text != ct_text;};
///force paint of text even if text was changed or not
virtual void forceTextPaint(bool force_text_paint = true){ct_force_text_paint = force_text_paint;};
///gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties
virtual CTextBox* getCTextBoxObject() { return ct_textbox; };
};
//! Sub class of CComponentsText. Shows text as label, text color=inactive mode, depending from color settings.
/*!
Usable like all other CCItems and provides paint of text with different properties for format, alignment, color, fonts etc.
The basic background of textboxes based on frame, body and shadow, known from othe CCItems.
Handling of text parts based up CTextBox attributes and methodes.
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,
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, 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)
:CComponentsText(x_pos, y_pos, w, h, text, mode, font_text, has_shadow, color_text, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_LABEL;
};
CComponentsLabel():CComponentsText()
{
initVarText();
cc_item_type = CC_ITEMTYPE_LABEL;
ct_col_text = COL_MENUCONTENTINACTIVE;
};
};
#endif

View File

@@ -30,7 +30,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include "cc_item_tvpic.h"
#include <video.h>
@@ -74,13 +74,20 @@ CComponentsPIP::~CComponentsPIP()
void CComponentsPIP::paint(bool do_save_bg)
{
int pig_x = x+fr_thickness;
int pig_y = y+fr_thickness;
//NOTE: real values are reqiured, if we paint not bound items or an own render methodes
int pig_x = (cc_parent ? cc_xr : x) + fr_thickness;
int pig_y = (cc_parent ? cc_yr : y) + fr_thickness;
int pig_w = width-2*fr_thickness;
int pig_h = height-2*fr_thickness;
paintInit(do_save_bg);
if (videoDecoder->getAspectRatio() == 1){
int tmpw = pig_w;
pig_w -= pig_w*25/100;
pig_x += tmpw/2-pig_w/2;
}
if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_tv){
videoDecoder->Pig(pig_x+2, pig_y, pig_w, pig_h, screen_w, screen_h);
}

View File

@@ -0,0 +1,69 @@
/*
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'
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_ITEM_TVPIC_H__
#define __CC_ITEM_TVPIC_H__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "cc.h"
#include <string>
//! Sub class of CComponentsItem. Shows a mini tv box, similar to a PIP-Feature with current tv-channel.
/*!
Usable like all other CCItems and provides a simple display of a mini tv box on screen.
A real PIP-Feature is only provided with correct hardware support and in soon in newer versions.
*/
class CComponentsPIP : public CComponentsItem
{
private:
///property: width of tv box
int screen_w;
///property: height of tv box
int screen_h;
///property: path to image that displayed, if no tv-mode is active, default: start.jpg
std::string pic_name;
public:
///constructor: initialize of position like all other items with x and y values, but dimensions in percent
CComponentsPIP( const int x_pos, const int y_pos, const int percent = 30, bool has_shadow = CC_SHADOW_OFF);
~CComponentsPIP();
///set property: width of tv box in pixel
void setScreenWidth(int screen_width){screen_w = screen_width;};
///set property: height of tv box in pixel
void setScreenHeight(int screen_heigth){screen_h = screen_heigth;};
///property: path to image that displayed, if no tv-mode is active
void setPicture(const std::string& image){pic_name = image;};
///show tv box
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///remove tv box from screen
void hide(bool no_restore = false);
};
#endif

View File

@@ -40,7 +40,9 @@ typedef enum
CC_ITEMTYPE_SHAPE_CIRCLE,
CC_ITEMTYPE_PIP,
CC_ITEMTYPE_FRM,
CC_ITEMTYPE_FRM_CLOCK,
CC_ITEMTYPE_FRM_HEADER,
CC_ITEMTYPE_FOOTER,
CC_ITEMTYPE_FRM_ICONFORM,
CC_ITEMTYPE_FRM_WINDOW,
CC_ITEMTYPE_LABEL,
@@ -74,6 +76,7 @@ typedef enum
{
CC_FBDATA_TYPE_BGSCREEN,
CC_FBDATA_TYPE_BOX,
CC_FBDATA_TYPE_SHADOW_BOX,
CC_FBDATA_TYPE_FRAME,
CC_FBDATA_TYPE_LINE,
CC_FBDATA_TYPE_BACKGROUND,
@@ -131,6 +134,7 @@ typedef struct comp_element_data_t
#define CC_SAVE_SCREEN_NO false
#define CC_NO_INDEX -1
#define CC_APPEND -1