#include "Frm12.h"

Frm12::Frm12(HmiApp* app, STTWidget *par, const string& id, const string& desc) : STTPage(app->getRuntime(), par, id, desc) {
	hmiApp = app;
}

Frm12::~Frm12() {
}

void Frm12::onInit() {

}

void Frm12::createParts() {
	setMainArg(0, 0, 1024, 420);
	setMainStyle(0, 0xffffff, 0xffff, 0, 255, 0, 0xc0c0c0);

	/*----------------------------- Panel : wMPanel3                     -----------------------------*/
	wMPanel3 = new STTPanel(p_rt, this, "wMPanel3");
	wMPanel3->setMainArg(0, 0, 800, 420, 2);
	wMPanel3->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 255, 1, 0xc0c0c0);

	/*----------------------------- Panel : wMPanel2                     -----------------------------*/
	wMPanel2 = new STTPanel(p_rt, this, "wMPanel2");
	wMPanel2->setMainArg(800, 0, 224, 420, 0);
	wMPanel2->setMainStyle(0, 0x8080c0, 0xffffff, GradDir::NONE, 255, 1, 0xc0c0c0);

	/*----------------------------- MSwitch : wMMSwitch6                 -----------------------------*/
	wMMSwitch6 = new STTButton(p_rt, wMPanel2, "wMMSwitch6", 2);
	wMMSwitch6->setMainArg(41, 149, 144, 52, false);
	wMMSwitch6->enStateLabel();
	wMMSwitch6->getStateLabel()->setMainArg(26, 13, 91, 26, "", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMMSwitch6->getStateLabel()->setFonts(0x0, 15, "文泉驿微米黑", 0);
	wMMSwitch6->getStateLabel()->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMMSwitch6->getStateLabel()->setFormatText(TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMMSwitch6->setImg("1", "./images/button_6-1_144X52X808080.svg", "CO2历史曲线");
	wMMSwitch6->setImg("0", "./images/button_6-0_144X52Xc0c0c0.svg", "CO2历史曲线");
	wMMSwitch6->onEventHandler(Event::CLICKED, this, (EHandler) &Frm12::wMMSwitch6_clk_cb);

	/*----------------------------- MSwitch : wMMSwitch7                 -----------------------------*/
	wMMSwitch7 = new STTButton(p_rt, wMPanel2, "wMMSwitch7", 2);
	wMMSwitch7->setMainArg(41, 222, 144, 52, false);
	wMMSwitch7->enStateLabel();
	wMMSwitch7->getStateLabel()->setMainArg(36, 13, 72, 26, "", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMMSwitch7->getStateLabel()->setFonts(0x0, 16, "文泉驿微米黑", 0);
	wMMSwitch7->getStateLabel()->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMMSwitch7->getStateLabel()->setFormatText(TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMMSwitch7->setImg("1", "./images/button_6-1_144X52X808080.svg", "环境曲线");
	wMMSwitch7->setImg("0", "./images/button_6-0_144X52Xc0c0c0.svg", "环境曲线");
	wMMSwitch7->onEventHandler(Event::CLICKED, this, (EHandler) &Frm12::wMMSwitch7_clk_cb);

	/*----------------------------- MSwitch : wMMSwitch8                 -----------------------------*/
	wMMSwitch8 = new STTButton(p_rt, wMPanel2, "wMMSwitch8", 2);
	wMMSwitch8->setMainArg(41, 71, 144, 52, false);
	wMMSwitch8->enStateLabel();
	wMMSwitch8->getStateLabel()->setMainArg(26, 13, 91, 26, "", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMMSwitch8->getStateLabel()->setFonts(0x0, 15, "文泉驿微米黑", 0);
	wMMSwitch8->getStateLabel()->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMMSwitch8->getStateLabel()->setFormatText(TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMMSwitch8->setImg("1", "./images/button_6-1_144X52X808080.svg", "实时曲线");
	wMMSwitch8->setImg("0", "./images/button_6-0_144X52Xc0c0c0.svg", "实时曲线");
	wMMSwitch8->onEventHandler(Event::CLICKED, this, (EHandler) &Frm12::wMMSwitch8_clk_cb);

	/*called after widget created.*/

	return; //createParts END
}

void Frm12::onLoad() {
	pm->open("Frm19", PageMode::EMBEDDED, wMPanel3);

}

bool Frm12::onClosing() {
	return true;
}

void Frm12::onDispose() {

}

void Frm12::wMMSwitch6_clk_cb(uint16_t code, LvEvent e) {
	pm->close("Frm19");
	pm->close("Frm16");
	pm->open("Frm13", PageMode::EMBEDDED, wMPanel3);
}

void Frm12::wMMSwitch7_clk_cb(uint16_t code, LvEvent e) {
	pm->close("Frm19");
	pm->close("Frm13");
	pm->open("Frm16", PageMode::EMBEDDED, wMPanel3);
}

void Frm12::wMMSwitch8_clk_cb(uint16_t code, LvEvent e) {
	pm->close("Frm16");
	pm->close("Frm16");
	pm->open("Frm19", PageMode::EMBEDDED, wMPanel3);
}
