Merge branch 'check/pu-cc' into master

needs buildfixing...

Conflicts:
	data/Makefile.am
	src/driver/framebuffer.h
	src/driver/volume.cpp
	src/gui/bedit/bouqueteditor_bouquets.cpp
	src/gui/bedit/bouqueteditor_channels.cpp
	src/gui/bouquetlist.cpp
	src/gui/channellist.cpp
	src/gui/filebrowser.cpp
	src/gui/imageinfo.cpp
	src/gui/infoviewer.cpp
	src/gui/streaminfo2.cpp
	src/gui/widget/textbox.cpp
This commit is contained in:
Stefan Seyfried
2013-04-06 11:21:55 +02:00
76 changed files with 4450 additions and 950 deletions

View File

@@ -22,4 +22,16 @@ noinst_LIBRARIES = libneutrino_gui_components.a
libneutrino_gui_components_a_SOURCES = \
components.cpp
cc_base.cpp \
cc_detailsline.cpp \
cc_frm.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_shapes.cpp \
cc_item_text.cpp \
cc_item_tvpig.cpp

View File

@@ -2,23 +2,23 @@
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic for GUI-related components.
Classes for generic GUI-related components.
Copyright (C) 2012, 2013, Thilo Graf 'dbt'
License: GPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
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 library is distributed in the hope that it will be useful,
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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the
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.
*/
@@ -26,85 +26,532 @@
#ifndef __COMPONENTS__
#define __COMPONENTS__
#include <driver/framebuffer.h>
#include <gui/color.h>
#include <gui/customcolor.h>
#include "cc_types.h"
#include <gui/widget/textbox.h>
#include <vector>
#include <string>
#include <driver/pictureviewer/pictureviewer.h>
//required typedefs
typedef struct comp_fbdata_t
{
int x;
int y;
int dx;
int dy;
fb_pixel_t color;
int r;
void * data;
fb_pixel_t* pixbuf;
bool is_frame;
int frame_thickness;
} comp_fbdata_struct_t;
// #define DEBUG_CC
class CComponents
{
protected:
int x, y, height, width, sw;
int x, y, height, width, corner_type, shadow_w;
int corner_rad, fr_thickness;
CFrameBuffer * frameBuffer;
std::vector<comp_fbdata_t> v_screen_val;
void paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg = true);
fb_pixel_t* saveScreen(int ax, int ay, int dx, int dy);
void clear();
std::vector<comp_fbdata_t> v_fbdata;
fb_pixel_t col_body, col_shadow, col_frame;
bool firstPaint, shadow, is_painted, paint_bg;
void initVarBasic();
void paintFbItems(bool do_save_bg = true);
fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
comp_screen_data_t saved_screen;
void clearSavedScreen();
virtual void clear();
public:
CComponents(const int x_pos = 0, const int y_pos = 0, const int h = 0, const int w = 0);
CComponents();
virtual~CComponents();
virtual void setXPos(const int& xpos){x = xpos;};
virtual void setYPos(const int& ypos){y = ypos;};
virtual void setHeight(const int& h){height = h;};
virtual void setWidth(const int& w){width = w;};
virtual void restore();
inline virtual void setXPos(const int& xpos){x = xpos;};
inline virtual void setYPos(const int& ypos){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;};
inline virtual int getXPos(){return x;};
inline virtual int getYPos(){return y;};
inline virtual int getHeight(){return height;};
inline virtual int getWidth(){return width;};
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"
inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
inline virtual void setColorBody(fb_pixel_t color){col_body = color;};
inline virtual void setColorShadow(fb_pixel_t color){col_shadow = color;};
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
inline virtual fb_pixel_t getColorFrame(){return col_frame;};
inline virtual fb_pixel_t getColorBody(){return col_body;};
inline virtual fb_pixel_t getColorShadow(){return col_shadow;};
/// set corner types: Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h).
inline virtual void setCornerType(const int& type){corner_type = type;};
inline virtual void setCornerRadius(const int& radius){corner_rad = radius;};
/// get corner types:
inline virtual int getCornerType(){return corner_type;};
inline virtual int getCornerRadius(){return corner_rad;};
inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;};
inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;};
virtual void hide();
virtual bool isPainted(){return is_painted;}
virtual void doPaintBg(bool do_paint){paint_bg = do_paint;};
};
class CComponentsItem : public CComponents
{
protected:
int cc_item_type;
int cc_item_index;
void hideCCItem(bool no_restore = false);
void paintInit(bool do_save_bg);
void initVarItem();
public:
enum
{
CC_ITEMTYPE_BASE,
CC_ITEMTYPE_PICTURE,
CC_ITEMTYPE_TEXT,
CC_ITEMTYPE_TEXT_INFOBOX,
CC_ITEMTYPE_SHAPE_SQUARE,
CC_ITEMTYPE_SHAPE_CIRCLE,
CC_ITEMTYPE_PIP,
CC_ITEMTYPE_FRM,
CC_ITEMTYPE_FRM_HEADER,
CC_ITEMTYPE_FRM_ICONFORM,
CC_ITEMTYPE_FRM_WINDOW,
CC_ITEMTYPE_LABEL,
CC_ITEMTYPES
};
CComponentsItem();
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
virtual void hide(bool no_restore = false);
virtual void kill();
virtual int getItemType();
virtual void syncSysColors();
};
class CComponentsPicture : public CComponentsItem
{
private:
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 initVarPicture();
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);
inline void setPictureOffset(const unsigned char offset){pic_offset = offset;};
inline void setPicturePaint(bool paint_p){pic_paint = paint_p;};
inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;};
void setPicture(const std::string& picture_name);
void setPictureAlign(const int alignment);
inline bool isPicPainted(){return pic_painted;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void hide(bool no_restore = false);
inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;};
void setMaxWidth(const int w_max){pic_max_w = w_max;};
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
const char* ct_text;
bool ct_text_sent;
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,
const char* 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();
void hide(bool no_restore = false);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
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;};
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};//see textbox.h for possible modes
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(const std::string& stext, 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 removeLineBreaks(std::string& str);
//get a Text Box object, so it's possible to get access directly to its methods
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,
const char* 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,
const char* info_text = NULL, 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;
fb_pixel_t col_line, col_shadow;
void initVarDline();
public:
CComponentsDetailLine();
CComponentsDetailLine( const int x_pos,const int y_pos_top, const int y_pos_down,
const int h_mark_up =16 , const int h_mark_down = 16,
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 = false);
void hide();
void setColor(fb_pixel_t color_line, fb_pixel_t color_shadow){col_line = color_line; col_shadow = color_shadow;};
void setYPosDown(const int& y_pos_down){y_down = y_pos_down;};
void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void kill();
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_;};
};
#define INFO_BOX_Y_OFFSET 2
class CComponentsInfoBox : public CComponents
#define FIRST_ELEMENT_INIT 10000
#define LOGO_MAX_WIDTH width/4
class CComponentsItemBox : public CComponentsItem
{
private:
int rad,fr_thickness;
bool shadow;
fb_pixel_t col_frame, col_body, col_shadow;
bool firstPaint;
std::vector<comp_fbdata_t> v_infobox_val;
protected:
int hSpacer;
int hOffset;
int vOffset;
int digit_offset, digit_h;
bool paintElements;
bool onlyOneTextElement;
fb_pixel_t it_col_text;
Font* font_text;
int hMax;
bool has_TextElement;
size_t firstElementLeft;
size_t firstElementRight;
size_t prevElementLeft;
size_t prevElementRight;
std::vector<comp_element_data_t> v_element_data;
bool isCalculated;
void clearElements();
void initVarItemBox();
void calSizeOfElements();
void calPositionOfElements();
void paintItemBox(bool do_save_bg = CC_SAVE_SCREEN_YES);
void calculateElements();
bool addElement(int align, int type, const std::string& element="", size_t *index=NULL);
void paintImage(size_t index, bool newElement);
void paintText(size_t index, bool newElement);
public:
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = true,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENTDARK_PLUS_0,fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
CComponentsItemBox();
virtual ~CComponentsItemBox();
void paint(bool do_save_bg = false, bool fullPaint = false);
void hide();
void restore(bool clear_ = true);
void setColor(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;};
inline virtual void setTextFont(Font* font){font_text = font;};
inline virtual void setTextColor(fb_pixel_t color_text){ it_col_text = color_text;};
virtual void refreshElement(size_t index, const std::string& element);
virtual void paintElement(size_t index, bool newElement= false);
virtual bool addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index=NULL);
virtual void clearTitlebar();
virtual void addText(const std::string& s_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
virtual void addText(neutrino_locale_t locale_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
virtual void addIcon(const std::string& s_icon_name, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
virtual void addPicture(const std::string& s_picture_path, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
virtual void addClock(const int align=CC_ALIGN_RIGHT, size_t *index=NULL);
virtual int getHeight();
};
class CComponentsTitleBar : public CComponentsItemBox
{
private:
const char* tb_c_text;
std::string tb_s_text, tb_icon_name;
neutrino_locale_t tb_locale_text;
int tb_text_align, tb_icon_align;
void initText();
void initIcon();
void initElements();
void initVarTitleBar();
public:
CComponentsTitleBar();
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const char* c_text = NULL, const std::string& s_icon ="",
fb_pixel_t color_text = COL_MENUHEAD, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0);
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const std::string& s_text ="", const std::string& s_icon ="",
fb_pixel_t color_text = COL_MENUHEAD, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0);
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t locale_text = NONEXISTANT_LOCALE, const std::string& s_icon ="",
fb_pixel_t color_text = COL_MENUHEAD, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsForm : public CComponentsItem
{
protected:
std::vector<CComponentsItem*> v_cc_items;
void initVarForm();
void paintForm(bool do_save_bg);
public:
CComponentsForm();
CComponentsForm(const int x_pos, const int y_pos, const int w, const int h, 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);
virtual ~CComponentsForm();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void hide(bool no_restore = false);
virtual void addCCItem(CComponentsItem* cc_Item);
virtual void insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item);
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 int getCCItemId(CComponentsItem* cc_Item);
virtual CComponentsItem* getCCItem(const uint& cc_item_id);
virtual void paintCCItems();
virtual void clearCCItems();
virtual void cleanCCForm();
};
class CComponentsIconForm : public CComponentsForm
{
private:
std::vector<std::string> v_icons;
int ccif_offset, ccif_icon_align;
void initMaxHeight(int *pheight);
protected:
void initVarIconForm();
public:
CComponentsIconForm();
CComponentsIconForm(const int x_pos, const int y_pos, const int w, const int h, const std::vector<std::string> v_icon_names, 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);
// ~CComponentsIconForm(); //inherited from CComponentsForm
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void initCCIcons();
void addIcon(const std::string& icon_name);
void addIcon(std::vector<std::string> icon_name);
void removeIcons(){v_icons.clear();};
void insertIcon(const uint& icon_id, const std::string& icon_name);
void removeIcon(const uint& icon_id);
void removeIcon(const std::string& icon_name);
void removeAllIcons();
void setIconOffset(const int offset){ccif_offset = offset;};
enum //alignements
{
CC_ICONS_FRM_ALIGN_RIGHT ,
CC_ICONS_FRM_ALIGN_LEFT
};
void setIconAlign(int alignment){ccif_icon_align = alignment;};
int getIconId(const std::string& icon_name);
};
class CComponentsHeader : public CComponentsForm
{
private:
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;
std::vector<std::string> v_cch_btn;
void initCCHeaderIcon();
void initCCHeaderText();
void initCCHeaderButtons();
void initCCHDefaultButtons();
void initCCButtonFormSize();
protected:
void initVarHeader();
public:
enum
{
CC_BTN_HELP = 0x02,
CC_BTN_INFO = 0x04,
CC_BTN_MENU = 0x40,
CC_BTN_EXIT = 0x80
};
enum
{
CC_HEADER_ITEM_ICON = 0,
CC_HEADER_ITEM_TEXT = 1,
CC_HEADER_ITEM_BUTTONS = 2
};
CComponentsHeader();
CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, const std::string& caption = "header", 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(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();
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();
};
class CComponentsWindow : public CComponentsForm
{
private:
CComponentsHeader * ccw_head;
std::string ccw_caption;
const char* ccw_icon_name;
int ccw_start_y;
int ccw_buttons;
void initHeader();
void initCCWItems();
protected:
void initVarWindow();
public:
enum
{
CC_WINDOW_ITEM_HEADER = 0
};
CComponentsWindow();
CComponentsWindow(const std::string& caption, const char* iconname = NULL);
CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname = NULL);
~CComponentsWindow();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void setWindowCaption(const std::string& text){ccw_caption = text;};
void setWindowCaption(neutrino_locale_t locale_text);
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;};
int getStartY(); //y value for start of the area below header
};
#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'
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
Library 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.h"
using namespace std;
//abstract basic class CComponents
CComponents::CComponents()
{
initVarBasic();
}
CComponents::~CComponents()
{
hide();
clearSavedScreen();
clear();
}
void CComponents::clearSavedScreen()
{
if (saved_screen.pixbuf)
delete[] saved_screen.pixbuf;
saved_screen.pixbuf = NULL;
}
void CComponents::initVarBasic()
{
x = saved_screen.x = 0;
y = saved_screen.y = 0;
height = saved_screen.dy = CC_HEIGHT_MIN;
width = saved_screen.dx = CC_WIDTH_MIN;
col_body = COL_MENUCONTENT_PLUS_0;
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
col_frame = COL_MENUCONTENT_PLUS_6;
corner_type = CORNER_ALL;
corner_rad = 0;
shadow = CC_SHADOW_OFF;
shadow_w = SHADOW_OFFSET;
fr_thickness = 0;
firstPaint = true;
is_painted = false;
paint_bg = true;
frameBuffer = CFrameBuffer::getInstance();
v_fbdata.clear();
saved_screen.pixbuf = NULL;
}
//paint framebuffer stuff and fill buffer
void CComponents::paintFbItems(bool do_save_bg)
{
if (firstPaint && do_save_bg) {
for(size_t i=0; i<v_fbdata.size(); i++){
if (v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BGSCREEN){
#ifdef DEBUG_CC
printf(" [CComponents]\n [%s - %d] firstPaint->save screen: %d, fbdata_type: %d\n", __FUNCTION__, __LINE__, firstPaint, v_fbdata[i].fbdata_type);
#endif
saved_screen.x = v_fbdata[i].x;
saved_screen.y = v_fbdata[i].y;
saved_screen.dx = v_fbdata[i].dx;
saved_screen.dy = v_fbdata[i].dy;
clearSavedScreen();
saved_screen.pixbuf = getScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy);
firstPaint = false;
break;
}
}
}
for(size_t i=0; i< v_fbdata.size() ;i++){
int fbtype = v_fbdata[i].fbdata_type;
#ifdef DEBUG_CC
printf(" [CComponents]\n [%s - %d], fbdata_[%d] \n x = %d\n y = %d\n dx = %d\n dy = %d\n", __FUNCTION__, __LINE__, i, v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
#endif
if (firstPaint){
if (do_save_bg && fbtype == CC_FBDATA_TYPE_LINE)
v_fbdata[i].pixbuf = getScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
//ensure painting of all line fb items with saved screens
if (fbtype == CC_FBDATA_TYPE_LINE)
firstPaint = true;
else
firstPaint = false;
}
if (fbtype != CC_FBDATA_TYPE_BGSCREEN){
if (fbtype == CC_FBDATA_TYPE_FRAME && v_fbdata[i].frame_thickness > 0)
frameBuffer->paintBoxFrame(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].frame_thickness, v_fbdata[i].color, v_fbdata[i].r);
else if (fbtype == CC_FBDATA_TYPE_BACKGROUND)
frameBuffer->paintBackgroundBoxRel(x, y, v_fbdata[i].dx, v_fbdata[i].dy);
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);
}
}
is_painted = true;
}
//screen area save
inline fb_pixel_t* CComponents::getScreen(int ax, int ay, int dx, int dy)
{
fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy];
frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf);
return pixbuf;
}
//restore screen from buffer
inline void CComponents::hide()
{
for(size_t i =0; i< v_fbdata.size() ;i++) {
if (v_fbdata[i].pixbuf != NULL){
frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf);
delete[] v_fbdata[i].pixbuf;
v_fbdata[i].pixbuf = NULL;
}
}
v_fbdata.clear();
is_painted = false;
}
//clean old screen buffer
inline void CComponents::clear()
{
for(size_t i =0; i< v_fbdata.size() ;i++)
if (v_fbdata[i].pixbuf != NULL)
delete[] v_fbdata[i].pixbuf;
v_fbdata.clear();
}

