CTestMenu: add sample code for CComponentsButtonRed

This commit is contained in:
2013-04-16 09:02:31 +02:00
parent 04afa10e02
commit b0846842f3
2 changed files with 23 additions and 2 deletions

View File

@@ -70,6 +70,7 @@ CTestMenu::CTestMenu()
header = NULL; header = NULL;
iconform = NULL; iconform = NULL;
window = NULL; window = NULL;
button = NULL;
} }
CTestMenu::~CTestMenu() CTestMenu::~CTestMenu()
@@ -82,6 +83,7 @@ CTestMenu::~CTestMenu()
delete header; delete header;
delete iconform; delete iconform;
delete window; delete window;
delete button;
} }
int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
@@ -328,6 +330,21 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
delete scanTs; delete scanTs;
return res; return res;
} }
else if (actionKey == "button"){
if (button == NULL)
button = new CComponentsButtonRed(100, 100, 100, 40, "Test");
if (!button->isPainted()){
if (button->isSelected())
button->setSelected(false);
else
button->setSelected(true);
button->paint();
}else
button->hide();
return res;
}
else if (actionKey == "circle"){ else if (actionKey == "circle"){
if (circle == NULL) if (circle == NULL)
circle = new CComponentsShapeCircle (100, 100, 100, false); circle = new CComponentsShapeCircle (100, 100, 100, false);
@@ -415,8 +432,9 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
else if (actionKey == "header"){ else if (actionKey == "header"){
int hh = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); int hh = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
if (header == NULL){ if (header == NULL){
header = new CComponentsHeader (100, 50, 500, hh, "Test-Header", NEUTRINO_ICON_INFO, CComponentsHeader::CC_BTN_HELP | CComponentsHeader::CC_BTN_EXIT | CComponentsHeader::CC_BTN_MENU); header = new CComponentsHeader (100, 50, 500, hh, "Test-Header"/*, NEUTRINO_ICON_INFO, CComponentsHeader::CC_BTN_HELP | CComponentsHeader::CC_BTN_EXIT | CComponentsHeader::CC_BTN_MENU*/);
header->addHeaderButton(NEUTRINO_ICON_BUTTON_RED); // header->addHeaderButton(NEUTRINO_ICON_BUTTON_RED);
header->setHeaderDefaultButtons(CComponentsHeader::CC_BTN_HELP | CComponentsHeader::CC_BTN_EXIT | CComponentsHeader::CC_BTN_MENU);
} }
// else //For existing instances it's recommended // else //For existing instances it's recommended
// //to remove old button icons before add new buttons, otherwise icons will be appended. // //to remove old button icons before add new buttons, otherwise icons will be appended.
@@ -549,6 +567,7 @@ void CTestMenu::showCCTests(CMenuWidget *widget)
{ {
widget->setSelected(selected); widget->setSelected(selected);
widget->addIntroItems(); widget->addIntroItems();
widget->addItem(new CMenuForwarderNonLocalized("Button", true, NULL, this, "button"));
widget->addItem(new CMenuForwarderNonLocalized("Circle", true, NULL, this, "circle")); widget->addItem(new CMenuForwarderNonLocalized("Circle", true, NULL, this, "circle"));
widget->addItem(new CMenuForwarderNonLocalized("Square", true, NULL, this, "square")); widget->addItem(new CMenuForwarderNonLocalized("Square", true, NULL, this, "square"));
widget->addItem(new CMenuForwarderNonLocalized("Picture", true, NULL, this, "picture")); widget->addItem(new CMenuForwarderNonLocalized("Picture", true, NULL, this, "picture"));

View File

@@ -33,6 +33,7 @@
#include <gui/widget/icons.h> #include <gui/widget/icons.h>
#include <gui/components/cc.h> #include <gui/components/cc.h>
#include <gui/components/cc_frm.h> #include <gui/components/cc_frm.h>
#include <gui/components/cc_frm_button.h>
#define TEST_MENU #define TEST_MENU
#include <string> #include <string>
@@ -48,6 +49,7 @@ class CTestMenu : public CMenuTarget
CComponentsHeader *header; CComponentsHeader *header;
CComponentsIconForm *iconform; CComponentsIconForm *iconform;
CComponentsWindow *window; CComponentsWindow *window;
CComponentsButton *button;
int width, selected; int width, selected;
void showTestMenu(); void showTestMenu();