VMS0201MF.cpp 10 KB

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