View File

@@ -0,0 +1,168 @@
/*
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
Copyright (C) 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
Library 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.h"
using namespace std;
//sub class CComponentsDetailLine from CComponents
CComponentsDetailLine::CComponentsDetailLine()
{
initVarDline();
//CComponents
x = 0;
y = 0;
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
col_body = COL_MENUCONTENT_PLUS_6;
//CComponentsDetailLine
y_down = 0;
h_mark_top = CC_HEIGHT_MIN;
h_mark_down = CC_HEIGHT_MIN;
}
CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_top, const int y_pos_down, const int h_mark_top_, const int h_mark_down_, fb_pixel_t color_line, fb_pixel_t color_shadow)
{
initVarDline();
//CComponents
x = x_pos;
y = y_pos_top;
col_shadow = color_shadow;
col_body = color_line;
//CComponentsDetailLine
y_down = y_pos_down;
h_mark_top = h_mark_top_;
h_mark_down = h_mark_down_;
}
void CComponentsDetailLine::initVarDline()
{
//CComponents
initVarBasic();
shadow_w = 1;
//CComponentsDetailLine
thickness = 4;
}
CComponentsDetailLine::~CComponentsDetailLine()
{
hide(); //restore background
clear();
}
// y_top (=y)
// xpos +--|h_mark_up
// |
// |
// |
// |
// |
// |
// |
// |
// |
// +--|h_mark_down
// y_down
//paint details line with current parameters
void CComponentsDetailLine::paint(bool do_save_bg)
{
clear();
int y_mark_top = y-h_mark_top/2+thickness/2;
int y_mark_down = y_down-h_mark_down/2+thickness/2;
int sw = shadow_w;
comp_fbdata_t fbdata[] =
{
/* vertical item mark | */
{CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_top, thickness, h_mark_top, col_body, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_LINE, x+width-sw, y_mark_top, sw, h_mark_top, col_shadow, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_top+h_mark_top, thickness+sw, sw , col_shadow, 0, 0, NULL, NULL},
/* horizontal item line - */
{CC_FBDATA_TYPE_LINE, x, y, width-thickness-sw, thickness, col_body, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_LINE, x+thickness, y+thickness, width-2*thickness-sw, sw, col_shadow, 0, 0, NULL, NULL},
/* vertical connect line [ */
{CC_FBDATA_TYPE_LINE, x, y+thickness, thickness, y_down-y-thickness, col_body, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_LINE, x+thickness, y+thickness+sw, sw, y_down-y-thickness-sw, col_shadow, 0, 0, NULL, NULL},
/* horizontal info line - */
{CC_FBDATA_TYPE_LINE, x, y_down, width-thickness-sw, thickness, col_body, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_LINE, x, y_down+thickness, width-thickness-sw, sw, col_shadow, 0, 0, NULL, NULL},
/* vertical info mark | */
{CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_down, thickness, h_mark_down, col_body, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_LINE, x+width-sw, y_mark_down, sw, h_mark_down, col_shadow, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_down+h_mark_down,thickness+sw, sw, col_shadow, 0, 0, NULL, NULL},
};
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++)
v_fbdata.push_back(fbdata[i]);
paintFbItems(do_save_bg);
}
//remove painted fb items from screen
void CComponentsDetailLine::kill()
{
//save current colors
fb_pixel_t c_tmp1, c_tmp2;
c_tmp1 = col_body;
c_tmp2 = col_shadow;
//set background color
col_body = col_shadow = COL_BACKGROUND;
//paint with background and restore, set last used colors
paint(CC_SAVE_SCREEN_NO);
col_body = c_tmp1;
col_shadow = c_tmp2;
firstPaint = true;
}
//synchronize colors for details line
//This is usefull if the system colors are changed during runtime
//so you can ensure correct applied system colors in relevant objects with unchanged instances.
void CComponentsDetailLine::syncSysColors()
{
col_body = COL_MENUCONTENT_PLUS_6;
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
}

