#include "Frm02.h"

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

Frm02::~Frm02() {
}

void Frm02::onInit() {

}

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

	/*----------------------------- 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, 0x5990f6, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton1->setReleasedArg("监 控 画 面", 0xffffff, "文泉驿微米黑", 24, 0);
	wMButton1->setReleasedStyle(0, 255, 0x5990f6, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton1->onEventHandler(Event::CLICKED, this, (EHandler) &Frm02::wMButton1_clk_cb);

	/*----------------------------- 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, 0x2957ad, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	wMButton2->setReleasedArg("项 目 介 绍", 0xffffff, "文泉驿微米黑", 24, 0);
	wMButton2->setReleasedStyle(0, 255, 0x2957ad, 0x2957ad, 0, 0, 0x999999, 1, 0xebebeb);
	/*----------------------------- 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, 0x2957ad, 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) &Frm02::wMButton3_clk_cb);

	/*----------------------------- Button : wMButton4                   -----------------------------*/
	wMButton4 = new STTButton(p_rt, this, "wMButton4", 0);
	wMButton4->setMainArg(769, 530, 254, 69, false);
	wMButton4->setPressedArg("设 备 信 息", 0xffffff, "文泉驿微米黑", 24, 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) &Frm02::wMButton4_clk_cb);

	/*----------------------------- 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);

	/*----------------------------- Label : wMLabel3                     -----------------------------*/
	wMLabel3 = new STTLabel(p_rt, this, "wMLabel3");
	wMLabel3->setMainArg(93, 103, 838, 379, "", TextAlign::LEFT, LabelLongMode::WRAP, 30);
	wMLabel3->setFonts(0xffffff, 22, "文泉驿微米黑", 0);
	wMLabel3->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 0, 0x0, 0);
	wMLabel3->setFormatText(TextAlign::LEFT, LabelLongMode::WRAP, 30);

	/*----------------------------- 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 Frm02::onLoad() {
	string text = "该样例工程主要展示了两路摄像头的出流及播放效果。\n\n"
			"两路摄像头均采用大华摄像头，出流地址为：\n"
			"rtsp://username:password@ip:port/cam/realmonitor?channel=1&subtype=0\n\n"
			"除了大华摄像头，目前本IDE还支持海康威视摄像头，出流地址为：\n"
			"rtsp://username:password@ip:port/h264/ch1/main/av_stream\n\n"
			"除了正常的出流显示外，还支持对视频的截图保存。具体详情可以查看相关文档。\n"
			"https://help.simtutai.cn/";
	wMLabel3->setText(text);
}

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

void Frm02::onDispose() {

}

void Frm02::wMButton1_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton1（监 控 画 面）的点击事件*/
	pm->close("Frm02");
}

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

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