CComponents: add new methodes to create forms

Create forms with default constructor and now you can add
cc-items into form with new member addCCItem().

The x/y values are valid to inside of form dimensions itself not inside of screen.
Addable cc-items are all CComponentItem objects and their inheritances
including CComponentsForm itself. So are even nestings possible.

Some changes on other cc-item classes were necessary.
For example, CComponentsPicture or CComponentsText and it's still
much to do.
This commit is contained in:
2012-11-01 16:46:28 +01:00
parent 98b1e38dfa
commit cda02273ea
2 changed files with 175 additions and 107 deletions

View File

@@ -81,12 +81,6 @@ enum
CC_ALIGN_VER_CENTER = 16 CC_ALIGN_VER_CENTER = 16
}; };
enum
{
CC_PIC_ICON,
CC_PIC_IMAGE
};
enum enum
{ {
CC_ITEMBOX_ICON, CC_ITEMBOX_ICON,
@@ -141,7 +135,7 @@ class CComponents
inline virtual void setHeight(const int& h){height = h;}; inline virtual void setHeight(const int& h){height = h;};
inline virtual void setWidth(const int& w){width = w;}; inline virtual void setWidth(const int& w){width = w;};
inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;}; inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;};
inline virtual int getXPos(){return x;}; inline virtual int getXPos(){return x;};
inline virtual int getYPos(){return y;}; inline virtual int getYPos(){return y;};
inline virtual int getHeight(){return height;}; inline virtual int getHeight(){return height;};
@@ -153,6 +147,10 @@ class CComponents
inline virtual void setColorBody(fb_pixel_t color){col_body = 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 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;}; inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;};
/// get colors
inline virtual fb_pixel_t getColorFrame(){return col_frame;};
inline virtual fb_pixel_t getColorBody(){return col_body;};
inline virtual fb_pixel_t getColorShadow(){return col_shadow;};
virtual void hide(); virtual void hide();
virtual bool isPainted(){return is_painted;}; virtual bool isPainted(){return is_painted;};
@@ -172,48 +170,55 @@ class CComponentsItem : public CComponents
/// 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;};
inline virtual void setCornerRadius(const int& radius){corner_rad = radius;}; inline virtual void setCornerRadius(const int& radius){corner_rad = radius;};
/// get corner types:
inline virtual int getCornerType(){return corner_type;};
inline virtual int getCornerRadius(){return corner_rad;};
inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;}; inline virtual void 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) = 0; 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 CComponentsItem class CComponentsPicture : public CComponentsItem
{ {
private: private:
enum
{
CC_PIC_IMAGE_MODE_OFF = 0, //paint pictures in icon mode, mainly not scaled
CC_PIC_IMAGE_MODE_ON = 1, //paint pictures in image mode, paint scaled if required
CC_PIC_IMAGE_MODE_AUTO = 2
};
std::string pic_name; std::string pic_name;
unsigned char pic_offset; unsigned char pic_offset;
bool pic_paint, pic_paintBg, pic_painted, do_paint; bool pic_paint, pic_paintBg, pic_painted, do_paint;
int pic_align, pic_x, pic_y, pic_width, pic_height; int pic_align, pic_x, pic_y, pic_width, pic_height;
int maxWidth, maxHeight, picMode; int maxWidth, maxHeight, pic_paint_mode;
void initVarPicture(); void initVarPicture();
void init( const int x_pos, const int y_pos, const std::string& picture_name, const int alignment, bool has_shadow, 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); fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow);
public: public:
CComponentsPicture( const int x_pos, const int y_pos,
const std::string& picture_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);
CComponentsPicture( const int x_pos, const int y_pos, const int w_max, const int h_max, CComponentsPicture( const int x_pos, const int y_pos, const int w_max, const int h_max,
const std::string& picture_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF, 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); 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 setPictureOffset(const unsigned char offset){pic_offset = offset;};
inline void setPicturePaint(bool paint_p){pic_paint = paint_p;}; inline void setPicturePaint(bool paint_p){pic_paint = paint_p;};
inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;}; inline void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;};
inline void setPicture(const std::string& picture_name); inline void setPicture(const std::string& picture_name);
void setPictureAlign(const int alignment); void setPictureAlign(const int alignment);
inline bool isPicPainted(){return pic_painted;}; inline bool isPicPainted(){return pic_painted;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void hide(bool no_restore = false); void hide(bool no_restore = false);
inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;}; inline void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;};
}; };
class CComponentsText : public CComponentsItem class CComponentsText : public CComponentsItem
@@ -234,6 +239,11 @@ class CComponentsText : public CComponentsItem
void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES); void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES);
public: public:
CComponentsText(); CComponentsText();
CComponentsText(const char* text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL);
CComponentsText( const int x_pos, const int y_pos, const int w, const int h,
const char* text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_text = COL_MENUCONTENT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
~CComponentsText(); ~CComponentsText();
void hide(bool no_restore = false); void hide(bool no_restore = false);
@@ -256,24 +266,23 @@ class CComponentsInfoBox : public CComponentsText
CComponentsText * cctext; CComponentsText * cctext;
CComponentsPicture * pic; CComponentsPicture * pic;
std::string pic_default_name; std::string pic_default_name;
void paintPicture(); void paintPicture();
// void paintText();
void initVarInfobox(); void initVarInfobox();
std::string pic_name; std::string pic_name;
public: public:
CComponentsInfoBox(); CComponentsInfoBox();
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h,
const char* info_text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL, const char* info_text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
bool has_shadow = CC_SHADOW_OFF, 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); 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(); ~CComponentsInfoBox();
inline void setSpaceOffset(const int offset){x_offset = offset;}; inline void setSpaceOffset(const int offset){x_offset = offset;};
inline void setPicture(const std::string& picture_name){pic_name = picture_name;}; inline void setPicture(const std::string& picture_name){pic_name = picture_name;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
}; };
@@ -285,7 +294,7 @@ class CComponentsShapeCircle : public CComponentsItem
public: public:
CComponentsShapeCircle( const int x_pos, const int y_pos, const int diam, bool has_shadow = CC_SHADOW_ON, 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); 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 void setDiam(const int& diam){d=width=height=diam, corner_rad=d/2;};
inline int getDiam(){return d;}; inline int getDiam(){return d;};
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
@@ -296,7 +305,7 @@ 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);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
}; };
@@ -307,7 +316,7 @@ class CComponentsPIP : public CComponentsItem
public: public:
CComponentsPIP( const int x_pos, const int y_pos, const int percent, bool has_shadow = CC_SHADOW_OFF); CComponentsPIP( const int x_pos, const int y_pos, const int percent, bool has_shadow = CC_SHADOW_OFF);
~CComponentsPIP(); ~CComponentsPIP();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void hide(bool no_restore = false); void hide(bool no_restore = false);
}; };
@@ -416,24 +425,22 @@ class CComponentsTitleBar : public CComponentsItemBox
class CComponentsForm : public CComponentsItem class CComponentsForm : public CComponentsItem
{ {
protected:
std::vector<CComponentsItem*> v_cc_items;
void paintCCItems();
private: private:
CComponentsTitleBar *tb;
std::string tb_text, tb_icon;
void initVarForm(); void initVarForm();
void paintHead();
public: public:
CComponentsForm(); CComponentsForm();
CComponentsForm(const int x_pos, const int y_pos, const int w, const int h);
CComponentsForm(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);
~CComponentsForm(); ~CComponentsForm();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void hide(bool no_restore = false); void hide(bool no_restore = false);
void setCaption(const std::string& text); void addCCItem(CComponentsItem* cc_Item);
void setCaption(neutrino_locale_t locale_text);
void setIcon(const std::string& icon_name){tb_icon = icon_name;};
}; };
#endif #endif