View File

@@ -0,0 +1,296 @@
/*
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
Library 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.h"
using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsForm from CComponentsItem
CComponentsForm::CComponentsForm()
{
//CComponentsForm
initVarForm();
}
CComponentsForm::CComponentsForm(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsForm
initVarForm();
//CComponents
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;
}
CComponentsForm::~CComponentsForm()
{
cleanCCForm();
}
void CComponentsForm::cleanCCForm()
{
#ifdef DEBUG_CC
printf("[CComponentsForm] [%s - %d] clean up...\n", __FUNCTION__, __LINE__);
#endif
// hide();
clearCCItems();
clearSavedScreen();
clear();
}
void CComponentsForm::clearCCItems()
{
if (v_cc_items.empty())
return;
#ifdef DEBUG_CC
printf(" [CComponentsForm] %s... delete %d cc-item(s) \n", __FUNCTION__, v_cc_items.size());
#endif
for(size_t i=0; i<v_cc_items.size(); i++) {
if (v_cc_items[i]){
#ifdef DEBUG_CC
printf(" [CComponentsForm] %s... delete form cc-item %d of %d (type=%d)\n", __FUNCTION__, i+1, v_cc_items.size(), v_cc_items[i]->getItemType());
#endif
delete v_cc_items[i];
v_cc_items[i] = NULL;
}
}
v_cc_items.clear();
}
void CComponentsForm::initVarForm()
{
//CComponentsItem
initVarItem();
//simple default dimensions
x = 0;
y = 0;
width = 150;
height = 150;
shadow = CC_SHADOW_OFF;
shadow_w = SHADOW_OFFSET;
col_frame = COL_MENUCONTENT_PLUS_6;
col_body = COL_MENUCONTENT_PLUS_0;
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
corner_rad = RADIUS_LARGE;
corner_type = CORNER_ALL;
//CComponentsForm
v_cc_items.clear();
}
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());
#endif
v_cc_items.push_back(cc_Item);
}
#ifdef DEBUG_CC
else
printf(" [CComponentsForm] %s-%d tried to add an empty or invalide cc_item !!!\n", __FUNCTION__, __LINE__);
#endif
}
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;
return -1;
}
CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id)
{
if (v_cc_items[cc_item_id])
return v_cc_items[cc_item_id];
return NULL;
}
void CComponentsForm::replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item)
{
if (!v_cc_items.empty()){
if (v_cc_items[cc_item_id]){
delete v_cc_items[cc_item_id];
v_cc_items[cc_item_id] = NULL;
v_cc_items[cc_item_id] = new_cc_Item;
}
}
#ifdef DEBUG_CC
else
printf("[CComponentsForm] %s replace cc_Item not possible, v_cc_items is empty\n", __FUNCTION__);
#endif
}
void CComponentsForm::replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item)
{
replaceCCItem(getCCItemId(old_cc_Item), new_cc_Item);
}
void CComponentsForm::insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item)
{
if (cc_Item == NULL){
#ifdef DEBUG_CC
printf("[CComponentsForm] %s parameter: cc_Item = %d...\n", __FUNCTION__, (int)cc_Item);
#endif
return;
}
if (v_cc_items.empty()){
v_cc_items.push_back(cc_Item);
#ifdef DEBUG_CC
printf("[CComponentsForm] %s insert cc_Item not possible, v_cc_items is empty, cc_Item added\n", __FUNCTION__);
#endif
}else
v_cc_items.insert(v_cc_items.begin()+cc_item_id, cc_Item);
}
void CComponentsForm::removeCCItem(const uint& cc_item_id)
{
if (!v_cc_items.empty()){
if (v_cc_items[cc_item_id]) {
delete v_cc_items[cc_item_id];
v_cc_items[cc_item_id] = NULL;
v_cc_items.erase(v_cc_items.begin()+cc_item_id);
}
}
#ifdef DEBUG_CC
else
printf("[CComponentsForm] %s removing cc_Item not possible, v_cc_items is empty...\n", __FUNCTION__);
#endif
}
void CComponentsForm::paintForm(bool do_save_bg)
{
//paint body
paintInit(do_save_bg);
//paint
paintCCItems();
}
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);
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);
//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
}
//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
}
//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);
}
}
void CComponentsForm::hide(bool no_restore)
{
// hack: ensure hiding of minitv during hide of forms and inherited classes,
// because the handling of minitv items are different to other item types
// and need an explizit call of hide()
for(size_t i=0; i<v_cc_items.size(); i++) {
if (v_cc_items[i]->getItemType() == CComponentsItem::CC_ITEMTYPE_PIP){
v_cc_items[i]->hide();
break;
}
}
//hide body
hideCCItem(no_restore);
}

View File

@@ -0,0 +1,322 @@
/*
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
Library 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.h"
using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsHeader inherit from CComponentsForm
CComponentsHeader::CComponentsHeader()
{
//CComponentsHeader
initVarHeader();
}
CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, const std::string& caption, const char* icon_name, const int buttons, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsHeader
initVarHeader();
x = x_pos;
y = y_pos;
width = w;
height = h > 0 ? h : g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
cch_text = caption;
cch_icon_name = icon_name;
cch_buttons = buttons;
initCCHDefaultButtons();
initCCHeaderItems();
}
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,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsHeader
initVarHeader();
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_locale_text = caption_locale;
cch_icon_name = icon_name;
cch_buttons = buttons;
initCCHDefaultButtons();
initCCHeaderItems();
}
void CComponentsHeader::initVarHeader()
{
//CComponentsForm
initVarForm();
cc_item_type = CC_ITEMTYPE_FRM_HEADER;
col_body = COL_MENUHEAD_PLUS_0;
corner_rad = RADIUS_LARGE,
corner_type = CORNER_TOP;
//init header height
cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
height = cch_font->getHeight();
//CComponentsHeader
cch_icon_obj = NULL;
cch_text_obj = NULL;
cch_icon_name = NULL;
cch_btn_obj = NULL;
cch_text = "header";
cch_locale_text = NONEXISTANT_LOCALE;
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_buttons = 0;
cch_btn_offset = 8;
v_cch_btn.clear();
}
CComponentsHeader::~CComponentsHeader()
{
#ifdef DEBUG_CC
printf("[~CComponentsHeader] [%s - %d] delete...\n", __FUNCTION__, __LINE__);
#endif
v_cch_btn.clear();
cleanCCForm();
}
void CComponentsHeader::setHeaderText(const std::string& caption)
{
cch_text = caption;
}
void CComponentsHeader::setHeaderText(neutrino_locale_t caption_locale)
{
cch_text = g_Locale->getText(caption_locale);
}
void CComponentsHeader::setHeaderIcon(const char* icon_name)
{
cch_icon_name = icon_name;
}
void CComponentsHeader::initCCHeaderIcon()
{
//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;
if (cch_icon_obj)
delete cch_icon_obj;
cch_icon_obj = NULL;
return;
}
//create instance for cch_icon_obj
if (cch_icon_obj == NULL){
#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);
//add item only one time
addCCItem(cch_icon_obj); //icon
}
//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->doPaintBg(false);
//set corner mode of icon item
cch_icon_obj->setCornerRadius(corner_rad-fr_thickness);
int cc_icon_corner_type = corner_type;
if (corner_type == CORNER_TOP_LEFT || corner_type == CORNER_TOP)
cc_icon_corner_type = CORNER_TOP_LEFT;
else
cc_icon_corner_type = CORNER_LEFT;
cch_icon_obj->setCornerType(cc_icon_corner_type);
//set width of icon object
cch_icon_w = cch_icon_obj->getWidth();
//adapt height
height = max(height, cch_icon_obj->getHeight());
}
}
void CComponentsHeader::addHeaderButton(const std::string& button_name)
{
v_cch_btn.push_back(button_name);
initCCHeaderButtons();
}
void CComponentsHeader::removeHeaderButtons()
{
v_cch_btn.clear();
cch_btn_obj->removeAllIcons();
initCCHeaderButtons();
}
void CComponentsHeader::initCCHDefaultButtons()
{
if (cch_buttons & CC_BTN_EXIT)
v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_HOME);
if (cch_buttons & CC_BTN_HELP)
v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_HELP);
if (cch_buttons & CC_BTN_INFO)
v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_INFO);
if (cch_buttons & CC_BTN_MENU)
v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_MENU);
#ifdef DEBUG_CC
printf("[CComponentsHeader] %s added %d default buttons...\n", __FUNCTION__, v_cch_btn.size());
#endif
}
void CComponentsHeader::setHeaderDefaultButtons(const int buttons)
{
cch_buttons = buttons;
v_cch_btn.clear();
initCCHDefaultButtons();
}
// calculate minimal width of icon form
void CComponentsHeader::initCCButtonFormSize()
{
ccif_width = 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);
}
}
void CComponentsHeader::initCCHeaderButtons()
{
//exit if no button defined
if (v_cch_btn.empty())
return;
initCCButtonFormSize();
if (cch_btn_obj == NULL){
cch_btn_obj = new CComponentsIconForm();
#ifdef DEBUG_CC
printf(" [CComponentsHeader]\n [%s - %d] init header buttons...\n", __FUNCTION__, __LINE__);
#endif
//add button form
addCCItem(cch_btn_obj); //buttons
}
//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->doPaintBg(false);
cch_btn_obj->setIconOffset(cch_btn_offset);
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());
}
}
void CComponentsHeader::initCCHeaderText()
{
//reset header text position first
cch_text_x = cch_icon_x+cch_icon_w;
//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());
#endif
cch_text_obj = new CComponentsText();
//add text item
addCCItem(cch_text_obj); //text
}
//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, 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());
}
}
void CComponentsHeader::initCCHeaderItems()
{
//init icon
initCCHeaderIcon();
//init text
initCCHeaderText();
//init buttons
initCCHeaderButtons();
}
void CComponentsHeader::paint(bool do_save_bg)
{
//prepare items
initCCHeaderItems();
//paint form contents
paintForm(do_save_bg);
}

View File

@@ -0,0 +1,197 @@
/*
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
Library 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.h"
using namespace std;
//sub class CComponentsIconForm inherit from CComponentsForm
CComponentsIconForm::CComponentsIconForm()
{
initVarIconForm();
}
CComponentsIconForm::CComponentsIconForm(const int x_pos, const int y_pos, const int w, const int h, const std::vector<std::string> v_icon_names, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarIconForm();
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;
v_icons = v_icon_names;
}
void CComponentsIconForm::initVarIconForm()
{
//CComponentsForm
initVarForm();
cc_item_type = CC_ITEMTYPE_FRM_ICONFORM;
//set default width and height to 0, this causes a dynamic adaptation of width and height of form
width = 0;
height = 0;
v_icons.clear();
ccif_offset = 2;
ccif_icon_align = CC_ICONS_FRM_ALIGN_LEFT;
}
void CComponentsIconForm::addIcon(const std::string& icon_name)
{
v_icons.push_back(icon_name);
}
void CComponentsIconForm::addIcon(std::vector<std::string> icon_name)
{
for (size_t i= 0; i< icon_name.size(); i++)
v_icons.push_back(icon_name[i]);
}
void CComponentsIconForm::insertIcon(const uint& icon_id, const std::string& icon_name)
{
v_icons.insert(v_icons.begin()+icon_id, icon_name);
}
void CComponentsIconForm::removeIcon(const uint& icon_id)
{
v_icons.erase(v_icons.begin()+icon_id);
}
void CComponentsIconForm::removeIcon(const std::string& icon_name)
{
int id = getIconId(icon_name);
removeIcon(id);
}
int CComponentsIconForm::getIconId(const std::string& icon_name)
{
for (size_t i= 0; i< v_icons.size(); i++)
if (v_icons[i] == icon_name)
return i;
return -1;
}
//For existing instances it's recommended
//to remove old items before add new icons, otherwise icons will be appended.
void CComponentsIconForm::removeAllIcons()
{
clearCCItems();
v_icons.clear();
}
//get maximal form height depends of biggest icon height, but don't touch defined form height
void CComponentsIconForm::initMaxHeight(int *pheight)
{
for (size_t i= 0; i< v_icons.size(); i++){
int dummy, htmp;
frameBuffer->getIconSize(v_icons[i].c_str(), &dummy, &htmp);
*pheight = max(htmp, height)/*+2*fr_thickness*/;
}
}
void CComponentsIconForm::initCCIcons()
{
int ccp_y = 0;
int ccp_h = 0;
int ccp_w = 0;
//calculate start pos of first icon
int ccp_x = 0 + fr_thickness; //CC_ICONS_FRM_ALIGN_LEFT;
if (ccif_icon_align == CC_ICONS_FRM_ALIGN_RIGHT)
ccp_x += (width - fr_thickness);
//get width of first icon
frameBuffer->getIconSize(v_icons[0].c_str(), &ccp_w, &ccp_h);
//get maximal form height
int h = 0;
initMaxHeight(&h);
//set xpos of first icon with right alignment, icon must positionized on the right border reduced with icon width
if (ccif_icon_align == CC_ICONS_FRM_ALIGN_RIGHT)
ccp_x -= ccp_w;
//init and add item objects
size_t i_cnt = v_icons.size(); //icon count
for (size_t i= 0; i< i_cnt; i++){
//create new cc-picture item object
CComponentsPicture *ccp = new CComponentsPicture(ccp_x, ccp_y, ccp_w, h, v_icons[i]);
ccp->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
ccp->doPaintBg(false);
//add item to form
addCCItem(ccp);
//reset current width for next object
ccp_w = 0;
//get next icon size if available
size_t next_i = i+1;
if (next_i != i_cnt)
frameBuffer->getIconSize(v_icons[next_i].c_str(), &ccp_w, &ccp_h);
//set next icon position
int tmp_offset = ( i<i_cnt ? ccif_offset : 0 );
if (ccif_icon_align == CC_ICONS_FRM_ALIGN_LEFT)
ccp_x += (ccp->getWidth() + tmp_offset);
if (ccif_icon_align == CC_ICONS_FRM_ALIGN_RIGHT)
ccp_x -= (ccp_w + tmp_offset);
}
//calculate width and height of form
int w_tmp = 0;
int h_tmp = 0;
for (size_t i= 0; i< i_cnt; i++){
w_tmp += v_cc_items[i]->getWidth()+ccif_offset+fr_thickness;
h_tmp = max(h_tmp, v_cc_items[i]->getHeight()+2*fr_thickness);
}
width = max(w_tmp, width);
height = max(h_tmp, height);
}
void CComponentsIconForm::paint(bool do_save_bg)
{
//init and add icons
initCCIcons();
//paint form contents
paintForm(do_save_bg);
}

