TVmsFormF.cpp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. //---------------------------------------------------------------------------
  2. #pragma hdrstop
  3. #include "TVmsFormF.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. try
  40. {
  41. if (pImageData)
  42. {
  43. pImageData->Picture->Bitmap->Canvas->Lock();
  44. bUnLock = true;
  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. pCriticalSection = new TCriticalSection();
  90. pBitmap = new Graphics::TBitmap;
  91. pStream = new TMemoryStream();
  92. }
  93. //---------------------------------------------------------------------------
  94. TVmsForm::~TVmsForm()
  95. {
  96. FLists.RemoveAll();
  97. if (pBitmap)
  98. {
  99. pBitmap->FreeImage();
  100. pBitmap->Assign(NULL);
  101. delete pBitmap;
  102. pBitmap = NULL;
  103. }
  104. if (pStream)
  105. {
  106. pStream->Clear();
  107. pStream->Position = 0;
  108. delete pStream;
  109. pStream = NULL;
  110. }
  111. if (pCriticalSection)
  112. {
  113. delete pCriticalSection;
  114. pCriticalSection = NULL;
  115. }
  116. }
  117. //---------------------------------------------------------------------------
  118. void TVmsForm::Clear()
  119. {
  120. //FLists.RemoveAll();
  121. SvcRes = false;
  122. FtpRes = false;
  123. FObjects = 0;
  124. }
  125. //---------------------------------------------------------------------------
  126. void TVmsForm::Init(int AWidth, int AHeight)
  127. {
  128. try
  129. {
  130. pBitmap->PixelFormat = pf4bit;
  131. pBitmap->Width = AWidth;
  132. pBitmap->Height= AHeight;
  133. }
  134. catch(Exception &e)
  135. {
  136. }
  137. }
  138. //---------------------------------------------------------------------------
  139. void TVmsForm::FormClear(TColor ABkColor)
  140. {
  141. try
  142. {
  143. pBitmap->FreeImage();
  144. pBitmap->Assign(NULL);
  145. pBitmap->PixelFormat = pf4bit;
  146. pBitmap->Width = Width;
  147. pBitmap->Height= Height;
  148. pBitmap->Canvas->Pen->Color = clWhite;
  149. pBitmap->Canvas->Pen->Width = 0;
  150. pBitmap->Canvas->Pen->Style = psClear;
  151. pBitmap->Canvas->Brush->Style = bsSolid;
  152. pBitmap->Canvas->Brush->Color = ABkColor;
  153. pBitmap->Canvas->Rectangle(0, 0, Width+1, Height+1);
  154. pStream->Clear();
  155. pStream->Position = 0;
  156. }
  157. catch(Exception &e)
  158. {
  159. }
  160. }
  161. //---------------------------------------------------------------------------
  162. TVmsFormObj *TVmsForm::GetItem(int AIdx)
  163. {
  164. TVmsFormObj *pFormObj = FLists.Find(AIdx);
  165. return pFormObj;
  166. }
  167. //---------------------------------------------------------------------------
  168. int TVmsForm::AddFormObject(TVmsFormObj *AFormObj)
  169. {
  170. FLists.Push(FObjects++, AFormObj);
  171. return FObjects;
  172. }
  173. //---------------------------------------------------------------------------
  174. TVmsFormObj *TVmsForm::AddFormObject()
  175. {
  176. TVmsFormObj *pVmsFormObj = NULL;
  177. if (FObjects < FTotal)
  178. {
  179. pVmsFormObj = GetItem(FObjects);
  180. FObjects++;
  181. }
  182. else
  183. {
  184. pVmsFormObj = new TVmsFormObj();
  185. FLists.Push(FTotal++, pVmsFormObj);
  186. FObjects++;
  187. }
  188. return pVmsFormObj;
  189. }
  190. //---------------------------------------------------------------------------
  191. //---------------------------------------------------------------------------
  192. //extern TVmsFormManager *VmsFormManager = NULL;
  193. //---------------------------------------------------------------------------
  194. TVmsFormManager::TVmsFormManager()
  195. {
  196. FTotal = 0;
  197. FObjects = 0;
  198. }
  199. //---------------------------------------------------------------------------
  200. TVmsFormManager::~TVmsFormManager()
  201. {
  202. FLists.RemoveAll();
  203. }
  204. //---------------------------------------------------------------------------
  205. void TVmsFormManager::Clear()
  206. {
  207. #ifdef VMS_CLEAR
  208. FLists.RemoveAll();
  209. #else
  210. FObjects = 0;
  211. FOR_STL(TVmsForm*, pForm, FLists)
  212. {
  213. pForm->Clear();
  214. }
  215. #endif
  216. }
  217. //---------------------------------------------------------------------------
  218. TVmsForm *TVmsFormManager::GetItem(int AIdx)
  219. {
  220. TVmsForm *pForm = FLists.Find(AIdx);
  221. return pForm;
  222. }
  223. //---------------------------------------------------------------------------
  224. int TVmsFormManager::AddForm(TVmsForm *AForm)
  225. {
  226. FLists.Push(FObjects++, AForm);
  227. return FObjects;
  228. }
  229. //---------------------------------------------------------------------------
  230. TVmsForm *TVmsFormManager::AddForm()
  231. {
  232. TVmsForm *pVmsForm = NULL;
  233. if (FObjects < FTotal)
  234. {
  235. pVmsForm = GetItem(FObjects);
  236. FObjects++;
  237. }
  238. else
  239. {
  240. pVmsForm = new TVmsForm();
  241. pVmsForm->Init(FormWidth, FormHeight);
  242. FLists.Push(FTotal++, pVmsForm);
  243. FObjects++;
  244. }
  245. return pVmsForm;
  246. }
  247. //---------------------------------------------------------------------------