Initial commit
This commit is contained in:
292
MyCode/Gui/PowerSuplyCfg.cpp
Normal file
292
MyCode/Gui/PowerSuplyCfg.cpp
Normal file
@@ -0,0 +1,292 @@
|
||||
#include "PowerSuplyCfg.h"
|
||||
#include "Runtime.h"
|
||||
|
||||
void TPowerSuplyCfg::Init(int x1, int y1, int aW, int aH, int OwnerX, int OwnerY, u32 aColor)
|
||||
{
|
||||
#define CH 30 //Caption Height
|
||||
unsigned short Left,Right, Top, Bottom, Width, Height, i;
|
||||
Bound.SetBySize(OwnerX + x1, OwnerY + y1, aW, aH);
|
||||
Left = Bound.Left +3;
|
||||
Top = Bound.Top+3;
|
||||
Width = aW - 7;
|
||||
Height = aH - 7;
|
||||
Right = Bound.Right -4;
|
||||
Bottom = Bound.Bottom -4;
|
||||
Caption.Init(Left,Top,Width, CH, 0, 0, clWhite, clMaroon);
|
||||
Content.Set(Left, Top+CH, Right, Bottom);
|
||||
Color = aColor;
|
||||
#undef CH
|
||||
|
||||
Caption.Border.Color = clGray;
|
||||
TMyString::sFromStr("安装->电源数量配置", Caption.Text);
|
||||
Caption.Visible = 1;
|
||||
|
||||
CtlIndex = 0;
|
||||
OnActive = 0;
|
||||
|
||||
Sta = 0;
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::RenderBackGround(void)
|
||||
{
|
||||
RectFillRender(Content.Left, Content.Top, Content.Right, Content.Bottom, Color);
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::RenderBackGround(unsigned int aClr)
|
||||
{
|
||||
RectFillRender(Content.Left, Content.Top, Content.Right, Content.Bottom, aClr);
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::DrawSelf(void)
|
||||
{
|
||||
unsigned int x, y, x2, y2, w, h;
|
||||
|
||||
VertLineRender(Bound.Left, Bound.Top, Bound.Height -1, 0xFFFFFFFF);
|
||||
VertLineRender(Bound.Right -1, Bound.Top +1, Bound.Height -2, 0xFF808080);
|
||||
VertLineRender(Bound.Right, Bound.Top, Bound.Height, 0xFF404040);
|
||||
|
||||
HorizLineRender(Bound.Left, Bound.Top, Bound.Width - 1, 0xFFFFFFFF);
|
||||
HorizLineRender(Bound.Left +1, Bound.Bottom -1, Bound.Width - 2, 0xFF808080);
|
||||
HorizLineRender(Bound.Left, Bound.Bottom, Bound.Width, 0xFF404040);
|
||||
|
||||
x = Bound.Left +2 ;
|
||||
x2 = Bound.Right -2;
|
||||
y = Bound.Top +2;
|
||||
y2 = Bound.Bottom - 2;
|
||||
w = Bound.Width -4;
|
||||
h = Bound.Height - 4;
|
||||
VertLineRender (x, y, h-1, 0xFF808080);
|
||||
HorizLineRender (x, y, w-1, 0xFF808080);
|
||||
|
||||
VertLineRender (x+1, y+1, h-2, 0xFF404040);
|
||||
HorizLineRender (x+1, y+1, w-2, 0xFF404040);
|
||||
|
||||
VertLineRender (x2-1, y+1, h-2, 0xFFD4D0C8);
|
||||
HorizLineRender (x+1, y2-1, w-2, 0xFFD4D0C8);
|
||||
|
||||
VertLineRender (x2, y, h, 0xFFFFFFFF);
|
||||
HorizLineRender (x, y2, w, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::Show(void)
|
||||
{
|
||||
RenderBackGround();
|
||||
DrawSelf();
|
||||
Caption.Show();
|
||||
|
||||
TextRender_string24(66, 180, clNearBlack, "1.上下键切换编辑项目");
|
||||
TextRender_string24(66, 220, clNearBlack, "2.左右键编辑或更改设定");
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::FullRedraw(int Prm)
|
||||
{
|
||||
if(Prm == 0){
|
||||
Show();
|
||||
aPanel->Show();
|
||||
ShowSta();
|
||||
}else
|
||||
if(Prm == 1){
|
||||
RectFillRender(GuiRedrawDataList[1][0], GuiRedrawDataList[1][1], GuiRedrawDataList[1][2], GuiRedrawDataList[1][3], Color);
|
||||
aPanel->Show();
|
||||
ShowSta();
|
||||
|
||||
//if(IsPermission)PmsIntervene4Gui.ReDraw4GuiRecall();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//______________________________________________________________________________________________________________________________
|
||||
|
||||
void TPowerSuplyCfg::Check4Selected(void)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i=0; i<4;i++)aPanel->Edit[i].Selected = 0;
|
||||
for(i=0; i<1;i++)aPanel->Btn[i].Selected = 0;
|
||||
if(1){
|
||||
switch(CtlIndex){
|
||||
case 0:
|
||||
aPanel->Edit[1].Selected = 1;
|
||||
break;
|
||||
//case 1:
|
||||
// aPanel->Edit[1].Selected = 1;
|
||||
// break;
|
||||
//case 2:
|
||||
// aPanel->Edit[2].Selected = 1;
|
||||
// break;
|
||||
case 1:
|
||||
aPanel->Btn[0].Selected = 1;
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________________________________________________________
|
||||
|
||||
TGuiMsgReturn TPowerSuplyCfg::KeyIn(unsigned char aKey)
|
||||
{
|
||||
TGuiMsgReturn aMsg = guiMsgNone;
|
||||
TGuiMsgReturn MBoxMsg = guiMsgNone;
|
||||
int iVal;
|
||||
|
||||
switch(aKey){
|
||||
case VK_DELETE:
|
||||
case VK_0:
|
||||
case VK_1:
|
||||
case VK_2:
|
||||
case VK_3:
|
||||
case VK_4:
|
||||
case VK_5:
|
||||
case VK_6:
|
||||
case VK_7:
|
||||
case VK_8:
|
||||
case VK_9:
|
||||
case VK_LEFT:
|
||||
case VK_RIGHT:
|
||||
if(CtlIndex == 0){
|
||||
if(WroteSubCount == 0)WroteSubCount = 1;
|
||||
else if(WroteSubCount == 1)WroteSubCount = 2;
|
||||
else WroteSubCount = 0;
|
||||
aPanel->Edit[1].Str.FromUInt2Dg(WroteSubCount);
|
||||
aPanel->Edit[1].SetPstTail();
|
||||
aPanel->Edit[1].Show();
|
||||
}
|
||||
break;
|
||||
case VK_UP:
|
||||
if(CtlIndex >0){
|
||||
CtlIndex--;
|
||||
Check4Selected();
|
||||
aPanel->ReDrawItems();
|
||||
}
|
||||
break;
|
||||
case VK_DOWN:
|
||||
if(CtlIndex <1){
|
||||
CtlIndex++;
|
||||
Check4Selected();
|
||||
aPanel->ReDrawItems();
|
||||
}
|
||||
break;
|
||||
case VK_TAB:
|
||||
break;
|
||||
case VK_EXECUTE:
|
||||
//Save Data Here
|
||||
if(CtlIndex == 1){
|
||||
Record.WritePowerSuplyCount(WroteMianCount, WroteSubCount);
|
||||
Record.ReadPowerSuplyCount();
|
||||
//if( (WroteMianCount == PowerPrmValue.MainCount) && (WroteSubCount == PowerPrmValue.SubCount) ){
|
||||
// ShowSta(1);
|
||||
// KeyPad.IsSendPowerSuplyCount = 1;
|
||||
//}else{
|
||||
// ShowSta(0);
|
||||
//}
|
||||
}
|
||||
break;
|
||||
case VK_RETURN:
|
||||
aMsg = guiMsgReturn;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(VK_EXECUTE != aKey){
|
||||
ShowSta(0);
|
||||
}
|
||||
|
||||
return aMsg;
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::ShowSta()
|
||||
{
|
||||
if(Sta == 0){
|
||||
TextRender_string24(66, 96, clNearBlack, Color, " ");
|
||||
}else
|
||||
if(Sta == 1){
|
||||
TextRender_string24(66, 96, clNearBlack, Color, "保存成功 ");
|
||||
}
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::ShowSta(int aSta)
|
||||
{
|
||||
Sta = aSta;
|
||||
ShowSta();
|
||||
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::InitPanel(void)
|
||||
{
|
||||
int x,y,x2,y2,i;
|
||||
|
||||
y = y+10;
|
||||
|
||||
aPanel->Init(350,100,424,220,0,0,clFrmFace, bvRaised);
|
||||
aPanel->Caption.Init(351,101, 424-3 ,32,0,0,clFrmFace,clFrmFace);
|
||||
|
||||
x = aPanel->Bound.Left;
|
||||
y = aPanel->Bound.Top;
|
||||
|
||||
aPanel->SText[0].Init(10,7,102,30,x,y,clNearBlack,clFrmFace);
|
||||
aPanel->SText[1].Init(10,39,102,30,x,y,clNearBlack,clFrmFace);
|
||||
//aPanel->SText[2].Init(10,71,102,30,x,y,clNearBlack,clFrmFace);
|
||||
//aPanel->SText[3].Init(10,103,102,30,x,y,clNearBlack,clFrmFace);
|
||||
|
||||
TMyString::sFromStr("主电数量", aPanel->SText[0].Text);
|
||||
TMyString::sFromStr("副电源数量", aPanel->SText[1].Text);
|
||||
TMyString::sFromStr("--", aPanel->SText[2].Text);
|
||||
TMyString::sFromStr("--", aPanel->SText[3].Text);
|
||||
|
||||
aPanel->Edit[0].Init(260,7,148,30,x,y,clNearBlack,clNearWhite);
|
||||
aPanel->Edit[1].Init(260,39,148,30,x,y,clNearBlack,clNearWhite);
|
||||
//aPanel->Edit[2].Init(260,71,148,30,x,y,clNearBlack,clNearWhite);
|
||||
//aPanel->Edit[3].Init(260,103,148,30,x,y,clNearBlack,clNearWhite);
|
||||
|
||||
aPanel->Edit[0].IsShowCursor = 0;
|
||||
aPanel->Edit[0].Enable = 0;
|
||||
aPanel->Edit[0].Visible = 1;
|
||||
aPanel->Edit[1].IsShowCursor = 0;
|
||||
aPanel->Edit[1].Enable = 0;
|
||||
aPanel->Edit[1].Visible = 1;
|
||||
for(i=1; i<2;i++){
|
||||
aPanel->Edit[i].Enable = 1;
|
||||
aPanel->Edit[i].Visible = 1;
|
||||
aPanel->Edit[i].SetMaxLen(3);
|
||||
aPanel->Edit[i].SetInputMaskEn();
|
||||
aPanel->Edit[i].Str.FromStr("20");
|
||||
aPanel->Edit[i].SetPstTail();
|
||||
}
|
||||
|
||||
aPanel->Btn[0].Init(260,150,148,36,x,y,clNearBlack,clFrmFace);
|
||||
aPanel->Btn[0].Caption.FromStr(" 保存设置");
|
||||
|
||||
for(i=0; i<1;i++){
|
||||
aPanel->Btn[i].Enable = 1;
|
||||
aPanel->Btn[i].Visible = 1;
|
||||
aPanel->Btn[i].SetCaptionLeftSpacing(2);
|
||||
aPanel->Btn[i].SelectedColor = clBlue;
|
||||
}
|
||||
|
||||
aPanel->Caption.Visible = 1;
|
||||
|
||||
aPanel->Show();
|
||||
LoadData();
|
||||
Check4Selected();
|
||||
aPanel->ReDrawItems();
|
||||
}
|
||||
|
||||
void TPowerSuplyCfg::LoadData()
|
||||
{
|
||||
WroteMianCount = PowerPrmValue.MainCount;
|
||||
//WroteSubCount = PowerPrmValue.SubCount;
|
||||
|
||||
aPanel->Edit[0].Str.FromUInt2Dg(WroteMianCount);
|
||||
aPanel->Edit[1].Str.FromUInt2Dg(WroteSubCount);
|
||||
|
||||
aPanel->Edit[0].SetPstTail();
|
||||
aPanel->Edit[1].SetPstTail();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user