View File

@@ -0,0 +1,138 @@
/*
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
Library 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.h"
#include <driver/screen_max.h>
using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsWindow inherit from CComponentsForm
CComponentsWindow::CComponentsWindow()
{
initVarWindow();
}
CComponentsWindow::CComponentsWindow(const std::string& caption, const char* iconname)
{
initVarWindow();
ccw_caption = caption;
ccw_icon_name = iconname;
}
CComponentsWindow::CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname)
{
initVarWindow();
ccw_caption = g_Locale->getText(locale_caption);
ccw_icon_name = iconname;
}
CComponentsWindow::~CComponentsWindow()
{
#ifdef DEBUG_CC
printf("[~CComponentsWindow] [%s - %d] delete...\n", __FUNCTION__, __LINE__);
#endif
cleanCCForm();
}
void CComponentsWindow::initVarWindow()
{
//CComponentsForm
initVarForm();
cc_item_type = CC_ITEMTYPE_FRM_WINDOW;
//using current screen settings for default dimensions
width = frameBuffer->getScreenWidth();
height = frameBuffer->getScreenHeight();
x=getScreenStartX(width);
y=getScreenStartY(height);
ccw_head = NULL;
ccw_caption = "";
ccw_icon_name = NULL;
ccw_start_y = 0;
ccw_buttons = 0; //no header buttons
setShadowOnOff(true);
}
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text)
{
ccw_caption = g_Locale->getText(locale_text);
}
void CComponentsWindow::initHeader()
{
if (ccw_head == NULL){
ccw_head = new CComponentsHeader();
initHeader();
//add header item only one time
addCCItem(ccw_head);
}
//set header properties
if (ccw_head){
ccw_head->setXPos(0);
ccw_head->setYPos(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);
}
}
int CComponentsWindow::getStartY()
{
initHeader();
return ccw_start_y;
}
void CComponentsWindow::initCCWItems()
{
#ifdef DEBUG_CC
printf("[CComponentsWindow] [%s - %d] init items...\n", __FUNCTION__, __LINE__);
#endif
initHeader();
}
void CComponentsWindow::paint(bool do_save_bg)
{
//prepare items before paint
initCCWItems();
//paint form contents
paintForm(do_save_bg);
}

View File

@@ -0,0 +1,153 @@
/*
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
Library 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.h"
using namespace std;
//abstract sub class CComponentsItem from CComponents
CComponentsItem::CComponentsItem()
{
//CComponentsItem
initVarItem();
cc_item_type = CC_ITEMTYPE_BASE;
}
// y
// x+------f-r-a-m-e-------+
// | |
// height body |
// | |
// +--------width---------+
void CComponentsItem::initVarItem()
{
//CComponents
initVarBasic();
cc_item_index = CC_NO_INDEX;
}
// Paint container background in cc-items with shadow, background and frame.
// This member must be called first in all paint() members before paint other items into the container.
// If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this!
void CComponentsItem::paintInit(bool do_save_bg)
{
clear();
if(!paint_bg)
return;
int sw = shadow ? shadow_w : 0;
int th = fr_thickness;
comp_fbdata_t fbdata[] =
{
{CC_FBDATA_TYPE_BGSCREEN, x, y, width+sw, height+sw, 0, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_SHADOW, x+sw, y+sw, width, height, col_shadow, corner_rad, 0, NULL, NULL},
{CC_FBDATA_TYPE_FRAME, x, y, width, height, col_frame, corner_rad, th, NULL, NULL},
{CC_FBDATA_TYPE_BOX, x+th, y+th, width-2*th, height-2*th, col_body, corner_rad-th, 0, NULL, NULL},
};
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++)
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
paintFbItems(do_save_bg);
}
//restore last saved screen behind form box,
//Do use parameter 'no restore' to override temporarly the restore funtionality.
//This could help to avoid ugly flicker efffects if it is necessary e.g. on often repaints, without changed contents.
void CComponentsItem::hideCCItem(bool no_restore)
{
is_painted = false;
if (saved_screen.pixbuf) {
frameBuffer->RestoreScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy, saved_screen.pixbuf);
if (no_restore) {
delete[] saved_screen.pixbuf;
saved_screen.pixbuf = NULL;
firstPaint = true;
}
}
}
void CComponentsItem::hide(bool no_restore)
{
hideCCItem(no_restore);
}
//hide rendered objects
void CComponentsItem::kill()
{
//save current colors
fb_pixel_t c_tmp1, c_tmp2, c_tmp3;
c_tmp1 = col_body;
c_tmp2 = col_shadow;
c_tmp3 = col_frame;
//set background color
col_body = col_frame = col_shadow = COL_BACKGROUND;
//paint with background and restore last used colors
paint(CC_SAVE_SCREEN_NO);
col_body = c_tmp1;
col_shadow = c_tmp2;
col_frame = c_tmp3;
firstPaint = true;
is_painted = false;
}
//synchronize colors for forms
//This is usefull if the system colors are changed during runtime
//so you can ensure correct applied system colors in relevant objects with unchanged instances.
void CComponentsItem::syncSysColors()
{
col_body = COL_MENUCONTENT_PLUS_0;
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
col_frame = COL_MENUCONTENT_PLUS_6;
}
//returns current item element type, if no available, return -1 as unknown type
int CComponentsItem::getItemType()
{
for(int i =0; i< (CC_ITEMTYPES) ;i++){
if (i == cc_item_type)
return i;
}
#ifdef DEBUG_CC
printf("[CComponentsItem] %s: unknown item type requested...\n", __FUNCTION__);
#endif
return -1;
}

View File

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

View File

@@ -0,0 +1,133 @@
/*
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
Library 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.h"
using namespace std;
//sub class CComponentsInfoBox from CComponentsItem
CComponentsInfoBox::CComponentsInfoBox()
{
//CComponentsInfoBox
initVarInfobox();
}
CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h,
const char* info_text, const int mode, Font* font_text,
bool has_shadow,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsInfoBox
initVarInfobox();
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;
ct_text = info_text;
ct_text_mode = mode;
ct_font = font_text;
ct_col_text = color_text;
}
CComponentsInfoBox::~CComponentsInfoBox()
{
hide();
clearSavedScreen();
clearCCText();
delete pic;
delete cctext;
clear();
}
void CComponentsInfoBox::initVarInfobox()
{
//CComponents, CComponentsItem, CComponentsText
initVarText();
cc_item_type = CC_ITEMTYPE_TEXT_INFOBOX;
//CComponentsInfoBox
pic = NULL;
cctext = NULL;
pic_name = "";
x_offset = 10;
x_text = x+fr_thickness+x_offset;;
}
void CComponentsInfoBox::paintPicture()
{
//init and set icon paint position
if (pic)
delete pic;
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness/*+y_offset*/, 0, 0, "");
//define icon
pic->setPicture(pic_name);
//fit icon into infobox
pic->setHeight(height-2*fr_thickness);
pic->setColorBody(col_body);
pic->paint(CC_SAVE_SCREEN_NO);
}
void CComponentsInfoBox::paint(bool do_save_bg)
{
paintInit(do_save_bg);
paintPicture();
//define text x position
x_text = x+fr_thickness+x_offset;
//set text to the left border if picture is not painted
if (pic->isPicPainted()){
int pic_w = pic->getWidth();
x_text += pic_w+x_offset;
}
//set text and paint text lines
if (ct_text){
if (cctext)
delete cctext;
cctext = new CComponentsText();
cctext->setText(ct_text, ct_text_mode, ct_font);
cctext->setDimensionsAll(x_text, y+fr_thickness, width-(x_text-x+x_offset+fr_thickness), height-2*fr_thickness);
cctext->paint(CC_SAVE_SCREEN_NO);
}
}

