//--------------------------------------------------------------------------- #include #include "AppGlobalF.h" #include "ITSSkinF.h" #include "ITSUtilF.h" #include "CenterCommF.h" #include "WindowMsgF.h" #pragma hdrstop #include "VMSMODL0F.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "cxContainer" #pragma link "cxControls" #pragma link "cxEdit" #pragma link "cxGraphics" #pragma link "cxGroupBox" #pragma link "cxLookAndFeelPainters" #pragma link "cxLookAndFeels" #pragma link "dxSkinBlack" #pragma link "dxSkinMcSkin" #pragma link "dxSkinsCore" #pragma link "dxSkinBlue" #pragma link "dxSkinCaramel" #pragma link "dxSkinCoffee" #pragma link "dxSkinDarkRoom" #pragma link "dxSkinDarkSide" #pragma link "dxSkinFoggy" #pragma link "dxSkinGlassOceans" #pragma link "dxSkiniMaginary" #pragma link "dxSkinLilian" #pragma link "dxSkinLiquidSky" #pragma link "dxSkinLondonLiquidSky" #pragma link "dxSkinMoneyTwins" #pragma link "dxSkinOffice2007Black" #pragma link "dxSkinOffice2007Blue" #pragma link "dxSkinOffice2007Green" #pragma link "dxSkinOffice2007Pink" #pragma link "dxSkinOffice2007Silver" #pragma link "dxSkinOffice2010Black" #pragma link "dxSkinOffice2010Blue" #pragma link "dxSkinOffice2010Silver" #pragma link "dxSkinSeven" #pragma link "dxSkinSharp" #pragma link "dxSkinSilver" #pragma link "dxSkinStardust" #pragma link "cxClasses" #pragma link "cxCustomData" #pragma link "cxData" #pragma link "cxDataStorage" #pragma link "cxFilter" #pragma link "cxGrid" #pragma link "cxGridCustomTableView" #pragma link "cxGridCustomView" #pragma link "cxGridLevel" #pragma link "cxGridTableView" #pragma link "cxStyles" #pragma link "cxTextEdit" #pragma link "dxSkinscxPCPainter" #pragma link "FRAME_VmsStatusF" #pragma link "cxLabel" #pragma resource "*.dfm" #define WIDTH_GAP 3 #define HEIGHT_GAP 3 //TVMSMODL0 *VMSMODL0 = NULL; //--------------------------------------------------------------------------- __fastcall TVMSMODL0::TVMSMODL0(TComponent* Owner, TVmsCtlr *AVmsObj) : TForm(Owner) { FVmsObj = AVmsObj; FScrollBox = NULL; FSelected = false; FDisplayMode = 0; FZoomRate = 1.0; FDispIndex = 0; FPlay = false; FWndParent = NULL; FZoomView = false; PnlForm->ParentColor = true; //PnlForm->Color = clBlack; FDispW = FVmsObj->WIDTH; FDispH = FVmsObj->HEIGHT; //PnlName->Caption = "[" + FVmsObj->VMS_CTLR_ID + "] " + FVmsObj->VMS_NM; Caption = FVmsObj->VMS_NM; PnlName->Caption = FVmsObj->VMS_NM; PnlName->Hint = String(FVmsObj->VMS_CTLR_ID) + "\r\n" + FVmsObj->VMS_NM; FGapW = 16; FGapH = 8; PnlForm->Align = alClient; ImgState1->Parent = ImgState0->Parent; ImgState2->Parent = ImgState0->Parent; ImgState1->Left = ImgState0->Left; ImgState1->Top = ImgState0->Top; ImgState2->Left = ImgState0->Left; ImgState2->Top = ImgState0->Top; ImgState1->Visible = false; ImgState2->Visible = false; LoadLocalSkin(); Application->ProcessMessages(); FProg = "."; TvModStatusList->OptionsView->Header = false; } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::LoadLocalSkin() { PnlMain->ParentColor = false; PnlMain->Color = clBtnFace; PnlForm->ParentColor = true; //PnlForm->Color = clBlack; FRAME_VmsStatus1->LoadLocalSkin(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::FormDestroy(TObject *Sender) { //CamStop(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::FormShow(TObject *Sender) { TmrShow->Enabled = true; RefreshVmsMessage(); RefreshVmsStatus(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::SetFormSize(int AFormW) { InitVmsModule(); RefreshVmsModuleStatus(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::SelectForm(bool ASelect) { FSelected = ASelect; if (ASelect) { //PopupMenu = PopupMenu1; PnlMain->ParentColor = false; PnlMain->Color = clBtnHighlight;//clBackground; } else { //PopupMenu = NULL; PnlMain->ParentColor = false; PnlMain->Color = clBtnFace; } } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::TmrShowTimer(TObject *Sender) { TmrShow->Enabled = false; PopupMenu = NULL; if (!FVmsObj) { PnlName->Caption = "VMS"; } RefreshVmsStatus(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::SetPlay(bool APlay) { FPlay = APlay; } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::FormClose(TObject *Sender, TCloseAction &Action) { //CamStop(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::PnlNameClick(TObject *Sender) { if (FScrollBox) FScrollBox->SetFocus(); if (FWndParent) { POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)FVmsObj, (LPARAM)this); } } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::OnFormClick(TObject *Sender) { if (FScrollBox) FScrollBox->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::RefreshVmsMessage() { //PnlSeq->Caption = String(FVmsObj->VmsMsg->Total); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::InitVmsModule() { CMM_ClearGridTableView(TvModStatusList); int DefFormW = 315; int DefModlW = DefFormW - 10; int nSeroCnt = FVmsObj->VMS_MODL_ROW; int nGaroCnt = FVmsObj->VMS_MODL_COL; int nTotWidth = CxModStatusList->Width; int nModSize = (nTotWidth-(nGaroCnt-2)) / nGaroCnt; if (nModSize < 11) { nModSize = 11; } int nModlWidth = (nModSize * nGaroCnt); int nViewW = (nModSize * nGaroCnt) + 4; int nViewH = (nSeroCnt * nModSize) + 4; if (nViewW < DefModlW) { nViewW = DefModlW; } CxModStatusList->Visible = false; TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController; try { int ii, jj; int nRow; int nCols = TvModStatusList->ColumnCount; TvModStatusList->OptionsView->DataRowHeight = nModSize; TvModStatusList->BeginUpdate(); pGDC->BeginUpdate(); for (ii = 0; ii < nCols; ii++) { TvModStatusList->Columns[ii]->Width = nModSize; TvModStatusList->Columns[ii]->Visible = false; } for (ii = 0; ii < nGaroCnt && ii < nCols; ii++) { TvModStatusList->Columns[ii]->Visible = true; } int idx = 0; for (ii = 0; ii < nSeroCnt; ii++) { nRow = pGDC->AppendRecord(); for (jj = 0; jj < nGaroCnt; jj++) { pGDC->Values[nRow][jj] = "O"; } } } __finally { pGDC->EndUpdate(); TvModStatusList->EndUpdate(); CxModStatusList->Visible = true; } Height = nViewH + 54; CxModStatusList->Height = nViewH; if (nModlWidth> Width) { Width = nViewW + 10; CxModStatusList->Width = nViewW; } } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::RefreshVmsModuleStatus() { int nSeroCnt = FVmsObj->VMS_MODL_ROW; int nGaroCnt = FVmsObj->VMS_MODL_COL; TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController; try { int ii, jj, nRow; TvModStatusList->BeginUpdate(); pGDC->BeginUpdate(); for (ii = 0; ii < nSeroCnt; ii++) { for (jj = 0; jj < nGaroCnt; jj++) { pGDC->Values[ii][jj] = "O"; } } FOR_STL(TVmsModlStts*, pStts, FVmsObj->FModlSttsLists) { int sero = pStts->ROW_NO; int garo = pStts->COL_NO; if (sero <= nSeroCnt && garo <= nGaroCnt && sero >= 1 && garo >= 1) { sero--; garo--; pGDC->Values[sero][garo] = pStts->MODL_STTS; } } } __finally { pGDC->EndUpdate(); TvModStatusList->EndUpdate(); } } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::RefreshVmsStatus() { if (FVmsObj->Stts->RPRS_STTS == "O") { if (!ImgState0->Visible) ImgState0->Visible = true; if ( ImgState1->Visible) ImgState1->Visible = false; if ( ImgState2->Visible) ImgState2->Visible = false; } else if (FVmsObj->Stts->RPRS_STTS == "X") { if ( ImgState0->Visible) ImgState0->Visible = false; //false if (!ImgState1->Visible) ImgState1->Visible = true; if ( ImgState2->Visible) ImgState2->Visible = false; //true } else { if ( ImgState0->Visible) ImgState0->Visible = false; if ( ImgState1->Visible) ImgState1->Visible = false; if (!ImgState2->Visible) ImgState2->Visible = true; } RefreshVmsModuleStatus(); FRAME_VmsStatus1->RefreshStatus(FVmsObj); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::CamPlay() { } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::CamStop() { } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::TvModStatusListCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone) { int nRecordIdx = AViewInfo->GridRecord->RecordIndex; if (nRecordIdx < 0) { return; } try { int nItemIdx = AViewInfo->Item->Index; if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[nItemIdx])) return; String sStatus = AViewInfo->GridRecord->DisplayTexts[nItemIdx]; if (sStatus == "O") { ACanvas->Canvas->Brush->Color = clLime; } else if (sStatus == "X") { ACanvas->Canvas->Brush->Color = clRed; } else { ACanvas->Canvas->Brush->Color = clSilver; } ACanvas->Canvas->Font->Color = ACanvas->Canvas->Brush->Color; } catch(...) { } } //---------------------------------------------------------------------------