VmsFormF.cpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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 = g_AppCfg.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. TPixelFormat PixelFormat = pBitmap->PixelFormat; //TODO
  145. try
  146. {
  147. pBitmap->FreeImage();
  148. pBitmap->Assign(NULL);
  149. //pBitmap->PixelFormat = g_AppCfg.PixelFormat;//pf4bit;
  150. //TODO
  151. if (pfDevice != PixelFormat && pfCustom != PixelFormat)
  152. {
  153. pBitmap->PixelFormat = PixelFormat;
  154. }
  155. pBitmap->Width = Width;
  156. pBitmap->Height= Height;
  157. pBitmap->Canvas->Pen->Color = clWhite;
  158. pBitmap->Canvas->Pen->Width = 0;
  159. pBitmap->Canvas->Pen->Style = psClear;
  160. pBitmap->Canvas->Brush->Style = bsSolid;
  161. pBitmap->Canvas->Brush->Color = ABkColor;
  162. pBitmap->Canvas->Rectangle(0, 0, Width+1, Height+1);
  163. pStream->Clear();
  164. pStream->Position = 0;
  165. }
  166. catch(Exception &e)
  167. {
  168. }
  169. }
  170. //---------------------------------------------------------------------------
  171. TVmsFormObj *TVmsForm::GetItem(int AIdx)
  172. {
  173. TVmsFormObj *pFormObj = FLists.Find(AIdx);
  174. return pFormObj;
  175. }
  176. //---------------------------------------------------------------------------
  177. int TVmsForm::AddFormObject(TVmsFormObj *AFormObj)
  178. {
  179. FLists.Push(FObjects++, AFormObj);
  180. return FObjects;
  181. }
  182. //---------------------------------------------------------------------------
  183. TVmsFormObj *TVmsForm::AddFormObject()
  184. {
  185. TVmsFormObj *pVmsFormObj = NULL;
  186. if (FObjects < FTotal)
  187. {
  188. pVmsFormObj = GetItem(FObjects);
  189. FObjects++;
  190. }
  191. else
  192. {
  193. pVmsFormObj = new TVmsFormObj();
  194. FLists.Push(FTotal++, pVmsFormObj);
  195. FObjects++;
  196. }
  197. return pVmsFormObj;
  198. }
  199. //---------------------------------------------------------------------------
  200. //---------------------------------------------------------------------------
  201. //extern TVmsFormManager *VmsFormManager = NULL;
  202. //---------------------------------------------------------------------------
  203. TVmsFormManager::TVmsFormManager()
  204. {
  205. FTotal = 0;
  206. FObjects = 0;
  207. }
  208. //---------------------------------------------------------------------------
  209. TVmsFormManager::~TVmsFormManager()
  210. {
  211. FLists.RemoveAll();
  212. }
  213. //---------------------------------------------------------------------------
  214. void TVmsFormManager::Clear()
  215. {
  216. #ifdef VMS_CLEAR
  217. FLists.RemoveAll();
  218. #else
  219. FObjects = 0;
  220. FOR_STL(TVmsForm*, pForm, FLists)
  221. {
  222. pForm->Clear();
  223. }
  224. #endif
  225. }
  226. //---------------------------------------------------------------------------
  227. TVmsForm *TVmsFormManager::GetItem(int AIdx)
  228. {
  229. TVmsForm *pForm = FLists.Find(AIdx);
  230. return pForm;
  231. }
  232. //---------------------------------------------------------------------------
  233. int TVmsFormManager::AddForm(TVmsForm *AForm)
  234. {
  235. FLists.Push(FObjects++, AForm);
  236. return FObjects;
  237. }
  238. //---------------------------------------------------------------------------
  239. TVmsForm *TVmsFormManager::AddForm()
  240. {
  241. TVmsForm *pVmsForm = NULL;
  242. if (FObjects < FTotal)
  243. {
  244. pVmsForm = GetItem(FObjects);
  245. FObjects++;
  246. }
  247. else
  248. {
  249. pVmsForm = new TVmsForm();
  250. pVmsForm->Init(FormWidth, FormHeight);
  251. FLists.Push(FTotal++, pVmsForm);
  252. FObjects++;
  253. }
  254. return pVmsForm;
  255. }
  256. //---------------------------------------------------------------------------