CComponents: rename Container onto Item, make void paint() abstract

CComponentsItem is shorter then CComponentsContainer, but also
plausible and appropriately.
paint() is required in all sub classes and useful for coming functions.
This commit is contained in:
2012-10-21 13:54:33 +02:00
parent 28904b79c7
commit e1c9749730
2 changed files with 165 additions and 170 deletions

View File

@@ -158,16 +158,16 @@ class CComponents
virtual bool isPainted(){return is_painted;}; virtual bool isPainted(){return is_painted;};
}; };
class CComponentsContainer : public CComponents class CComponentsItem : public CComponents
{ {
protected: protected:
int corner_rad, fr_thickness; int corner_rad, fr_thickness;
void hideContainer(bool no_restore = false); void hideContainer(bool no_restore = false);
void paintInit(bool do_save_bg); void paintInit(bool do_save_bg);
void initVarContainer(); void initVarItem();
public: public:
CComponentsContainer(); CComponentsItem();
/// 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 setCornerType(const int& type){corner_type = type;};
@@ -176,14 +176,14 @@ class CComponentsContainer : public CComponents
inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;}; inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;};
inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;}; inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;};
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
virtual void hide(bool no_restore = false); virtual void hide(bool no_restore = false);
virtual void kill(); virtual void kill();
virtual void syncSysColors(); virtual void syncSysColors();
}; };
class CComponentsPicture : public CComponentsContainer class CComponentsPicture : public CComponentsItem
{ {
private: private:
std::string pic_name; std::string pic_name;
@@ -217,7 +217,7 @@ class CComponentsPicture : public CComponentsContainer
}; };
#define INFO_BOX_Y_OFFSET 2 #define INFO_BOX_Y_OFFSET 2
class CComponentsInfoBox : public CComponentsContainer class CComponentsInfoBox : public CComponentsItem
{ {
private: private:
const char* text; const char* text;
@@ -257,7 +257,7 @@ class CComponentsInfoBox : public CComponentsContainer
}; };
class CComponentsShapeCircle : public CComponentsContainer class CComponentsShapeCircle : public CComponentsItem
{ {
private: private:
int d; int d;
@@ -269,14 +269,14 @@ class CComponentsShapeCircle : public CComponentsContainer
inline int getDiam(){return d;}; inline int getDiam(){return d;};
}; };
class CComponentsShapeSquare : public CComponentsContainer class CComponentsShapeSquare : public CComponentsItem
{ {
public: public:
CComponentsShapeSquare( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON, 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); 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);
}; };
class CComponentsPIP : public CComponentsContainer class CComponentsPIP : public CComponentsItem
{ {
private: private:
int screen_w, screen_h; int screen_w, screen_h;
@@ -314,7 +314,7 @@ class CComponentsDetailLine : public CComponents
#define FIRST_ELEMENT_INIT 10000 #define FIRST_ELEMENT_INIT 10000
#define LOGO_MAX_WIDTH width/4 #define LOGO_MAX_WIDTH width/4
class CComponentsItemBox : public CComponentsContainer class CComponentsItemBox : public CComponentsItem
{ {
protected: protected:
int hSpacer; int hSpacer;
@@ -390,7 +390,7 @@ class CComponentsTitleBar : public CComponentsItemBox
}; };
class CComponentsForm : public CComponentsContainer class CComponentsForm : public CComponentsItem
{ {
private: private:
CComponentsTitleBar *tb; CComponentsTitleBar *tb;
@@ -410,7 +410,7 @@ class CComponentsForm : public CComponentsContainer
void setIcon(const std::string& icon_name){tb_icon = icon_name;}; void setIcon(const std::string& icon_name){tb_icon = icon_name;};
}; };
class CComponentsText : public CComponentsContainer class CComponentsText : public CComponentsItem
{ {
private: private:
Font* ct_font; Font* ct_font;

View File

@@ -161,11 +161,11 @@ inline void CComponents::clear()
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//abstract sub class CComponentsContainer from CComponents //abstract sub class CComponentsItem from CComponents
CComponentsContainer::CComponentsContainer() CComponentsItem::CComponentsItem()
{ {
//CComponentsContainer //CComponentsItem
initVarContainer(); initVarItem();
} }
// y // y
@@ -175,17 +175,17 @@ CComponentsContainer::CComponentsContainer()
// | | // | |
// +--------width---------+ // +--------width---------+
void CComponentsContainer::initVarContainer() void CComponentsItem::initVarItem()
{ {
//CComponents //CComponents
initVarBasic(); initVarBasic();
//ComponentsContainer //CComponentsItem
corner_rad = 0; corner_rad = 0;
fr_thickness = 0; fr_thickness = 0;
} }
void CComponentsContainer::paintInit(bool do_save_bg) void CComponentsItem::paintInit(bool do_save_bg)
{ {
clear(); clear();
@@ -206,15 +206,10 @@ void CComponentsContainer::paintInit(bool do_save_bg)
paintFbItems(do_save_bg); paintFbItems(do_save_bg);
} }
void CComponentsContainer::paint(bool do_save_bg)
{
paintInit(do_save_bg);
}
//restore last saved screen behind form box, //restore last saved screen behind form box,
//Do use parameter 'no restore' to override temporarly the restore funtionality. //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. //This could help to avoid ugly flicker efffects if it is necessary e.g. on often repaints, without changed contents.
void CComponentsContainer::hideContainer(bool no_restore) void CComponentsItem::hideContainer(bool no_restore)
{ {
is_painted = false; is_painted = false;
@@ -228,14 +223,14 @@ void CComponentsContainer::hideContainer(bool no_restore)
} }
} }
void CComponentsContainer::hide(bool no_restore) void CComponentsItem::hide(bool no_restore)
{ {
hideContainer(no_restore); hideContainer(no_restore);
} }
//hide rendered objects //hide rendered objects
void CComponentsContainer::kill() void CComponentsItem::kill()
{ {
//save current colors //save current colors
fb_pixel_t c_tmp1, c_tmp2, c_tmp3; fb_pixel_t c_tmp1, c_tmp2, c_tmp3;
@@ -258,7 +253,7 @@ void CComponentsContainer::kill()
//synchronize colors for forms //synchronize colors for forms
//This is usefull if the system colors are changed during runtime //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. //so you can ensure correct applied system colors in relevant objects with unchanged instances.
void CComponentsContainer::syncSysColors() void CComponentsItem::syncSysColors()
{ {
col_body = COL_MENUCONTENT_PLUS_0; col_body = COL_MENUCONTENT_PLUS_0;
col_shadow = COL_MENUCONTENTDARK_PLUS_0; col_shadow = COL_MENUCONTENTDARK_PLUS_0;
@@ -266,11 +261,11 @@ void CComponentsContainer::syncSysColors()
} }
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//sub class CComponentsInfoBox from CComponentsContainer //sub class CComponentsInfoBox from CComponentsItem
CComponentsInfoBox::CComponentsInfoBox() CComponentsInfoBox::CComponentsInfoBox()
{ {
//CComponents, ComponentsContainer //CComponents, CComponentsItem
initVarContainer(); initVarItem();
//CComponentsInfoBox //CComponentsInfoBox
initVarInfobox(); initVarInfobox();
@@ -285,8 +280,8 @@ CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const i
bool has_shadow, bool has_shadow,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{ {
//CComponents, ComponentsContainer //CComponents, CComponentsItem
initVarContainer(); initVarItem();
x = x_pos; x = x_pos;
y = y_pos; y = y_pos;
@@ -317,8 +312,8 @@ CComponentsInfoBox::~CComponentsInfoBox()
void CComponentsInfoBox::initVarInfobox() void CComponentsInfoBox::initVarInfobox()
{ {
//CComponents, ComponentsContainer //CComponents, CComponentsItem
initVarContainer(); initVarItem();
//CComponentsInfoBox //CComponentsInfoBox
box = NULL; box = NULL;
@@ -413,11 +408,11 @@ void CComponentsInfoBox::removeLineBreaks(std::string& str)
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//sub class CComponentsShapeSquare from CComponentsContainer //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) 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)
{ {
//ComponentsContainer //CComponentsItem
initVarContainer(); initVarItem();
x = x_pos; x = x_pos;
y = y_pos; y = y_pos;
@@ -431,12 +426,12 @@ CComponentsShapeSquare::CComponentsShapeSquare(const int x_pos, const int y_pos,
} }
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//sub class CComponentsShapeCircle from CComponentsContainer //sub class CComponentsShapeCircle from CComponentsItem
CComponentsShapeCircle::CComponentsShapeCircle( int x_pos, int y_pos, int diam, bool has_shadow, 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) fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{ {
//CComponents, CComponentsContainer //CComponents, CComponentsItem
initVarContainer(); initVarItem();
//CComponents //CComponents
x = x_pos; x = x_pos;
@@ -451,7 +446,7 @@ CComponentsShapeCircle::CComponentsShapeCircle( int x_pos, int y_pos, int diam,
//CComponentsShapeCircle //CComponentsShapeCircle
width = height = d = diam; width = height = d = diam;
//CComponentsContainer //CComponentsItem
corner_rad = d/2; corner_rad = d/2;
} }
@@ -603,11 +598,11 @@ void CComponentsDetailLine::syncSysColors()
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//sub class CComponentsPIP from CComponentsContainer //sub class CComponentsPIP from CComponentsItem
CComponentsPIP::CComponentsPIP( const int x_pos, const int y_pos, const int percent, bool has_shadow) CComponentsPIP::CComponentsPIP( const int x_pos, const int y_pos, const int percent, bool has_shadow)
{ {
//CComponents, CComponentsContainer //CComponents, CComponentsItem
initVarContainer(); initVarItem();
//CComponentsPIP //CComponentsPIP
screen_w = frameBuffer->getScreenWidth(true); screen_w = frameBuffer->getScreenWidth(true);
@@ -648,7 +643,7 @@ void CComponentsPIP::hide(bool no_restore)
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//sub class CComponentsPicture from CComponentsContainer //sub class CComponentsPicture from CComponentsItem
CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos, CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos,
const std::string& picture_name, const int alignment, bool has_shadow, const std::string& picture_name, const int alignment, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow) fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
@@ -678,8 +673,8 @@ CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos, const
void CComponentsPicture::init( int x_pos, int y_pos, const string& picture_name, const int alignment, bool has_shadow, void CComponentsPicture::init( int x_pos, int y_pos, const string& picture_name, const int alignment, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow) fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
{ {
//CComponents, CComponentsContainer //CComponents, CComponentsItem
initVarContainer(); initVarItem();
//CComponentsPicture //CComponentsPicture
pic_name = picture_name; pic_name = picture_name;
@@ -785,7 +780,7 @@ void CComponentsPicture::hide(bool no_restore)
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//sub class CComponentsItemBox from CComponentsContainer //sub class CComponentsItemBox from CComponentsItem
CComponentsItemBox::CComponentsItemBox() CComponentsItemBox::CComponentsItemBox()
{ {
//CComponentsItemBox //CComponentsItemBox
@@ -802,8 +797,8 @@ CComponentsItemBox::~CComponentsItemBox()
void CComponentsItemBox::initVarItemBox() void CComponentsItemBox::initVarItemBox()
{ {
//CComponents, CComponentsContainer //CComponents, CComponentsItem
initVarContainer(); initVarItem();
//CComponentsItemBox //CComponentsItemBox
it_col_text = COL_MENUCONTENT; it_col_text = COL_MENUCONTENT;
@@ -1384,8 +1379,8 @@ CComponentsForm::~CComponentsForm()
void CComponentsForm::initVarForm() void CComponentsForm::initVarForm()
{ {
//CComponentsContainer //CComponentsItem
initVarContainer(); initVarItem();
//simple default dimensions //simple default dimensions
x = 0; x = 0;
@@ -1459,7 +1454,7 @@ void CComponentsForm::hide(bool no_restore)
} }
//sub class CComponentsText from CComponentsContainer //sub class CComponentsText from CComponentsItem
CComponentsText::CComponentsText() CComponentsText::CComponentsText()
{ {
//CComponentsText //CComponentsText
@@ -1480,8 +1475,8 @@ CComponentsText::~CComponentsText()
void CComponentsText::initVarText() void CComponentsText::initVarText()
{ {
//CComponents, CComponentsContainer //CComponents, CComponentsItem
initVarContainer(); initVarItem();
//CComponentsText //CComponentsText
ct_font = NULL; ct_font = NULL;