//--------------------------------------------------------------------------- #include #pragma hdrstop #include "DesignViewForm.h" #include "Main_F.h" #include "define.h" #include "common.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_DESIGN_VIEWER StringTable[0] #define IDS_COPY StringTable[1] #define IDS_SAVE StringTable[2] //--------------------------------------------------------------------------- TDesignView_F *DesignView_F; //--------------------------------------------------------------------------- __fastcall TDesignView_F::TDesignView_F(TComponent* Owner) : TForm(Owner) { StringTable.Create(BaseDir, Language, "DesignViewer"); Caption=IDS_DESIGN_VIEWER; pmdmToClipBoard->Caption=IDS_COPY; pmdmSave->Caption=IDS_SAVE; clickx=0; clicky=0; cursor = Cursor; //width=TEX_MAX_WIDTH; // ¹Ù´Ã¼ö //height=0; // ¹Ù´Ã¼ö //unused wtimes=2; // °¡·Î¹è¼ö htimes=2; // ¼¼·Î¹è¼ö } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::DVResize(RECT r){ ClientWidth=r.right*wtimes; ClientHeight=r.bottom*htimes; chartTempL2->Create(r.right*wtimes,r.bottom*htimes,24); } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::Show(TexLayer *texlayer, TTexpiaBitmap *chartTempL, int DistX, int DistY){ if(!chartTempL) return; int width = texlayer->complete_needle; int maxrun=0; int minrun=0; for(int j2=0;j2texlayer->TexList->Count;j2++){ Tex *tex = ((Tex *)Main->texlayer->TexList->Items[j2]); for(int i2=0;i2Curve->Count;i2++) { KO *ko = (KO *)tex->Curve->Items[i2]; maxrun = max(ko->in,max(ko->via,max(ko->out,maxrun))); minrun = min(ko->in,min(ko->via,min(ko->out,minrun))); } } width+=(maxrun-minrun); RECT r=Rect(0,0,width*DistX,Main->texlayer->GetHeight()*DistY); if(r.right<128) wtimes=8; else if(r.right<512) wtimes=3; else if(r.right<800) wtimes=2; else wtimes=1; if(r.bottom<512) htimes=3; else htimes=2; DVResize(r); HDC dc=chartTempL->CreateDC(); HDC dc2=chartTempL2->CreateDC(); for(int i=0;iHandle; texlayer->Draw2(dc2, Rect(0,0,r.right*wtimes, r.bottom*htimes), DistX, DistY, false); BitBlt(hDC,0,0,chartTempL2->Width,chartTempL2->Height, dc2,0,0,SRCCOPY); chartTempL->DeleteDC(dc); chartTempL2->DeleteDC(dc); } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::FormCreate(TObject *Sender) { SetFont(); chartTempL2 = new TTexpiaBitmap; SavePictureDialog->InitialDir=BaseDir+"\\bmp"; SavePictureDialog->DefaultExt = "bmp"; SavePictureDialog->FileName = "Noname1"; SavePictureDialog->Filter="Bitmaps (*.bmp)|*.bmp|JPEG Image File (*.jpg)|*.jpg"; } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::SetFont() { SetSmallFont(Font); } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::FormDestroy(TObject *Sender) { delete chartTempL2; chartTempL2=NULL; } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { clickx=X; clicky=Y; cursor = Cursor; if(Button==mbLeft) Screen->Cursor=crSizeAll; } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::FormMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { Left+=X-clickx; Top+=Y-clicky; Screen->Cursor=cursor; } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::FormPaint(TObject *Sender) { HDC dc2=chartTempL2->CreateDC(); HDC hDC = Canvas->Handle; BitBlt(hDC,0,0,chartTempL2->Width,chartTempL2->Height, dc2,0,0,SRCCOPY); chartTempL2->DeleteDC(dc2); } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::pmdmToClipBoardClick(TObject *Sender) { BITMAPHANDLE bh; HDC dcSrc = NULL, dcDst = NULL; memset(&bh, 0, sizeof(BITMAPHANDLE)); L_CreateBitmap(&bh, TYPE_CONV, chartTempL2->Width, chartTempL2->Height, 24, ORDER_BGR, NULL, TOP_LEFT); dcDst = L_CreateLeadDC(&bh); dcSrc = chartTempL2->CreateDC(); BitBlt(dcDst, 0, 0, chartTempL2->Width, chartTempL2->Height, dcSrc, 0, 0, SRCCOPY); chartTempL2->DeleteDC(dcSrc); L_DeleteLeadDC(dcDst); dcDst = NULL; L_CopyToClipboard(Handle, &bh); L_FreeBitmap(&bh); } //--------------------------------------------------------------------------- void __fastcall TDesignView_F::pmdmSaveClick(TObject *Sender) { if (SavePictureDialog->Execute()) { if(SavePictureDialog->FilterIndex==1){ chartTempL2->SaveToFile(SavePictureDialog->FileName, FILE_BMP); } else if(SavePictureDialog->FilterIndex==2){ chartTempL2->SaveToFile(SavePictureDialog->FileName, FILE_JFIF, 2);//2´Â ¹«¼Õ½Ç } } } //---------------------------------------------------------------------------