View File

@@ -269,6 +269,42 @@ CComponentsText::CComponentsText()
initVarText(); initVarText();
} }
CComponentsText::CComponentsText(const char* text, const int mode, Font* font_text)
{
//CComponentsText
initVarText();
ct_text = text;
ct_text_mode = mode;
ct_font = font_text;
}
CComponentsText::CComponentsText( const int x_pos, const int y_pos, const int w, const int h,
const char* text, const int mode, Font* font_text,
bool has_shadow,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsText
initVarText();
//CComponents
x = x_pos,
y = y_pos,
width = w;
height = h;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
shadow = has_shadow;
ct_font = font_text;
ct_text = text;
ct_text_mode = mode;
ct_col_text = color_text;
}
CComponentsText::~CComponentsText() CComponentsText::~CComponentsText()
{ {
@@ -444,7 +480,7 @@ void CComponentsInfoBox::paintPicture()
{ {
//init and set icon paint position //init and set icon paint position
if (pic == NULL) if (pic == NULL)
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness/*+y_offset*/, ""); pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness/*+y_offset*/, 0, 0, "");
pic->setXPos(x+fr_thickness+x_offset); pic->setXPos(x+fr_thickness+x_offset);
pic->setYPos(y+fr_thickness); pic->setYPos(y+fr_thickness);
@@ -730,40 +766,27 @@ void CComponentsPIP::hide(bool no_restore)
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//sub class CComponentsPicture from CComponentsItem //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)
{
init(x_pos, y_pos, picture_name, alignment, has_shadow, color_frame, color_background, color_shadow);
maxWidth = 0;
maxHeight = 0;
picMode = CC_PIC_ICON;
initVarPicture();
}
CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos, const int w_max, const int h_max, CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos, const int w_max, const int h_max,
const std::string& picture_name, const int alignment, bool has_shadow, 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) fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
{ {
init(x_pos, y_pos, picture_name, alignment, has_shadow, color_frame, color_background, color_shadow); init(x_pos, y_pos, image_name, alignment, has_shadow, color_frame, color_background, color_shadow);
maxWidth = w_max; maxWidth = w_max;
maxHeight = h_max; maxHeight = h_max;
picMode = CC_PIC_IMAGE; pic_paint_mode = CC_PIC_IMAGE_MODE_AUTO,
initVarPicture(); initVarPicture();
} }
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& image_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, CComponentsItem //CComponents, CComponentsItem
initVarItem(); initVarItem();
//CComponentsPicture //CComponentsPicture
pic_name = picture_name; pic_name = image_name;
pic_align = alignment; pic_align = alignment;
pic_offset = 1; pic_offset = 1;
pic_paint = true; pic_paint = true;
@@ -805,9 +828,22 @@ void CComponentsPicture::initVarPicture()
pic_painted = false; pic_painted = false;
do_paint = false; do_paint = false;
if (picMode == CC_PIC_ICON) //set the image mode depends of name syntax, icon names contains no path,
//so we can detect the required image mode
if (pic_paint_mode == CC_PIC_IMAGE_MODE_AUTO){
if (!access(pic_name.c_str(), F_OK ))
pic_paint_mode = CC_PIC_IMAGE_MODE_ON;
else
pic_paint_mode = CC_PIC_IMAGE_MODE_OFF;
}
if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF){
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height); frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
else { pic_width = max(pic_width, maxWidth);
pic_height = max(pic_height, maxHeight);
}
if (pic_paint_mode == CC_PIC_IMAGE_MODE_ON) {
g_PicViewer->getSize(pic_name.c_str(), &pic_width, &pic_height); g_PicViewer->getSize(pic_name.c_str(), &pic_width, &pic_height);
if((pic_width > maxWidth) || (pic_height > maxHeight)) if((pic_width > maxWidth) || (pic_height > maxHeight))
g_PicViewer->rescaleImageDimensions(&pic_width, &pic_height, maxWidth, maxHeight); g_PicViewer->rescaleImageDimensions(&pic_width, &pic_height, maxWidth, maxHeight);
@@ -850,9 +886,9 @@ void CComponentsPicture::paint(bool do_save_bg)
pic_painted = false; pic_painted = false;
if (do_paint){ if (do_paint){
if (picMode == CC_PIC_ICON) if (pic_paint_mode == CC_PIC_IMAGE_MODE_OFF)
pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0, pic_offset, pic_paint, pic_paintBg, col_body); pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0, pic_offset, pic_paint, pic_paintBg, col_body);
else else if (pic_paint_mode == CC_PIC_IMAGE_MODE_ON)
pic_painted = g_PicViewer->DisplayImage(pic_name, pic_x, pic_y, pic_width, pic_height); pic_painted = g_PicViewer->DisplayImage(pic_name, pic_x, pic_y, pic_width, pic_height);
do_paint = false; do_paint = false;
} }
@@ -1080,7 +1116,7 @@ void CComponentsItemBox::paintImage(size_t index, bool newElement)
pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, v_element_data[index].width, pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, v_element_data[index].width,
v_element_data[index].height, v_element_data[index].element); v_element_data[index].height, v_element_data[index].element);
else else
pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, v_element_data[index].element); pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, 0, 0, v_element_data[index].element);
v_element_data[index].handler1 = (void*)pic; v_element_data[index].handler1 = (void*)pic;
} }
@@ -1448,18 +1484,53 @@ void CComponentsTitleBar::paint(bool do_save_bg)
//------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------
//sub class CComponentsForm from CComponentsItemBox //sub class CComponentsForm from CComponentsItem
CComponentsForm::CComponentsForm() CComponentsForm::CComponentsForm()
{ {
//CComponentsForm //CComponentsForm
initVarForm(); initVarForm();
} }
CComponentsForm::CComponentsForm(const int x_pos, const int y_pos, const int w, const int h)
{
//CComponentsForm
initVarForm();
//CComponents
x = x_pos;
y = y_pos;
width = w;
height = h;
}
CComponentsForm::CComponentsForm(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
//CComponentsForm
initVarForm();
//CComponents
x = x_pos;
y = y_pos;
width = w;
height = h;
shadow = has_shadow;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
}
CComponentsForm::~CComponentsForm() CComponentsForm::~CComponentsForm()
{ {
hide(); hide();
clearSavedScreen(); clearSavedScreen();
delete tb; for(size_t i=0; i<v_cc_items.size(); i++) {
delete v_cc_items[i];
v_cc_items[i] = NULL;
}
v_cc_items.clear();
clear(); clear();
} }
@@ -1467,9 +1538,9 @@ void CComponentsForm::initVarForm()
{ {
//CComponentsItem //CComponentsItem
initVarItem(); initVarItem();
//simple default dimensions //simple default dimensions
x = 0; x = 0;
y = 0; y = 0;
width = 150; width = 150;
height = 150; height = 150;
@@ -1480,57 +1551,50 @@ void CComponentsForm::initVarForm()
col_shadow = COL_MENUCONTENTDARK_PLUS_0; col_shadow = COL_MENUCONTENTDARK_PLUS_0;
corner_rad = RADIUS_LARGE; corner_rad = RADIUS_LARGE;
corner_type = CORNER_ALL; corner_type = CORNER_ALL;
//CComponentsForm //CComponentsForm
tb = NULL; v_cc_items.clear();
tb_text = "no caption";
tb_icon = ""; }
void CComponentsForm::addCCItem(CComponentsItem* cc_Item)
{
v_cc_items.push_back(cc_Item);
} }
void CComponentsForm::paint(bool do_save_bg) void CComponentsForm::paint(bool do_save_bg)
{ {
//paint body //paint body
paintInit(do_save_bg); paintInit(do_save_bg);
//paint header //paint items
paintHead(); paintCCItems();
} }
void CComponentsForm::paintHead() void CComponentsForm::paintCCItems()
{ {
//init header size_t items_count = v_cc_items.size();
if (tb == NULL){ int x_tmp = x-fr_thickness;
tb = new CComponentsTitleBar(); int y_tmp = y-fr_thickness;
// int w_tmp = (width-2*fr_thickness)/items_count;
// int h_tmp = (height-2*fr_thickness)/items_count;
for(size_t i=0; i<items_count; i++) {
//get current item position
int ccx = v_cc_items[i]->getXPos();
int ccy = v_cc_items[i]->getYPos();
//init icon //set adapted position onto form
if (!tb_icon.empty()) v_cc_items[i]->setXPos(x_tmp+ccx);
tb->addIcon(tb_icon, CC_ALIGN_LEFT); v_cc_items[i]->setYPos(y_tmp+ccy);
//init text //paint element without saved screen!
if (!tb_text.empty()) v_cc_items[i]->paint(CC_SAVE_SCREEN_NO);
tb->addText(tb_text, CC_ALIGN_LEFT);
int tbh = tb->getHeight(); //restore position
tb->setDimensionsAll(x, y, width, tbh); v_cc_items[i]->setXPos(ccx);
v_cc_items[i]->setYPos(ccy);
} }
//paint titlebar
tb->paint(CC_SAVE_SCREEN_NO);
}
void CComponentsForm::setCaption(const string& text)
{
if (tb){
delete tb;
tb = NULL;
}
tb_text = text;
}
void CComponentsForm::setCaption(neutrino_locale_t locale_text)
{
string tmptxt = g_Locale->getText(locale_text);
setCaption(tmptxt);
} }
void CComponentsForm::hide(bool no_restore) void CComponentsForm::hide(bool no_restore)
@@ -1538,6 +1602,3 @@ void CComponentsForm::hide(bool no_restore)
//hide body //hide body
hideContainer(no_restore); hideContainer(no_restore);
} }