View File

@@ -0,0 +1,186 @@
/*
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
Library 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.h"
#include <unistd.h>
extern CPictureViewer * g_PicViewer;
using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsPicture from CComponentsItem
CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos, const int w, const int h,
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)
{
init(x_pos, y_pos, image_name, alignment, has_shadow, color_frame, color_background, color_shadow);
width = w;
height = h;
pic_paint_mode = CC_PIC_IMAGE_MODE_AUTO,
initVarPicture();
}
void CComponentsPicture::init( int x_pos, int y_pos, const string& image_name, const int alignment, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
{
//CComponents, CComponentsItem
initVarItem();
cc_item_type = CC_ITEMTYPE_PICTURE;
//CComponentsPicture
pic_name = image_name;
pic_align = alignment;
pic_offset = 1;
pic_paint = true;
pic_paintBg = false;
pic_painted = false;
do_paint = false;
pic_max_w = 0;
pic_max_h = 0;
if (pic_name.empty())
pic_width = pic_height = 0;
//CComponents
x = pic_x = x_pos;
y = pic_y = y_pos;
height = 0;
width = 0;
shadow = has_shadow;
shadow_w = SHADOW_OFFSET;
col_frame = color_frame;
col_body = color_background;
col_shadow = color_shadow;
}
void CComponentsPicture::setPicture(const std::string& picture_name)
{
pic_name = picture_name;
initVarPicture();
}
void CComponentsPicture::setPictureAlign(const int alignment)
{
pic_align = alignment;
initVarPicture();
}
void CComponentsPicture::initVarPicture()
{
pic_width = pic_height = 0;
pic_painted = false;
do_paint = false;
if (pic_max_w == 0)
pic_max_w = width-2*fr_thickness;
if (pic_max_h == 0)
pic_max_h = height-2*fr_thickness;
//set the image mode depends of name syntax, icon names contains no path,
//so we can detect the required image mode
if (pic_paint_mode == CC_PIC_IMAGE_MODE_AUTO){
if (!access(pic_name.c_str(), F_OK ))
pic_paint_mode = CC_PIC_IMAGE_MODE_ON;
else
pic_paint_mode = CC_PIC_IMAGE_MODE_OFF;
}
if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF){
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
#if 0
pic_width = max(pic_width, pic_max_w);
pic_height = max(pic_height, pic_max_h);
#endif
}
if (pic_paint_mode == CC_PIC_IMAGE_MODE_ON) {
g_PicViewer->getSize(pic_name.c_str(), &pic_width, &pic_height);
if((pic_width > pic_max_w) || (pic_height > pic_max_h))
g_PicViewer->rescaleImageDimensions(&pic_width, &pic_height, pic_max_w, pic_max_h);
}
#ifdef DEBUG_CC
if (pic_width == 0 || pic_height == 0)
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;
}
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)
{
initVarPicture();
paintInit(do_save_bg);
pic_painted = false;
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;
}
}
void CComponentsPicture::hide(bool no_restore)
{
hideCCItem(no_restore);
pic_painted = false;
}

View File

@@ -0,0 +1,101 @@
/*
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
Library 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.h"
using namespace std;
//sub class CComponentsShapeSquare from CComponentsItem
CComponentsShapeSquare::CComponentsShapeSquare(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsItem
initVarItem();
cc_item_type = CC_ITEMTYPE_SHAPE_SQUARE;
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;
}
void CComponentsShapeSquare::paint(bool do_save_bg)
{
paintInit(do_save_bg);
}
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsShapeCircle from CComponentsItem
CComponentsShapeCircle::CComponentsShapeCircle( int x_pos, int y_pos, int diam, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponents, CComponentsItem
initVarItem();
cc_item_type = CC_ITEMTYPE_SHAPE_CIRCLE;
//CComponents
x = x_pos;
y = y_pos;
//width = height = d = diam;
shadow = has_shadow;
shadow_w = SHADOW_OFFSET;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
//CComponentsShapeCircle
width = height = d = diam;
//CComponentsItem
corner_rad = d/2;
}
// y
// x+ - +
//
//
//
// |----d-i-a-m----|
//
//
//
// + - +
void CComponentsShapeCircle::paint(bool do_save_bg)
{
paintInit(do_save_bg);
}

View File

@@ -0,0 +1,207 @@
/*
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
Library 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.h"
using namespace std;
//sub class CComponentsText from CComponentsItem
CComponentsText::CComponentsText()
{
//CComponentsText
initVarText();
}
CComponentsText::CComponentsText( const int x_pos, const int y_pos, const int w, const int h,
const char* text, const int mode, Font* font_text,
bool has_shadow,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsText
initVarText();
//CComponents
x = x_pos,
y = y_pos,
width = w;
height = h;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
shadow = has_shadow;
ct_font = font_text;
ct_text = text;
ct_text_mode = mode;
ct_col_text = color_text;
}
CComponentsText::~CComponentsText()
{
hide();
clearSavedScreen();
clearCCText();
clear();
}
void CComponentsText::initVarText()
{
//CComponents, CComponentsItem
initVarItem();
cc_item_type = CC_ITEMTYPE_TEXT;
//CComponentsText
ct_font = NULL;
ct_box = NULL;
ct_textbox = NULL;
ct_text = NULL;
ct_text_mode = CTextBox::AUTO_WIDTH;
ct_col_text = COL_MENUCONTENT;
ct_text_sent = false;
}
void CComponentsText::initCCText()
{
//set default font, if is no font definied
if (ct_font == NULL)
ct_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL];
//define height from font size
height = max(height, ct_font->getHeight());
//text box dimensions
if (ct_box== NULL){
//ensure that we have a new instance
delete ct_box;
ct_box = NULL;
}
ct_box = new CBox();
ct_box->iX = x+fr_thickness;
ct_box->iY = y+fr_thickness;
ct_box->iWidth = width-2*fr_thickness;
ct_box->iHeight = height-2*fr_thickness;
//init textbox
if (ct_textbox == NULL)
ct_textbox = new CTextBox();
//set text box properties
ct_textbox->setTextFont(ct_font);
ct_textbox->setTextMode(ct_text_mode);
ct_textbox->setWindowPos(ct_box);
ct_textbox->setTextBorderWidth(0);
ct_textbox->enableBackgroundPaint(false);
ct_textbox->setBackGroundColor(col_body);
ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type);
ct_textbox->setTextColor(ct_col_text);
ct_textbox->setWindowMaxDimensions(ct_box->iWidth, ct_box->iHeight);
ct_textbox->setWindowMinDimensions(ct_box->iWidth, ct_box->iHeight);
//set text
string new_text = static_cast <string> (ct_text);
ct_text_sent = ct_textbox->setText(&new_text, ct_box->iWidth);
#ifdef DEBUG_CC
printf(" [CComponentsText] [%s - %d] init text: %s [x %d, y %d, h %d, w %d]\n", __FUNCTION__, __LINE__, ct_text, ct_box->iX, ct_box->iY, height, width);
#endif
}
void CComponentsText::clearCCText()
{
if (ct_box)
delete ct_box;
ct_box = NULL;
if (ct_textbox)
delete ct_textbox;
ct_textbox = NULL;
}
void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text)
{
ct_text = g_Locale->getText(locale_text);
ct_text_mode = mode;
ct_font = font_text;
}
void CComponentsText::setText(const char* ctext, const int mode, Font* font_text)
{
ct_text = ctext;
ct_text_mode = mode;
ct_font = font_text;
}
void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text)
{
ct_text = stext.c_str();
ct_text_mode = mode;
ct_font = font_text;
}
void CComponentsText::paintText(bool do_save_bg)
{
paintInit(do_save_bg);
initCCText();
if (ct_text_sent)
ct_textbox->paint();
ct_text_sent = false;
}
void CComponentsText::paint(bool do_save_bg)
{
paintText(do_save_bg);
}
void CComponentsText::hide(bool no_restore)
{
if (ct_textbox)
ct_textbox->hide();
hideCCItem(no_restore);
}
//small helper to remove excessiv linbreaks
void CComponentsText::removeLineBreaks(std::string& str)
{
std::string::size_type spos = str.find_first_of("\r\n");
while (spos != std::string::npos) {
str.replace(spos, 1, " ");
spos = str.find_first_of("\r\n");
}
}

View File

@@ -0,0 +1,99 @@
/*
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
Library 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.h"
#include <video.h>
extern cVideo * videoDecoder;
using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsPIP from CComponentsItem
CComponentsPIP::CComponentsPIP( const int x_pos, const int y_pos, const int percent, bool has_shadow)
{
//CComponents, CComponentsItem
initVarItem();
cc_item_type = CC_ITEMTYPE_PIP;
//CComponentsPIP
screen_w = frameBuffer->getScreenWidth(true);
screen_h = frameBuffer->getScreenHeight(true);
pic_name = DATADIR;
pic_name += "/neutrino/icons/start.jpg";
//CComponents
x = x_pos;
y = y_pos;
width = percent*screen_w/100;
height = percent*screen_h/100;
shadow = has_shadow;
shadow_w = SHADOW_OFFSET;
col_frame = COL_BACKGROUND;
col_body = COL_BACKGROUND;
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
}
CComponentsPIP::~CComponentsPIP()
{
hide();
videoDecoder->Pig(-1, -1, -1, -1);
clearSavedScreen();
clear();
}
void CComponentsPIP::paint(bool do_save_bg)
{
int pig_x = x+fr_thickness;
int pig_y = y+fr_thickness;
int pig_w = width-2*fr_thickness;
int pig_h = height-2*fr_thickness;
paintInit(do_save_bg);
if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_tv){
videoDecoder->Pig(pig_x+2, pig_y, pig_w, pig_h, screen_w, screen_h);
}
else{ //paint an alternate image if no tv mode available
CComponentsPicture pic = CComponentsPicture (pig_x, pig_y, pig_w, pig_h, pic_name, CC_ALIGN_LEFT);
pic.paint(CC_SAVE_SCREEN_NO);
}
}
void CComponentsPIP::hide(bool no_restore)
{
videoDecoder->Pig(-1, -1, -1, -1);
hideCCItem(no_restore);
}

View File

@@ -0,0 +1,113 @@
/*
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
Library 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_TYPES__
#define __CC_TYPES__
#include <driver/framebuffer.h>
#include <system/localize.h>
//required typedefs
typedef struct comp_fbdata_t
{
int fbdata_type;
int x;
int y;
int dx;
int dy;
fb_pixel_t color;
int r;
int frame_thickness;
fb_pixel_t* pixbuf;
void * data;
} comp_fbdata_struct_t;
//fb data object types
typedef enum
{
CC_FBDATA_TYPE_BGSCREEN,
CC_FBDATA_TYPE_SHADOW,
CC_FBDATA_TYPE_BOX,
CC_FBDATA_TYPE_FRAME,
CC_FBDATA_TYPE_LINE,
CC_FBDATA_TYPE_BACKGROUND,
CC_FBDATA_TYPES
}FBDATA_TYPES;
typedef struct comp_screen_data_t
{
int x;
int y;
int dx;
int dy;
fb_pixel_t* pixbuf;
} comp_screen_data_struct_t;
//align types
enum
{
CC_ALIGN_RIGHT = 0,
CC_ALIGN_LEFT = 1,
CC_ALIGN_TOP = 2,
CC_ALIGN_BOTTOM = 4,
CC_ALIGN_HOR_CENTER = 8,
CC_ALIGN_VER_CENTER = 16
};
enum
{
CC_ITEMBOX_ICON,
CC_ITEMBOX_PICTURE,
CC_ITEMBOX_TEXT,
CC_ITEMBOX_CLOCK
};
typedef struct comp_element_data_t
{
int type;
int align;
std::string element;
int x;
int y;
int width;
int height;
void* handler1;
void* handler2;
}comp_element_data_struct_t;
#define CC_WIDTH_MIN 16
#define CC_HEIGHT_MIN 16
#define CC_SHADOW_ON true
#define CC_SHADOW_OFF false
#define CC_SAVE_SCREEN_YES true
#define CC_SAVE_SCREEN_NO false
#define CC_NO_INDEX -1
#endif

View File

@@ -1,283 +0,0 @@
/*
Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic for GUI-related components.
Copyright (C) 2012, 2013, Thilo Graf 'dbt'
Copyright (C) 2012, Michael Liebmann 'micha-bbg'
License: GPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; 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.h"
//basic class CComponents
CComponents::CComponents(const int x_pos, const int y_pos, const int h, const int w)
{
x = x_pos;
y = y_pos;
height = h;
width = w;
sw = 0; //shadow width
frameBuffer = CFrameBuffer::getInstance();
v_screen_val.clear();
}
CComponents::~CComponents()
{
clear();
}
//paint framebuffer stuff and fill buffer
void CComponents::paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg)
{
int i;
for(i=0; i< items_count ;i++){
if (do_save_bg)
fbdata[i].pixbuf = saveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy);
v_screen_val.push_back(fbdata[i]);
}
for(i=0; i< items_count ;i++){
if (fbdata[i].is_frame)
frameBuffer->paintBoxFrame(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].frame_thickness, fbdata[i].color, fbdata[i].r);
else
frameBuffer->paintBoxRel(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].color, fbdata[i].r);
}
}
//screen area save
inline fb_pixel_t* CComponents::saveScreen(int ax, int ay, int dx, int dy)
{
fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy];
frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf);
return pixbuf;
}
//restore screen
inline void CComponents::restore()
{
for(size_t i =0; i< v_screen_val.size() ;i++) {
if (v_screen_val[i].pixbuf != NULL){
frameBuffer->RestoreScreen(v_screen_val[i].x, v_screen_val[i].y, v_screen_val[i].dx, v_screen_val[i].dy, v_screen_val[i].pixbuf);
delete[] v_screen_val[i].pixbuf;
}
}
v_screen_val.clear();
}
//clean old screen buffer
inline void CComponents::clear()
{
for(size_t i =0; i< v_screen_val.size() ;i++)
if (v_screen_val[i].pixbuf != NULL)
delete[] v_screen_val[i].pixbuf;
v_screen_val.clear();
}
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsDetailLine
CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_top, const int y_pos_down, const int h_mark_top_, const int h_mark_down_, fb_pixel_t color_line, fb_pixel_t color_shadow)
{
x = x_pos;
width = 16;
thickness = 4;
sw = 1; //shadow width
y = y_pos_top;
y_down = y_pos_down;
h_mark_top = h_mark_top_;
h_mark_down = h_mark_down_;
col_line = color_line;
col_shadow = color_shadow;
}
CComponentsDetailLine::~CComponentsDetailLine()
{
clear();
}
// y_top (=y)
// xpos +--|h_mark_up
// |
// |
// |
// |
// |
// |
// |
// |
// |
// +--|h_mark_down
// y_down
#define DLINE_ITEMS_COUNT 12
//paint details line with current parameters
void CComponentsDetailLine::paint(bool do_save_bg)
{
clear();
int y_mark_top = y-h_mark_top/2+thickness/2;
int y_mark_down = y_down-h_mark_down/2+thickness/2;
comp_fbdata_t fbdata[DLINE_ITEMS_COUNT] =
{
/* vertical item mark | */
{x+width-thickness-sw, y_mark_top, thickness, h_mark_top, col_line, 0, NULL, NULL, false, 0},
{x+width-sw, y_mark_top, sw, h_mark_top, col_shadow, 0, NULL, NULL, false, 0},
{x+width-thickness-sw, y_mark_top+h_mark_top, thickness+sw, sw , col_shadow, 0, NULL, NULL, false, 0},
/* horizontal item line - */
{x, y, width-thickness-sw, thickness, col_line, 0, NULL, NULL, false, 0},
{x+thickness, y+thickness, width-2*thickness-sw, sw, col_shadow, 0, NULL, NULL, false, 0},
/* vertical connect line [ */
{x, y+thickness, thickness, y_down-y-thickness, col_line, 0, NULL, NULL, false, 0},
{x+thickness, y+thickness+sw, sw, y_down-y-thickness-sw, col_shadow, 0, NULL, NULL, false, 0},
/* horizontal info line - */
{x, y_down, width-thickness-sw, thickness, col_line, 0, NULL, NULL, false, 0},
{x, y_down+thickness, width-thickness-sw, sw, col_shadow, 0, NULL, NULL, false, 0},
/* vertical info mark | */
{x+width-thickness-sw, y_mark_down, thickness, h_mark_down, col_line, 0, NULL, NULL, false, 0},
{x+width-sw, y_mark_down, sw, h_mark_down, col_shadow, 0, NULL, NULL, false, 0},
{x+width-thickness-sw, y_mark_down+h_mark_down,thickness+sw, sw, col_shadow, 0, NULL, NULL, false, 0},
};
paintFbItems(fbdata, DLINE_ITEMS_COUNT, do_save_bg);
}
//remove painted lines from screen
void CComponentsDetailLine::hide()
{
//caching current colors
fb_pixel_t c_tmp1, c_tmp2;
c_tmp1 = col_line;
c_tmp2 = col_shadow;
//set background color
col_line = col_shadow = COL_BACKGROUND;
//paint with background and restore, set last used colors
paint(false);
col_line = c_tmp1;
col_shadow = c_tmp2;
}
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsInfoBox
CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
x = x_pos;
y = y_pos;
width = w;
height = h;
rad = 0;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
fr_thickness = 2;
firstPaint = true;
v_infobox_val.clear();
}
#define INFOBOX_ITEMS_COUNT 3
void CComponentsInfoBox::paint(bool do_save_bg, bool fullPaint)
{
clear();
rad = RADIUS_LARGE;
comp_fbdata_t fbdata[INFOBOX_ITEMS_COUNT] =
{
{x+SHADOW_OFFSET, y+SHADOW_OFFSET, width, height, col_shadow, rad, NULL, NULL, false, 0},
{x, y, width, height, col_frame, rad, NULL, NULL, false, 0},
{x+fr_thickness, y+fr_thickness, width-2*fr_thickness, height-2*fr_thickness, col_body, rad, NULL, NULL, false, 0},
};
int start = (shadow) ? 0 : 1;
if (firstPaint) {
if (do_save_bg) {
v_infobox_val.clear();
for(int i = start; i < INFOBOX_ITEMS_COUNT; i++) {
fbdata[i].pixbuf = saveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy);
v_infobox_val.push_back(fbdata[i]);
fbdata[i].pixbuf = NULL;
}
}
// paint infobox full
paintFbItems((comp_fbdata_t*)&fbdata[start], INFOBOX_ITEMS_COUNT - start, false);
firstPaint = false;
}
else {
if (fullPaint)
// paint infobox full
paintFbItems((comp_fbdata_t*)&fbdata[start], INFOBOX_ITEMS_COUNT - start, false);
else
// paint body only
paintFbItems((comp_fbdata_t*)&fbdata[INFOBOX_ITEMS_COUNT - 1], 1, false);
}
}
//restore infobox
void CComponentsInfoBox::restore(bool clear_)
{
if (!v_infobox_val.empty()) {
for(size_t i =0; i< v_infobox_val.size() ;i++) {
if (v_infobox_val[i].pixbuf != NULL) {
frameBuffer->RestoreScreen(v_infobox_val[i].x, v_infobox_val[i].y, v_infobox_val[i].dx, v_infobox_val[i].dy, v_infobox_val[i].pixbuf);
if (clear_)
delete[] v_infobox_val[i].pixbuf;
}
}
if (clear_) {
v_infobox_val.clear();
firstPaint = true;
}
}
}
void CComponentsInfoBox::hide()
{
//caching current colors
fb_pixel_t c_tmp1, c_tmp2, c_tmp3;
c_tmp1 = col_body;
c_tmp2 = col_shadow;
c_tmp3 = col_frame;
//set background color
col_body = col_frame = col_shadow = COL_BACKGROUND;
//paint with background and restore, set last used colors
paint(false, true);
col_body = c_tmp1;
col_shadow = c_tmp2;
col_frame = c_tmp3;
}