VMS0201MF.cpp 10 KB

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