VmsFormF.cpp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. //---------------------------------------------------------------------------
  2. #pragma hdrstop
  3. #include "VmsFormF.h"
  4. //---------------------------------------------------------------------------
  5. #pragma package(smart_init)
  6. //---------------------------------------------------------------------------
  7. TVmsFormObj::TVmsFormObj()
  8. {
  9. pImageData = NULL;
  10. pImageStream = NULL;
  11. IFSC_ID = NULL;
  12. }
  13. //---------------------------------------------------------------------------
  14. TVmsFormObj::~TVmsFormObj()
  15. {
  16. if (pImageData)
  17. {
  18. pImageData->Picture->Bitmap->FreeImage();
  19. pImageData->Picture->Assign(NULL);
  20. delete pImageData;
  21. pImageData = NULL;
  22. }
  23. if (pImageStream)
  24. {
  25. pImageStream->Clear();
  26. pImageStream->Position = 0;
  27. delete pImageStream;
  28. pImageStream = NULL;
  29. }
  30. }
  31. //---------------------------------------------------------------------------
  32. void TVmsFormObj::Clear()
  33. {
  34. }
  35. //---------------------------------------------------------------------------
  36. TImage *TVmsFormObj::NewImage()
  37. {
  38. bool bUnLock = false;
  39. if (pImageData)
  40. {
  41. pImageData->Picture->Bitmap->Canvas->Lock();
  42. bUnLock = true;
  43. }
  44. try
  45. {
  46. try
  47. {
  48. if (pImageStream)
  49. {
  50. pImageStream->Clear();
  51. pImageStream->Position = 0;
  52. }
  53. else
  54. {
  55. pImageStream = new TMemoryStream();
  56. }
  57. if (pImageData)
  58. {
  59. pImageData->Picture->Bitmap->FreeImage();
  60. pImageData->Picture->Assign(NULL);
  61. }
  62. else
  63. {
  64. pImageData = new TImage(NULL);
  65. }
  66. }
  67. catch(Exception &e)
  68. {
  69. }
  70. }
  71. __finally
  72. {
  73. if (bUnLock)
  74. {
  75. pImageData->Picture->Bitmap->Canvas->Unlock();
  76. }
  77. }
  78. return pImageData;
  79. }
  80. //---------------------------------------------------------------------------
  81. //---------------------------------------------------------------------------
  82. TVmsForm::TVmsForm()
  83. {
  84. FTotal = 0;
  85. SvcRes = false;
  86. FtpRes = false;
  87. FObjects= 0;
  88. TrfBakImgId = "";
  89. Success = false;
  90. FtpFileName = "";
  91. LocalFileName = "";
  92. pCriticalSection = new TCriticalSection();
  93. pBitmap = new Graphics::TBitmap;
  94. pStream = new TMemoryStream();
  95. }
  96. //---------------------------------------------------------------------------
  97. TVmsForm::~TVmsForm()
  98. {
  99. FLists.RemoveAll();
  100. if (pBitmap)
  101. {
  102. pBitmap->FreeImage();
  103. pBitmap->Assign(NULL);
  104. delete pBitmap;
  105. pBitmap = NULL;
  106. }
  107. if (pStream)
  108. {
  109. pStream->Clear();
  110. pStream->Position = 0;
  111. delete pStream;
  112. pStream = NULL;
  113. }
  114. if (pCriticalSection)
  115. {
  116. delete pCriticalSection;
  117. pCriticalSection = NULL;
  118. }
  119. }
  120. //---------------------------------------------------------------------------
  121. void TVmsForm::Clear()
  122. {
  123. //FLists.RemoveAll();
  124. SvcRes = false;
  125. FtpRes = false;
  126. FObjects = 0;
  127. }
  128. //---------------------------------------------------------------------------
  129. void TVmsForm::Init(int AWidth, int AHeight)
  130. {
  131. try
  132. {
  133. //pBitmap->PixelFormat = pf4bit;
  134. pBitmap->Width = AWidth;
  135. pBitmap->Height= AHeight;
  136. }
  137. catch(Exception &e)
  138. {
  139. }
  140. }
  141. //---------------------------------------------------------------------------
  142. void TVmsForm::FormClear(TColor ABkColor)
  143. {
  144. try
  145. {
  146. pBitmap->FreeImage();
  147. pBitmap->Assign(NULL);
  148. //pBitmap->PixelFormat = pf4bit;
  149. pBitmap->Width = Width;
  150. pBitmap->Height= Height;
  151. pBitmap->Canvas->Pen->Color = clWhite;
  152. pBitmap->Canvas->Pen->Width = 0;
  153. pBitmap->Canvas->Pen->Style = psClear;
  154. pBitmap->Canvas->Brush->Style = bsSolid;
  155. pBitmap->Canvas->Brush->Color = ABkColor;
  156. pBitmap->Canvas->Rectangle(0, 0, Width+1, Height+1);
  157. pStream->Clear();
  158. pStream->Position = 0;
  159. }
  160. catch(Exception &e)
  161. {
  162. }
  163. }
  164. //---------------------------------------------------------------------------
  165. TVmsFormObj *TVmsForm::GetItem(int AIdx)
  166. {
  167. TVmsFormObj *pFormObj = FLists.Find(AIdx);
  168. return pFormObj;
  169. }
  170. //---------------------------------------------------------------------------
  171. int TVmsForm::AddFormObject(TVmsFormObj *AFormObj)
  172. {
  173. FLists.Push(FObjects++, AFormObj);
  174. return FObjects;
  175. }
  176. //---------------------------------------------------------------------------
  177. TVmsFormObj *TVmsForm::AddFormObject()
  178. {
  179. TVmsFormObj *pVmsFormObj = NULL;
  180. if (FObjects < FTotal)
  181. {
  182. pVmsFormObj = GetItem(FObjects);
  183. FObjects++;
  184. }
  185. else
  186. {
  187. pVmsFormObj = new TVmsFormObj();
  188. FLists.Push(FTotal++, pVmsFormObj);
  189. FObjects++;
  190. }
  191. return pVmsFormObj;
  192. }
  193. //---------------------------------------------------------------------------
  194. //---------------------------------------------------------------------------
  195. //extern TVmsFormManager *VmsFormManager = NULL;
  196. //---------------------------------------------------------------------------
  197. TVmsFormManager::TVmsFormManager()
  198. {
  199. FTotal = 0;
  200. FObjects = 0;
  201. }
  202. //---------------------------------------------------------------------------
  203. TVmsFormManager::~TVmsFormManager()
  204. {
  205. FLists.RemoveAll();
  206. }
  207. //---------------------------------------------------------------------------
  208. void TVmsFormManager::Clear()
  209. {
  210. #ifdef VMS_CLEAR
  211. FLists.RemoveAll();
  212. #else
  213. FObjects = 0;
  214. FOR_STL(TVmsForm*, pForm, FLists)
  215. {
  216. pForm->Clear();
  217. }
  218. #endif
  219. }
  220. //---------------------------------------------------------------------------
  221. TVmsForm *TVmsFormManager::GetItem(int AIdx)
  222. {
  223. TVmsForm *pForm = FLists.Find(AIdx);
  224. return pForm;
  225. }
  226. //---------------------------------------------------------------------------
  227. int TVmsFormManager::AddForm(TVmsForm *AForm)
  228. {
  229. FLists.Push(FObjects++, AForm);
  230. return FObjects;
  231. }
  232. //---------------------------------------------------------------------------
  233. TVmsForm *TVmsFormManager::AddForm()
  234. {
  235. TVmsForm *pVmsForm = NULL;
  236. if (FObjects < FTotal)
  237. {
  238. pVmsForm = GetItem(FObjects);
  239. FObjects++;
  240. }
  241. else
  242. {
  243. pVmsForm = new TVmsForm();
  244. pVmsForm->Init(FormWidth, FormHeight);
  245. FLists.Push(FTotal++, pVmsForm);
  246. FObjects++;
  247. }
  248. return pVmsForm;
  249. }
  250. //---------------------------------------------------------------------------