123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include "TVmsFormF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- TVmsFormObj::TVmsFormObj()
- {
- pImageData = NULL;
- pImageStream = NULL;
- IFSC_ID = NULL;
- }
- //---------------------------------------------------------------------------
- TVmsFormObj::~TVmsFormObj()
- {
- if (pImageData)
- {
- pImageData->Picture->Bitmap->FreeImage();
- pImageData->Picture->Assign(NULL);
- delete pImageData;
- pImageData = NULL;
- }
- if (pImageStream)
- {
- pImageStream->Clear();
- pImageStream->Position = 0;
- delete pImageStream;
- pImageStream = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void TVmsFormObj::Clear()
- {
- }
- //---------------------------------------------------------------------------
- TImage *TVmsFormObj::NewImage()
- {
- bool bUnLock = false;
- try
- {
- if (pImageData)
- {
- pImageData->Picture->Bitmap->Canvas->Lock();
- bUnLock = true;
- }
- try
- {
- if (pImageStream)
- {
- pImageStream->Clear();
- pImageStream->Position = 0;
- }
- else
- {
- pImageStream = new TMemoryStream();
- }
- if (pImageData)
- {
- pImageData->Picture->Bitmap->FreeImage();
- pImageData->Picture->Assign(NULL);
- }
- else
- {
- pImageData = new TImage(NULL);
- }
- }
- catch(Exception &e)
- {
- }
- }
- __finally
- {
- if (bUnLock)
- {
- pImageData->Picture->Bitmap->Canvas->Unlock();
- }
- }
- return pImageData;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- TVmsForm::TVmsForm()
- {
- FTotal = 0;
- SvcRes = false;
- FtpRes = false;
- FObjects= 0;
- TrfBakImgId = "";
- pCriticalSection = new TCriticalSection();
- pBitmap = new Graphics::TBitmap;
- pStream = new TMemoryStream();
- }
- //---------------------------------------------------------------------------
- TVmsForm::~TVmsForm()
- {
- FLists.RemoveAll();
- if (pBitmap)
- {
- pBitmap->FreeImage();
- pBitmap->Assign(NULL);
- delete pBitmap;
- pBitmap = NULL;
- }
- if (pStream)
- {
- pStream->Clear();
- pStream->Position = 0;
- delete pStream;
- pStream = NULL;
- }
- if (pCriticalSection)
- {
- delete pCriticalSection;
- pCriticalSection = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void TVmsForm::Clear()
- {
- //FLists.RemoveAll();
- SvcRes = false;
- FtpRes = false;
- FObjects = 0;
- }
- //---------------------------------------------------------------------------
- void TVmsForm::Init(int AWidth, int AHeight)
- {
- try
- {
- pBitmap->PixelFormat = pf4bit;
- pBitmap->Width = AWidth;
- pBitmap->Height= AHeight;
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void TVmsForm::FormClear(TColor ABkColor)
- {
- try
- {
- pBitmap->FreeImage();
- pBitmap->Assign(NULL);
- pBitmap->PixelFormat = pf4bit;
- pBitmap->Width = Width;
- pBitmap->Height= Height;
- pBitmap->Canvas->Pen->Color = clWhite;
- pBitmap->Canvas->Pen->Width = 0;
- pBitmap->Canvas->Pen->Style = psClear;
- pBitmap->Canvas->Brush->Style = bsSolid;
- pBitmap->Canvas->Brush->Color = ABkColor;
- pBitmap->Canvas->Rectangle(0, 0, Width+1, Height+1);
- pStream->Clear();
- pStream->Position = 0;
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- TVmsFormObj *TVmsForm::GetItem(int AIdx)
- {
- TVmsFormObj *pFormObj = FLists.Find(AIdx);
- return pFormObj;
- }
- //---------------------------------------------------------------------------
- int TVmsForm::AddFormObject(TVmsFormObj *AFormObj)
- {
- FLists.Push(FObjects++, AFormObj);
- return FObjects;
- }
- //---------------------------------------------------------------------------
- TVmsFormObj *TVmsForm::AddFormObject()
- {
- TVmsFormObj *pVmsFormObj = NULL;
- if (FObjects < FTotal)
- {
- pVmsFormObj = GetItem(FObjects);
- FObjects++;
- }
- else
- {
- pVmsFormObj = new TVmsFormObj();
- FLists.Push(FTotal++, pVmsFormObj);
- FObjects++;
- }
- return pVmsFormObj;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- //extern TVmsFormManager *VmsFormManager = NULL;
- //---------------------------------------------------------------------------
- TVmsFormManager::TVmsFormManager()
- {
- FTotal = 0;
- FObjects = 0;
- }
- //---------------------------------------------------------------------------
- TVmsFormManager::~TVmsFormManager()
- {
- FLists.RemoveAll();
- }
- //---------------------------------------------------------------------------
- void TVmsFormManager::Clear()
- {
- #ifdef VMS_CLEAR
- FLists.RemoveAll();
- #else
- FObjects = 0;
- FOR_STL(TVmsForm*, pForm, FLists)
- {
- pForm->Clear();
- }
- #endif
- }
- //---------------------------------------------------------------------------
- TVmsForm *TVmsFormManager::GetItem(int AIdx)
- {
- TVmsForm *pForm = FLists.Find(AIdx);
- return pForm;
- }
- //---------------------------------------------------------------------------
- int TVmsFormManager::AddForm(TVmsForm *AForm)
- {
- FLists.Push(FObjects++, AForm);
- return FObjects;
- }
- //---------------------------------------------------------------------------
- TVmsForm *TVmsFormManager::AddForm()
- {
- TVmsForm *pVmsForm = NULL;
- if (FObjects < FTotal)
- {
- pVmsForm = GetItem(FObjects);
- FObjects++;
- }
- else
- {
- pVmsForm = new TVmsForm();
- pVmsForm->Init(FormWidth, FormHeight);
- FLists.Push(FTotal++, pVmsForm);
- FObjects++;
- }
- return pVmsForm;
- }
- //---------------------------------------------------------------------------
|