123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "FrmVmsOprMainF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "VMS0201MF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxDropDownEdit"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxMaskEdit"
- #pragma link "cxTextEdit"
- #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 "cxImage"
- #pragma link "cxLabel"
- #pragma link "cxStyles"
- #pragma link "dxSkinscxPCPainter"
- #pragma resource "*.dfm"
- //TVMS0201M *VMS0201M = NULL;
- //---------------------------------------------------------------------------
- __fastcall TVMS0201M::TVMS0201M(TComponent* AOwner, HWND AHandle, String ACaption, int AScreenIdx)
- : TForm(AOwner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- FListForm = new TList();
- FScreenName = ACaption;
- FScreenIndex = AScreenIdx;
- FPlay = false;
- FMinWidth = 1000;
- FMinHeight = 1000;
- FMaxWidth = 0;
- FMaxHeight = 0;
- FWndParent = AHandle;
- Caption = ACaption;
- FDisplayMode = 0;
- FViewWidth = 320;
- TvVmsMsg->OptionsView->DataRowHeight = 0;
- TvVmsMsg->OptionsView->CellAutoHeight = true;
- TvVmsMsg->OptionsView->Indicator = true;
- TvVmsMsg->OptionsCustomize->ColumnMoving = false;
- TvVmsMsg->OptionsCustomize->ColumnSorting = false;
- //TvVmsMsg->Columns[0]->Width = 40;
- //TvVmsMsg->Columns[0]->Options->HorzSizing = false;
- for (int ii = 0; ii < INT_VMS_MAX_FORM; ii++)
- {
- TvVmsMsg->Columns[2+ii]->Caption = "Phase " + String(ii+1);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::FormCreate(TObject *Sender)
- {
- ScrollBox->ParentColor = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::FormShow(TObject *Sender)
- {
- Refresh();
- ScrollBox->Align = alClient;
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::ScrollBoxClick(TObject *Sender)
- {
- ScrollBox->SetFocus();
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::ScrollBoxMouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled)
- {
- ScrollBox->VertScrollBar->Position -= WheelDelta;
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::SetPlay(bool APlay)
- {
- #if 0
- try
- {
- for(int ii = 0; ii < FListForm->Count; ii++)
- {
- TVMSFORM0 *pForm = (TVMSFORM0*)FListForm->Items[ii];
- pForm->Play = APlay;
- }
- }
- catch(Exception &e)
- {
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::FormResize(TObject *Sender)
- {
- RecalFormPosition();
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::RecalFormPosition()
- {
- #if 0
- int h = 0;
- for (int ii = 0; ii < FpnlForm->ControlCount; ii++)
- {
- if (FpnlForm->Controls[ii]->BoundsRect.Bottom > h)
- h = FpnlForm->Controls[ii]->BoundsRect.Bottom;
- }
- FpnlForm->Height = h+50;
- ScrollBox->HorzScrollBar->Range = 0;
- ScrollBox->VertScrollBar->Range = FpnlForm->Height;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::RefreshScenario()
- {
- CMM_ClearGridTableView(TvVmsMsg);
- int ii, jj;
- int nCols = 0;
- TcxDataController *pGDC = TvVmsMsg->DataController;
- try
- {
- LockWindowUpdate(Handle);
- int nRow;
- TvVmsMsg->BeginUpdate();
- pGDC->BeginUpdate();
- for (ii = 0; ii < INT_VMS_MAX_FORM; ii++)
- {
- TvVmsMsg->Columns[2+ii]->Visible = false;
- TvVmsMsg->Columns[2+ii]->Width = FMinWidth;
- }
- for(jj = 0; jj < FListForm->Count; jj++)
- {
- TVmsCtlr *pObj = (TVmsCtlr*)FListForm->Items[jj];
- nRow = pGDC->AppendRecord();
- //pObj->VMS_CTLR_NMBR;
- String sVms = (pObj->VMS_CTLR_NMBR) + " [" + pObj->VMS_CTLR_ID + "]\r\n" + pObj->VMS_NM + "\r\n" + ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME);
- sVms += "\r\n" + VmsOperMode(pObj);
- pGDC->Values[nRow][ColSch01->Index] = sVms;
- pGDC->Values[nRow][ColSch02->Index] = pObj->VmsMsg->OFFER_YN ? "Y" : "N";
- pObj->Lock();
- if (pObj->VmsMsg->Total > nCols) nCols = pObj->VmsMsg->Total;
- for(ii = 0; ii < pObj->VmsMsg->Total && ii < INT_VMS_MAX_FORM; ii++)
- {
- //TvVmsMsg->Columns[2+ii]->Width = FMaxWidth;
- Graphics::TBitmap *pBitmap = pObj->VmsMsg->PHASE[ii].pVmsBmp;
- TStream *pImgStream = new TMemoryStream();
- try
- {
- pBitmap->SaveToStream(pImgStream);
- void *p;
- Variant v;
- int aBound[]={0, pImgStream->Size - 1};
- v = VarArrayCreate(aBound, 1, varByte);
- p = VarArrayLock(v);
- pImgStream->Position = 0;
- pImgStream->Read(p, pImgStream->Size);
- VarArrayUnlock(v);
- pGDC->Values[nRow][2+ii] = v;
- } catch(Exception &e) {}
- SAFE_DELETE(pImgStream);
- }
- pObj->UnLock();
- }
- for (ii = 0; ii < nCols; ii++)
- {
- TvVmsMsg->Columns[2+ii]->Visible = true;
- }
- }
- __finally
- {
- pGDC->EndUpdate();
- TvVmsMsg->EndUpdate();
- //TvVmsMsg->ApplyBestFit(NULL, false, false);
- LockWindowUpdate(0);
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TVMS0201M::AddVmsForm(String AVmsNmbr)
- {
- TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(AVmsNmbr);
- if (!pObj) return false;
- if (pObj->WIDTH > FMaxWidth) FMaxWidth = pObj->WIDTH;
- if (pObj->WIDTH < FMinWidth) FMinWidth = pObj->WIDTH;
- if (pObj->HEIGHT > FMaxHeight) FMaxHeight = pObj->HEIGHT;
- if (pObj->HEIGHT < FMinHeight) FMinHeight = pObj->HEIGHT;
- #if 0
- TVMSFORM0 *pForm = new TVMSFORM0(this, pObj);
- pForm->SetFormSize(pObj->WIDTH);
- pForm->Parent = FpnlForm;
- pForm->FScrollBox = ScrollBox;
- pForm->FWndParent = Handle;
- pForm->Show();
- FListForm->Add(pForm);
- #else
- FListForm->Add(pObj);
- #endif
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::FpnlFormClick(TObject *Sender)
- {
- ScrollBox->SetFocus();
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::OnVmsSelectMessage(TMessage &Msg)
- {
- if (FWndParent)
- {
- POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)Msg.WParam, (LPARAM)Msg.LParam);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::FormDestroy(TObject *Sender)
- {
- ClearFormList();
- SAFE_DELETE(FListForm);
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::SetFormSize(int AWidth)
- {
- try
- {
- LockWindowUpdate(Handle);
- for(int ii = 0; ii < FListForm->Count; ii++)
- {
- TVMSFORM0 *pForm = (TVMSFORM0*)FListForm->Items[ii];
- pForm->SetFormSize(AWidth);
- FViewWidth = pForm->Width;
- }
- }
- __finally
- {
- LockWindowUpdate(0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::ClearFormList()
- {
- #if 0
- try
- {
- LockWindowUpdate(Handle);
- for(int ii = 0; ii < FListForm->Count; ii++)
- {
- TVMSFORM0 *pForm = (TVMSFORM0*)FListForm->Items[ii];
- pForm->Hide();
- SAFE_DELETE(pForm);
- }
- FListForm->Clear();
- }
- __finally
- {
- LockWindowUpdate(0);
- }
- #else
- LockWindowUpdate(Handle);
- FListForm->Clear();
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TVMS0201M::ColSch01CustomDrawCell(TcxCustomGridTableView *Sender,
- TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- if (AViewInfo)
- {
- String sOffer = AViewInfo->GridRecord->DisplayTexts[ColSch02->Index];
- if (sOffer == "N")
- {
- ACanvas->Canvas->Font->Color = clRed;
- }
- }
- }
- //---------------------------------------------------------------------------
|