#include "Frm01.h"

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

Frm01::~Frm01() {
}

void Frm01::onInit(){
}

void Frm01::createParts() {
	setMainArg(0, 0, 1024, 600);
	setMainStyle(0, 0x2957ad, 0x2957ad, 0, 255, 0, 0xc0c0c0);

	/*----------------------------- Video : wMVideo1                     -----------------------------*/
	wMVideo1 = new STTFFmpeg(p_rt, this, "wMVideo1");
	wMVideo1->channel = 0;
	wMVideo1->setRotate(0);
	wMVideo1->setMainArg(17, 128, 480, 320, "rtsp://admin:whxtt2022@192.168.1.107:554/cam/realmonitor?channel=1&subtype=0");

	/*----------------------------- Video : wMVideo2                     -----------------------------*/
	wMVideo2 = new STTFFmpeg(p_rt, this, "wMVideo2");
	wMVideo2->channel = 1;
	wMVideo2->setRotate(0);
	wMVideo2->setMainArg(522, 128, 480, 320, "rtsp://admin:whxtt2022@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0");

	/*----------------------------- Label : wMLabel1                     -----------------------------*/
	wMLabel1 = new STTLabel(p_rt, this, "wMLabel1");
	wMLabel1->setMainArg(391, 6, 227, 60, "监 控 画 面", TextAlign::CENTER, LabelLongMode::CLIP, 30);
	wMLabel1->setFonts(0xffffff, 30, "文泉驿微米黑", 0);
	wMLabel1->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMLabel1->setFormatText(TextAlign::CENTER, LabelLongMode::CLIP, 30);

	/*----------------------------- Button : wMButton1                   -----------------------------*/
	wMButton1 = new STTButton(p_rt, this, "wMButton1", 0);
	wMButton1->setMainArg(1, 530, 254, 69, false);
	wMButton1->setPressedArg("监 控 画 面", 0x0, "文泉驿微米黑", 22, 0);
	wMButton1->setPressedStyle(0, 255, 0x2957ad, 0x999999, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton1->setReleasedArg("监 控 画 面", 0xffffff, "文泉驿微米黑", 24, 0);
	wMButton1->setReleasedStyle(0, 255, 0x2957ad, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	/*----------------------------- Button : wMButton2                   -----------------------------*/
	wMButton2 = new STTButton(p_rt, this, "wMButton2", 0);
	wMButton2->setMainArg(257, 530, 254, 69, false);
	wMButton2->setPressedArg("项 目 介 绍", 0xffffff, "文泉驿微米黑", 22, 0);
	wMButton2->setPressedStyle(0, 255, 0x5990f6, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton2->setReleasedArg("项 目 介 绍", 0xffffff, "文泉驿微米黑", 24, 0);
	wMButton2->setReleasedStyle(0, 255, 0x5990f6, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton2->onEventHandler(Event::CLICKED, this, (EHandler) &Frm01::wMButton2_clk_cb);

	/*----------------------------- Button : wMButton3                   -----------------------------*/
	wMButton3 = new STTButton(p_rt, this, "wMButton3", 0);
	wMButton3->setMainArg(513, 530, 254, 69, false);
	wMButton3->setPressedArg("产 品 介 绍", 0xffffff, "文泉驿微米黑", 22, 0);
	wMButton3->setPressedStyle(0, 255, 0x5990f6, 0x999999, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton3->setReleasedArg("产 品 介 绍", 0xffffff, "文泉驿微米黑", 24, 0);
	wMButton3->setReleasedStyle(0, 255, 0x5990f6, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton3->onEventHandler(Event::CLICKED, this, (EHandler) &Frm01::wMButton3_clk_cb);

	/*----------------------------- Button : wMButton4                   -----------------------------*/
	wMButton4 = new STTButton(p_rt, this, "wMButton4", 0);
	wMButton4->setMainArg(769, 530, 254, 69, false);
	wMButton4->setPressedArg("设 备 信 息", 0xffffff, "文泉驿微米黑", 22, 0);
	wMButton4->setPressedStyle(0, 255, 0x5990f6, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton4->setReleasedArg("设 备 信 息", 0xffffff, "文泉驿微米黑", 24, 0);
	wMButton4->setReleasedStyle(0, 255, 0x5990f6, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton4->onEventHandler(Event::CLICKED, this, (EHandler) &Frm01::wMButton4_clk_cb);

	/*----------------------------- Timer : wMTimer1                     -----------------------------*/
	wMTimer1 = new STTTimer(p_rt, this, "wMTimer1", false);
	wMTimer1->set(500, 1);
	wMTimer1->onEventHandler(Event::READY, this, (EHandler) &Frm01::wMTimer1_timer_cb);

	/*----------------------------- Image : wMImage1                     -----------------------------*/
	wMImage1 = new STTImage(p_rt, this, "wMImage1");
	wMImage1->setMainArg(0, 0, 171, 76);
	wMImage1->addStateImg("0", "./images/img17435568919082_171X76R0.png");

	/*called after widget created.*/

	return; //createParts END
}

void Frm01::onLoad(){
	wMTimer1->start();

}

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

void Frm01::onDispose(){

}

void Frm01::wMTimer1_timer_cb(uint16_t code, LvEvent e) {
	wMVideo1->play();
	wMVideo2->play();
}

void Frm01::wMButton2_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton2（项 目 介 绍）的点击事件*/
	pm->open("Frm02",PageMode::MODAL);
}

void Frm01::wMButton3_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton3（产 品 介 绍）的点击事件*/
	pm->open("Frm03",PageMode::MODAL);
}

void Frm01::wMButton4_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton4（设 备 信 息）的点击事件*/
	pm->open("Frm04",PageMode::MODAL);
}
