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;};
};
class CComponentsContainer : public CComponents
class CComponentsItem : public CComponents
{
protected:
int corner_rad, fr_thickness;
void hideContainer(bool no_restore = false);
void paintInit(bool do_save_bg);
void initVarContainer();
void initVarItem();
public:
CComponentsContainer();
CComponentsItem();
/// set corner types: Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h).
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 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 kill();
virtual void syncSysColors();
};
class CComponentsPicture : public CComponentsContainer
class CComponentsPicture : public CComponentsItem
{
private:
std::string pic_name;
@@ -217,7 +217,7 @@ class CComponentsPicture : public CComponentsContainer
};
#define INFO_BOX_Y_OFFSET 2
class CComponentsInfoBox : public CComponentsContainer
class CComponentsInfoBox : public CComponentsItem
{
private:
const char* text;
@@ -257,7 +257,7 @@ class CComponentsInfoBox : public CComponentsContainer
};
class CComponentsShapeCircle : public CComponentsContainer
class CComponentsShapeCircle : public CComponentsItem
{
private:
int d;
@@ -269,14 +269,14 @@ class CComponentsShapeCircle : public CComponentsContainer
inline int getDiam(){return d;};
};
class CComponentsShapeSquare : public CComponentsContainer
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);
};
class CComponentsPIP : public CComponentsContainer
class CComponentsPIP : public CComponentsItem
{
private:
int screen_w, screen_h;
@@ -314,7 +314,7 @@ class CComponentsDetailLine : public CComponents
#define FIRST_ELEMENT_INIT 10000
#define LOGO_MAX_WIDTH width/4
class CComponentsItemBox : public CComponentsContainer
class CComponentsItemBox : public CComponentsItem
{
protected:
int hSpacer;
@@ -390,7 +390,7 @@ class CComponentsTitleBar : public CComponentsItemBox
};
class CComponentsForm : public CComponentsContainer
class CComponentsForm : public CComponentsItem
{
private:
CComponentsTitleBar *tb;
@@ -410,7 +410,7 @@ class CComponentsForm : public CComponentsContainer
void setIcon(const std::string& icon_name){tb_icon = icon_name;};
};
class CComponentsText : public CComponentsContainer
class CComponentsText : public CComponentsItem
{
private:
Font* ct_font;

View File

@@ -161,11 +161,11 @@ inline void CComponents::clear()
//-------------------------------------------------------------------------------------------------------
//abstract sub class CComponentsContainer from CComponents
CComponentsContainer::CComponentsContainer()
//abstract sub class CComponentsItem from CComponents
CComponentsItem::CComponentsItem()
{
//CComponentsContainer
initVarContainer();
//CComponentsItem
initVarItem();
}
// y
@@ -175,17 +175,17 @@ CComponentsContainer::CComponentsContainer()
// | |
// +--------width---------+
void CComponentsContainer::initVarContainer()
void CComponentsItem::initVarItem()
{
//CComponents
initVarBasic();
//ComponentsContainer
//CComponentsItem
corner_rad = 0;
fr_thickness = 0;
}
void CComponentsContainer::paintInit(bool do_save_bg)
void CComponentsItem::paintInit(bool do_save_bg)
{
clear();
@@ -206,15 +206,10 @@ void CComponentsContainer::paintInit(bool 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,
//Do use parameter 'no restore' to override temporarly the restore funtionality.
//This could help to avoid ugly flicker efffects if it is necessary e.g. on often repaints, without changed contents.
void CComponentsContainer::hideContainer(bool no_restore)
void CComponentsItem::hideContainer(bool no_restore)
{
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);
}
//hide rendered objects
void CComponentsContainer::kill()
void CComponentsItem::kill()
{
//save current colors
fb_pixel_t c_tmp1, c_tmp2, c_tmp3;
@@ -258,7 +253,7 @@ void CComponentsContainer::kill()
//synchronize colors for forms
//This is usefull if the system colors are changed during runtime
//so you can ensure correct applied system colors in relevant objects with unchanged instances.
void CComponentsContainer::syncSysColors()
void CComponentsItem::syncSysColors()
{
col_body = COL_MENUCONTENT_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()
{
//CComponents, ComponentsContainer
initVarContainer();
//CComponents, CComponentsItem
initVarItem();
//CComponentsInfoBox
initVarInfobox();
@@ -285,8 +280,8 @@ CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const i
bool has_shadow,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponents, ComponentsContainer
initVarContainer();
//CComponents, CComponentsItem
initVarItem();
x = x_pos;
y = y_pos;
@@ -317,8 +312,8 @@ CComponentsInfoBox::~CComponentsInfoBox()
void CComponentsInfoBox::initVarInfobox()
{
//CComponents, ComponentsContainer
initVarContainer();
//CComponents, CComponentsItem
initVarItem();
//CComponentsInfoBox
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)
{
//ComponentsContainer
initVarContainer();
//CComponentsItem
initVarItem();
x = x_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,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponents, CComponentsContainer
initVarContainer();
//CComponents, CComponentsItem
initVarItem();
//CComponents
x = x_pos;
@@ -451,7 +446,7 @@ CComponentsShapeCircle::CComponentsShapeCircle( int x_pos, int y_pos, int diam,
//CComponentsShapeCircle
width = height = d = diam;
//CComponentsContainer
//CComponentsItem
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)
{
//CComponents, CComponentsContainer
initVarContainer();
//CComponents, CComponentsItem
initVarItem();
//CComponentsPIP
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,
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)
@@ -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,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
{
//CComponents, CComponentsContainer
initVarContainer();
//CComponents, CComponentsItem
initVarItem();
//CComponentsPicture
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
@@ -802,8 +797,8 @@ CComponentsItemBox::~CComponentsItemBox()
void CComponentsItemBox::initVarItemBox()
{
//CComponents, CComponentsContainer
initVarContainer();
//CComponents, CComponentsItem
initVarItem();
//CComponentsItemBox
it_col_text = COL_MENUCONTENT;
@@ -1384,8 +1379,8 @@ CComponentsForm::~CComponentsForm()
void CComponentsForm::initVarForm()
{
//CComponentsContainer
initVarContainer();
//CComponentsItem
initVarItem();
//simple default dimensions
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
@@ -1480,8 +1475,8 @@ CComponentsText::~CComponentsText()
void CComponentsText::initVarText()
{
//CComponents, CComponentsContainer
initVarContainer();
//CComponents, CComponentsItem
initVarItem();
//CComponentsText
ct_font = NULL;