VMS0201MF.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #pragma hdrstop
  7. #include "VMS0201MF.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma link "cxContainer"
  11. #pragma link "cxControls"
  12. #pragma link "cxDropDownEdit"
  13. #pragma link "cxEdit"
  14. #pragma link "cxGraphics"
  15. #pragma link "cxLookAndFeelPainters"
  16. #pragma link "cxLookAndFeels"
  17. #pragma link "cxMaskEdit"
  18. #pragma link "cxTextEdit"
  19. #pragma link "dxSkinBlack"
  20. #pragma link "dxSkinMcSkin"
  21. #pragma link "dxSkinsCore"
  22. #pragma link "dxSkinBlue"
  23. #pragma link "dxSkinCaramel"
  24. #pragma link "dxSkinCoffee"
  25. #pragma link "dxSkinDarkRoom"
  26. #pragma link "dxSkinDarkSide"
  27. #pragma link "dxSkinFoggy"
  28. #pragma link "dxSkinGlassOceans"
  29. #pragma link "dxSkiniMaginary"
  30. #pragma link "dxSkinLilian"
  31. #pragma link "dxSkinLiquidSky"
  32. #pragma link "dxSkinLondonLiquidSky"
  33. #pragma link "dxSkinMoneyTwins"
  34. #pragma link "dxSkinOffice2007Black"
  35. #pragma link "dxSkinOffice2007Blue"
  36. #pragma link "dxSkinOffice2007Green"
  37. #pragma link "dxSkinOffice2007Pink"
  38. #pragma link "dxSkinOffice2007Silver"
  39. #pragma link "dxSkinOffice2010Black"
  40. #pragma link "dxSkinOffice2010Blue"
  41. #pragma link "dxSkinOffice2010Silver"
  42. #pragma link "dxSkinSeven"
  43. #pragma link "dxSkinSharp"
  44. #pragma link "dxSkinSilver"
  45. #pragma link "dxSkinStardust"
  46. #pragma link "cxClasses"
  47. #pragma link "cxCustomData"
  48. #pragma link "cxData"
  49. #pragma link "cxDataStorage"
  50. #pragma link "cxFilter"
  51. #pragma link "cxGrid"
  52. #pragma link "cxGridCustomTableView"
  53. #pragma link "cxGridCustomView"
  54. #pragma link "cxGridLevel"
  55. #pragma link "cxGridTableView"
  56. #pragma link "cxImage"
  57. #pragma link "cxLabel"
  58. #pragma link "cxStyles"
  59. #pragma link "dxSkinscxPCPainter"
  60. #pragma resource "*.dfm"
  61. //TVMS0201M *VMS0201M = NULL;
  62. //---------------------------------------------------------------------------
  63. __fastcall TVMS0201M::TVMS0201M(TComponent* AOwner, HWND AHandle, String ACaption, int AScreenIdx)
  64. : TForm(AOwner)
  65. {
  66. FListForm = new TList();
  67. FScreenName = ACaption;
  68. FScreenIndex = AScreenIdx;
  69. FPlay = false;
  70. FMinWidth = 1000;
  71. FMinHeight = 1000;
  72. FMaxWidth = 0;
  73. FMaxHeight = 0;
  74. FWndParent = AHandle;
  75. Caption = ACaption;
  76. FDisplayMode = 0;
  77. FViewWidth = 320;
  78. TvVmsMsg->OptionsView->DataRowHeight = 0;
  79. TvVmsMsg->OptionsView->CellAutoHeight = true;
  80. TvVmsMsg->OptionsView->Indicator = true;
  81. TvVmsMsg->OptionsCustomize->ColumnMoving = false;
  82. TvVmsMsg->OptionsCustomize->ColumnSorting = false;
  83. //TvVmsMsg->Columns[0]->Width = 40;
  84. //TvVmsMsg->Columns[0]->Options->HorzSizing = false;
  85. for (int ii = 0; ii < INT_VMS_MAX_FORM; ii++)
  86. {
  87. TvVmsMsg->Columns[2+ii]->Caption = "Phase " + String(ii+1);
  88. }
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TVMS0201M::FormCreate(TObject *Sender)
  92. {
  93. ScrollBox->ParentColor = true;
  94. }
  95. //---------------------------------------------------------------------------
  96. void __fastcall TVMS0201M::FormShow(TObject *Sender)
  97. {
  98. Refresh();
  99. ScrollBox->Align = alClient;
  100. TmrShow->Enabled = true;
  101. }
  102. //---------------------------------------------------------------------------
  103. void __fastcall TVMS0201M::TmrShowTimer(TObject *Sender)
  104. {
  105. TmrShow->Enabled = false;
  106. }
  107. //---------------------------------------------------------------------------
  108. void __fastcall TVMS0201M::ScrollBoxClick(TObject *Sender)
  109. {
  110. ScrollBox->SetFocus();
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TVMS0201M::ScrollBoxMouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled)
  114. {
  115. ScrollBox->VertScrollBar->Position -= WheelDelta;
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TVMS0201M::SetPlay(bool APlay)
  119. {
  120. #if 0
  121. try
  122. {
  123. for(int ii = 0; ii < FListForm->Count; ii++)
  124. {
  125. TVMSFORM0 *pForm = (TVMSFORM0*)FListForm->Items[ii];
  126. pForm->Play = APlay;
  127. }
  128. }
  129. catch(Exception &e)
  130. {
  131. }
  132. #endif
  133. }
  134. //---------------------------------------------------------------------------
  135. void __fastcall TVMS0201M::FormResize(TObject *Sender)
  136. {
  137. RecalFormPosition();
  138. }
  139. //---------------------------------------------------------------------------
  140. void __fastcall TVMS0201M::RecalFormPosition()
  141. {
  142. #if 0
  143. int h = 0;
  144. for (int ii = 0; ii < FpnlForm->ControlCount; ii++)
  145. {
  146. if (FpnlForm->Controls[ii]->BoundsRect.Bottom > h)
  147. h = FpnlForm->Controls[ii]->BoundsRect.Bottom;
  148. }
  149. FpnlForm->Height = h+50;
  150. ScrollBox->HorzScrollBar->Range = 0;
  151. ScrollBox->VertScrollBar->Range = FpnlForm->Height;
  152. #endif
  153. }
  154. //---------------------------------------------------------------------------
  155. void __fastcall TVMS0201M::RefreshScenario()
  156. {
  157. CMM_ClearGridTableView(TvVmsMsg);
  158. int nDataRowHeight = 64;
  159. TcxDataController *pGDC = TvVmsMsg->DataController;
  160. try
  161. {
  162. LockWindowUpdate(Handle);
  163. int ii, jj;
  164. int nCols = 0;
  165. int nRow;
  166. TvVmsMsg->BeginUpdate();
  167. pGDC->BeginUpdate();
  168. for (ii = 0; ii < INT_VMS_MAX_FORM; ii++)
  169. {
  170. TvVmsMsg->Columns[2+ii]->Visible = false;
  171. TvVmsMsg->Columns[2+ii]->Width = FMinWidth;
  172. }
  173. for(jj = 0; jj < FListForm->Count; jj++)
  174. {
  175. TVmsCtlr *pObj = (TVmsCtlr*)FListForm->Items[jj];
  176. nRow = pGDC->AppendRecord();
  177. String sOperMode;
  178. if (pObj->OPER_MODE == "A") {
  179. sOperMode = "ÀÚµ¿";
  180. }
  181. else
  182. if (pObj->OPER_MODE == "M") {
  183. sOperMode = "¼öµ¿";
  184. }
  185. else {
  186. sOperMode = "¿î¿µ¸ðµå - " + pObj->OPER_MODE;
  187. }
  188. String sVms = pObj->VMS_CTLR_ID;
  189. sVms += " [" + pObj->VMS_CTLR_ID + "]";
  190. sVms += "\r\n" + pObj->VMS_NM + "\r\n";
  191. sVms += pObj->FVmsMsg->OFFER_DT;
  192. sVms += "\r\n" + sOperMode;
  193. pGDC->Values[nRow][ColSch01->Index] = sVms;
  194. pGDC->Values[nRow][ColSch02->Index] = pObj->FVmsMsg->OFFER_YN ? "Y" : "N";
  195. pObj->Lock();
  196. if (pObj->FVmsMsg->Total > nCols) nCols = pObj->FVmsMsg->Total;
  197. for(ii = 0; ii < pObj->FVmsMsg->Total && ii < INT_VMS_MAX_FORM; ii++)
  198. {
  199. Graphics::TBitmap *pBitmap = pObj->FVmsMsg->PHASE[ii].DSPL_PICT;
  200. TStream *pImgStream = new TMemoryStream();
  201. try
  202. {
  203. pBitmap->SaveToStream(pImgStream);
  204. if (pBitmap->Height > nDataRowHeight) {
  205. nDataRowHeight = pBitmap->Height;
  206. }
  207. void *p;
  208. Variant v;
  209. int aBound[]={0, pImgStream->Size - 1};
  210. v = VarArrayCreate(aBound, 1, varByte);
  211. p = VarArrayLock(v);
  212. pImgStream->Position = 0;
  213. pImgStream->Read(p, pImgStream->Size);
  214. VarArrayUnlock(v);
  215. pGDC->Values[nRow][2+ii] = v;
  216. } catch(Exception &e) {}
  217. SAFE_DELETE(pImgStream);
  218. }
  219. pObj->UnLock();
  220. }
  221. for (ii = 0; ii < nCols; ii++)
  222. {
  223. TvVmsMsg->Columns[2+ii]->Visible = true;
  224. }
  225. }
  226. __finally
  227. {
  228. //TvVmsMsg->OptionsView->DataRowHeight = nDataRowHeight;
  229. pGDC->EndUpdate();
  230. TvVmsMsg->EndUpdate();
  231. //TvVmsMsg->ApplyBestFit(NULL, false, false);
  232. LockWindowUpdate(0);
  233. }
  234. }
  235. //---------------------------------------------------------------------------
  236. bool __fastcall TVMS0201M::AddVmsForm(String AVmsNmbr)
  237. {
  238. TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(AVmsNmbr);
  239. if (!pObj) return false;
  240. if (pObj->WIDTH > FMaxWidth) FMaxWidth = pObj->WIDTH;
  241. if (pObj->WIDTH < FMinWidth) FMinWidth = pObj->WIDTH;
  242. if (pObj->HEIGHT > FMaxHeight) FMaxHeight = pObj->HEIGHT;
  243. if (pObj->HEIGHT < FMinHeight) FMinHeight = pObj->HEIGHT;
  244. #if 0
  245. TVMSFORM0 *pForm = new TVMSFORM0(this, pObj);
  246. pForm->SetFormSize(pObj->WIDTH);
  247. pForm->Parent = FpnlForm;
  248. pForm->FScrollBox = ScrollBox;
  249. pForm->FWndParent = Handle;
  250. pForm->Show();
  251. FListForm->Add(pForm);
  252. #else
  253. FListForm->Add(pObj);
  254. #endif
  255. return true;
  256. }
  257. //---------------------------------------------------------------------------
  258. void __fastcall TVMS0201M::FpnlFormClick(TObject *Sender)
  259. {
  260. ScrollBox->SetFocus();
  261. }
  262. //---------------------------------------------------------------------------
  263. void __fastcall TVMS0201M::OnVmsSelectMessage(TMessage &Msg)
  264. {
  265. if (FWndParent)
  266. {
  267. POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)Msg.WParam, (LPARAM)Msg.LParam);
  268. }
  269. }
  270. //---------------------------------------------------------------------------
  271. void __fastcall TVMS0201M::FormDestroy(TObject *Sender)
  272. {
  273. ClearFormList();
  274. SAFE_DELETE(FListForm);
  275. }
  276. //---------------------------------------------------------------------------
  277. void __fastcall TVMS0201M::SetFormSize(int AWidth)
  278. {
  279. try
  280. {
  281. LockWindowUpdate(Handle);
  282. for(int ii = 0; ii < FListForm->Count; ii++)
  283. {
  284. TVMSFORM0 *pForm = (TVMSFORM0*)FListForm->Items[ii];
  285. pForm->SetFormSize(AWidth);
  286. FViewWidth = pForm->Width;
  287. }
  288. }
  289. __finally
  290. {
  291. LockWindowUpdate(0);
  292. }
  293. }
  294. //---------------------------------------------------------------------------
  295. void __fastcall TVMS0201M::ClearFormList()
  296. {
  297. #if 0
  298. try
  299. {
  300. LockWindowUpdate(Handle);
  301. for(int ii = 0; ii < FListForm->Count; ii++)
  302. {
  303. TVMSFORM0 *pForm = (TVMSFORM0*)FListForm->Items[ii];
  304. pForm->Hide();
  305. SAFE_DELETE(pForm);
  306. }
  307. FListForm->Clear();
  308. }
  309. __finally
  310. {
  311. LockWindowUpdate(0);
  312. }
  313. #else
  314. LockWindowUpdate(Handle);
  315. FListForm->Clear();
  316. #endif
  317. }
  318. //---------------------------------------------------------------------------
  319. void __fastcall TVMS0201M::ColSch01CustomDrawCell(TcxCustomGridTableView *Sender,
  320. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  321. bool &ADone)
  322. {
  323. if (AViewInfo)
  324. {
  325. String sOffer = AViewInfo->GridRecord->DisplayTexts[ColSch02->Index];
  326. if (sOffer == "N")
  327. {
  328. ACanvas->Canvas->Font->Color = clRed;
  329. }
  330. }
  331. }
  332. //---------------------------------------------------------------------------