CComponentsWindow: add sub class CComponentsWindow

This commit is contained in:
2012-11-30 22:53:55 +01:00
parent 7ac1550277
commit fa9ffdd46e
4 changed files with 116 additions and 5 deletions

View File

@@ -547,4 +547,31 @@ class CComponentsHeader : public CComponentsForm
void removeHeaderButtons();
};
class CComponentsWindow : public CComponentsForm
{
private:
CComponentsHeader * ccw_head;
std::string ccw_caption;
const char* ccw_icon_name;
void initHeader();
void initCCWItems();
protected:
void initVarWindow();
public:
enum
{
CC_WINDOW_ITEM_HEADER = 0
};
CComponentsWindow();
~CComponentsWindow();
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
void refresh(){initCCWItems();};
void setWindowCaption(const std::string& text){ccw_caption = text;};
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
};
#endif

View File

@@ -359,6 +359,7 @@ void CComponentsText::initCCText()
ct_textbox->setWindowPos(ct_box);
ct_textbox->setTextBorderWidth(0);
ct_textbox->enableBackgroundPaint(false);
ct_textbox->setBackGroundColor(col_body);
ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type);
ct_textbox->setTextColor(ct_col_text);
ct_textbox->setWindowMaxDimensions(ct_box->iWidth, ct_box->iHeight);
@@ -404,6 +405,7 @@ void CComponentsText::paint(bool do_save_bg)
void CComponentsText::hide(bool no_restore)
{
if (ct_textbox)
ct_textbox->hide();
hideCCItem(no_restore);
@@ -1532,7 +1534,9 @@ void CComponentsForm::clearCCItems()
{
if (v_cc_items.empty())
return;
#ifdef DEBUG_CC
printf("[CComponentsForm] %s... cleanup %d form cc-items\n", __FUNCTION__, v_cc_items.size());
#endif
for(size_t i=0; i<v_cc_items.size(); i++) {
if (v_cc_items[i])
delete v_cc_items[i];
@@ -1910,6 +1914,7 @@ void CComponentsHeader::initCCHeaderText()
cch_text_obj = new CComponentsText(cch_text_x, cch_items_y, width-cch_icon_w-fr_thickness, height-2*fr_thickness, cch_text.c_str());
cch_text_obj->setTextFont(cch_font);
cch_text_obj->setTextColor(cch_col_text);
cch_text_obj->setColorBody(col_body);
cch_text_obj->doPaintBg(false);
//corner of text item
@@ -1920,10 +1925,10 @@ void CComponentsHeader::initCCHeaderText()
void CComponentsHeader::initCCHItems()
{
#if 0
//clean up first possible old item objects, includes delete and clean up vector
clearCCItems();
//clean up first possible old item objects, includes delete and clean up vector
clearCCItems();
#endif
//init icon
initCCHeaderIcon();
@@ -1942,7 +1947,7 @@ void CComponentsHeader::initCCHItems()
addCCItem(cch_btn_obj); //buttons
}
void CComponentsHeader::paint(bool do_save_bg)
{
//paint body
@@ -2121,3 +2126,57 @@ void CComponentsIconForm::paint(bool do_save_bg)
//paint
paintCCItems();
}
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsWindow inherit from CComponentsForm
CComponentsWindow::CComponentsWindow()
{
initVarWindow();
}
void CComponentsWindow::initVarWindow()
{
//CComponentsForm
initVarForm();
ccw_head = NULL;
ccw_caption = "";
ccw_icon_name = NULL;
setShadowOnOff(true);
}
CComponentsWindow::~CComponentsWindow()
{
if (ccw_head)
delete ccw_head;
}
void CComponentsWindow::initHeader()
{
if (ccw_head == NULL)
ccw_head = new CComponentsHeader();
ccw_head->setXPos(0);
ccw_head->setYPos(0);
ccw_head->setWidth(width);
ccw_head->setHeaderIcon(ccw_icon_name);
ccw_head->setHeaderText(ccw_caption);
}
void CComponentsWindow::initCCWItems()
{
initHeader();
if (ccw_head)
addCCItem(ccw_head);
}
void CComponentsWindow::paint(bool do_save_bg)
{
//paint body
paintInit(do_save_bg);
//paint
paintCCItems();
}

View File

@@ -70,6 +70,7 @@ CTestMenu::CTestMenu()
txt = NULL;
header = NULL;
iconform = NULL;
window = NULL;
}
CTestMenu::~CTestMenu()
@@ -82,6 +83,7 @@ CTestMenu::~CTestMenu()
delete txt;
delete header;
delete iconform;
delete window;
}
int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
@@ -498,6 +500,27 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
}
return res;
}
else if (actionKey == "window"){
if (window == NULL){
window = new CComponentsWindow();
window->setWindowCaption("|.....................|");
window->setDimensionsAll(50, 50, 800, 480);
window->setWindowIcon(NEUTRINO_ICON_INFO);
}
else{
// window->setDimensionsAll(50, 50, 800, 480);
window->setWindowIcon(NEUTRINO_ICON_LOCK);
window->setWindowCaption("Test");
}
window->refresh();
if (!window->isPainted())
window->paint();
else
window->hide();
return res;
}
showTestMenu();
@@ -546,6 +569,7 @@ void CTestMenu::showCCTests(CMenuWidget *widget)
widget->addItem(new CMenuForwarderNonLocalized("Text", true, NULL, this, "text"));
widget->addItem(new CMenuForwarderNonLocalized("Header", true, NULL, this, "header"));
widget->addItem(new CMenuForwarderNonLocalized("Icon-Form", true, NULL, this, "iconform"));
widget->addItem(new CMenuForwarderNonLocalized("Window", true, NULL, this, "window"));
}
void CTestMenu::showHWTests(CMenuWidget *widget)

View File

@@ -47,6 +47,7 @@ class CTestMenu : public CMenuTarget
CComponentsText *txt;
CComponentsHeader *header;
CComponentsIconForm *iconform;
CComponentsWindow *window;
int width, selected;
void showTestMenu();