VMS0201MF.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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 = String(pObj->VMS_CTLR_NMBR);
  181. sVms += " [" + pObj->VMS_CTLR_ID + "]";
  182. sVms += "\r\n" + pObj->VMS_NM + "\r\n";
  183. sVms += 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_VMS_MAX_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 = VmsCtlrManager->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. //---------------------------------------------------------------------------