VMS0201MF.cpp 10 KB

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