CComponents: split some header files

CComponentsInfoBox
CComponentsShapeCircle/Square
CComponentsDetailLine
CComponentsPIP
CComponentsText/CComponentsLabel
CComponentsPicture
This commit is contained in:
2013-05-26 18:11:06 +02:00
parent 09d6881b20
commit d39eaa22fc
23 changed files with 566 additions and 222 deletions

View File

@@ -230,215 +230,4 @@ class CComponentsItem : public CComponents
virtual bool isEnabled(){return cc_item_enabled;};
};
class CComponentsPicture : public CComponentsItem
{
protected:
void initVarPicture();
enum
{
CC_PIC_IMAGE_MODE_OFF = 0, //paint pictures in icon mode, mainly not scaled
CC_PIC_IMAGE_MODE_ON = 1, //paint pictures in image mode, paint scaled if required
CC_PIC_IMAGE_MODE_AUTO = 2
};
std::string pic_name;
unsigned char pic_offset;
bool pic_paint, pic_paintBg, pic_painted, do_paint;
int pic_align, pic_x, pic_y, pic_width, pic_height;
int pic_max_w, pic_max_h, pic_paint_mode;
void init( const int x_pos, const int y_pos, const std::string& image_name, const int alignment, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow);
public:
CComponentsPicture( const int x_pos, const int y_pos, const int w, const int h,
const std::string& image_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
virtual inline void setPictureOffset(const unsigned char offset){pic_offset = offset;};
virtual inline void setPicturePaint(bool paint_p){pic_paint = paint_p;};
virtual inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;};
virtual void setPicture(const std::string& picture_name);
virtual void setPictureAlign(const int alignment);
virtual inline bool isPicPainted(){return pic_painted;};
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
virtual void hide(bool no_restore = false);
virtual inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;};
virtual void setMaxWidth(const int w_max){pic_max_w = w_max;};
virtual void setMaxHeight(const int h_max){pic_max_h = h_max;};
};
class CComponentsText : public CComponentsItem
{
protected:
CTextBox * ct_textbox;
CBox * ct_box;
Font * ct_font;
fb_pixel_t ct_col_text;
int ct_text_mode; //see textbox.h for possible modes
std::string ct_text, ct_old_text;
bool ct_text_sent, ct_paint_textbg, ct_force_text_paint;
static std::string iToString(int int_val); //helper to convert int to string
void initVarText();
void clearCCText();
void initCCText();
void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES);
public:
CComponentsText();
CComponentsText( const int x_pos, const int y_pos, const int w, const int h,
std::string text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_text = COL_MENUCONTENT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
virtual ~CComponentsText();
//default members to paint a text box and hide painted text
//hide textbox
void hide(bool no_restore = false);
//paint text box, parameter do_save_bg: default = true, causes fill of backckrond pixel buffer
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
//send options for text font (size and type), color and mode (allignment)
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
//see textbox.h for possible allignment modes
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};
//send option to CTextBox object to paint background box behind text or not
virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;};
//sets text mainly with string also possible with overloades members for loacales, const char and text file
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
//helper to remove linebreak chars from a string if needed
virtual void removeLineBreaks(std::string& str);
//returns true, if text was changed
virtual bool textChanged(){return ct_old_text != ct_text;};
//force paint of text even if text was changed or not
virtual void forceTextPaint(bool force_text_paint = true){ct_force_text_paint = force_text_paint;};
//gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties
virtual CTextBox* getCTextBoxObject() { return ct_textbox; };
};
class CComponentsLabel : public CComponentsText
{
public:
CComponentsLabel( const int x_pos, const int y_pos, const int w, const int h,
std::string text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_text = COL_MENUCONTENTINACTIVE, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsText(x_pos, y_pos, w, h, text, mode, font_text, has_shadow, color_text, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_LABEL;
};
CComponentsLabel():CComponentsText()
{
initVarText();
cc_item_type = CC_ITEMTYPE_LABEL;
ct_col_text = COL_MENUCONTENTINACTIVE;
};
};
#define INFO_BOX_Y_OFFSET 2
class CComponentsInfoBox : public CComponentsText
{
private:
int x_text, x_offset;
CComponentsPicture * pic;
std::string pic_default_name;
void paintPicture();
void initVarInfobox();
std::string pic_name;
public:
CComponentsText * cctext;
CComponentsInfoBox();
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h,
std::string info_text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_text = COL_MENUCONTENT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
~CComponentsInfoBox();
inline void setSpaceOffset(const int offset){x_offset = offset;};
inline void setPicture(const std::string& picture_name){pic_name = picture_name;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsShapeCircle : public CComponentsItem
{
private:
int d;
public:
CComponentsShapeCircle( const int x_pos, const int y_pos, const int diam, bool has_shadow = CC_SHADOW_ON,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
inline void setDiam(const int& diam){d=width=height=diam, corner_rad=d/2;};
inline int getDiam(){return d;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsShapeSquare : public CComponentsItem
{
public:
CComponentsShapeSquare( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsPIP : public CComponentsItem
{
private:
int screen_w, screen_h;
std::string pic_name; //alternate picture if is no tv picture available
public:
CComponentsPIP( const int x_pos, const int y_pos, const int percent = 30, bool has_shadow = CC_SHADOW_OFF);
~CComponentsPIP();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void hide(bool no_restore = false);
void setScreenWidth(int screen_width){screen_w = screen_width;};
void setScreenHeight(int screen_heigth){screen_h = screen_heigth;};
void setPicture(const std::string& image){pic_name = image;};
};
class CComponentsDetailLine : public CComponents
{
private:
int thickness, y_down, h_mark_top, h_mark_down;
void initVarDline();
public:
CComponentsDetailLine();
CComponentsDetailLine( const int x_pos,const int y_pos_top, const int y_pos_down,
const int h_mark_up = CC_HEIGHT_MIN , const int h_mark_down = CC_HEIGHT_MIN,
fb_pixel_t color_line = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
~CComponentsDetailLine();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
inline void setColors(fb_pixel_t color_line, fb_pixel_t color_shadow){col_body = color_line; col_shadow = color_shadow;};
void syncSysColors();
inline void setYPosDown(const int& y_pos_down){y_down = y_pos_down;};
inline void setHMarkTop(const int& h_mark_top_){h_mark_top = h_mark_top_;};
inline void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
};
#endif