mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-01 09:51:22 +02:00
Merge remote-tracking branch 'check/next-cc'
needs some build-fixing and merge errors are likely :-( Conflicts: configure.ac data/icons/start.jpg data/locale/deutsch.locale data/locale/unmaintained/dutch.locale lib/libdvbsub/Makefile.am lib/libdvbsub/dvbsubtitle.cpp lib/libtuxtxt/Makefile.am src/Makefile.am src/daemonc/Makefile.am src/driver/audiodec/Makefile.am src/driver/framebuffer.cpp src/driver/framebuffer.h src/driver/pictureviewer/Makefile.am src/driver/rcinput.cpp src/driver/streamts.cpp src/driver/volume.cpp src/eitd/Makefile.am src/gui/Makefile.am src/gui/audioplayer.cpp src/gui/bedit/Makefile.am src/gui/bedit/bouqueteditor_chanselect.cpp src/gui/bouquetlist.cpp src/gui/channellist.cpp src/gui/components/Makefile.am src/gui/epgview.cpp src/gui/eventlist.cpp src/gui/infoviewer.cpp src/gui/infoviewer_bb.cpp src/gui/keybind_setup.cpp src/gui/moviebrowser.cpp src/gui/movieplayer.cpp src/gui/scan.cpp src/gui/scan_setup.cpp src/gui/test_menu.cpp src/gui/test_menu.h src/gui/update.cpp src/gui/videosettings.cpp src/gui/widget/Makefile.am src/gui/widget/buttons.cpp src/gui/widget/stringinput.cpp src/neutrino.cpp src/nhttpd/tuxboxapi/coolstream/Makefile.am src/system/Makefile.am src/system/setting_helpers.cpp src/system/settings.h src/zapit/include/zapit/client/zapitclient.h src/zapit/include/zapit/femanager.h src/zapit/include/zapit/getservices.h src/zapit/lib/zapitclient.cpp src/zapit/src/Makefile.am src/zapit/src/capmt.cpp src/zapit/src/femanager.cpp src/zapit/src/frontend.cpp src/zapit/src/getservices.cpp
This commit is contained in:
@@ -12,8 +12,13 @@ INCLUDES = \
|
||||
@FREETYPE_CFLAGS@
|
||||
|
||||
if BOXTYPE_COOL
|
||||
if BOXMODEL_APOLLO
|
||||
INCLUDES += -I$(top_srcdir)/lib/libcoolstream2
|
||||
else
|
||||
INCLUDES += -I$(top_srcdir)/lib/libcoolstream
|
||||
endif
|
||||
endif
|
||||
|
||||
if USE_STB_HAL
|
||||
INCLUDES += -I$(STB_HAL_INC)
|
||||
endif
|
||||
@@ -24,6 +29,7 @@ noinst_LIBRARIES = libneutrino_gui_components.a
|
||||
libneutrino_gui_components_a_SOURCES = \
|
||||
cc_base.cpp \
|
||||
cc_detailsline.cpp \
|
||||
cc_frm_button.cpp \
|
||||
cc_frm.cpp \
|
||||
cc_frm_header.cpp \
|
||||
cc_frm_icons.cpp \
|
||||
|
@@ -15,7 +15,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -32,20 +32,21 @@
|
||||
#include <string>
|
||||
#include <driver/pictureviewer/pictureviewer.h>
|
||||
|
||||
// #define DEBUG_CC
|
||||
//#define DEBUG_CC
|
||||
|
||||
class CComponents
|
||||
{
|
||||
private:
|
||||
bool allowPaint(const int& i);
|
||||
protected:
|
||||
int x, y, height, width, corner_type, shadow_w;
|
||||
int corner_rad, fr_thickness;
|
||||
int corner_rad, fr_thickness, fr_thickness_sel;
|
||||
CFrameBuffer * frameBuffer;
|
||||
std::vector<comp_fbdata_t> v_fbdata;
|
||||
fb_pixel_t col_body, col_shadow, col_frame;
|
||||
fb_pixel_t col_body, col_shadow, col_frame, col_frame_sel;
|
||||
bool firstPaint, shadow, is_painted, paint_bg;
|
||||
|
||||
void initVarBasic();
|
||||
bool allowPaint(int i);
|
||||
void paintFbItems(bool do_save_bg = true);
|
||||
virtual fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
|
||||
comp_screen_data_t saved_screen;
|
||||
@@ -58,6 +59,7 @@ class CComponents
|
||||
|
||||
inline virtual void setXPos(const int& xpos){x = xpos;};
|
||||
inline virtual void setYPos(const int& ypos){y = ypos;};
|
||||
inline virtual void setPos(const int& xpos, const int& ypos){x = xpos; y = ypos;};
|
||||
inline virtual void setHeight(const int& h){height = h;};
|
||||
inline virtual void setWidth(const int& w){width = w;};
|
||||
inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;};
|
||||
@@ -66,31 +68,38 @@ class CComponents
|
||||
inline virtual int getYPos(){return y;};
|
||||
inline virtual int getHeight(){return height;};
|
||||
inline virtual int getWidth(){return width;};
|
||||
inline virtual void getSize(int* w, int* h){*w=width; *h=height;};
|
||||
inline virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;};
|
||||
|
||||
/// set colors: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
|
||||
///set 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
|
||||
///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).
|
||||
///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:
|
||||
///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;};
|
||||
|
||||
|
||||
///hide current screen and restore background
|
||||
virtual void hide();
|
||||
///erase current screen without restore of background, as similar to paintBackgroundBoxRel() from CFrameBuffer
|
||||
virtual void kill();
|
||||
///returns paint mode, true=item was painted
|
||||
virtual bool isPainted(){return is_painted;}
|
||||
///allows paint of elemetary item parts (shadow, frame and body), similar as background, set it usually to false, if item used in a form
|
||||
virtual void doPaintBg(bool do_paint){paint_bg = do_paint;};
|
||||
|
||||
};
|
||||
|
||||
class CComponentsItem : public CComponents
|
||||
@@ -98,6 +107,14 @@ class CComponentsItem : public CComponents
|
||||
protected:
|
||||
int cc_item_type;
|
||||
int cc_item_index;
|
||||
bool cc_item_enabled, cc_item_selected;
|
||||
|
||||
///Pointer to the form object in which this item is embedded.
|
||||
///Is typically the type CComponentsForm or derived classes, default intialized with NULL
|
||||
CComponents *cc_parent;
|
||||
|
||||
///contains real position and dimensions on screen,
|
||||
int cc_item_xr, cc_item_yr;
|
||||
|
||||
void hideCCItem(bool no_restore = false);
|
||||
void paintInit(bool do_save_bg);
|
||||
@@ -105,17 +122,33 @@ class CComponentsItem : public CComponents
|
||||
|
||||
public:
|
||||
CComponentsItem();
|
||||
|
||||
///sets pointer to the form object in which this item is embedded.
|
||||
virtual void setParent(CComponents *parent){cc_parent = parent;};
|
||||
|
||||
///sets real position on screen. Use this, if item contains own render methods and item is added to a form
|
||||
virtual void setRealPos(const int& xr, const int& yr){cc_item_xr = xr; cc_item_yr = yr;};
|
||||
virtual int getRealXPos(){return cc_item_xr;};
|
||||
virtual int getRealYPos(){return cc_item_yr;};
|
||||
|
||||
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();
|
||||
|
||||
///setters for item select stats
|
||||
virtual void setSelected(bool selected){cc_item_selected = selected;};
|
||||
virtual void setEnable(bool enabled){cc_item_enabled = enabled;};
|
||||
///getters for item enable stats
|
||||
virtual bool isSelected(){return cc_item_selected;};
|
||||
virtual bool isEnabled(){return cc_item_enabled;};
|
||||
};
|
||||
|
||||
class CComponentsPicture : public CComponentsItem
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
void initVarPicture();
|
||||
|
||||
enum
|
||||
{
|
||||
CC_PIC_IMAGE_MODE_OFF = 0, //paint pictures in icon mode, mainly not scaled
|
||||
@@ -129,7 +162,6 @@ class CComponentsPicture : public CComponentsItem
|
||||
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);
|
||||
|
||||
@@ -138,18 +170,18 @@ class CComponentsPicture : public CComponentsItem
|
||||
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);
|
||||
virtual inline void setPictureOffset(const unsigned char offset){pic_offset = offset;};
|
||||
virtual inline void setPicturePaint(bool paint_p){pic_paint = paint_p;};
|
||||
virtual inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;};
|
||||
virtual void setPicture(const std::string& picture_name);
|
||||
virtual void setPictureAlign(const int alignment);
|
||||
|
||||
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;};
|
||||
virtual inline bool isPicPainted(){return pic_painted;};
|
||||
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
virtual void hide(bool no_restore = false);
|
||||
virtual inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;};
|
||||
virtual void setMaxWidth(const int w_max){pic_max_w = w_max;};
|
||||
virtual void setMaxHeight(const int h_max){pic_max_h = h_max;};
|
||||
};
|
||||
|
||||
class CComponentsText : public CComponentsItem
|
||||
@@ -161,8 +193,10 @@ class CComponentsText : public CComponentsItem
|
||||
|
||||
fb_pixel_t ct_col_text;
|
||||
int ct_text_mode; //see textbox.h for possible modes
|
||||
const char* ct_text;
|
||||
bool ct_text_sent, ct_paint_textbg;
|
||||
std::string ct_text, ct_old_text;
|
||||
bool ct_text_sent, ct_paint_textbg, ct_force_text_paint;
|
||||
|
||||
static std::string iToString(int int_val); //helper to convert int to string
|
||||
|
||||
void initVarText();
|
||||
void clearCCText();
|
||||
@@ -171,32 +205,51 @@ class CComponentsText : public CComponentsItem
|
||||
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,
|
||||
std::string text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
|
||||
bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_text = COL_MENUCONTENT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||
virtual ~CComponentsText();
|
||||
|
||||
void hide(bool no_restore = false);
|
||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
|
||||
//default members to paint a text box and hide painted text
|
||||
//hide textbox
|
||||
void hide(bool no_restore = false);
|
||||
//paint text box, parameter do_save_bg: default = true, causes fill of backckrond pixel buffer
|
||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
|
||||
//send options for text font (size and type), color and mode (allignment)
|
||||
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
|
||||
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
|
||||
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};//see textbox.h for possible modes
|
||||
virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;};
|
||||
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);
|
||||
//see textbox.h for possible allignment modes
|
||||
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};
|
||||
|
||||
//get a Text Box object, so it's possible to get access directly to its methods
|
||||
CTextBox* getCTextBoxObject() { return ct_textbox; };
|
||||
//send option to CTextBox object to paint background box behind text or not
|
||||
virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;};
|
||||
|
||||
//sets text mainly with string also possible with overloades members for loacales, const char and text file
|
||||
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||
|
||||
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||
virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||
virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||
|
||||
//helper to remove linebreak chars from a string if needed
|
||||
virtual void removeLineBreaks(std::string& str);
|
||||
|
||||
//returns true, if text was changed
|
||||
virtual bool textChanged(){return ct_old_text != ct_text;};
|
||||
//force paint of text even if text was changed or not
|
||||
virtual void forceTextPaint(bool force_text_paint = true){ct_force_text_paint = force_text_paint;};
|
||||
|
||||
//gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties
|
||||
virtual CTextBox* getCTextBoxObject() { return ct_textbox; };
|
||||
};
|
||||
|
||||
class CComponentsLabel : public CComponentsText
|
||||
{
|
||||
public:
|
||||
CComponentsLabel( const int x_pos, const int y_pos, const int w, const int h,
|
||||
const char* text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
|
||||
std::string text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
|
||||
bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_text = COL_MENUCONTENTINACTIVE, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
|
||||
:CComponentsText(x_pos, y_pos, w, h, text, mode, font_text, has_shadow, color_text, color_frame, color_body, color_shadow)
|
||||
@@ -228,7 +281,7 @@ class CComponentsInfoBox : public CComponentsText
|
||||
|
||||
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,
|
||||
std::string info_text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
|
||||
bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_text = COL_MENUCONTENT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||
|
||||
@@ -295,7 +348,6 @@ class CComponentsDetailLine : public CComponents
|
||||
~CComponentsDetailLine();
|
||||
|
||||
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;};
|
||||
@@ -303,240 +355,4 @@ class CComponentsDetailLine : public CComponents
|
||||
inline void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
|
||||
};
|
||||
|
||||
#define FIRST_ELEMENT_INIT 10000
|
||||
#define LOGO_MAX_WIDTH width/4
|
||||
class CComponentsItemBox : public CComponentsItem
|
||||
{
|
||||
protected:
|
||||
int hSpacer;
|
||||
int hOffset;
|
||||
int vOffset;
|
||||
int digit_offset, digit_h;
|
||||
bool paintElements;
|
||||
bool onlyOneTextElement;
|
||||
fb_pixel_t it_col_text;
|
||||
Font* font_text;
|
||||
int hMax;
|
||||
bool has_TextElement;
|
||||
size_t firstElementLeft;
|
||||
size_t firstElementRight;
|
||||
size_t prevElementLeft;
|
||||
size_t prevElementRight;
|
||||
std::vector<comp_element_data_t> v_element_data;
|
||||
bool isCalculated;
|
||||
|
||||
void clearElements();
|
||||
void initVarItemBox();
|
||||
void calSizeOfElements();
|
||||
void calPositionOfElements();
|
||||
void paintItemBox(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
void calculateElements();
|
||||
bool addElement(int align, int type, const std::string& element="", size_t *index=NULL);
|
||||
void paintImage(size_t index, bool newElement);
|
||||
void paintText(size_t index, bool newElement);
|
||||
|
||||
public:
|
||||
CComponentsItemBox();
|
||||
virtual ~CComponentsItemBox();
|
||||
|
||||
inline virtual void setTextFont(Font* font){font_text = font;};
|
||||
inline virtual void setTextColor(fb_pixel_t color_text){ it_col_text = color_text;};
|
||||
|
||||
virtual void refreshElement(size_t index, const std::string& element);
|
||||
virtual void paintElement(size_t index, bool newElement= false);
|
||||
virtual bool addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index=NULL);
|
||||
virtual void clearTitlebar();
|
||||
virtual void addText(const std::string& s_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
|
||||
virtual void addText(neutrino_locale_t locale_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
|
||||
virtual void addIcon(const std::string& s_icon_name, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
|
||||
virtual void addPicture(const std::string& s_picture_path, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
|
||||
virtual void addClock(const int align=CC_ALIGN_RIGHT, size_t *index=NULL);
|
||||
virtual int getHeight();
|
||||
};
|
||||
|
||||
class CComponentsTitleBar : public CComponentsItemBox
|
||||
{
|
||||
private:
|
||||
const char* tb_c_text;
|
||||
std::string tb_s_text, tb_icon_name;
|
||||
neutrino_locale_t tb_locale_text;
|
||||
int tb_text_align, tb_icon_align;
|
||||
|
||||
void initText();
|
||||
void initIcon();
|
||||
void initElements();
|
||||
void initVarTitleBar();
|
||||
|
||||
public:
|
||||
CComponentsTitleBar();
|
||||
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const char* c_text = NULL, const std::string& s_icon ="",
|
||||
fb_pixel_t color_text = COL_MENUHEAD, 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
|
||||
|
@@ -16,7 +16,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -64,11 +64,13 @@ void CComponents::initVarBasic()
|
||||
col_body = COL_MENUCONTENT_PLUS_0;
|
||||
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
|
||||
col_frame = COL_MENUCONTENT_PLUS_6;
|
||||
col_frame_sel = COL_MENUCONTENTSELECTED_PLUS_0;
|
||||
corner_type = CORNER_ALL;
|
||||
corner_rad = 0;
|
||||
shadow = CC_SHADOW_OFF;
|
||||
shadow_w = SHADOW_OFFSET;
|
||||
fr_thickness = 0;
|
||||
fr_thickness_sel = 3;
|
||||
|
||||
firstPaint = true;
|
||||
is_painted = false;
|
||||
@@ -78,7 +80,7 @@ void CComponents::initVarBasic()
|
||||
saved_screen.pixbuf = NULL;
|
||||
}
|
||||
|
||||
bool CComponents::allowPaint(int i)
|
||||
bool CComponents::allowPaint(const int& i)
|
||||
{
|
||||
if(v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BOX)
|
||||
return true;
|
||||
@@ -118,6 +120,10 @@ void CComponents::paintFbItems(bool do_save_bg)
|
||||
}
|
||||
|
||||
for(size_t i=0; i< v_fbdata.size() ;i++){
|
||||
// Don't paint if dx or dy are 0
|
||||
if ((v_fbdata[i].dx == 0) || (v_fbdata[i].dy == 0))
|
||||
continue;
|
||||
|
||||
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);
|
||||
@@ -138,7 +144,7 @@ void CComponents::paintFbItems(bool do_save_bg)
|
||||
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 if( allowPaint(i) )
|
||||
else if( allowPaint(i) || fbtype == CC_FBDATA_TYPE_LINE)
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -168,6 +174,16 @@ inline void CComponents::hide()
|
||||
is_painted = false;
|
||||
}
|
||||
|
||||
//erase rendered objects
|
||||
void CComponents::kill()
|
||||
{
|
||||
for(size_t i =0; i< v_fbdata.size() ;i++)
|
||||
frameBuffer->paintBackgroundBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
|
||||
clear();
|
||||
firstPaint = true;
|
||||
is_painted = false;
|
||||
}
|
||||
|
||||
//clean old screen buffer
|
||||
inline void CComponents::clear()
|
||||
{
|
||||
|
@@ -16,7 +16,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -113,8 +113,8 @@ void CComponentsDetailLine::paint(bool do_save_bg)
|
||||
{
|
||||
/* 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},
|
||||
{CC_FBDATA_TYPE_LINE, x+width-sw, y_mark_top+sw, sw, h_mark_top-sw, col_shadow, 0, 0, NULL, NULL},
|
||||
{CC_FBDATA_TYPE_LINE, x+width-thickness, y_mark_top+h_mark_top, thickness, 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},
|
||||
@@ -126,12 +126,12 @@ void CComponentsDetailLine::paint(bool do_save_bg)
|
||||
|
||||
/* 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},
|
||||
{CC_FBDATA_TYPE_LINE, x+sw, y_down+thickness, width-thickness-2*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},
|
||||
{CC_FBDATA_TYPE_LINE, x+width-sw, y_mark_down+sw, sw, h_mark_down-sw, col_shadow, 0, 0, NULL, NULL},
|
||||
{CC_FBDATA_TYPE_LINE, x+width-thickness, y_mark_down+h_mark_down,thickness, sw, col_shadow, 0, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++)
|
||||
@@ -140,24 +140,6 @@ void CComponentsDetailLine::paint(bool do_save_bg)
|
||||
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.
|
||||
|
@@ -16,7 +16,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc.h"
|
||||
#include "cc_frm.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -129,6 +129,7 @@ void CComponentsForm::addCCItem(CComponentsItem* 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
|
||||
cc_Item->setParent(this);
|
||||
v_cc_items.push_back(cc_Item);
|
||||
}
|
||||
#ifdef DEBUG_CC
|
||||
@@ -233,7 +234,6 @@ void CComponentsForm::paintCCItems()
|
||||
//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){
|
||||
@@ -270,6 +270,11 @@ void CComponentsForm::paintCCItems()
|
||||
printf("[CComponentsForm] %s: item %d too large, definied height=%d, possible height=%d \n", __FUNCTION__, i, h_item, v_cc_items[i]->getHeight());
|
||||
#endif
|
||||
}
|
||||
|
||||
//set real position dimension to item
|
||||
int real_x = v_cc_items[i]->getXPos();
|
||||
int real_y = v_cc_items[i]->getYPos();
|
||||
v_cc_items[i]->setRealPos(real_x, real_y);
|
||||
|
||||
//paint element without saved screen!
|
||||
v_cc_items[i]->paint(CC_SAVE_SCREEN_NO);
|
||||
|
194
src/gui/components/cc_frm.h
Normal file
194
src/gui/components/cc_frm.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2012, 2013, Thilo Graf 'dbt'
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CC_FORM_H__
|
||||
#define __CC_FORM_H__
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <gui/components/cc.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
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
|
144
src/gui/components/cc_frm_button.cpp
Normal file
144
src/gui/components/cc_frm_button.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2012, 2013, Thilo Graf 'dbt'
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
|
||||
#include "cc_frm_button.h"
|
||||
|
||||
#define FRAME_TH 3
|
||||
|
||||
using namespace std;
|
||||
|
||||
CComponentsButton::CComponentsButton( const int x_pos, const int y_pos, const int w, const int h,
|
||||
const std::string& caption, const std::string& icon_name,
|
||||
bool selected, bool enabled, bool has_shadow,
|
||||
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
||||
{
|
||||
initVarButton();
|
||||
cc_btn_icon = icon_name;
|
||||
cc_btn_capt = caption;
|
||||
cc_btn_capt_col = COL_MENUCONTENT;
|
||||
cc_btn_text_w = cc_btn_font->getRenderWidth(cc_btn_capt, true);
|
||||
cc_btn_text_h = cc_btn_font->getHeight();
|
||||
|
||||
x = x_pos;
|
||||
y = y_pos;
|
||||
width = max(w, cc_btn_text_w);
|
||||
height = max(h, cc_btn_text_h);
|
||||
shadow = has_shadow;
|
||||
shadow_w = SHADOW_OFFSET;
|
||||
col_frame = color_frame;
|
||||
col_body = color_body;
|
||||
col_shadow = color_shadow;
|
||||
cc_item_enabled = enabled;
|
||||
cc_item_selected = selected;
|
||||
fr_thickness = FRAME_TH;
|
||||
}
|
||||
|
||||
void CComponentsButton::initVarButton()
|
||||
{
|
||||
initVarForm();
|
||||
cc_item_type = CC_ITEMTYPE_BUTTON;
|
||||
cc_btn_icon_obj = NULL;
|
||||
cc_btn_capt_obj = NULL;
|
||||
cc_btn_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL];
|
||||
cc_btn_icon = "";
|
||||
cc_btn_capt = "";
|
||||
cc_btn_text_w = 0;
|
||||
cc_btn_text_h = 0;
|
||||
}
|
||||
|
||||
void CComponentsButton::initIcon()
|
||||
{
|
||||
//init cch_icon_obj only if an icon available
|
||||
if (cc_btn_icon.empty()) {
|
||||
if (cc_btn_icon_obj)
|
||||
delete cc_btn_icon_obj;
|
||||
cc_btn_icon_obj = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (cc_btn_icon_obj == NULL){
|
||||
cc_btn_icon_obj = new CComponentsPicture(0, 0, 0, 0, cc_btn_icon);
|
||||
|
||||
addCCItem(cc_btn_icon_obj);
|
||||
}
|
||||
|
||||
if (cc_btn_icon_obj){
|
||||
cc_btn_icon_obj->setDimensionsAll(this->getRealXPos(), this->getRealYPos(), height/*-2*fr_thickness*/, height-2*fr_thickness);
|
||||
cc_btn_icon_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER);
|
||||
cc_btn_icon_obj->doPaintBg(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsButton::initCaption()
|
||||
{
|
||||
if (cc_btn_capt_obj == NULL){
|
||||
cc_btn_capt_obj = new CComponentsLabel();
|
||||
|
||||
addCCItem(cc_btn_capt_obj);
|
||||
}
|
||||
|
||||
int cap_x = this->getRealXPos()+(width/2)-(cc_btn_text_w/2);
|
||||
int cap_h = height/*-2*fr_thickness*/;
|
||||
int cap_y = this->getRealYPos();
|
||||
|
||||
if (cc_btn_icon_obj)
|
||||
cap_x = this->getRealXPos()+cc_btn_icon_obj->getWidth();
|
||||
|
||||
if (cc_btn_capt_obj){
|
||||
cc_btn_capt_obj->setDimensionsAll(cap_x, cap_y, width-cap_x, cap_h);
|
||||
cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? COL_MENUCONTENT : COL_MENUCONTENTINACTIVE);
|
||||
cc_btn_capt_obj->setText(cc_btn_capt, CTextBox::NO_AUTO_LINEBREAK, cc_btn_font);
|
||||
cc_btn_capt_obj->forceTextPaint(); //here required;
|
||||
cc_btn_capt_obj->doPaintBg(false);
|
||||
|
||||
//corner of text item
|
||||
cc_btn_capt_obj->setCornerRadius(corner_rad-fr_thickness);
|
||||
cc_btn_capt_obj->setCornerType(corner_type);
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsButton::initCCBtnItems()
|
||||
{
|
||||
initIcon();
|
||||
|
||||
initCaption();
|
||||
}
|
||||
|
||||
|
||||
void CComponentsButton::paint(bool do_save_bg)
|
||||
{
|
||||
//prepare items before paint
|
||||
initCCBtnItems();
|
||||
|
||||
//paint form contents
|
||||
paintForm(do_save_bg);
|
||||
}
|
121
src/gui/components/cc_frm_button.h
Normal file
121
src/gui/components/cc_frm_button.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2012, 2013, Thilo Graf 'dbt'
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CC_BUTTONS_H__
|
||||
#define __CC_BUTTONS_H__
|
||||
|
||||
#include "config.h"
|
||||
#include "cc.h"
|
||||
#include "cc_frm.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
class CComponentsButton : public CComponentsForm
|
||||
{
|
||||
protected:
|
||||
void initVarButton();
|
||||
|
||||
///caption and icon properties
|
||||
std::string cc_btn_capt; //text
|
||||
std::string cc_btn_icon; //icon name, only icons supported, to find in gui/widget/icons.h
|
||||
fb_pixel_t cc_btn_capt_col; //text color
|
||||
Font* cc_btn_font; //text font
|
||||
int cc_btn_text_w, cc_btn_text_h; //width and height of text, too long text will be truncated
|
||||
|
||||
///icon and text objects
|
||||
CComponentsPicture *cc_btn_icon_obj;
|
||||
CComponentsLabel *cc_btn_capt_obj;
|
||||
|
||||
///initialize of objects
|
||||
void initIcon();
|
||||
void initCaption();
|
||||
void initCCBtnItems();
|
||||
|
||||
public:
|
||||
///basic constructor for button object with most needed params, no button icon is definied here
|
||||
CComponentsButton( const int x_pos, const int y_pos, const int w, const int h,
|
||||
const std::string& caption, const std::string& icon_name,
|
||||
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||
|
||||
virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_color;};
|
||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
};
|
||||
|
||||
///sub classes for button objects with most needed params, and predefined color buttons, but functionality is the same as in CComponentsButton
|
||||
class CComponentsButtonRed : public CComponentsButton
|
||||
{
|
||||
public:
|
||||
CComponentsButtonRed( const int x_pos, const int y_pos, const int w, const int h,
|
||||
const std::string& caption,
|
||||
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
|
||||
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_RED, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
|
||||
{
|
||||
cc_item_type = CC_ITEMTYPE_BUTTON_RED;
|
||||
};
|
||||
};
|
||||
|
||||
class CComponentsButtonGreen : public CComponentsButton
|
||||
{
|
||||
public:
|
||||
CComponentsButtonGreen( const int x_pos, const int y_pos, const int w, const int h,
|
||||
const std::string& caption,
|
||||
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
|
||||
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_GREEN, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
|
||||
{
|
||||
cc_item_type = CC_ITEMTYPE_BUTTON_GREEN;
|
||||
};
|
||||
};
|
||||
|
||||
class CComponentsButtonYellow : public CComponentsButton
|
||||
{
|
||||
public:
|
||||
CComponentsButtonYellow( const int x_pos, const int y_pos, const int w, const int h,
|
||||
const std::string& caption,
|
||||
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
|
||||
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_YELLOW, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
|
||||
{
|
||||
cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW;
|
||||
};
|
||||
};
|
||||
|
||||
class CComponentsButtonBlue : public CComponentsButton
|
||||
{
|
||||
public:
|
||||
CComponentsButtonBlue( const int x_pos, const int y_pos, const int w, const int h,
|
||||
const std::string& caption,
|
||||
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
|
||||
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_BLUE, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
|
||||
{
|
||||
cc_item_type = CC_ITEMTYPE_BUTTON_BLUE;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif /*__CC_BUTTONS_H__*/
|
@@ -16,7 +16,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc.h"
|
||||
#include "cc_frm.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -286,6 +286,7 @@ void CComponentsHeader::initCCHeaderText()
|
||||
//set header text properties
|
||||
if (cch_text_obj){
|
||||
cch_text_obj->setText(cch_text, CTextBox::AUTO_WIDTH, cch_font);
|
||||
cch_text_obj->forceTextPaint(); //here required
|
||||
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, width-cch_icon_w-fr_thickness, height-2*fr_thickness);
|
||||
cch_text_obj->setTextColor(cch_col_text);
|
||||
cch_text_obj->setColorBody(col_body);
|
||||
|
@@ -16,7 +16,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc.h"
|
||||
#include "cc_frm.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -41,7 +41,7 @@ CComponentsIconForm::CComponentsIconForm()
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
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();
|
||||
|
@@ -16,7 +16,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc.h"
|
||||
#include "cc_frm.h"
|
||||
#include <driver/screen_max.h>
|
||||
|
||||
using namespace std;
|
||||
|
@@ -16,7 +16,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -53,7 +53,11 @@ void CComponentsItem::initVarItem()
|
||||
{
|
||||
//CComponents
|
||||
initVarBasic();
|
||||
cc_item_index = CC_NO_INDEX;
|
||||
cc_item_index = CC_NO_INDEX;
|
||||
cc_item_xr = cc_item_yr = -1;
|
||||
cc_item_enabled = true;
|
||||
cc_item_selected = false;
|
||||
cc_parent = NULL;
|
||||
}
|
||||
|
||||
// Paint container background in cc-items with shadow, background and frame.
|
||||
@@ -68,13 +72,31 @@ void CComponentsItem::paintInit(bool do_save_bg)
|
||||
|
||||
int sw = shadow ? shadow_w : 0;
|
||||
int th = fr_thickness;
|
||||
fb_pixel_t col_frame_cur = col_frame;
|
||||
|
||||
//calculate current needed frame thickeness and color, if item selected or not
|
||||
if (cc_item_selected){
|
||||
col_frame_cur = col_frame_sel;
|
||||
th = max(fr_thickness_sel, fr_thickness);
|
||||
}
|
||||
|
||||
//calculate current needed corner radius for body box, depends of frame thickness
|
||||
int rad = (corner_rad>th) ? corner_rad-th : corner_rad;
|
||||
|
||||
//calculate positon of shadow areas
|
||||
int x_sh = corner_rad>0 ? x+width-2*corner_rad+sw : x+width; //right
|
||||
int y_sh = corner_rad>0 ? y+height-2*corner_rad+sw : y+height; //bottom
|
||||
|
||||
//calculate current shadow width depends of current corner_rad
|
||||
int sw_cur = corner_rad>0 ? 2*corner_rad : sw;
|
||||
|
||||
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},
|
||||
{CC_FBDATA_TYPE_BGSCREEN, x, y, width+sw, height+sw, 0, 0, 0, NULL, NULL},
|
||||
{CC_FBDATA_TYPE_BOX, x_sh, y+sw, sw_cur, height, col_shadow, corner_rad, 0, NULL, NULL},//shadow right
|
||||
{CC_FBDATA_TYPE_BOX, x+sw, y_sh, width, sw_cur, col_shadow, corner_rad, 0, NULL, NULL},//shadow bottom
|
||||
{CC_FBDATA_TYPE_FRAME, x, y, width, height, col_frame_cur, corner_rad, th, NULL, NULL},//frame
|
||||
{CC_FBDATA_TYPE_BOX, x+th, y+th, width-2*th, height-2*th, col_body, rad, 0, NULL, NULL},//body
|
||||
};
|
||||
|
||||
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++)
|
||||
@@ -107,28 +129,6 @@ 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.
|
||||
|
@@ -16,7 +16,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc.h"
|
||||
#include "cc_misc.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@@ -42,7 +42,7 @@ CComponentsInfoBox::CComponentsInfoBox()
|
||||
}
|
||||
|
||||
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,
|
||||
std::string 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)
|
||||
{
|
||||
@@ -128,13 +128,15 @@ void CComponentsInfoBox::paint(bool do_save_bg)
|
||||
}
|
||||
|
||||
//set text and paint text lines
|
||||
if (ct_text){
|
||||
if (!ct_text.empty()){
|
||||
if (cctext)
|
||||
delete cctext;
|
||||
|
||||
cctext = new CComponentsText();
|
||||
cctext->setText(ct_text, ct_text_mode, ct_font);
|
||||
cctext->doPaintTextBoxBg(false);
|
||||
cctext->doPaintTextBoxBg(ct_paint_textbg);
|
||||
cctext->doPaintBg(false);
|
||||
cctext->setTextColor(ct_col_text);
|
||||
cctext->setDimensionsAll(x_text, y+fr_thickness, width-(x_text-x+x_offset+fr_thickness), height-2*fr_thickness);
|
||||
cctext->paint(CC_SAVE_SCREEN_NO);
|
||||
}
|
||||
|
@@ -172,7 +172,11 @@ void CComponentsPicture::paint(bool do_save_bg)
|
||||
initVarPicture();
|
||||
paintInit(do_save_bg);
|
||||
pic_painted = false;
|
||||
|
||||
|
||||
#ifdef DEBUG_CC
|
||||
printf(" [CComponentsPicture] %s: paint image: %s (do_paint=%d)\n", __FUNCTION__, pic_name.c_str(), do_paint);
|
||||
#endif
|
||||
|
||||
if (do_paint){
|
||||
if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF)
|
||||
pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0 /*pic_max_h*/, pic_offset, pic_paint, pic_paintBg, col_body);
|
||||
|
@@ -66,8 +66,8 @@ CProgressBar::CProgressBar( const int x_pos, const int y_pos, const int w, const
|
||||
pb_blink = blinkenlights;
|
||||
pb_invert = inv;
|
||||
pb_red = r;
|
||||
pb_green = g;
|
||||
pb_yellow = b;
|
||||
pb_green = g;
|
||||
pb_yellow = b;
|
||||
pb_active_col = active_col;
|
||||
pb_passive_col = passive_col;
|
||||
}
|
||||
@@ -85,10 +85,10 @@ void CProgressBar::initVarProgressbar()
|
||||
pb_bl_changed = g_settings.progressbar_color;
|
||||
pb_last_width = -1;
|
||||
pb_red = 40;
|
||||
pb_green = 100;
|
||||
pb_yellow = 70;
|
||||
pb_active_col = COL_INFOBAR_PLUS_7;
|
||||
pb_passive_col = COL_INFOBAR_PLUS_3;
|
||||
pb_green = 100;
|
||||
pb_yellow = 70;
|
||||
pb_active_col = COL_INFOBAR_PLUS_7;
|
||||
pb_passive_col = COL_INFOBAR_PLUS_3;
|
||||
pb_value = 0;
|
||||
pb_max_value = 0;
|
||||
pb_paint_zero = false;
|
||||
@@ -113,8 +113,8 @@ void CProgressBar::initDimensions()
|
||||
pb_max_value = pb_value;
|
||||
|
||||
// start positions x/y active bar
|
||||
pb_x = x + fr_thickness;
|
||||
pb_y = y + fr_thickness;
|
||||
pb_x = (cc_item_xr > -1 ? cc_item_xr : x) + fr_thickness;
|
||||
pb_y = (cc_item_yr > -1 ? cc_item_yr : y) + fr_thickness;
|
||||
|
||||
// width for active bar with current value
|
||||
pb_active_width = max(0, pb_last_width);
|
||||
@@ -146,7 +146,7 @@ void CProgressBar::paintSimple()
|
||||
}
|
||||
|
||||
if (pb_paint_zero && pb_value == 0)
|
||||
frameBuffer->paintLine(x+fr_thickness , y+fr_thickness, x+width-3, y+height-3, pb_active_col); // zero line
|
||||
frameBuffer->paintLine(pb_x , pb_y, pb_x+width-3, pb_y+height-3, pb_active_col); // zero line
|
||||
}
|
||||
|
||||
void CProgressBar::paintAdvanced()
|
||||
|
@@ -31,6 +31,9 @@
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <errno.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -42,7 +45,7 @@ CComponentsText::CComponentsText()
|
||||
}
|
||||
|
||||
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,
|
||||
std::string 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)
|
||||
{
|
||||
@@ -87,11 +90,13 @@ void CComponentsText::initVarText()
|
||||
ct_font = NULL;
|
||||
ct_box = NULL;
|
||||
ct_textbox = NULL;
|
||||
ct_text = NULL;
|
||||
ct_text = "";
|
||||
ct_old_text = ct_text;
|
||||
ct_text_mode = CTextBox::AUTO_WIDTH;
|
||||
ct_col_text = COL_MENUCONTENT;
|
||||
ct_text_sent = false;
|
||||
ct_paint_textbg = true;
|
||||
ct_paint_textbg = false;
|
||||
ct_force_text_paint = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,11 +137,12 @@ void CComponentsText::initCCText()
|
||||
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);
|
||||
//send text to CTextBox object, but paint text only if text has changed or force option is enabled
|
||||
if ((ct_old_text != ct_text) || ct_force_text_paint)
|
||||
ct_text_sent = ct_textbox->setText(&ct_text, ct_box->iWidth);
|
||||
ct_old_text = ct_text;
|
||||
#ifdef DEBUG_CC
|
||||
printf(" [CComponentsText] [%s - %d] init text: %s [x %d, y %d, h %d, w %d]\n", __FUNCTION__, __LINE__, ct_text, ct_box->iX, ct_box->iY, height, width);
|
||||
printf(" [CComponentsText] [%s - %d] init text: %s [x %d, y %d, h %d, w %d]\n", __FUNCTION__, __LINE__, ct_text.c_str(), ct_box->iX, ct_box->iY, height, width);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -151,28 +157,56 @@ void CComponentsText::clearCCText()
|
||||
ct_textbox = NULL;
|
||||
}
|
||||
|
||||
void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text)
|
||||
|
||||
void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text)
|
||||
{
|
||||
ct_text = g_Locale->getText(locale_text);
|
||||
ct_old_text = ct_text;
|
||||
ct_text = stext;
|
||||
ct_text_mode = mode;
|
||||
ct_font = font_text;
|
||||
#ifdef DEBUG_CC
|
||||
printf(" [CComponentsText] [%s - %d] ct_text: %s \n", __FUNCTION__, __LINE__, ct_text.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text)
|
||||
{
|
||||
string stext = g_Locale->getText(locale_text);
|
||||
setText(stext, mode, 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;
|
||||
|
||||
setText((string)ctext, mode, font_text);
|
||||
}
|
||||
|
||||
void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text)
|
||||
void CComponentsText::setText(const int digit, const int mode, Font* font_text)
|
||||
{
|
||||
ct_text = stext.c_str();
|
||||
ct_text_mode = mode;
|
||||
ct_font = font_text;
|
||||
string s_digit = iToString(digit);
|
||||
setText(s_digit, mode, font_text);
|
||||
}
|
||||
|
||||
//set text lines directly from a file, returns true on succsess
|
||||
bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text)
|
||||
{
|
||||
string file = path_to_textfile;
|
||||
string txt = "";
|
||||
|
||||
ifstream in (file.c_str(), ios::in);
|
||||
if (!in){
|
||||
printf("[CComponentsText] [%s - %d] error while open %s -> %s\n", __FUNCTION__, __LINE__, file.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
string line;
|
||||
|
||||
while(getline(in, line)){
|
||||
txt += line + '\n';
|
||||
}
|
||||
in.close();
|
||||
|
||||
setText(txt, mode, font_text);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CComponentsText::paintText(bool do_save_bg)
|
||||
@@ -191,9 +225,9 @@ void CComponentsText::paint(bool do_save_bg)
|
||||
|
||||
void CComponentsText::hide(bool no_restore)
|
||||
{
|
||||
|
||||
if (ct_textbox)
|
||||
ct_textbox->hide();
|
||||
ct_old_text = "";
|
||||
hideCCItem(no_restore);
|
||||
}
|
||||
|
||||
@@ -206,3 +240,13 @@ void CComponentsText::removeLineBreaks(std::string& str)
|
||||
spos = str.find_first_of("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//helper, converts int to string
|
||||
string CComponentsText::iToString(int int_val)
|
||||
{
|
||||
ostringstream i_str;
|
||||
i_str << int_val;
|
||||
string i_string(i_str.str());
|
||||
return i_string;
|
||||
}
|
||||
|
113
src/gui/components/cc_misc.h
Normal file
113
src/gui/components/cc_misc.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Experimental Classes for generic GUI-related components. Not really used.
|
||||
Copyright (C) 2012, Michael Liebmann 'micha-bbg
|
||||
Copyright (C) 2012, Thilo Graf 'dbt'
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CC_MISC__
|
||||
#define __CC_MISC__
|
||||
|
||||
#include "config.h"
|
||||
#include <gui/components/cc.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
#define FIRST_ELEMENT_INIT 10000
|
||||
#define LOGO_MAX_WIDTH width/4
|
||||
class CComponentsItemBox : public CComponentsItem
|
||||
{
|
||||
protected:
|
||||
int hSpacer;
|
||||
int hOffset;
|
||||
int vOffset;
|
||||
int digit_offset, digit_h;
|
||||
bool paintElements;
|
||||
bool onlyOneTextElement;
|
||||
fb_pixel_t it_col_text;
|
||||
Font* font_text;
|
||||
int hMax;
|
||||
bool has_TextElement;
|
||||
size_t firstElementLeft;
|
||||
size_t firstElementRight;
|
||||
size_t prevElementLeft;
|
||||
size_t prevElementRight;
|
||||
std::vector<comp_element_data_t> v_element_data;
|
||||
bool isCalculated;
|
||||
|
||||
void clearElements();
|
||||
void initVarItemBox();
|
||||
void calSizeOfElements();
|
||||
void calPositionOfElements();
|
||||
void paintItemBox(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
void calculateElements();
|
||||
bool addElement(int align, int type, const std::string& element="", size_t *index=NULL);
|
||||
void paintImage(size_t index, bool newElement);
|
||||
void paintText(size_t index, bool newElement);
|
||||
|
||||
public:
|
||||
CComponentsItemBox();
|
||||
virtual ~CComponentsItemBox();
|
||||
|
||||
inline virtual void setTextFont(Font* font){font_text = font;};
|
||||
inline virtual void setTextColor(fb_pixel_t color_text){ it_col_text = color_text;};
|
||||
|
||||
virtual void refreshElement(size_t index, const std::string& element);
|
||||
virtual void paintElement(size_t index, bool newElement= false);
|
||||
virtual bool addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index=NULL);
|
||||
virtual void clearTitlebar();
|
||||
virtual void addText(const std::string& s_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
|
||||
virtual void addText(neutrino_locale_t locale_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
|
||||
virtual void addIcon(const std::string& s_icon_name, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
|
||||
virtual void addPicture(const std::string& s_picture_path, const int align=CC_ALIGN_LEFT, size_t *index=NULL);
|
||||
virtual void addClock(const int align=CC_ALIGN_RIGHT, size_t *index=NULL);
|
||||
virtual int getHeight();
|
||||
};
|
||||
|
||||
class CComponentsTitleBar : public CComponentsItemBox
|
||||
{
|
||||
private:
|
||||
const char* tb_c_text;
|
||||
std::string tb_s_text, tb_icon_name;
|
||||
neutrino_locale_t tb_locale_text;
|
||||
int tb_text_align, tb_icon_align;
|
||||
|
||||
void initText();
|
||||
void initIcon();
|
||||
void initElements();
|
||||
void initVarTitleBar();
|
||||
|
||||
public:
|
||||
CComponentsTitleBar();
|
||||
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const char* c_text = NULL, const std::string& s_icon ="",
|
||||
fb_pixel_t color_text = COL_MENUHEAD, 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);
|
||||
|
||||
};
|
||||
|
||||
#endif /*__CC_MISC__*/
|
@@ -15,7 +15,7 @@
|
||||
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.
|
||||
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
|
||||
@@ -45,6 +45,11 @@ typedef enum
|
||||
CC_ITEMTYPE_FRM_WINDOW,
|
||||
CC_ITEMTYPE_LABEL,
|
||||
CC_ITEMTYPE_PROGRESSBAR,
|
||||
CC_ITEMTYPE_BUTTON,
|
||||
CC_ITEMTYPE_BUTTON_RED,
|
||||
CC_ITEMTYPE_BUTTON_GREEN,
|
||||
CC_ITEMTYPE_BUTTON_YELLOW,
|
||||
CC_ITEMTYPE_BUTTON_BLUE,
|
||||
|
||||
CC_ITEMTYPES
|
||||
}CC_ITEMTYPES_T;
|
||||
@@ -68,7 +73,6 @@ typedef struct comp_fbdata_t
|
||||
typedef enum
|
||||
{
|
||||
CC_FBDATA_TYPE_BGSCREEN,
|
||||
CC_FBDATA_TYPE_SHADOW,
|
||||
CC_FBDATA_TYPE_BOX,
|
||||
CC_FBDATA_TYPE_FRAME,
|
||||
CC_FBDATA_TYPE_LINE,
|
||||
|
Reference in New Issue
Block a user