//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "stdio.h" // for test #include "math.h" #include "Main.h" #include "Define.h" #include "File.h" #include "MainImage.h" #include "Palette.h" #include "FileManager_F.h" #include "StyleCombo_F.h" #include "PatternLibrary.h" // added 2004/06/01 #include "ComboPrint_F.h" #include "ComboPrint_F.h" #include "MainMenu.h" // added for Combo by monkman (2004.10.26) #include "Exception.h" #include "PenAndNaviTab_F.h" //--------------------------------------------------------------------------- #define CENTER_X 150 // ±âÁØÁ¡ÀÌ µé¾î°¥ Á¡ÀÇ ÁÂÇ¥ #define CENTER_Y 50 #define MARGIN_X 50 // ¿©¹é ÁÂÇ¥ #define MARGIN_Y 50 #define IDS_StyleCombo StringTable[0] #define IDS_OpenedStyleGBox StringTable[1] #define IDS_IstStyleLabel StringTable[2] #define IDS_spLeftBtn StringTable[3] #define IDS_spRightBtn StringTable[4] #define IDS_ComboMenuGBox StringTable[5] #define IDS_sbSelectPattern StringTable[6] #define IDS_sbSelectColor StringTable[7] #define IDS_sbSaveFile StringTable[8] #define IDS_sbOpenFile StringTable[9] #define IDS_sbPrint StringTable[10] #define IDS_PatterLibraryGBox StringTable[11] #define IDS_sbDeletePattern StringTable[12] #define IDS_sbLoadPatternFile StringTable[13] #define IDS_StyleGroupBox StringTable[14] #define IDS_PSpatternNum StringTable[15] #define IDS_spPatternNumRun StringTable[16] #define IDS_sbExit StringTable[17] #define IDS_COMBOMSGBOX1 StringTable[18] #define IDS_COMBOMSGBOX2 StringTable[19] #define IDS_COMBOMSGBOX3 StringTable[20] #define IDS_COMBOMSGBOX4 StringTable[21] #define IDS_COMBOMSGBOX5 StringTable[22] #define IDS_COMBOMSGBOX6 StringTable[23] #define IDS_COMBOMSGBOX7 StringTable[24] #define IDS_COMBOMSGBOX8 StringTable[25] #define IDS_COMBOMSGBOX9 StringTable[26] #define IDS_COMBOMSGBOX10 StringTable[27] #define IDS_COMBOMSGBOX11 StringTable[28] #define IDS_COMBOMSGBOX12 StringTable[29] //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPImage" #pragma link "TPLayerImage" #pragma link "TPStretchImage" #pragma link "RzEdit" #pragma link "RzSpnEdt" #pragma link "RzPanel" #pragma resource "*.dfm" TStyleComboForm *StyleComboForm; //--------------------------------------------------------------------------- __fastcall TStyleComboForm::TStyleComboForm(TComponent* Owner) : TForm(Owner) { StringTable.Create(DirectoryItem, Language, "StyleCombo"); SetSmallFont(Font); Caption = IDS_StyleCombo; OpenedStyleGBox->Caption = IDS_OpenedStyleGBox; IstStyleLabel->Caption = IDS_IstStyleLabel; spLeftBtn->Hint = IDS_spLeftBtn; spRightBtn->Hint = IDS_spRightBtn; ComboMenuGBox->Caption = IDS_ComboMenuGBox; sbSelectPattern->Hint = IDS_sbSelectPattern; sbSelectColor->Hint = IDS_sbSelectColor; sbSaveFile->Hint = IDS_sbSaveFile; sbOpenFile->Hint = IDS_sbOpenFile; sbPrint->Hint = IDS_sbPrint; PatterLibraryGBox->Caption = IDS_PatterLibraryGBox; sbDeletePattern->Hint = IDS_sbDeletePattern; sbLoadPatternFile->Hint = IDS_sbLoadPatternFile; StyleGroupBox->Caption = IDS_StyleGroupBox; PSpatternNum->Hint = IDS_PSpatternNum; spPatternNumRun->Hint = IDS_spPatternNumRun; sbExit->Hint = IDS_sbExit; //------------------------------------------------------------------------- DataCode = T_STYLIST; MainHeader = new STYLEDATAFILEHEADER; MainVecData = new TList; V_DATA = new TList; // All Vector List S_IMAGE = new TList; // Small Pattern Image List S_SHAPE = new TList; // Small Pattern Shape List S_DATA = new TList; // Small Pattern Image Data List - for test V_HEADER= new TList; // All Vector Header ListOfImage = new TList; ListOfShape = new TList; ListOfButton = new TList; ListOfScrollBox = new TList; ListOfOpenedStyle = new TList; pNumInMainImage = 0; // MainImage¿¡ ÀÖ´Â Style¾ÈÀÇ Pattern°³¼ö cNumInMainImage = 0; // MainImage¿¡ ÀÖ´Â Style¾ÈÀÇ Color°³¼ö imageMouseUpNum = 0; OpenedStyleNum = 0; // ¸î¹øÂ° Opened Style NumberÀÎÁö È®ÀÎ Çϱâ À§Çؼ­ isDblClick = false; SelectAllShape = false; FirstRun = true; // óÀ½ RunÀ» ´­·¶À» ¶§ PushScrollBox = false; // ScrollBoxÀ» ´­·¶´ÂÁö È®ÀÎ - for test isDblClick = false; isSaved = false; // added 2004/06/01 NotChanged = false; // added 2004/06/01 ComboScrollBox->BorderStyle = Forms::bsNone; ComboScrollBox->DoubleBuffered = true; // added 2004/06/01 PatternLibraryScrollBox->BorderStyle = Forms::bsNone; PatternLibraryScrollBox->DoubleBuffered = true; // added 2004/06/01 OpenedStretchImage = NULL; onComboScrollBox = false; // added 2004/06/18 for Wheel Mouse onPatternLibraryScrollBox = false; // added 2004/06/18 for Wheel Mouse } //--------------------------------------------------------------------------- __fastcall TSmallImageData::TSmallImageData() { kind = -1; // 0:Image, 1:Color isSameImage = -1; isSameColor = -1; patternNumber = -1; } //--------------------------------------------------------------------------- __fastcall TSmallImageData::~TSmallImageData() { } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::InitForm() { Top = 0; Left = 0; Width = GetSystemMetrics(SM_CXSCREEN); Height = GetSystemMetrics(SM_CYSCREEN) - GetSystemMetrics(SM_CYCAPTION) - 50; // Full ScreenÀ¸·Î ½ÇÇà ¾ÈµÇ´Â ¹®Á¦ ¶§¹®¿¡.. by celberus WindowState = wsMaximized; Item = C_NONE; // Menu ReadIniFile(); // New PatternLibrary Class PatternLibrary = new TPatternLibrary; PatternLibrary->InitForm(); // Palette À§Ä¡ Á¶Á¤ PaletteForm->Left = ClientWidth/2; PaletteForm->Top = ComboMenuGBox->Top; PaletteForm->Visible = false; // Combo Start CopyMainVecData(MainVecData); if (MainVecData->Count < 1) { StyleComboForm->Visible = true; return; } // Draw Style Combo // ComboScrollBox->Visible = false; // PatternLibraryScrollBox->Visible = false; StatusProgress->Maximum = MainVecData->Count * (3+PSpatternNum->Value*2); CheckIsSamePattern(StatusProgress); PatternLibrary->AddPatternInMainImage(MainVecData, pNumInMainImage, cNumInMainImage, StatusProgress); // for test InitStyleInForm(PSpatternNum->Value, StatusProgress); runNum++; // RunÀ» ´©¸¥ Ƚ¼ö // Create Image for Opened Style -------------------------------------------------- TPLayerImage *SourceImage; OpenedStretchImage = new TPStretchImage(this); OpenedStretchImage->Parent = OpenedStyleGBox; SourceImage = (TPLayerImage *)ListOfImage->Items[0]; OpenedStretchImage->Bitmap->Create(SourceImage->uBitmap->Width, SourceImage->uBitmap->Height, 24); OpenedStretchImage->Bitmap->FillRect(Rect(0, 0, SourceImage->uBitmap->Width, SourceImage->uBitmap->Height), clWhite); PatternLibrary->RatioCalculate(OpenedStretchImage, OpenedStretchImage->Bitmap, shOpenedStyle->Width, shOpenedStyle->Height); OpenedStretchImage->Top = shOpenedStyle->Top + (shOpenedStyle->Height - OpenedStretchImage->Height)/2; OpenedStretchImage->Left = shOpenedStyle->Left + (shOpenedStyle->Width - OpenedStretchImage->Width)/2; //---------------------------------------------------------------------------------- // ComboScrollBox->Visible = true; // PatternLibraryScrollBox->Visible = true; StatusProgress->End(); StyleComboForm->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ExitForm() { WriteIniFile(); if (PaletteForm){ if (PenAndNaviTabForm) { PaletteForm->Left = MainForm->PaletteFormPos.x; PaletteForm->Top = PenAndNaviTabForm->Top + PenAndNaviTabForm->Height; } else { PaletteForm->Left = MainForm->PaletteFormPos.x; PaletteForm->Top = MainForm->PaletteFormPos.y; } PaletteForm->BringToFront(); PaletteForm->Visible = true; } ResetShape(); ResetV_DATAList(); ResetV_HEADER(); // ResetS_IMAGEList(); ResetS_DATAList(); ResetV_HEADER(); ResetMainVecData(); DelPermutationArray(); DelPatternNColor(); if (V_DATA) delete V_DATA; V_DATA=NULL; if (S_IMAGE) delete S_IMAGE; S_IMAGE=NULL; if (S_DATA) delete S_DATA; S_DATA=NULL; if (V_HEADER) delete V_HEADER; V_HEADER=NULL; if (ListOfImage) delete ListOfImage; ListOfImage=NULL; if (ListOfShape) delete ListOfShape; ListOfShape=NULL; if (ListOfButton) delete ListOfButton; ListOfButton=NULL; if (ListOfScrollBox) delete ListOfScrollBox; ListOfScrollBox=NULL; if (OpenedStretchImage) delete OpenedStretchImage; OpenedStretchImage=NULL; ResetOpenedStyle(); if (ListOfOpenedStyle) delete ListOfOpenedStyle; ListOfOpenedStyle=NULL; if (MainVecData) delete MainVecData; MainVecData=NULL; if (MainHeader) delete MainHeader; MainHeader=NULL; PatternLibrary->ExitForm(); if (PatternLibrary) delete PatternLibrary; PatternLibrary=NULL; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ReadIniFile() { BEGIN_LOG(""); TIniFile *StyleComboIni = NULL; StyleComboIni = new TIniFile(AppDataItem + "\\Style.ini"); if (StyleComboIni) { int ptnum = StyleComboIni->ReadInteger("StyleCombo", "PatternNum", 6); PSpatternNum->Value = ptnum; delete StyleComboIni; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::WriteIniFile() { BEGIN_LOG(""); TIniFile *StyleComboIni = NULL; StyleComboIni = new TIniFile(AppDataItem + "\\Style.ini"); if (StyleComboIni) { StyleComboIni->WriteInteger("StyleCombo", "PatternNum", PSpatternNum->Value); delete StyleComboIni; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::InitStyleInForm(int StyleNum, TStatusProgress *stProgress, bool Reload) { TList *DataList = MainVecData; TVecData *vData; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int ImageWidth, ImageHeight, ShapeWidth, ShapeHeight; int realWidth, realHeight, tHeight; double Zoom; RECT rect; getPatternNum = 0; sendedStyleNum = StyleNum; bool isFirst=true; int check; for (int i = 0; i < DataList->Count; i++) { vData = (TVecData *)DataList->Items[i]; if (vData->Kind == V_TEXTBOX || vData->ChildList) { VecDraw->GetRectForMouseMove(vData, rect); minx = min(minx, rect.left); maxx = max(maxx, rect.right); miny = min(miny, rect.top); maxy = max(maxy, rect.bottom); } else { minx = min(minx, vData->First.x); minx = min(minx, vData->Second.x); maxx = max(maxx, vData->First.x); maxx = max(maxx, vData->Second.x); miny = min(miny, vData->First.y); miny = min(miny, vData->Second.y); maxy = max(maxy, vData->First.y); maxy = max(maxy, vData->Second.y); } if (stProgress) stProgress->Position += 1; } // ¿©±â±îÁö for realWidth = maxx - minx; realHeight = maxy - miny; ShapeWidth = (ComboScrollBox->Width/3)-10; //ShapeHeight = (ShapeWidth * realHeight / realWidth)-10; if (ShapeWidth > realWidth) ShapeHeight = realHeight + 20; else ShapeHeight = realHeight*((double)ShapeWidth/realWidth) + 20; ImageWidth = ShapeWidth - 8; ImageHeight = ShapeHeight - 8; if (ShapeWidth > ShapeHeight){ if (realWidth > ShapeWidth){ double wz = (double)ShapeWidth/realWidth; double hz = (double)ShapeHeight/realHeight; if (wz > hz) Zoom = hz; else Zoom = wz; } else Zoom = 0.0; } else { int h = GetSystemMetrics(SM_CYSCREEN) - GetSystemMetrics(SM_CYCAPTION) - 50; if (ShapeHeight > h - 160){ ShapeHeight = h - 160; ImageHeight = ShapeHeight - 8; } if (realHeight > ShapeHeight){ double wz = (double)ShapeWidth/realWidth; double hz = (double)ShapeHeight/realHeight; if (wz > hz) Zoom = hz; else Zoom = wz; } else Zoom = 0.0; } // // À̹ÌÁö°¡ Ŭ°æ¿ì Comboâ¾È¿¡ »çÀÌÁî°¡ ¸ÂÁö ¾ÊÀº °æ¿ì°¡ À־ ÀÌ·¸°Ô ó¸®Çß´Ù. // // VecDrawInCombo¿¡ ÀÖ´Â ZoomÀ» °è»êÇϱ⠱ÍÂú¾Æ¼­ ÀÌ·¸°Ô ó¸®~ ÀÌ·¸°Ô ÇÏ´Ï µÇ´Â°Í °°´Ù. // if (realHeight > ComboScrollBox->Height || realWidth > (ComboScrollBox->Width/2)) // { // if ( realWidth > ImageWidth ) Zoom = (double)ImageWidth / realWidth; // else Zoom = (double)realWidth / ImageWidth; // } // else Zoom=0.0; if (FirstRun || PatternLibrary->anyChanged) { bImageRandNum = 0; bColorRandNum = 0; DelPermutationArray(); // patternÀÇ °³¼ö°¡ º¯°æµÇ¾ú±â ¶§¹®¿¡ Reset DelPatternNColor(); GetPatternNColor(); InitPermutation(); // for test bImageRandNum = pPermutationNum/StyleNum; bColorRandNum = cPermutationNum/StyleNum; } if (Reload) // È­ÀÏOpenÀ» ÇßÀ» °æ¿ì { ReloadStyleInForm(ImageWidth, ImageHeight, StyleNum, Zoom, stProgress); FirstRun = false; } else RunStyleCombo(ImageWidth, ImageHeight, StyleNum, Zoom, stProgress); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::GetPatternNColor() { int pNum = PatternLibrary->PatternNumber; int cNum = PatternLibrary->ColorNumber; PatternArr = new int[pNum]; ColorArr = new int[cNum]; int tpNum=0, tcNum=0; TPatternDATA *patternData; // ListOfpData : the LIst of Pattern Data) if (PatternLibrary->PatternNumber > 0) { for (int i=0; iListOfpData->Count; i++) { patternData = (TPatternDATA *)PatternLibrary->ListOfpData->Items[i]; if (patternData->kindOfPattern == 0) { PatternArr[tpNum]=i; tpNum++; if (pNum==tpNum) break; } } } if (PatternLibrary->ColorNumber > 0) { for (int i=0; iListOfpData->Count; i++) { patternData = (TPatternDATA *)PatternLibrary->ListOfpData->Items[i]; if (patternData->kindOfPattern == 1) { ColorArr[tcNum]=i; tcNum++; if (cNum==tcNum) break; } } } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::DelPatternNColor() { delete[] PatternArr; delete[] ColorArr; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::RunStyleCombo(int ImageWidth, int ImageHeight, int StyleNum, double Zoom, TStatusProgress *stProgress) { TRegIniFile *RegIniFile; String DirectoryBin; String DirectoryName; String FileName; int ShapeHeight = ImageHeight + 8; int ShapeWidth = ImageWidth + 8; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw DirectoryBin = RegIniFile->ReadString("Directory", "Bin", DefaultDir + "\\Bin"); DirectoryName = DirectoryBin + "\\TexStylist\\StyleNo\\"; // ListOfImage->Count != StyleNum¸¦ Ãß°¡ÇÑ ÀÌÀ¯´Â ÀúÀåµÈ ÆÄÀÏÀ» ¿­¾úÀ» ¶§ ´Ù¸¥ °æ¿ì°¡ Àֱ⠶§¹® if (ListOfImage->Count != StyleNum) { StyleNum = PSpatternNum->Value; FirstRun = true; ResetV_DATAList(); ResetS_IMAGEList(); ResetS_DATAList(); ResetV_HEADER(); ResetShape(); runNum = 0; } for (int i=0; iParent = ComboScrollBox; comboShape->Parent = ComboScrollBox; comboImage->Parent = ComboScrollBox; pScrollBox->Parent = ComboScrollBox; comboShape->SendToBack(); comboShape->Pen->Color = Graphics::clSkyBlue; comboShape->Height = ShapeHeight; comboShape->Width = ShapeWidth; comboShape->Top = 5 + i/3 * (ShapeHeight + 83); comboShape->Left = 5 + i%3 * (ShapeWidth + 5); comboImage->Height = ImageHeight; comboImage->Width = ImageWidth; comboImage->Top = comboShape->Top + 4; comboImage->Left = comboShape->Left + 4; comboImage->OnDblClick = tempLayerImageDblClick; comboImage->OnMouseDown = tempLayerImageMouseDown; comboImage->OnMouseMove = tempLayerImageMouseMove; comboImage->OnMouseLeave = tempLayerImageMouseLeave; comboImage->PopupMenu = ImagePopupMenu; sbImageNum->Width = 33; sbImageNum->Height = 33; sbImageNum->Top = comboImage->Top + 4; sbImageNum->Left = comboImage->Left + 4; FileName = IntToStr(i+1) + ".bmp"; sbImageNum->Glyph->LoadFromFile(DirectoryName+FileName); sbImageNum->NumGlyphs = 1; sbImageNum->AllowAllUp = true; sbImageNum->GroupIndex = i+1; sbImageNum->Flat = true; sbImageNum->OnClick = tempSpButtonClick; sbImageNum->BringToFront(); sbImageNum->Hint = IDS_COMBOMSGBOX12; // IDS_COMBOMSGBOX12: ¹öư ´©·ç¸é °íÁ¤ sbImageNum->ShowHint = true; pScrollBox->Width = comboShape->Width; pScrollBox->Height = 81; pScrollBox->Top = comboShape->Top + comboShape->Height + 1; pScrollBox->Left = comboShape->Left; pScrollBox->DoubleBuffered = true; pScrollBox->BorderStyle = Forms::bsNone; pScrollBox->VertScrollBar->Visible = false; pScrollBox->OnMouseMove = patternScrollBoxMouseMove; for (int j=0; jParent = pScrollBox; SmallImage->Bitmap->Create(50, 60, 24); SmallImage->Bitmap->FillRect(Rect(0, 0, 50, 60), clWhite); SmallImage->Width = 50; SmallImage->Height = 60; SmallImage->Top = 2; SmallImage->Left = 5 + j*55; SmallImage->OnMouseDown = tempSmallStImageMouseDown; SmallShape->Parent = pScrollBox; SmallShape->Width = 52; SmallShape->Height = 62; SmallShape->Top = SmallImage->Top-1; SmallShape->Left = SmallImage->Left-1; SmallShape->Brush->Color = clWhite; SmallShape->Brush->Style = bsSolid; SmallShape->Pen->Color = (TColor)0xB5B5B5; SmallShape->Pen->Style = psSolid; SmallImage->BringToFront(); sPatternList->Add(SmallImage); sClassList->Add(sImageData); sShapeList->Add(SmallShape); } S_IMAGE->Add(sPatternList); S_DATA->Add(sClassList); S_SHAPE->Add(sShapeList); comboImage->uBitmap->Create(ImageWidth, ImageHeight, 24); comboImage->uBitmap->FillRect(Rect(0, 0, ImageWidth, ImageHeight), clWhite); TTexpiaBitmap *tempImage = new TTexpiaBitmap; tempImage->Create(comboImage->uBitmap->Width, comboImage->uBitmap->Height, comboImage->uBitmap->BitsPerPixel, comboImage->uBitmap->RGB); comboImage->uBitmap->CopyToTexpia(tempImage, 0, 0, comboImage->uBitmap->Width, comboImage->uBitmap->Height, 0, 0, SRCCOPY); HDC dcDst = tempImage->CreateDC(); InitTransToCombo(VecDataList); V_DATA->Add(VecDataList); VecDrawInCombo(dcDst, VecDataList, ImageWidth, ImageHeight, 0, Zoom ,i, stProgress); tempImage->DeleteDC(dcDst); comboImage->uBitmap->Copy(tempImage, SRCCOPY); delete tempImage; ListOfImage->Add(comboImage); ListOfShape->Add(comboShape); ListOfButton->Add(sbImageNum); ListOfScrollBox->Add(pScrollBox); PatternLibrary->anyChanged = false; // for test } else { TSpeedButton *sbImageNum; sbImageNum = (TSpeedButton *)ListOfButton->Items[i]; if (sbImageNum->Down) continue; TList *VecDataList; // Vector Object List TPLayerImage *comboImage; VecDataList = (TList *)V_DATA->Items[i]; comboImage = (TPLayerImage *)ListOfImage->Items[i]; comboImage->uBitmap->FillRect(Rect(0, 0, comboImage->Width, comboImage->Height), clWhite); TTexpiaBitmap *tempImage = new TTexpiaBitmap; tempImage->Create(comboImage->uBitmap->Width, comboImage->uBitmap->Height, comboImage->uBitmap->BitsPerPixel, comboImage->uBitmap->RGB); comboImage->uBitmap->CopyToTexpia(tempImage, 0, 0, comboImage->uBitmap->Width, comboImage->uBitmap->Height, 0, 0, SRCCOPY); HDC dcDst = tempImage->CreateDC(); VecDrawInCombo(dcDst, VecDataList, comboImage->Width, comboImage->Height, StyleNum, Zoom, i, NULL); tempImage->DeleteDC(dcDst); comboImage->uBitmap->Copy(tempImage, SRCCOPY); delete tempImage; comboImage->Repaint(); } } FirstRun = false; delete RegIniFile; } //--------------------------------------------------------------------------- // MaingImageÀÇ Vector Data¸¦ CopyÇÏ´Â ÇÔ¼ö (¸Þ¸ð¸®¿¡ ¿Ã·Á³õ±â À§Çؼ­) void __fastcall TStyleComboForm::CopyMainVecData(TList *MainList) { TList *DataList = VecDraw->NVector->DataList; TVecData *data = NULL, *cdata = NULL, *motivedata = NULL; PasteRange = Rect(50000, 50000, 0, 0); RECT rect; int number = VecDraw->CheckStyle(); if (number != 0) { PSTYLEDATAFILEHEADER pheader; pheader = (PSTYLEDATAFILEHEADER)MainImageForm->StyleHeader->Items[abs(number)-1]; VecDraw->CopySTYHeader(MainHeader, *pheader); } for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX || data->ChildList) { VecDraw->GetRectForMouseMove(data, rect); PasteRange.left = min((double)PasteRange.left, (double)rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); } else if (data->Kind == V_TEXT || data->Kind == V_ELLIPSE) { // Font°¡ ÀÖÀ» ¶§ Error°¡ ¹ß»ýÇØ¼­ ÀÌ·¸°Ô ó¸®Çß´Ù. // V_ELLIPSE¿¡¼­ ¿¡·¯°¡ ¹ß»ýÇØ¼­ Ãß°¡Çß´Ù. PasteRange.left = min((double)PasteRange.left, min(data->First.x, data->Second.x)-(data->PenThick+1)*2); PasteRange.right = max((double)PasteRange.right, max(data->First.x, data->Second.x)+(data->PenThick+1)*2); PasteRange.top = min((double)PasteRange.top, min(data->First.y, data->Second.y)-(data->PenThick+1)*2); PasteRange.bottom = max((double)PasteRange.bottom, max(data->First.y, data->Second.y)+(data->PenThick+1)*2); } else { SET_RECT; PasteRange.left = min((double)PasteRange.left, min(data->First.x, data->Second.x)-(data->PenThick+1)*2); PasteRange.right = max((double)PasteRange.right, max(data->First.x, data->Second.x)+(data->PenThick+1)*2); PasteRange.top = min((double)PasteRange.top, min(data->First.y, data->Second.y)-(data->PenThick+1)*2); PasteRange.bottom = max((double)PasteRange.bottom, max(data->First.y, data->Second.y)+(data->PenThick+1)*2); } } int check=0; // ButtonÀÇ enable À¯¹« °Ë»ç for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; cdata = new TVecData(0); // Instance°ªÀ» ±¸ºÐÇÒ Çʿ䰡 ¾øÀ¸¹Ç·Î OÀ¸·Î ÃʱâÈ­Çß´Ù. cdata->Copy(data); cdata->First.x -= PasteRange.left; cdata->Second.x -= PasteRange.left; cdata->First.y -= PasteRange.top; cdata->Second.y -= PasteRange.top; cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) { for (int j = 0; j < cdata->nCount*3+1; j++) { cdata->pList[j].x -= PasteRange.left; cdata->pList[j].y -= PasteRange.top; } } if (cdata->Kind == V_TEXTBOX) { cdata->StartPoint.x -= PasteRange.left; cdata->StartPoint.y -= PasteRange.top; for (int k = 0; k < 5; k++) { cdata->pList[k].x -= PasteRange.left; cdata->pList[k].y -= PasteRange.top; } cdata->CenterPoint.x = (cdata->First.x + cdata->Second.x)/2; cdata->CenterPoint.y = (cdata->First.y + cdata->Second.y)/2; } // added by maxleo21c (°°Àº PatternÀÎÁö ¾Ë±â À§Çؼ­~) cdata->isSameImage = data->isSameImage; cdata->isSameColor = data->isSameColor; /* if (cdata->ChildList) { //090407 by david for (int j = 0; j < cdata->ChildList->Count; j++) { motivedata = (TVecData *)DataList->Items[j]; motivedata->First.x -= PasteRange.left; motivedata->Second.x -= PasteRange.left; motivedata->First.y -= PasteRange.top; motivedata->Second.y -= PasteRange.top; motivedata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. if (motivedata->Kind == V_LINE || motivedata->Kind == V_CURVE) { for (int k = 0; k < motivedata->nCount*3+1; k++) { motivedata->pList[k].x -= PasteRange.left; motivedata->pList[k].y -= PasteRange.top; } } } //cdata->centerX -= PasteRange.left; //cdata->centerY -= PasteRange.top; } */ if (cdata->bPatternFill || cdata->bFill ) check++; MainList->Add(cdata); } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::CheckIsSamePattern(TStatusProgress *stProgress) { TList *DataList = MainVecData; TVecData *data = NULL; int isSameArrColor[20]; // isSame ¹øÈ£¸¦ ÀúÀåÇÏ´Â ¹è¿­ int isSameArrImage[20]; // isSame ¹øÈ£¸¦ ÀúÀåÇÏ´Â ¹è¿­ bool isFirstColor=true, isFirstImage=true; for (int i = 0; i < DataList->Count; i++) { stProgress->Position += 1; data = (TVecData *)DataList->Items[i]; if (data->bFill) { if (!isFirstColor) { for(int j=0; jBrush) { data->isSameColor=j; goto bypass; } } } isFirstColor=false; data->isSameColor=cNumInMainImage; isSameArrColor[cNumInMainImage]=data->Brush; cNumInMainImage++; // MainImageÀÇ Style¾È¿¡ Pattern°³¼ö // ¿©±â±îÁö else } if (data->bPatternFill) { if (!isFirstImage) { for(int j=0; jBrush) { data->isSameImage=j; goto bypass; } } } isFirstImage=false; data->isSameImage=pNumInMainImage; isSameArrImage[pNumInMainImage]=data->Brush; pNumInMainImage++; // MainImageÀÇ Style¾È¿¡ Pattern°³¼ö } bypass: } // ¿©±â±îÁö for¹® } //--------------------------------------------------------------------------- // °¢°¢ÀÇ Image¿¡ MainImage¿¡¼­ °¡Á®¿Â Data¸¦ CopyÇÑ´Ù. int __fastcall TStyleComboForm::InitTransToCombo(TList *TransList) { TList *DataList = MainVecData; TVecData *data = NULL, *cdata = NULL; PasteRange = Rect(50000, 50000, 0, 0); RECT rect; PSTYLEDATAFILEHEADER pheader = new STYLEDATAFILEHEADER; VecDraw->CopySTYHeader(pheader, *MainHeader); V_HEADER->Add(pheader); for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (data->Kind == V_TEXTBOX || data->ChildList) { VecDraw->GetRectForMouseMove(data, rect); PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); } else if (data->Kind == V_TEXT || data->Kind == V_ELLIPSE) { // Font°¡ ÀÖÀ» ¶§ Error°¡ ¹ß»ýÇØ¼­ ÀÌ·¸°Ô ó¸®Çß´Ù. // V_ELLIPSE¿¡¼­ ¿¡·¯°¡ ¹ß»ýÇØ¼­ Ãß°¡Çß´Ù. PasteRange.left = min((double)PasteRange.left, min(data->First.x, data->Second.x)-(data->PenThick+1)*2); //data->PenThick*2 PasteRange.right = max((double)PasteRange.right, max(data->First.x, data->Second.x)+(data->PenThick+1)*2); PasteRange.top = min((double)PasteRange.top, min(data->First.y, data->Second.y)-(data->PenThick+1)*2); PasteRange.bottom = max((double)PasteRange.bottom, max(data->First.y, data->Second.y)+(data->PenThick+1)*2); } else { SET_RECT; PasteRange.left = min((double)PasteRange.left, min(data->First.x, data->Second.x)-(data->PenThick+1)*2); PasteRange.right = max((double)PasteRange.right, max(data->First.x, data->Second.x)+(data->PenThick+1)*2); PasteRange.top = min((double)PasteRange.top, min(data->First.y, data->Second.y)-(data->PenThick+1)*2); PasteRange.bottom = max((double)PasteRange.bottom, max(data->First.y, data->Second.y)+(data->PenThick+1)*2); } } for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; cdata = new TVecData(0); // Instance°ªÀ» ±¸ºÐÇÒ Çʿ䰡 ¾øÀ¸¹Ç·Î OÀ¸·Î ÃʱâÈ­Çß´Ù. cdata->Copy(data); cdata->First.x -= PasteRange.left; cdata->Second.x -= PasteRange.left; cdata->First.y -= PasteRange.top; cdata->Second.y -= PasteRange.top; cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) { for (int j = 0; j < cdata->nCount*3+1; j++) { cdata->pList[j].x -= PasteRange.left; cdata->pList[j].y -= PasteRange.top; } } if (cdata->Kind == V_TEXTBOX) { cdata->StartPoint.x -= PasteRange.left; cdata->StartPoint.y -= PasteRange.top; for (int k = 0; k < 5; k++) { cdata->pList[k].x -= PasteRange.left; cdata->pList[k].y -= PasteRange.top; } cdata->CenterPoint.x = (cdata->First.x + cdata->Second.x)/2; cdata->CenterPoint.y = (cdata->First.y + cdata->Second.y)/2; } // added by maxleo21c (°°Àº PatternÀÎÁö ¾Ë±â À§Çؼ­~) cdata->isSameImage = data->isSameImage; cdata->isSameColor = data->isSameColor; TransList->Add(cdata); } return TransList->Count; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ResetShape() { TPStretchImage *tImage; TShape *tShape; TSpeedButton *sbButton; TScrollBox *tScrollBox; if (!ListOfShape) return; while (ListOfShape->Count>0) { tShape = (TShape *)ListOfShape->Last(); ListOfShape->Remove(tShape); delete tShape; tShape=NULL; tImage = (TPStretchImage *)ListOfImage->Last(); ListOfImage->Remove(tImage); delete tImage; tImage=NULL; sbButton = (TSpeedButton *)ListOfButton->Last(); ListOfButton->Remove(sbButton); delete sbButton; sbButton=NULL; tScrollBox = (TScrollBox *)ListOfScrollBox->Last(); ListOfScrollBox->Remove(tScrollBox); delete tScrollBox; tScrollBox=NULL; } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ResetV_DATAList() { TList *tList; TVecData *vData; if (!V_DATA) return; while (V_DATA->Count>0) { tList = (TList *)V_DATA->Last(); while (tList->Count>0) { vData = (TVecData *)tList->Last(); tList->Remove(vData); delete vData; vData=NULL; } V_DATA->Remove(tList); delete tList; tList=NULL; } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ResetS_IMAGEList() { TList *sPatternList; TPStretchImage *smallImage; TList *sShapeList; // Small Pattern Shape List if (!S_IMAGE) return; while (S_IMAGE->Count>0) { sPatternList = (TList *)S_IMAGE->Last(); sShapeList = (TList *)S_SHAPE->Last(); while (sPatternList->Count>0) { smallImage = (TPStretchImage *)sPatternList->Last(); sPatternList->Remove(smallImage); delete smallImage; smallImage=NULL; } S_IMAGE->Remove(sPatternList); delete sPatternList; sPatternList=NULL; S_SHAPE->Remove(sShapeList); delete sShapeList; sShapeList=NULL; } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ResetS_DATAList() { TList *sDataList; TSmallImageData *sImageData; if (!S_DATA) return; while (S_DATA->Count>0) { sDataList = (TList *)S_DATA->Last(); while (sDataList->Count>0) { sImageData = (TSmallImageData *)sDataList->Last(); sDataList->Remove(sImageData); delete sImageData; sImageData=NULL; } S_DATA->Remove(sDataList); delete sDataList; sDataList=NULL; } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ResetOpenedStyle() { TTexpiaBitmap *tBitmap; if (!ListOfOpenedStyle) return; while (ListOfOpenedStyle->Count>0) { tBitmap = (TTexpiaBitmap *)ListOfOpenedStyle->Last(); ListOfOpenedStyle->Remove(tBitmap); delete tBitmap; tBitmap=NULL; } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ResetMainVecData() { TVecData *data; if (!MainVecData) return; while (MainVecData->Count>0) { data = (TVecData *)MainVecData->Last(); MainVecData->Remove(data); delete data; data=NULL; } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ResetV_HEADER() { PSTYLEDATAFILEHEADER pheader; if (!V_HEADER) return; while (V_HEADER->Count>0) { pheader = (PSTYLEDATAFILEHEADER)V_HEADER->Last(); V_HEADER->Remove(pheader); delete pheader; pheader=NULL; } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::VecDrawInCombo(HDC dcDst, TList *list, double CWidth, double CHeight, int StyleNum, double Zoom, int nowImageNum, TStatusProgress *stProgress) { HPEN hOldPen = NULL , hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int cenx, ceny, width, height; TVecData *data; int randPatternNum=0, StartX, StartY, PlusNum=0; double textCenterX, textCenterY; int OffsetX, OffsetY; //by linuxjun for CurvedVectorText RECT rect; gdp::Graphics graphics(dcDst); // using GDI+ gdp::Point *pPoints = NULL; //graphics.SetPageUnit(gdp::UnitPixel); graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing for (int i = 0; i < list->Count; i++) { // objectÀ§Ä¡ º¸Á¤ if (stProgress) stProgress->Position += 1; data = (TVecData *)list->Items[i]; //if(data->bAntialiasing) graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); //else graphics.SetSmoothingMode(gdp::SmoothingModeNone); if (data->Kind == V_TEXTBOX || data->ChildList) { VecDraw->GetRectForMouseMove(data, rect); minx = min(minx, rect.left); maxx = max(maxx, rect.right); miny = min(miny, rect.top); maxy = max(maxy, rect.bottom); } else if (data->Kind == V_TEXT || data->Kind == V_ELLIPSE) { // Font°¡ ÀÖÀ» ¶§ Error°¡ ¹ß»ýÇØ¼­ ÀÌ·¸°Ô ó¸®Çß´Ù. // V_ELLIPSE¿¡¼­ ¿¡·¯°¡ ¹ß»ýÇØ¼­ Ãß°¡Çß´Ù. minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); } else { SET_RECT; minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); } } cenx = (minx+maxx)/2; ceny = (miny+maxy)/2; // center Á¡ width = maxx-minx; height = maxy-miny; // zoom º¸Á¤À§ÇØ if (Zoom == 0.0) { Zoom = CWidth/width < CHeight/height ? CWidth/width : CHeight/height; Zoom *= 0.95; // ¿©¹éÁÖ±â Zoom = Zoom > 1.0 ? 1.0 : Zoom; Zoom = Zoom < 4.0/8.0 ? 4.0/8.0 : Zoom; }else { Zoom *= 0.95; // ¿©¹éÁÖ±â } ZoomValue = Zoom; // Small Image¸¦ º¯°æÇؼ­ ÇöÀç Combo°á°ú¹°ÀÇ Image/color PatternÀ» WidthValue = CWidth; // º¯°æÇÒ ¶§ »ç¿ëÇϱâ À§Çؼ­ ¸¸µé¾îÁø º¯¼öµéÀÌ´Ù. HeightValue = CHeight; // VecDrawAtMouseUpinSmallImage()¿¡¼­ »ç¿ëµÈ´Ù. CenterX = cenx; CenterY = ceny; int sPatternNum = 0, check = 0, ccheck = 0; bool first=true, cfirst=true; randPatternNum=0; TList *spList, *sdList; // Small Pattern Image List spList = (TList *)S_IMAGE->Items[nowImageNum]; sdList = (TList *)S_DATA->Items[nowImageNum]; TPStretchImage *sImage; TPStretchImage *smallImage; TTexpiaBitmap *realImageBitmap; int sW, sH; // isSameImage, isSameColorÀ» ºñ±³Çϱâ À§ÇÑ Àӽà ¹è¿­ int **checkColor, **checkImage; checkColor = new int*[cNumInMainImage]; checkImage = new int*[pNumInMainImage]; for (int j = 0; j < cNumInMainImage; j++) checkColor[j] = new int[2]; for (int j = 0; j < pNumInMainImage; j++) checkImage[j] = new int[2]; int sColorNum=0; int sImageNum=0; for (int i = 0; i < list->Count; i++) { if (stProgress) stProgress->Position += 1; data = (TVecData *)list->Items[i]; int FirstX = (data->First.x - cenx) * Zoom + CWidth/2 + 0.5; int FirstY = (data->First.y - ceny) * Zoom + CHeight/2 + 0.5; int SecondX = (data->Second.x - cenx) * Zoom + CWidth/2 + 0.5; int SecondY = (data->Second.y - ceny) * Zoom + CHeight/2 + 0.5; int pw = data->PenThick/2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Pen ObjectPen(penColor, data->PenThick*Zoom); if (data->Kind == V_TEXTBOX) { pPoints = new gdp::Point[5]; } else { if (data->bClosed){ pPoints = new gdp::Point[(data->nCount+1)*3+1]; } else { pPoints = new gdp::Point[data->nCount*3+1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int is = 0; is < data->nCount*3 +1; is++) { pPoints[is].X = (data->pList[is].x - cenx) * Zoom + CWidth/2 + 0.5; pPoints[is].Y = (data->pList[is].y - ceny) * Zoom + CHeight/2 + 0.5; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - cenx) * Zoom + CWidth/2 + 0.5; StartY = (data->StartPoint.y - ceny) * Zoom + CHeight/2 + 0.5; textCenterX = (data->CenterPoint.x - cenx) * Zoom + CWidth/2 + 0.5; textCenterY = (data->CenterPoint.y - ceny) * Zoom + CHeight/2 + 0.5; OffsetX = cenx; //by linuxjun for CurvedVectorText OffsetY = ceny; //by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - cenx) * Zoom + CWidth/2 + 0.5; pPoints[i].Y = (data->pList[i].y - ceny) * Zoom + CHeight/2 + 0.5; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount*3] = pPoints[0]; pPoints[data->nCount*3+1] = pPoints[1]; pPoints[data->nCount*3+2] = pPoints[2]; pPoints[data->nCount*3+3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) // PatternFill À϶§ { Byte *byte, *sByte; int w, h, GetNum=0; double doublebrush = 0.0; w = data->TBitmapSource->Width; h = data->TBitmapSource->Height; // °°Àº PatternÀ» ³Ö¾î¾ß ÇÏ´ÂÁö È®ÀÎÇÏ´Â ºÎºÐ--------------------------- if (!first) { for(int k=0; kisSameImage) { if (PatternLibrary->PatternNumber < 1 || pPermutationNum == 0) goto paintPattern; TTexpiaBitmap *tBitmap; HDC sDC, tDC; tBitmap = (TTexpiaBitmap *)PatternLibrary->GetRealImageBitmap(checkImage[k][1]); delete data->TBitmapSource; data->TBitmapSource = new TTexpiaBitmap; data->TBitmapSource->Create(tBitmap->Width, tBitmap->Height, tBitmap->BitsPerPixel); data->TBitmapSource->Copy(tBitmap, SRCCOPY); goto paintPattern; } } } //---------------------------------------------------------------------- // Pattern Library¿¡ PatternÀÌ ¾øÀ» °æ¿ì MainImage¿¡ ÀÖ´Â PatternÀ» ±×¸°´Ù. if (PatternLibrary->PatternNumber < 1 || pPermutationNum == 0) { SmallPatternImagePaint(sPatternNum, spList, sdList, data->TBitmapSource, data->isSameImage); sPatternNum++; checkImage[sImageNum][0]=data->isSameImage; sImageNum++; first=false; goto byPassPaint; } first=false; if (bImageRandNum>=5) randPatternNum = iPermutationArray[(runNum+bImageRandNum*nowImageNum)%pPermutationNum][data->isSameImage]; else randPatternNum = iPermutationArray[(runNum*StyleNum+nowImageNum)%pPermutationNum][data->isSameImage]; realImageBitmap = (TTexpiaBitmap *)PatternLibrary->GetRealImageBitmap(randPatternNum); sImage = (TPStretchImage *)PatternLibrary->GetPatternImage(randPatternNum); checkImage[sImageNum][0]=data->isSameImage; checkImage[sImageNum][1]=randPatternNum; // ÇöÀç SourceImage¸¦ °¡Áø Data Number¸¦ ÀúÀå sImageNum++; // Small Image¸¦ ±×·ÁÁÖ´Â ºÎºÐ------------------------------------------ SmallPatternImagePaint(sPatternNum, spList, sdList, sImage->Bitmap, data->isSameImage); sPatternNum++; //---------------------------------------------------------------------- // Image¿¡ PatternÀ» ±×·ÁÁÖ´Â ºÎºÐ-------------------------------------- delete data->TBitmapSource; data->TBitmapSource = new TTexpiaBitmap; data->TBitmapSource->Create(realImageBitmap->Width, realImageBitmap->Height, realImageBitmap->BitsPerPixel); data->TBitmapSource->Copy(realImageBitmap, SRCCOPY); paintPattern: VecDraw->MakePatternBitmap(data); byPassPaint: int bltwidth = SecondX - FirstX; int bltheight = SecondY - FirstY; HDC dcPattern = NULL, dcMask = NULL; if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC())==NULL) goto patternfail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0,0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) // ColorFill À϶§ { int GetNum=0; // °°Àº ColorÀ» ³Ö¾î¾ß ÇÏ´ÂÁö È®ÀÎÇÏ´Â ºÎºÐ--------------------------- if (cfirst) { for(int k=0; kisSameColor) { if (PatternLibrary->ColorNumber < 1) goto ColorNext; data->Brush = (TColor)checkColor[k][1]; goto ColorNext; } } } // Pattern Library¿¡ Color°¡ ¾øÀ» °æ¿ì MainImage¿¡ ÀÖ´Â ColorÀ» Ä¥ÇÑ´Ù. if (PatternLibrary->ColorNumber < 1 || cPermutationNum == 0) { // SmallImage Color Fill ºÎºÐ SmallColorImagePaint(sPatternNum, spList, sdList, data->Brush, data->isSameColor); sPatternNum++; checkColor[sColorNum][0]=data->isSameColor; sColorNum++; goto ColorNext; } // Small Image¸¦ ±×·ÁÁÖ´Â ºÎºÐ------------------------------------------ if (bColorRandNum>=5) randPatternNum = cPermutationArray[(runNum+bColorRandNum*nowImageNum)%cPermutationNum][data->isSameColor]; else randPatternNum = cPermutationArray[(runNum*StyleNum+nowImageNum)%cPermutationNum][data->isSameColor]; data->Brush=PatternLibrary->GetColorBrush(randPatternNum); SmallColorImagePaint(sPatternNum, spList, sdList, data->Brush, data->isSameColor); sPatternNum++; checkColor[sColorNum][0]=data->isSameColor; checkColor[sColorNum][1]=data->Brush; sColorNum++; //---------------------------------------------------------------------- ColorNext: logbrush.lbColor = data->Brush; hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch (data->PenStyle) { case 0: nPenStyle = int (PS_SOLID); break; case 1: nPenStyle = int (PS_DASH); break; case 2: nPenStyle = int (PS_DOT); break; case 3: nPenStyle = int (PS_DASHDOT); break; case 4: nPenStyle = int (PS_DASHDOTDOT);break; case 5: nPenStyle = P_USERSTYLE; // 2005 Vector upgrade shin 0330 int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0}; VecDraw->CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (VecDraw->osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick*Zoom+0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * Zoom + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); if (data->ChildList) { VecDrawInComboForMotive(dcDst, data, CWidth, CHeight, StyleNum, Zoom, nowImageNum, cenx, ceny); } else { PAINT_VECTOR; } if (pPoints) delete []pPoints; pPoints = NULL; if (dashValues) delete []dashValues; dashValues = NULL; if (data->Kind == V_TEXTBOX) DrawTextBox(dcDst, data, StartX, StartY, textCenterX, textCenterY, Zoom, PlusNum, OffsetX, OffsetY); //by linuxjun for CurvedVectorText if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } } for (int j = 0; j < cNumInMainImage; j++) delete[] checkColor[j]; for (int j = 0; j < pNumInMainImage; j++) delete[] checkImage[j]; delete[] checkColor; delete[] checkImage; return; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::VecDrawInComboForMotive(HDC dcDst, TVecData* ParentData, double CWidth, double CHeight, int StyleNum, double Zoom, int nowImageNum, int cenx, int ceny) { TList *tDataList = ParentData->ChildList; TList *DataList = new TList; TList * ResultBezierPointList; TPointList *tempPointList; TVecData *data = NULL; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList; /* for (int i = 0 ; i < ParentData->ChildList->Count; i++) { TVecData *temp = (TVecData *) ParentData->ChildList->Items[i]; temp->bSelected = ParentData->bSelected; } */ /* centerX¿Í centerY¸¦ ÅëÇØ¼­ CHildµéÀÇ center¸¦ ±¸Çϰí, ¹ØÀÇ bezierpointlistÀÇ ÀÌ¿ë(pTempList)À» ÅëÇØ¼­ childÀÇ À§Ä¡¸¦ Á¤ÇØÁØ´Ù. parent ¸¦ n°³·Î ³ª´«´Ù¸é, 3n+1°³ÀÇ Á¡ÀÌ ÀÖ´Ù. (index·Î 0~3n) 0,3,6,9....3nÀ» °¡Á®´Ù ¾²¸é µÊ. */ double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); //»ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; int quotient = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); if (quotient==0) quotient = 1; switch (ParentData->mode) { case 0: // ²Ë ä¿ì±â nSegment = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); if (nSegment ==0) nSegment = 1; ParentData->gap = double(CurveLength/nSegment); ParentData->motivecount = nSegment; break; case 1: // °³¼ö ¼³Á¤ nSegment = StrToInt(ParentData->motivecount); if (nSegment ==0) nSegment = 1; ParentData->gap = double(CurveLength/nSegment); break; case 2: // °£°Ý ¼³Á¤ nSegment = int(CurveLength/ParentData->gap); if (nSegment ==0) nSegment = 1; ParentData->motivecount = nSegment; break; } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); if (!ResultBezierPointList) { delete DataList; DataList; delete BezierPointList; BezierPointList = NULL; return; } pTempList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(nSegment*3+1)); double *tangentlist = new double[nSegment+1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = VecDraw->FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = VecDraw->FindCurveTangent(&ParentData->pList[0], 0); for(int i=0;iCount;i++) { tempPointList = (TPointList *)ResultBezierPointList->Items[i]; for(tempPointList->First();!tempPointList->IsDone();tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = VecDraw->FindingNormalOnBezier(&ParentData->pList[i*3], dInterval, 0, count%2); tangentlist[count] = VecDraw->FindCurveTangent(&ParentData->pList[i*3], dInterval); pTempList[count*3 - 2] = pTempList[count*3 - 3]; pTempList[count*3 - 1].x = normalPoint.x; pTempList[count*3 - 1].y = normalPoint.y; pTempList[count*3].x = normalPoint.x; pTempList[count*3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed){ // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment*3] = pTempList[0]; pTempList[nSegment*3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; //------------------------------------------------------------ HPEN hOldPen = NULL , hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int width, height; int randPatternNum=0, StartX, StartY, PlusNum=0; double textCenterX, textCenterY; int OffsetX, OffsetY; //by linuxjun for CurvedVectorText RECT rect; gdp::Graphics graphics(dcDst); // using GDI+ gdp::Point *pPoints = NULL; graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing //------------------------------------------ TVecData *tdata; // motive childÀÇ È®´ë Ãà¼Ò for (int i =0; i < tDataList->Count; i++) { data = (TVecData *)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); for (int l = 0; l < data->nCount*3 +1; l++) { tdata->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; tdata->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } DataList->Add(tdata); } //------------------------------------------ for (int k = 0; k < nSegment; k++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; //Rotation ÇÏ´Â ºÎºÐ---------------------- for (int l = 0; l < data->nCount*3 +1; l++) { data->pList[l].x = data->pList[l].x - ParentData->centerX + pTempList[3*k].x; data->pList[l].y = data->pList[l].y - ParentData->centerY + pTempList[3*k].y; } for (int l = 0; l < data->nCount*3 +1; l++) { double dx = data->pList[l].x - pTempList[3*k].x; double dy = data->pList[l].y - pTempList[3*k].y; data->pList[l].x = dx*cos(tangentlist[k]) - dy*sin(tangentlist[k]) + pTempList[3*k].x; data->pList[l].y = dx*sin(tangentlist[k]) + dy*cos(tangentlist[k]) + pTempList[3*k].y; } //------------------------------------------ SET_RECT; int FirstX = (data->First.x - cenx) * Zoom + CWidth/2 + 0.5; int FirstY = (data->First.y - ceny) * Zoom + CHeight/2 + 0.5; int SecondX = (data->Second.x - cenx) * Zoom + CWidth/2 + 0.5; int SecondY = (data->Second.y - ceny) * Zoom + CHeight/2 + 0.5; int pw = data->PenThick/2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Pen ObjectPen(penColor, data->PenThick*Zoom); if (data->Kind == V_TEXTBOX) { pPoints = new gdp::Point[5]; } else { if (data->bClosed){ pPoints = new gdp::Point[(data->nCount+1)*3+1]; } else { pPoints = new gdp::Point[data->nCount*3+1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int is = 0; is < data->nCount*3 +1; is++) { pPoints[is].X = (data->pList[is].x - cenx) * Zoom + CWidth/2 + 0.5; pPoints[is].Y = (data->pList[is].y - ceny) * Zoom + CHeight/2 + 0.5; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - cenx) * Zoom + CWidth/2 + 0.5; StartY = (data->StartPoint.y - ceny) * Zoom + CHeight/2 + 0.5; textCenterX = (data->CenterPoint.x - cenx) * Zoom + CWidth/2 + 0.5; textCenterY = (data->CenterPoint.y - ceny) * Zoom + CHeight/2 + 0.5; OffsetX = cenx; //by linuxjun for CurvedVectorText OffsetY = ceny; //by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - cenx) * Zoom + CWidth/2 + 0.5; pPoints[i].Y = (data->pList[i].y - ceny) * Zoom + CHeight/2 + 0.5; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount*3] = pPoints[0]; pPoints[data->nCount*3+1] = pPoints[1]; pPoints[data->nCount*3+2] = pPoints[2]; pPoints[data->nCount*3+3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) // PatternFill À϶§ { int bltwidth = SecondX - FirstX; int bltheight = SecondY - FirstY; HDC dcPattern = NULL, dcMask = NULL; VecDraw->MakePatternBitmap(data); data->TBitmapSource->SaveToFile("c:\\test_s.bmp", FILE_BMP); data->TBitmap->SaveToFile("c:\\test.bmp", FILE_BMP); if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC())==NULL) goto patternfail; SetStretchBltMode(dcDst, HALFTONE); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0,0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) // ColorFill À϶§ { logbrush.lbColor = data->Brush; hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch (data->PenStyle) { case 0: nPenStyle = int (PS_SOLID); break; case 1: nPenStyle = int (PS_DASH); break; case 2: nPenStyle = int (PS_DOT); break; case 3: nPenStyle = int (PS_DASHDOT); break; case 4: nPenStyle = int (PS_DASHDOTDOT);break; case 5: nPenStyle = P_USERSTYLE; // 2005 Vector upgrade shin 0330 int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0}; VecDraw->CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (VecDraw->osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick*Zoom+0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * Zoom + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); PAINT_VECTOR; if (pPoints) delete[] pPoints; pPoints = NULL; if (dashValues) { delete[] dashValues; dashValues = NULL;} if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount*3 +1; l++) { double dx = data->pList[l].x - pTempList[3*k].x; double dy = data->pList[l].y - pTempList[3*k].y; data->pList[l].x = dx*cos(-tangentlist[k]) - dy*sin(-tangentlist[k]) + pTempList[3*k].x; data->pList[l].y = dx*sin(-tangentlist[k]) + dy*cos(-tangentlist[k]) + pTempList[3*k].y; } for (int l = 0; l < data->nCount*3 +1; l++) { data->pList[l].x = data->pList[l].x + ParentData->centerX - pTempList[3*k].x; data->pList[l].y = data->pList[l].y + ParentData->centerY - pTempList[3*k].y; } } } for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; delete data; } DataList->Clear(); delete DataList; DataList = NULL; delete[] tangentlist; return; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::DrawTextBox(HDC dcDst, TVecData *tData, int StartX, int StartY, double textCenterX, double textCenterY, double FontZoom, int PlusNum, int OffsetX, int OffsetY) //by linuxjun for CurvedVectorText { int fontSize; TSWordData *tsWordData; int tLine = 0, line; int tSecondX, tSecondY; double realCharX, realCharY, tempX = 0.0, tempY; double angleChangedX, angleChangedY; int cx, cy; double angle = tData->TextAngle; //WCHAR fname[100], wordBstr[100]; String fname, wordBstr; String tempString, wordString; gdp::Graphics graphics(dcDst); // using GDI+ graphics.SetPageUnit(gdp::UnitPixel); //graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing if (tData->bAntialiasing){ graphics.SetTextRenderingHint(gdp::TextRenderingHintAntiAlias); // text antialiasing } realCharX = StartX; realCharY = StartY; cx = textCenterX; cy = textCenterY; line = (tData->ListOfAllLine->GetLineTextBox(0))->lineHeight; tempY = ((line) * 0.8) * FontZoom; for (int k = 0; k < tData->nCount; k++) { tsWordData = (TSWordData *)tData->ListOfAllLine->Items(k); fontSize = tsWordData->LFont.lfHeight; tsWordData->LFont.lfHeight = fontSize * FontZoom; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; // using GDI+ tempString = tsWordData->LFont.lfFaceName; // ZeroMemory(fname, sizeof(fname)); // MultiByteToWideChar(CP_ACP, 0, tempString.c_str(), tempString.Length(), fname, sizeof(fname) / sizeof(fname[0])); fname = tempString; wordBstr = tsWordData->Word; gdp::FontFamily fontFamily(fname.c_str()); gdp::Font font(dcDst, &tsWordData->LFont); gdp::Color wordColor(GetRValue(tsWordData->Color), GetGValue(tsWordData->Color), GetBValue(tsWordData->Color)); gdp::SolidBrush wordBrush(wordColor); //gdp::StringFormat fontFormat; // layoutRect //fontFormat.SetAlignment(gdp::StringAlignmentCenter); //fontFormat.SetFormatFlags(gdp::StringFormatFlagsNoClip); gdp::StringFormat fontFormat; fontFormat.SetFormatFlags(gdp::StringFormatFlagsNoClip); if (tsWordData->Word[0] == '\r') { tLine++; line = (tData->ListOfAllLine->GetLineTextBox(tLine))->lineHeight; realCharX = StartX; tempY = ((line) * 0.8 * tsWordData->HeightGap) * FontZoom; realCharY += tempY; } else { tempX = realCharX; realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; // ZeroMemory(wordBstr, sizeof(wordBstr)); // if (tsWordData->UsedByte == 1){ // MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 1, wordBstr, // sizeof(wordBstr) / sizeof(wordBstr[0])); // } else { // MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 2, wordBstr, // sizeof(wordBstr) / sizeof(wordBstr[0])); // } int cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); float ascent = font.GetSize()*cellascent/fontFamily.GetEmHeight(gdp::FontStyleRegular); // baseInterval : realCharY(¶óÀÎÀÇ ½ÃÀÛÁ¡ yÁÂÇ¥)¿¡¼­ ±âÁؼ±(ascentÀÇ ÇÏÇѼ±)±îÁöÀÇ °£°Ý float baseInterval = (line * 0.142 * tsWordData->HeightGap) * FontZoom; float fontsize = font.GetSize(); float leftInterval = fontsize*0.17; if(tData->ListOfAllLine->CurveData){ //-->by linuxjun for CurvedVectorText double dTemp; int PositionX; int PositionY; int px; int py; double OriginX,OriginY; double tempCenterX, tempCenterY; px = (tData->StartPoint.x - OffsetX)*FontZoom - StartX; py = (tData->StartPoint.y - OffsetY)*FontZoom - StartY; PositionX = OffsetX; PositionY = OffsetY; OriginX = (tsWordData->px - OffsetX)*FontZoom - tsWordData->Interval * tsWordData->WidthGap * FontZoom / 2 - px; // OriginY = (tsWordData->py - OffsetY)*FontZoom - 0.8*tsWordData->LFont.lfHeight * tsWordData->HeightGap * FontZoom - py; // OriginX = (tsWordData->px - OffsetX)*FontZoom - px; OriginY = (tsWordData->py - OffsetY)*FontZoom - ascent - py; tempCenterX = (tsWordData->px - OffsetX)*FontZoom - px; tempCenterY = (tsWordData->py - OffsetY)*FontZoom - py; angle = acos(tsWordData->tx); if(tsWordData->ty >= 0){ angle = 180*angle/M_PI; }else{ angle = 360 - 180*angle/M_PI; } gdp::PointF origin((float)OriginX, (float)OriginY); gdp::Matrix matrix; matrix.RotateAt(angle, gdp::PointF(tempCenterX, tempCenterY), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); graphics.ResetTransform(); //<--by linuxjun for CurvedVectorText }else{ gdp::PointF origin((float)tempX - leftInterval, (float)(realCharY - ascent - baseInterval)); // gdp::RectF layoutRect(tempX, realCharY - font.GetHeight(&graphics)*0.88, (float)tsWordData->Interval * FontZoom, (float)font.GetHeight(&graphics)); if (tsWordData->LFont.lfEscapement) { double tx = tempX - cx; double ty = cy - realCharY; gdp::Matrix matrix; matrix.RotateAt(360 - angle, gdp::PointF(cx, cy), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); //graphics.DrawString(wordBstr, wcslen(wordBstr), &font, layoutRect, &fontFormat, &wordBrush); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); graphics.ResetTransform(); } else { //graphics.DrawString(wordBstr, wcslen(wordBstr), &font, layoutRect, &fontFormat, &wordBrush); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); } } } tsWordData->LFont.lfHeight = fontSize; } /* int fontSize; TSWordData *tsWordData; HFONT font = NULL, oldfont = NULL; int tLine = 0, line; HBRUSH Brush; int tSecondX, tSecondY; double realCharX, realCharY, tempX = 0.0, tempY; double angleChangedX, angleChangedY; double angle = tData->TextAngle / 180 * M_PI; int cx, cy; realCharX = StartX; realCharY = StartY; cx = textCenterX; cy = textCenterY; line = (tData->ListOfAllLine->GetLineTextBox(0))->lineHeight; tempY = ((line) * 0.8) * FontZoom; for (int k = 0; k < tData->nCount; k++) { tsWordData = (TSWordData *)tData->ListOfAllLine->Items(k); fontSize = tsWordData->LFont.lfHeight; tsWordData->LFont.lfHeight = fontSize * FontZoom; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; SetTextAlign(dcDst, TA_BOTTOM); SetTextColor(dcDst, tsWordData->Color); SetBkMode(dcDst, TRANSPARENT); font = CreateFontIndirect(&tsWordData->LFont); oldfont = (HFONT)SelectObject(dcDst, font); if (tsWordData->UsedByte == 1) { if (tsWordData->Word[0] == '\r') { tLine++; line = (tData->ListOfAllLine->GetLineTextBox(tLine))->lineHeight; realCharX = StartX; tempY = ((line) * 0.8 * tsWordData->HeightGap) * FontZoom; realCharY += tempY; } else { tempX = realCharX; if (tsWordData->LFont.lfEscapement) { double tx = tempX - cx; double ty = cy - realCharY; angleChangedX = tx*cos(-angle) + ty*sin(-angle) + cx; angleChangedY = cy - (-tx*sin(-angle) + ty*cos(-angle)); TextOut(dcDst, angleChangedX, angleChangedY, tsWordData->Word, 1); realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; } else { realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; TextOut(dcDst, tempX, realCharY, tsWordData->Word, 1); } } } else { tempX = realCharX; if (tsWordData->LFont.lfEscapement) { double tx = tempX - cx; double ty = cy - realCharY; angleChangedX = tx*cos(-angle) + ty*sin(-angle) + cx; angleChangedY = cy - (-tx*sin(-angle) + ty*cos(-angle)); TextOut(dcDst, angleChangedX, angleChangedY, tsWordData->Word, 2); realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; } else { realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; TextOut(dcDst, tempX, realCharY, tsWordData->Word, 2); } } SelectObject(dcDst, oldfont); DeleteObject(font); tsWordData->LFont.lfHeight = fontSize; } */ } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::SmallPatternImagePaint(int sPatternNum, TList *spList, TList *sdList, TTexpiaBitmap *sBitmap, int isSameImage) { TTexpiaBitmap *tBitmap = new TTexpiaBitmap; int w = sBitmap->Width; int h = sBitmap->Height; // ¹®Á¦Á¡: »çÀÌÁî°¡ Ʋ¸± °æ¿ì ºñÆ®¸ÊÀ» º¹»çÇÒ¶§ ¿¡·¯°¡ ¹ß»ýÇØ¼­ // ±×³É °°Àº Å©±â·Î ¸¸µé±â À§Çؼ­¼­ »ó¼ö°ªÀ» ³Ö¾ú´Ù. w = 50; h =60; Byte *byte, *sByte, *line; TSmallImageData *sImageData; TPStretchImage *SmallImage; SmallImage = (TPStretchImage *)spList->Items[sPatternNum]; sImageData = (TSmallImageData *)sdList->Items[sPatternNum]; sImageData->kind = 0; sImageData->isSameImage = isSameImage; SmallImage->Bitmap->FillRect(Rect(0, 0, 50, 60), clWhite); tBitmap->Create(sBitmap->Width, sBitmap->Height, 24); tBitmap->Copy(sBitmap, SRCCOPY); tBitmap->ResizeStretch(w, h, true); tBitmap->StartScanLine(); SmallImage->Bitmap->StartScanLine(); for (int k = 0; k < h; k++) { byte = tBitmap->GetScanLine(k); sByte = SmallImage->Bitmap->GetScanLine(k); for (int l = 0; l < w; l++) { sByte[3*l] = byte[3*l]; sByte[3*l+1] = byte[3*l+1]; sByte[3*l+2] = byte[3*l+2]; } SmallImage->Bitmap->PutScanLine(k); } tBitmap->StopScanLine(); SmallImage->Bitmap->StopScanLine(); SmallImage->Repaint(); delete tBitmap; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::SmallColorImagePaint(int sPatternNum, TList *spList, TList *sdList, TColor BrushColor, int isSameColor) { Byte *line, *byte; TPStretchImage *SmallImage; TSmallImageData *sImageData; SmallImage = (TPStretchImage *)spList->Items[sPatternNum]; sImageData = (TSmallImageData *)sdList->Items[sPatternNum]; sImageData->kind = 1; sImageData->isSameColor = isSameColor; SmallImage->Bitmap->FillRect(Rect(0, 0, 50, 60), clWhite); SmallImage->Bitmap->StartScanLine(); for (int y=0; yBitmap->Height; y++) { line=SmallImage->Bitmap->GetScanLine(y); for (int x=0; xBitmap->Width; x++) { line[3*x] = (BrushColor >> 16) & 0xFF; line[3*x+1]= (BrushColor >> 8 ) & 0xFF; line[3*x+2]= (BrushColor ) & 0xFF; } SmallImage->Bitmap->PutScanLine(y); } SmallImage->Bitmap->StopScanLine(); SmallImage->Repaint(); } //--------------------------------------------------------------------------- // Image Size¸¦ Á¶ÀýÇÏ´Â ÇÔ¼ö (FullView¿¡¼­ CopyÇÑ ºÎºÐ) void __fastcall TStyleComboForm::RatioCalculate(TPStretchImage *tImage, int &W, int &H) { int ratio; bool bRatio; int smallImageW = 50; int smallImageH = 60; int width = tImage->Bitmap->Width; int height = tImage->Bitmap->Height; if (tImage->Bitmap) { ratio = 1; if (smallImageW < width || smallImageH < height) { while (true) { if (smallImageW >= width/ratio && smallImageH >= height/ratio) { break; } ratio++; } bRatio = false; } else { while (true) { if (smallImageW < width*ratio || smallImageH < height*ratio) { ratio--; break; } ratio++; } bRatio = true; } if (bRatio) { W = width*ratio; H = height*ratio; } else { W = width/ratio; H = height/ratio; } } } //--------------------------------------------------------------------------- //¼ýÀÚ ¹öưÀÇ À̹ÌÁö¸¦ º¯°æÇØ ÁÖ±â À§Çؼ­ »ç¿ë (Number <-> Fix) void __fastcall TStyleComboForm::tempSpButtonClick(TObject *Sender) { TRegIniFile *RegIniFile; String DirectoryBin; String DirectoryName; String FileName; TSpeedButton *sbImageNum; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw DirectoryBin = RegIniFile->ReadString("Directory", "Bin", DefaultDir + "\\Bin"); DirectoryName = DirectoryBin + "\\TexStylist\\StyleNo\\"; int i = ListOfButton->IndexOf(Sender); if (i<0) return; sbImageNum = (TSpeedButton *)ListOfButton->Items[i]; if (sbImageNum->Down) { FileName = "FIX.bmp"; sbImageNum->Glyph->LoadFromFile(DirectoryName+FileName); } else { FileName = IntToStr(i+1) + ".bmp"; sbImageNum->Glyph->LoadFromFile(DirectoryName+FileName); } delete RegIniFile; } //--------------------------------------------------------------------------- // ´õºí Ŭ¸¯À» ÇÒ ¶§ ¿¡·¯°¡ ¹ß»ýÇØ¼­ ÀÌ·¸°Ô ó¸®Çß´Ù. // ÀÌ»óÇÏ°Ô ´õºíŬ¸¯ÇÏ¸é ´õºíŬ¸¯ À̺¥Æ® ÈÄ¿¡ ¸¶¿ì½º ´Ù¿î À̺¥Æ®°¡ ¹ß»ý void __fastcall TStyleComboForm::tempLayerImageDblClick(TObject *Sender) { isDblClick = true; } //--------------------------------------------------------------------------- // LayerImage¸¦ Ŭ¸¯Çؼ­ Image/Color PatternÀ» º¯°æÇÒ ¼ö ÀÖµµ·Ï ¸¸µé¾ú´Ù. // ÇÏÁö¸¸ ¾î´À º¤Å͸¦ ¼±ÅÃÇß´ÂÁö ±¸ºÐÀÌ ¸ðÈ£ÇØ¼­ ÇöÀç »ç¿ëÇÏÁö ¾Ê°í ÀÖ´Ù. // ¸¸¾àÀ» À§Çؼ­ ³²°ÜµÐ´Ù. void __fastcall TStyleComboForm::tempLayerImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (!isDblClick) { int i = ListOfImage->IndexOf(Sender); if (Shift.Contains(ssLeft) && Item == C_NONE) { if (i<0) return; imageMouseUpNum = i; TShape *comboShape; comboShape = (TShape *)ListOfShape->Items[i]; if (comboShape->Pen->Color == Graphics::clSkyBlue) comboShape->Pen->Color = clRed; else comboShape->Pen->Color = Graphics::clSkyBlue; // if (PatternLibrary->GetSelectedShapeNumber(i)) // LayerImageMouseDownForChanging(imageMouseUpNum, X, Y); } else if (Shift.Contains(ssMiddle) && Item == C_SELECTCOLOR) { if (i<0) return; COLORREF color; TPLayerImage *SourceImage; SourceImage = (TPLayerImage *)ListOfImage->Items[i]; color = SourceImage->uBitmap->GetPixelColor(X, Y); PaletteForm->DIB256Palette->SetNormal(PaletteForm->DIB256Palette->ChoiceIndex, GetRValue(color), GetGValue(color), GetBValue(color)); PaletteForm->DIB256Palette->Repaint(); } return; } ImageDblClickOpen(imageMouseUpNum); isDblClick = false; } //--------------------------------------------------------------------------- // Popup Menu ¿¡¼­ MainImage·Î Combo °á°ú¸¦ OpenÇÏ´Â ÇÔ¼ö void __fastcall TStyleComboForm::ImagePopUpOpenClick(TObject *Sender) { TShape *comboShape; TMainImageForm *Child = NULL; TPException ec = EC_NONE; TPCanvasInfor CanvasInfor; PSTYLEDATAFILEHEADER pheader, pheader2; // Ä«ÇÇ¿ë long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; double maxthick = 0; TList *list; // Vector Object List TVecData *data; HDC dcDst = NULL, dcSrc = NULL; TTexpiaBitmap *tempBitmap; bool anySelected = false; for (int i=0; iCount; i++) { comboShape = (TShape *)ListOfShape->Items[i]; if (comboShape->Pen->Color == clRed) { anySelected = true; minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; maxthick = 0; list = (TList *)V_DATA->Items[i]; for (int j = 0; j < list->Count; j++) { // ¿ì¼± Range ±¸ÇØÁÖ°í data = (TVecData *)list->Items[j]; minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); maxthick = max(maxthick, data->PenThick); } CanvasInfor.Width = maxx - minx + maxthick*2; CanvasInfor.Height = maxy - miny + maxthick*2; CanvasInfor.DotsPerInch = 160; CanvasInfor.SizeType = cstFree; CanvasInfor.Width += MARGIN_X*2; //¿©¹éÁÂÇ¥¸¦ ´õÇØÁÖ´Â ºÎºÐ CanvasInfor.Height += MARGIN_Y*2; // ·¹À̾ ÆÄÀÏ·Î ÀúÀåµÉ¶§ ÀÛ¾÷±¸¿ªÀº ÀúÀåÀÌ µÇÁö ¾Ê±â ¶§¹®¿¡ // ½ÇÁ¦ ÀÛ¾÷±¸¿ªÀº ´«¿¡ º¸ÀÌÁö ¾ÊÁö¸¸ ³²¾ÆÀÖ´Â °æ¿ì°¡ µÈ´Ù - by monkman (2005.06.16) //if (MainImageForm) MainImageForm->iMainImage->Deactivate(); if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if ((ec = Child->InitForm2(CanvasInfor, 24))!=EC_NONE) goto fail; pheader = (PSTYLEDATAFILEHEADER)V_HEADER->Items[i]; VecDraw->InitCombiMerge(list, 0, true, false); Child->StyleDivision = int(pheader->Division); Child->StyleType = int(pheader->Type); pheader2 = new STYLEDATAFILEHEADER; VecDraw->CopySTYHeader(pheader2, *pheader); Child->StyleHeader->Add(pheader2); // Save Opened Style to LIst TPLayerImage *SourceImage; TTexpiaBitmap *tBitmap = new TTexpiaBitmap; SourceImage = (TPLayerImage *)ListOfImage->Items[i]; tBitmap->Create(SourceImage->uBitmap->Width, SourceImage->uBitmap->Height, 24); SourceImage->uBitmap->CopyToTexpia(tBitmap, 0, 0, tBitmap->Width, tBitmap->Height, 0, 0, SRCCOPY); //tBitmap->Copy(SourceImage->uBitmap, SRCCOPY); ListOfOpenedStyle->Add(tBitmap); // Show(); } } if (!anySelected) { // IDS_COMBOMSGBOX8 : ¼±ÅÃµÈ Image°¡ ¾ø½À´Ï´Ù. Application->MessageBox(IDS_COMBOMSGBOX8.c_str(), L"Information", MB_ICONINFORMATION | MB_OK); return; // ¼±ÅÃµÈ Image°¡ ¾øÀ¸¸é return } // IstStyleLabel->Font->Size = 10; // IstStyleLabel->Font->Color = clMenuHighlight; // IstStyleLabel->Font->Style = TFontStyles()<< fsBold; OpenedStyleNum = ListOfOpenedStyle->Count; IstStyleLabel->Caption = IDS_IstStyleLabel + " ("+ IntToStr(OpenedStyleNum) +"/" + IntToStr(OpenedStyleNum) + ")"; tempBitmap = (TTexpiaBitmap *)ListOfOpenedStyle->Last(); if ((dcDst = OpenedStretchImage->Bitmap->CreateDC())==NULL) goto fail; if ((dcSrc = tempBitmap->CreateDC())==NULL) goto fail; SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, 0,0, OpenedStretchImage->Bitmap->Width, OpenedStretchImage->Bitmap->Height, dcSrc, 0,0, tempBitmap->Width, tempBitmap->Height, SRCCOPY); if(dcSrc) tempBitmap->DeleteDC(dcSrc); dcSrc = NULL; if(dcDst) OpenedStretchImage->Bitmap->DeleteDC(dcDst); dcDst = NULL; OpenedStretchImage->Repaint(); if (OpenedStyleNum <= 1) spLeftBtn->Enabled = false; else spLeftBtn->Enabled = true; spRightBtn->Enabled = false; return; fail: if (Child) delete Child; Child=NULL; if(dcSrc) tempBitmap->DeleteDC(dcSrc); dcSrc = NULL; if(dcDst) OpenedStretchImage->Bitmap->DeleteDC(dcDst); dcDst = NULL; return; } //--------------------------------------------------------------------------- // DblClickÇØ¼­ MainImage·Î Combo °á°ú¸¦ OpenÇÏ´Â ÇÔ¼ö // ImagePopUpOpenClick()¿Í °°Áö¸¸ ÇϳªÀÇ Image¸¸ OpenÇϱ⿡ ´Ù½Ã ¸¸µé¾ú´Ù. void __fastcall TStyleComboForm::ImageDblClickOpen(int ImageNum) { TShape *comboShape; TMainImageForm *Child = NULL; TPException ec = EC_NONE; TPCanvasInfor CanvasInfor; PSTYLEDATAFILEHEADER pheader, pheader2; // Ä«ÇÇ¿ë long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; double maxthick = 0; TList *list; // Vector Object List TVecData *data; RECT rect; HDC dcDst = NULL, dcSrc = NULL; TPLayerImage *sImage; TTexpiaBitmap *tBitmap = new TTexpiaBitmap; comboShape = (TShape *)ListOfShape->Items[ImageNum]; maxthick = 0; list = (TList *)V_DATA->Items[ImageNum]; for (int j = 0; j < list->Count; j++) { // ¿ì¼± Range ±¸ÇØÁÖ°í data = (TVecData *)list->Items[j]; if (data->Kind == V_TEXTBOX || data->ChildList) { VecDraw->GetRectForMouseMove(data, rect); minx = min(minx, rect.left); maxx = max(maxx, rect.right); miny = min(miny, rect.top); maxy = max(maxy, rect.bottom); } else { minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); maxthick = max(maxthick, data->PenThick); } } CanvasInfor.Width = maxx - minx + maxthick*2; CanvasInfor.Height = maxy - miny + maxthick*2; CanvasInfor.DotsPerInch = 160; CanvasInfor.SizeType = cstFree; CanvasInfor.Width += MARGIN_X*2; //¿©¹éÁÂÇ¥¸¦ ´õÇØÁÖ´Â ºÎºÐ CanvasInfor.Height += MARGIN_Y*2; // ·¹À̾ ÆÄÀÏ·Î ÀúÀåµÉ¶§ ÀÛ¾÷±¸¿ªÀº ÀúÀåÀÌ µÇÁö ¾Ê±â ¶§¹®¿¡ // ½ÇÁ¦ ÀÛ¾÷±¸¿ªÀº ´«¿¡ º¸ÀÌÁö ¾ÊÁö¸¸ ³²¾ÆÀÖ´Â °æ¿ì°¡ µÈ´Ù - by monkman (2005.06.16) //if (MainImageForm) MainImageForm->iMainImage->Deactivate(); if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if ((ec = Child->InitForm2(CanvasInfor, 24))!=EC_NONE) goto fail; pheader = (PSTYLEDATAFILEHEADER)V_HEADER->Items[ImageNum]; VecDraw->InitCombiMerge(list, 0, true, false); Child->StyleDivision = int(pheader->Division); Child->StyleType = int(pheader->Type); pheader2 = new STYLEDATAFILEHEADER; VecDraw->CopySTYHeader(pheader2, *pheader); Child->StyleHeader->Add(pheader2); // Save Opened Style to LIst sImage = (TPLayerImage *)ListOfImage->Items[ImageNum]; tBitmap->Create(sImage->uBitmap->Width, sImage->uBitmap->Height, 24); sImage->uBitmap->CopyToTexpia(tBitmap, 0, 0, sImage->uBitmap->Width, sImage->uBitmap->Height, 0, 0, SRCCOPY); ListOfOpenedStyle->Add(tBitmap); // IstStyleLabel->Font->Size = 10; // IstStyleLabel->Font->Color = clMenuHighlight; // IstStyleLabel->Font->Style = TFontStyles()<< fsBold; OpenedStyleNum = ListOfOpenedStyle->Count; IstStyleLabel->Caption = IDS_IstStyleLabel + " ("+ IntToStr(OpenedStyleNum) +"/" + IntToStr(OpenedStyleNum) + ")"; if ((dcDst = OpenedStretchImage->Bitmap->CreateDC())==NULL) goto fail; if ((dcSrc = tBitmap->CreateDC())==NULL) goto fail; SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, 0,0, OpenedStretchImage->Bitmap->Width, OpenedStretchImage->Bitmap->Height, dcSrc, 0,0, tBitmap->Width, tBitmap->Height, SRCCOPY); if(dcSrc) tBitmap->DeleteDC(dcSrc); dcSrc = NULL; if(dcDst) OpenedStretchImage->Bitmap->DeleteDC(dcDst); dcDst = NULL; OpenedStretchImage->Repaint(); // Show(); if (OpenedStyleNum <= 1) spLeftBtn->Enabled = false; else spLeftBtn->Enabled = true; spRightBtn->Enabled = false; return; fail: if (Child) delete Child; Child=NULL; if(dcSrc) tBitmap->DeleteDC(dcSrc); dcSrc = NULL; if(dcDst) OpenedStretchImage->Bitmap->DeleteDC(dcDst); dcDst = NULL; return; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ThumbNailPrint() { int dpiX, dpiY; int pageX, pageY; int realPageW, realPageH; int imageW, imageH; int imageDPI = 160; double Zoom; int NumOfSeleted, Max, ratio, Top, Left, Num, imagew, imageh; double tempzoom, maxsurface, surface; TShape *tShape; HDC dcTemp = NULL; // Ãß°¡ TTexpiaBitmap PrintBitmap; // Ãß°¡ TPrinter *print = Printer(); try { HDC hPrtdc = print->Handle; // HORZSIZE Width, in millimeters, of the physical screen. pageX = GetDeviceCaps(hPrtdc, HORZRES); pageY = GetDeviceCaps(hPrtdc, VERTRES); // LOGPIXELSX Number of pixels per logical inch along the screen width. dpiX = GetDeviceCaps(hPrtdc, LOGPIXELSX); dpiY = GetDeviceCaps(hPrtdc, LOGPIXELSY); // Image¿Í Printer Canvas¸¦ ºñ±³Çؼ­ ¾òÀº Printer Canvas Size (160 DPI) realPageW = pageX * imageDPI / dpiX; realPageH = pageY * imageDPI / dpiY; GetStyleSize((TList *)V_DATA->Items[0], imageW, imageH); NumOfSeleted=0; for (int i=0; iCount; i++) { tShape=(TShape *)ListOfShape->Items[i]; if (tShape->Pen->Color != Graphics::clSkyBlue) NumOfSeleted++; } Max=1; ratio=1; tempzoom = 0.0; maxsurface = 0.0; for (int i = 1; i < 20; i++) { imagew = imageW+50; imageh = imageH+50; // Margin ¼³Á¤ tempzoom = realPageW > (imagew*i) ? 1.0 : double(realPageW)/i/imagew; surface = tempzoom*tempzoom*imagew*imageh*NumOfSeleted; if (surface > maxsurface && (tempzoom*imageh*int(double(NumOfSeleted)/i+0.999))Title = title; // if (!PrintBitmap.Create(print->PageWidth, print->PageHeight, 24)) goto next; // PrintBitmap.FillRect(Rect(0, 0, PrintBitmap.Width, PrintBitmap.Height), clWhite); // if ((dcTemp = PrintBitmap.CreateDC()) == NULL) goto next; PrintBitmap.Create(print->PageWidth, print->PageHeight, 24); PrintBitmap.FillRect(Rect(0, 0, PrintBitmap.Width, PrintBitmap.Height), clWhite); dcTemp = PrintBitmap.CreateDC(); print->Copies = ComboPrintForm->SpinEditPage->Value; print->BeginDoc(); HDC hCanvasDC = print->Canvas->Handle; for (int i=0; iCount; i++) { tShape=(TShape *)ListOfShape->Items[i]; if (tShape->Pen->Color == Graphics::clSkyBlue) continue; Left = 0 + (imageW + 50) * (Num%Max); Top = 0 + (imageH + 50) * (Num/Max); PrintDraw(dcTemp, Left, Top, dpiX, dpiY, imageDPI, i, Zoom); Num++; } BitBlt(hCanvasDC,0,0,print->PageWidth,print->PageHeight,dcTemp,0,0,SRCCOPY); // Ãß°¡ print->EndDoc(); } catch(EPrinter&){ print->EndDoc(); } if (dcTemp) PrintBitmap.DeleteDC(dcTemp); // Ãß°¡ } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::RealSizePrint() { int dpiX, dpiY; int pageX, pageY; int realPageW, realPageH; int imageW, imageH; int imageDPI = 160; double Zoom; bool sOption = ComboPrintForm->WithChipCheckBox->Checked; int sHeight=0; HDC dcTemp = NULL; // Ãß°¡ TTexpiaBitmap TempBitmap; // Ãß°¡ TPrinter *print = Printer(); try { HDC hPrtdc = print->Handle; // HORZSIZE Width, in millimeters, of the physical screen. pageX = GetDeviceCaps(hPrtdc, HORZRES); pageY = GetDeviceCaps(hPrtdc, VERTRES); // LOGPIXELSX Number of pixels per logical inch along the screen width. dpiX = GetDeviceCaps(hPrtdc, LOGPIXELSX); dpiY = GetDeviceCaps(hPrtdc, LOGPIXELSY); // Image¿Í Printer Canvas¸¦ ºñ±³Çؼ­ ¾òÀº Printer Canvas Size (160 DPI) realPageW = pageX * imageDPI / dpiX; realPageH = pageY * imageDPI / dpiY; GetStyleSize((TList *)V_DATA->Items[0], imageW, imageH); if (sOption) CheckPrintSSize(imageW, imageH, sHeight); int Max=1; Zoom = (double)realPageW / (imageW+50); Max = realPageW < (imageW+50) * ((int)Zoom) ? (int)Zoom - 1 : (int)Zoom; TShape *tShape; int Top=0, Left=0, Num=0; // print->Title = title; print->Copies = ComboPrintForm->SpinEditPage->Value; print->BeginDoc(); HDC hCanvasDC = print->Canvas->Handle; if (!TempBitmap.Create(print->PageWidth, print->PageHeight, 24)) goto fail; TempBitmap.FillRect(Rect(0, 0, TempBitmap.Width, TempBitmap.Height), clWhite); if ((dcTemp = TempBitmap.CreateDC()) == NULL) goto fail; for (int i=0; iCount; i++) { tShape=(TShape *)ListOfShape->Items[i]; if (tShape->Pen->Color == Graphics::clSkyBlue) continue; Left = 0 + (imageW + 50) * (Num%Max); if (sOption) { Top = 0 + (imageH + sHeight + 100) * (Num/Max); if (Top+imageH+sHeight+100 > realPageH) { BitBlt(hCanvasDC,0,0,print->PageWidth,print->PageHeight,dcTemp,0,0,SRCCOPY); // Ãß°¡ TempBitmap.FillRect(Rect(0, 0, TempBitmap.Width, TempBitmap.Height), clWhite); print->NewPage(); Left=0; Top=0; Num=1; goto next; } } else { Top = 0 + (imageH + 50) * (Num/Max); if (Top+imageH+50 > realPageH) { BitBlt(hCanvasDC,0,0,print->PageWidth,print->PageHeight,dcTemp,0,0,SRCCOPY); // Ãß°¡ TempBitmap.FillRect(Rect(0, 0, TempBitmap.Width, TempBitmap.Height), clWhite); print->NewPage(); Left=0; Top=0; Num=1; goto next; } } Num++; next: // hCanvasDC -> dcTemp·Î º¯°æ PrintDraw(dcTemp, Left, Top, dpiX, dpiY, imageDPI, i, 1.0); if (sOption) PrintS_ImageDraw(dcTemp, Left, Top+imageH+30, dpiX, dpiY, imageDPI, i, 1.0, imageW);// for test } BitBlt(hCanvasDC,0,0,print->PageWidth,print->PageHeight,dcTemp,0,0,SRCCOPY); // Ãß°¡ print->EndDoc(); } catch(EPrinter&){ print->EndDoc(); } fail: if (dcTemp) TempBitmap.DeleteDC(dcTemp); // Ãß°¡ } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::PrintDraw(HDC dcDst, int posx, int posy, int dpiX, int dpiY, int dpi, int number, double Zoom) { TList *DataList; // Vector Object List TVecData *data; DataList = (TList *)V_DATA->Items[number]; HPEN hOldPen = NULL , hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; // int ZoomIn = DPI; int ZoomOut = dpi; // PositionX : LayerImage ÁÂÇ¥°è int PositionX = posx*(-1); int PositionY = posy*(-1); // ±×·ÁÁÖ°íÀÚ ÇÏ´Â °÷ÀÇ ÁÂÇ¥°è int px = 0, py = 0, StartX, StartY, PlusNum=0; double textCenterX, textCenterY; int OffsetX, OffsetY; //by linuxjun for CurvedVectorText RECT Src; gdp::Graphics graphics(dcDst); // using GDI+ gdp::Point *pPoints = NULL; graphics.SetPageUnit(gdp::UnitPixel); for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (data->bAntialiasing){ graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing } int FirstX = (data->First.x - PositionX) * dpiX * Zoom / ZoomOut - px; int FirstY = (data->First.y - PositionY) * dpiX * Zoom / ZoomOut - px; int SecondX = (data->Second.x - PositionX) * dpiX * Zoom / ZoomOut - px; int SecondY = (data->Second.y - PositionY) * dpiY * Zoom / ZoomOut - py; int pw = data->PenThick / 2 * Zoom ; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick* dpiX / ZoomOut * Zoom); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::Point[5]; } else { if (data->bClosed){ pPoints = new gdp::Point[(data->nCount+1)*3+1]; } else { pPoints = new gdp::Point[data->nCount*3+1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount*3 +1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * dpiX / ZoomOut * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * dpiY / ZoomOut * Zoom - py; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX) * dpiX / ZoomOut * Zoom - px; StartY = (data->StartPoint.y - PositionY) * dpiY / ZoomOut * Zoom - py; textCenterX = (data->CenterPoint.x - PositionX) * dpiX / ZoomOut * Zoom - px; textCenterY = (data->CenterPoint.y - PositionY) * dpiY / ZoomOut * Zoom - py; OffsetX = PositionX; //by linuxjun for CurvedVectorText OffsetY = PositionY; //by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * dpiX / ZoomOut * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * dpiY / ZoomOut * Zoom - py; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount*3] = pPoints[0]; pPoints[data->nCount*3+1] = pPoints[1]; pPoints[data->nCount*3+2] = pPoints[2]; pPoints[data->nCount*3+3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ int bltwidth, bltheight; HDC dcPattern, dcMask; bltwidth = data->TBitmap->Width * dpiX / ZoomOut * Zoom; bltheight = data->TBitmap->Height * dpiY / ZoomOut * Zoom; if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto fail; if ((dcMask = data->MaskBitmap->CreateDC())==NULL) goto fail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0,0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; }else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); }else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch (data->PenStyle) { case 0: nPenStyle = int (PS_SOLID); break; case 1: nPenStyle = int (PS_DASH); break; case 2: nPenStyle = int (PS_DOT); break; case 3: nPenStyle = int (PS_DASHDOT); break; case 4: nPenStyle = int (PS_DASHDOTDOT);break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0}; VecDraw->CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 /* case 5: // 2005 Vector upgrade shin 0303 nPenStyle = P_USERSTYLE; int count = data->DashValues[0]; dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = data->DashValues[i+1]; } //ObjectPen.GetCompoundArray(dashValues, count); ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 */ } if (VecDraw->osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick* dpiX / ZoomOut * Zoom, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); }else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * dpiX / ZoomOut * Zoom+0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (data->ChildList) { PrintDrawMotive(dcDst, posx, posy, dpiX, dpiY, dpi, number, Zoom, data); } else { PAINT_VECTOR; } if (pPoints) delete []pPoints; pPoints = NULL; if (dashValues) delete []dashValues; dashValues = NULL; if (data->Kind == V_TEXTBOX) DrawTextBox(dcDst, data, StartX, StartY, textCenterX, textCenterY, (double)dpiX / ZoomOut * Zoom, PlusNum, OffsetX, OffsetY); //by linuxjun for CurvedVectorText if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } } return; fail: delete data; data = NULL; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::PrintDrawMotive(HDC dcDst, int posx, int posy, int dpiX, int dpiY, int dpi, int number, double Zoom, TVecData *ParentData) { TList *tDataList = ParentData->ChildList; TList *DataList = new TList; TList * ResultBezierPointList; TPointList *tempPointList; TVecData *data = NULL; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList; double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); //»ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; int quotient = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); if (quotient==0) quotient = 1; switch (ParentData->mode) { case 0: // ²Ë ä¿ì±â nSegment = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); if (nSegment ==0) nSegment = 1; ParentData->gap = double(CurveLength/nSegment); ParentData->motivecount = nSegment; break; case 1: // °³¼ö ¼³Á¤ nSegment = StrToInt(ParentData->motivecount); if (nSegment ==0) nSegment = 1; ParentData->gap = double(CurveLength/nSegment); break; case 2: // °£°Ý ¼³Á¤ nSegment = int(CurveLength/ParentData->gap); if (nSegment ==0) nSegment = 1; ParentData->motivecount = nSegment; break; } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); if (!ResultBezierPointList) { delete DataList; DataList; delete BezierPointList; BezierPointList = NULL; return; } pTempList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(nSegment*3+1)); double *tangentlist = new double[nSegment+1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = VecDraw->FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = VecDraw->FindCurveTangent(&ParentData->pList[0], 0); for(int i=0;iCount;i++) { tempPointList = (TPointList *)ResultBezierPointList->Items[i]; for(tempPointList->First();!tempPointList->IsDone();tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = VecDraw->FindingNormalOnBezier(&ParentData->pList[i*3], dInterval, 0, count%2); tangentlist[count] = VecDraw->FindCurveTangent(&ParentData->pList[i*3], dInterval); pTempList[count*3 - 2] = pTempList[count*3 - 3]; pTempList[count*3 - 1].x = normalPoint.x; pTempList[count*3 - 1].y = normalPoint.y; pTempList[count*3].x = normalPoint.x; pTempList[count*3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed){ // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment*3] = pTempList[0]; pTempList[nSegment*3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; //------------------------------------------------------------ HPEN hOldPen = NULL , hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int ZoomOut = dpi; // PositionX : LayerImage ÁÂÇ¥°è int PositionX = posx*(-1); int PositionY = posy*(-1); // ±×·ÁÁÖ°íÀÚ ÇÏ´Â °÷ÀÇ ÁÂÇ¥°è int px = 0, py = 0, StartX, StartY, PlusNum=0; double textCenterX, textCenterY; int OffsetX, OffsetY; //by linuxjun for CurvedVectorText RECT Src; gdp::Graphics graphics(dcDst); // using GDI+ gdp::Point *pPoints = NULL; graphics.SetPageUnit(gdp::UnitPixel); //------------------------------------------ TVecData *tdata; // motive childÀÇ È®´ë Ãà¼Ò for (int i =0; i < tDataList->Count; i++) { data = (TVecData *)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); for (int l = 0; l < data->nCount*3 +1; l++) { tdata->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; tdata->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } DataList->Add(tdata); } //------------------------------------------ for (int k = 0; k < nSegment; k++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (data->bAntialiasing){ graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing } //Rotation ÇÏ´Â ºÎºÐ---------------------- for (int l = 0; l < data->nCount*3 +1; l++) { data->pList[l].x = data->pList[l].x - ParentData->centerX + pTempList[3*k].x; data->pList[l].y = data->pList[l].y - ParentData->centerY + pTempList[3*k].y; } for (int l = 0; l < data->nCount*3 +1; l++) { double dx = data->pList[l].x - pTempList[3*k].x; double dy = data->pList[l].y - pTempList[3*k].y; data->pList[l].x = dx*cos(tangentlist[k]) - dy*sin(tangentlist[k]) + pTempList[3*k].x; data->pList[l].y = dx*sin(tangentlist[k]) + dy*cos(tangentlist[k]) + pTempList[3*k].y; } //------------------------------------------ SET_RECT; int FirstX = (data->First.x - PositionX) * dpiX * Zoom / ZoomOut - px; int FirstY = (data->First.y - PositionY) * dpiX * Zoom / ZoomOut - px; int SecondX = (data->Second.x - PositionX) * dpiX * Zoom / ZoomOut - px; int SecondY = (data->Second.y - PositionY) * dpiY * Zoom / ZoomOut - py; int pw = data->PenThick / 2 * Zoom ; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick* dpiX / ZoomOut * Zoom); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::Point[5]; } else { if (data->bClosed){ pPoints = new gdp::Point[(data->nCount+1)*3+1]; } else { pPoints = new gdp::Point[data->nCount*3+1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount*3 +1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * dpiX / ZoomOut * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * dpiY / ZoomOut * Zoom - py; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX) * dpiX / ZoomOut * Zoom - px; StartY = (data->StartPoint.y - PositionY) * dpiY / ZoomOut * Zoom - py; textCenterX = (data->CenterPoint.x - PositionX) * dpiX / ZoomOut * Zoom - px; textCenterY = (data->CenterPoint.y - PositionY) * dpiY / ZoomOut * Zoom - py; OffsetX = PositionX; //by linuxjun for CurvedVectorText OffsetY = PositionY; //by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * dpiX / ZoomOut * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * dpiY / ZoomOut * Zoom - py; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount*3] = pPoints[0]; pPoints[data->nCount*3+1] = pPoints[1]; pPoints[data->nCount*3+2] = pPoints[2]; pPoints[data->nCount*3+3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ int bltwidth, bltheight; HDC dcPattern, dcMask; VecDraw->MakePatternBitmap(data); bltwidth = data->TBitmap->Width * dpiX / ZoomOut * Zoom; bltheight = data->TBitmap->Height * dpiY / ZoomOut * Zoom; if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto fail; if ((dcMask = data->MaskBitmap->CreateDC())==NULL) goto fail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0,0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; }else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); }else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch (data->PenStyle) { case 0: nPenStyle = int (PS_SOLID); break; case 1: nPenStyle = int (PS_DASH); break; case 2: nPenStyle = int (PS_DOT); break; case 3: nPenStyle = int (PS_DASHDOT); break; case 4: nPenStyle = int (PS_DASHDOTDOT);break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0}; VecDraw->CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (VecDraw->osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick* dpiX / ZoomOut * Zoom, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); }else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * dpiX / ZoomOut * Zoom+0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } PAINT_VECTOR; if (pPoints) delete []pPoints; pPoints = NULL; if (dashValues) delete []dashValues; dashValues = NULL; if (data->Kind == V_TEXTBOX) DrawTextBox(dcDst, data, StartX, StartY, textCenterX, textCenterY, (double)dpiX / ZoomOut * Zoom, PlusNum, OffsetX, OffsetY); //by linuxjun for CurvedVectorText if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount*3 +1; l++) { double dx = data->pList[l].x - pTempList[3*k].x; double dy = data->pList[l].y - pTempList[3*k].y; data->pList[l].x = dx*cos(-tangentlist[k]) - dy*sin(-tangentlist[k]) + pTempList[3*k].x; data->pList[l].y = dx*sin(-tangentlist[k]) + dy*cos(-tangentlist[k]) + pTempList[3*k].y; } for (int l = 0; l < data->nCount*3 +1; l++) { data->pList[l].x = data->pList[l].x + ParentData->centerX - pTempList[3*k].x; data->pList[l].y = data->pList[l].y + ParentData->centerY - pTempList[3*k].y; } } } pPoints = NULL; for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; delete data; } DataList->Clear(); delete DataList; DataList = NULL; delete[] tangentlist; return; fail: if (pPoints) delete []pPoints; pPoints = NULL; for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; delete data; } DataList->Clear(); delete DataList; DataList = NULL; delete[] tangentlist; delete data; data = NULL; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::CheckPrintSSize(int imageW, int imageH, int &sHeight) { int max; int sImageWidth = tempSmallStImage->Width; int sImageHeight = tempSmallStImage->Height; int sImageNum = ((TList *)S_IMAGE->Items[0])->Count; int totalSImageW = (tempSmallStImage->Width + 5) * sImageNum; if ( totalSImageW < sImageWidth ) { sHeight = 0; return; } sHeight = (bool)totalSImageW/sImageWidth > (max=totalSImageW/sImageWidth) ? max+1 : max; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::PrintS_ImageDraw(HDC dcDst, int posx, int posy, int dpiX, int dpiY, int dpi, int number, double Zoom, int sImageW) { HDC sImageDC; int X, Y; int ZoomOut = dpi; int sposx = posx + tempSmallStImage->Width; int sposy = posy + tempSmallStImage->Height; int FirstX = posx * dpiX * Zoom / ZoomOut; int FirstY = posy * dpiY * Zoom / ZoomOut; int SecondX = sposx * dpiX * Zoom / ZoomOut; int SecondY = sposy * dpiY * Zoom / ZoomOut; int sPirntW = SecondX - FirstX; int sPrintH = SecondY - FirstY; int ZsImageW = sImageW * dpiX * Zoom / ZoomOut; int max = ZsImageW / sPirntW; TList *sPatternList; TPStretchImage *sImage; sPatternList = (TList *)S_IMAGE->Items[number]; for (int i=0; iCount; i++) { X = FirstX + (sPirntW + 10)*(i%max); Y = FirstY + (sPirntW + 10)*(i/max); sImage = (TPStretchImage *)sPatternList->Items[i]; sImageDC = sImage->Bitmap->CreateDC(); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, X, Y, sPirntW, sPrintH, sImageDC, 0,0, sImage->Bitmap->Width, sImage->Bitmap->Height, SRCCOPY); sImage->Bitmap->DeleteDC(sImageDC); } } //--------------------------------------------------------------------------- bool __fastcall TStyleComboForm::SaveToFile(HANDLE fh) { TList *list; TVecData *data; TTexpiaBitmap *RealImageBitmap; //===Combo Version 110 Ãß°¡ (2004/05/13) //===TextBoxÃß°¡·Î 120À¸·Î º¯°æ (04.11.03) // Gdiplus Ãß°¡·Î 130À¸·Î º¯°æ (05.03.09) // groupindex ±¸Á¶ º¯°æ ¹× gradientfill Ãß°¡·Î 140À¸·Î º¯°æ 080822 // Version : 150 - MotiveObject Ãß°¡ // Version : 151 - Arrow int Version = StyleComboFileVersion, count = 0, PatternCount, StyleCount; STYLEDATAFILEHEADER header; PSTYLEDATAFILEHEADER pheader; TPatternDATA *patterndata; DWORD dwWrite; TRect Src; PatternCount = PatternLibrary->ListOfNumber->Count; StyleCount = V_DATA->Count; if (!WriteFile(fh, &Version, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &PatternCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &StyleCount, sizeof(int), &dwWrite, NULL)) goto fail; ////////// Pattern ÀúÀå for (int i = 0; i < PatternLibrary->ListOfNumber->Count; i++) { // ¹®Á¦Á¡: ÆÐÅÏ¿¡ À̹ÌÁö°¡ ¾øÀ» ¼öµµ ÀÖ´Ù. À̰æ¿ì¸¦ »ý°¢ÇÏÁö ¾Ê°í // ÇÁ·Î±×·¥À» ®±â ¶§¹®¿¡ ¹®Á¦°¡ ¹ß»ýÇß´Ù. patterndata = (TPatternDATA *)PatternLibrary->ListOfpData->Items[i]; if (!WriteFile(fh, &patterndata->bpp, sizeof(WORD), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &patterndata->Width, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &patterndata->Height, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &patterndata->kindOfPattern, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &patterndata->selectedColor, sizeof(COLORREF), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &patterndata->isSelected, sizeof(bool), &dwWrite, NULL)) goto fail; if (PatternLibrary->PatternNumber > 0 && patterndata->kindOfPattern ==0) { patterndata->RealImageBitmap->SaveToTexpiaFile(fh, cmZLib); } } /////////// ¿øº» Style ÀúÀå count = MainVecData->Count; header = *MainHeader; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; VectorListSave(MainVecData, fh); header.FileIndex = 0; // ÃʱâÈ­ÇØÁØ´Ù - by monkman (2011.01.04) if (!WriteFile(fh, &header, sizeof(STYLEDATAFILEHEADER), &dwWrite, NULL)) goto fail; /////////// °¢ LayerImageº° data ÀúÀå for (int i = 0; i < V_DATA->Count; i++) { list = (TList *)V_DATA->Items[i]; count = list->Count; pheader = (PSTYLEDATAFILEHEADER)V_HEADER->Items[i]; header = *pheader; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; VectorListSave(list, fh); header.FileIndex = 0; // ÃʱâÈ­ÇØÁØ´Ù - by monkman (2011.01.04) if (!WriteFile(fh, &header, sizeof(STYLEDATAFILEHEADER), &dwWrite, NULL)) goto fail; } return true; fail: return false; } //--------------------------------------------------------------------------- bool __fastcall TStyleComboForm::VectorListSave(TList *list, HANDLE fh) { TVecData *data; DWORD dwWrite; int linecount, wordcount, lineheight; TSWordData *srcWordData; int TempCapStyle[2] = {0, 0}; for (int i = 0; i < list->Count; i++) { data = (TVecData *)list->Items[i]; if (!WriteFile(fh, &data->Kind, sizeof(EVecKind), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->First, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Second, sizeof(POINT), &dwWrite, NULL)) goto fail; //Combo Version 130 Ãß°¡ if (!WriteFile(fh, &data->bAntialiasing, sizeof(bool), &dwWrite, NULL)) goto fail; switch (data->Kind) { case V_LINE: case V_CURVE: if (!WriteFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PenThick, sizeof(double), &dwWrite, NULL)) goto fail; // Combo Version 130 int->double shin if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bRound, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bFill, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bWinding, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Color, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Brush, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bClosed, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, data->pList, sizeof(DPOINT)*(data->nCount*3+1), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bPatternFill, sizeof(bool), &dwWrite, NULL)) goto fail; if (data->bPatternFill) { int w = data->TBitmapSource->Width, h = data->TBitmapSource->Height; if (!WriteFile(fh, &data->PatternAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PatternAdjustX, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PatternAdjustY, sizeof(int), &dwWrite, NULL)) goto fail; //===Combo Version 110 Ãß°¡ (2004/05/13) if (!WriteFile(fh, &data->RatioX, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->RatioY, sizeof(int), &dwWrite, NULL)) goto fail; //========================= if (!WriteFile(fh, &w, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &h, sizeof(int), &dwWrite, NULL)) goto fail; data->TBitmapSource->SaveToTexpiaFile(fh, cmZLib); } //Combo Version 130 Ãß°¡ if (!WriteFile(fh, data->DashValues, sizeof(double)*7, &dwWrite, NULL)) goto fail; //Combo Version 140 Ãß°¡ if (!WriteFile(fh, &data->bGradientFill, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bGradientFill){ if (!WriteFile(fh, &data->gradientItem, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gradientColorCount, sizeof(int), &dwWrite, NULL)) goto fail; int count = data->gradientColorCount; if (!WriteFile(fh, data->gradientColors, sizeof(RGBQUAD)*count, &dwWrite, NULL)) goto fail; } // Version 150 Ãß°¡ 090304 if (!WriteFile(fh, &data->bMotive, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bMotive) { if (!WriteFile(fh, &data->mode, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gap, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->motivecount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->proportion, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childwidth, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childheight, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->centerX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->centerY, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->ChildCount, sizeof(int), &dwWrite, NULL)) goto fail; VectorListSave(data->ChildList, fh); } //Combo Version 151 Ãß°¡ - Arrow TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; if (!WriteFile(fh, TempCapStyle, sizeof(int) * 2, &dwWrite, NULL)) goto fail; if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->SaveToFile(fh)) goto fail; // if (!WriteFile(fh, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapWidth, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapHeight, sizeof(double), &dwWrite, NULL)) // goto fail; } break; case V_TEXT: if (!WriteFile(fh, &data->Color, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Font, sizeof(LOGFONT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, data->TextString.c_str(), sizeof(char)*data->nCount, &dwWrite, NULL)) goto fail; break; // Version 120¿¡¼­ Ãß°¡ÇÑ ³»¿ë case V_TEXTBOX: if (!WriteFile(fh, &data->CharH, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->CharW, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->TextAngle, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->StartPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->CenterPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; linecount = data->ListOfAllLine->LineCount; if (!WriteFile(fh, &linecount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iListOfAllLine->GetLineTextBox(i)->LineDataList->Count; if (!WriteFile(fh, &wordcount, sizeof(int), &dwWrite, NULL)) goto fail; for (int j=0; jListOfAllLine->GetLineTextBox(i)->LineDataList->Items[j]; if (!WriteFile(fh, &srcWordData->Selected, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->PPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->LFont, sizeof(LOGFONT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, srcWordData->Word, sizeof(char)*2, &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->UsedByte, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->Color, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->Interval, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->HeightGap, sizeof(float), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->WidthGap, sizeof(float), &dwWrite, NULL)) goto fail; //Combo Version 130 Ãß°¡ if (!WriteFile(fh, &srcWordData->bNameChanged, sizeof(bool), &dwWrite, NULL)) goto fail; } lineheight = data->ListOfAllLine->GetLineTextBox(i)->lineHeight; // lineHeight ÀúÀå if (!WriteFile(fh, &lineheight, sizeof(int), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, data->pList, sizeof(DPOINT)*5, &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; break; } if (!WriteFile(fh, &data->isSameColor, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->isSameImage, sizeof(int), &dwWrite, NULL)) goto fail; } return true; fail: return false; } //--------------------------------------------------------------------------- bool __fastcall TStyleComboForm::LoadFromFile(HANDLE fh) { TList *list; int Version, count, PatternCount, StyleCount; STYLEDATAFILEHEADER header; PSTYLEDATAFILEHEADER pheader; TTexpiaBitmap *bitmap; TPatternDATA *patterndata; DWORD dwRead; TRect Src; ComboScrollBox->Visible = false; PatternLibraryScrollBox->Visible = false; if (!ReadFile(fh, &Version, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &PatternCount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &StyleCount, sizeof(int), &dwRead, NULL)) goto fail; ////////// ÇöÀç Combo Version 110 ////////// TextBoxÃß°¡·Î 120À¸·Î º¯°æ (04.11.03) ////////// GdiplusÃß°¡·Î 130À¸·Î º¯°æ (05.03.09) if (Version > StyleComboFileVersion) { EXCEPTION_MESSAGE_OK(EC_FILE_NOT_OPEN_NEWERVERSION); return false; } ////////// Pattern ºÒ·¯¿À±â for (int i = 0; i < PatternCount; i++) { patterndata = new TPatternDATA; if (!ReadFile(fh, &patterndata->bpp, sizeof(WORD), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &patterndata->Width, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &patterndata->Height, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &patterndata->kindOfPattern, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &patterndata->selectedColor, sizeof(COLORREF), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &patterndata->isSelected, sizeof(bool), &dwRead, NULL)) goto fail; if (patterndata->kindOfPattern == 0) { bitmap = new TTexpiaBitmap; if (!bitmap->Create(patterndata->Width, patterndata->Height, patterndata->bpp)) goto fail; bitmap->LoadFromTexpiaFile(fh, cmZLib); PatternLibrary->ReloadDataFromFile(patterndata, bitmap); delete bitmap; } else PatternLibrary->ReloadDataFromFile(patterndata); delete patterndata; } /////////// ¿øº» Style ºÒ·¯¿À±â ResetMainVecData(); if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; /////////// StatusProgress Start StatusProgress->Maximum = count * (3+StyleCount*3); VectorListLoad(MainVecData, fh, count, Version, StatusProgress); if (!ReadFile(fh, &header, sizeof(STYLEDATAFILEHEADER), &dwRead, NULL)) goto fail; header.FileIndex = 0; // ÃʱâÈ­ÇØÁØ´Ù - by monkman (2011.01.04) VecDraw->CopySTYHeader(MainHeader, header); /////////// °¢ LayerImageº° data ºÒ·¯¿À±â for (int i = 0; i < StyleCount; i++) { list = new TList; if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; VectorListLoad(list, fh, count, Version, StatusProgress); if (!ReadFile(fh, &header, sizeof(STYLEDATAFILEHEADER), &dwRead, NULL)) goto fail; header.FileIndex = 0; // ÃʱâÈ­ÇØÁØ´Ù - by monkman (2011.01.04) pheader = new STYLEDATAFILEHEADER; VecDraw->CopySTYHeader(pheader, header); V_DATA->Add(list); V_HEADER->Add(pheader); } FirstRun = true; pNumInMainImage = 0; // MainImage¿¡ ÀÖ´Â Style¾ÈÀÇ Pattern°³¼ö cNumInMainImage = 0; // MainImage¿¡ ÀÖ´Â Style¾ÈÀÇ Color°³¼ö CheckIsSamePattern(StatusProgress); InitStyleInForm(StyleCount, StatusProgress, true); PSpatternNum->Value = StyleCount; ComboScrollBox->Visible = true; PatternLibraryScrollBox->Visible = true; // Create Image for Opened Style -------------------------------------------------- if (!OpenedStretchImage) { TPLayerImage *SourceImage; OpenedStretchImage = new TPStretchImage(this); OpenedStretchImage->Parent = OpenedStyleGBox; SourceImage = (TPLayerImage *)ListOfImage->Items[0]; OpenedStretchImage->Bitmap->Create(SourceImage->Bitmap->Width, SourceImage->Bitmap->Height, 24); OpenedStretchImage->Bitmap->FillRect(Rect(0, 0, SourceImage->Bitmap->Width, SourceImage->Bitmap->Height), clWhite); PatternLibrary->RatioCalculate(OpenedStretchImage, OpenedStretchImage->Bitmap, shOpenedStyle->Width, shOpenedStyle->Height); OpenedStretchImage->Top = shOpenedStyle->Top + (shOpenedStyle->Height - OpenedStretchImage->Height)/2; OpenedStretchImage->Left = shOpenedStyle->Left + (shOpenedStyle->Width - OpenedStretchImage->Width)/2; } //---------------------------------------------------------------------------------- StatusProgress->End(); return true; fail: delete bitmap; return false; } //------------------------------------------------------------------------- bool __fastcall TStyleComboForm::VectorListLoad(TList *list, HANDLE fh, int count, int Version, TStatusProgress *stProgress) { TVecData *data; DWORD dwRead; int linecount, wordcount, lineheight; for (int i = 0; i < count; i++) { if (stProgress) stProgress->Position += 1; if ((data = new TVecData(0))==NULL) goto fail; if (!ReadFile(fh, &data->Kind, sizeof(EVecKind), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->First, sizeof(POINT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Second, sizeof(POINT), &dwRead, NULL)) goto fail; //====Combo Version 130 Ãß°¡ (05.03.09) if (Version >= 130){ if (!ReadFile(fh, &data->bAntialiasing, sizeof(bool), &dwRead, NULL)) goto fail; } else { data->bAntialiasing = false; } int tempthick; switch (data->Kind) { case V_LINE: case V_CURVE: if (!ReadFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwRead, NULL)) goto fail; //====Combo Version 130 Ãß°¡ (05.03.09) if (Version >= 130){ if (!ReadFile(fh, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; } else { if (!ReadFile(fh, &tempthick, sizeof(int), &dwRead, NULL)) goto fail; data->PenThick = tempthick; } if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bRound, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bFill, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bWinding, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Brush, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bClosed, sizeof(bool), &dwRead, NULL)) goto fail; //if (!ReadFile(fh, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; if(Version < 140) //130 ÀÌÇÏ ¹öÀüÀÇ groupÀ» ÀÐ¾î ¿À±â À§ÇØ { int temp; if (!ReadFile(fh, &temp, sizeof(int), &dwRead, NULL)) goto fail; int tempIndex = 0; for(int i = 0; i < 10; i++) //¹øÈ£°¡ ÀÖ´Â group index¸¦ ÀÐÀ½ { if((temp & (1 << i))) tempIndex += (1 << i); } for(int i = 10; i < 32; i++) //¹øÈ£°¡ ¾ø´Â group index¸¦ ÀÐÀ½ { if((temp & (1 << i))) { tempIndex += ((i - 9) * 10000); break; } } data->GroupIndex = tempIndex; }else { if (!ReadFile(fh, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; } data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); if (!ReadFile(fh, data->pList, sizeof(DPOINT)*(data->nCount*3+1), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bPatternFill, sizeof(bool), &dwRead, NULL)) goto fail; if (data->bPatternFill) { int w, h; if (!ReadFile(fh, &data->PatternAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->PatternAdjustX, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->PatternAdjustY, sizeof(int), &dwRead, NULL)) goto fail; //====Combo Version 120 Ãß°¡ (2004/05/13) if (Version >= 110) { if (!ReadFile(fh, &data->RatioX, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->RatioY, sizeof(int), &dwRead, NULL)) goto fail; } //========================== if (!ReadFile(fh, &w, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &h, sizeof(int), &dwRead, NULL)) goto fail; data->TBitmapSource = new TTexpiaBitmap; if (!data->TBitmapSource->Create(w, h, 24)) goto fail; data->TBitmapSource->LoadFromTexpiaFile(fh, cmZLib); VecDraw->MakePatternBitmap(data); } //====Combo Version 130 Ãß°¡ (05.03.09) if (Version >= 130){ if (!ReadFile(fh, data->DashValues, sizeof(double)*7, &dwRead, NULL)) goto fail; } //====Combo Version 140 Ãß°¡ 080514 if (Version >= 140){ if (!ReadFile(fh, &data->bGradientFill, sizeof(int), &dwRead, NULL)) goto fail; if (data->bGradientFill){ if (!ReadFile(fh, &data->gradientItem, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gradientColorCount, sizeof(int), &dwRead, NULL)) goto fail; int count = data->gradientColorCount; data->gradientColors = new RGBQUAD[count]; if (!ReadFile(fh, data->gradientColors, sizeof(RGBQUAD)*count, &dwRead, NULL)) goto fail; } } //====Combo Version 150 Ãß°¡ 090407 if (Version >= 150){ if (!ReadFile(fh, &data->bMotive, sizeof(int), &dwRead, NULL)) goto fail; if (data->bMotive){ if (!ReadFile(fh, &data->mode, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gap, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->motivecount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->proportion, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childwidth, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childheight, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerX, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerY, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->ChildCount, sizeof(int), &dwRead, NULL)) goto fail; if (data->ChildList) data->DeleteChildList(); data->ChildList = new TList; VectorListLoad(data->ChildList, fh, data->ChildCount, Version, NULL); } } //====Combo Version 151 Ãß°¡ - Arrow if (Version >= 151){ int TempCapStyle[2] = {0, 0}; if (!ReadFile(fh, TempCapStyle, sizeof(int) * 2, &dwRead, NULL)) goto fail; data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->LoadFromFile(fh)) goto fail; // if (!ReadFile(fh, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapWidth, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapHeight, sizeof(double), &dwRead, NULL)) // goto fail; } } break; case V_TEXT: char tempchar; if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Font, sizeof(LOGFONT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; for (int k = 0; k < data->nCount; k++) { if (!ReadFile(fh, &tempchar, sizeof(char), &dwRead, NULL)) goto fail; data->TextString += tempchar; } /* data->Kind = V_TEXTBOX; VecDraw->ChangeTextToTextBox(data);*/ break; case V_TEXTBOX: if (!ReadFile(fh, &data->CharH, sizeof(int), &dwRead, NULL)) goto fail; // ±ÛÀÚÀÇ Å©±â if (!ReadFile(fh, &data->CharW, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->TextAngle, sizeof(double), &dwRead, NULL)) goto fail; // TextBoxÀÇ Angle·Î »ç¿ëµÊ if (!ReadFile(fh, &data->StartPoint, sizeof(POINT), &dwRead, NULL)) goto fail; // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ if (!ReadFile(fh, &data->CenterPoint, sizeof(POINT), &dwRead, NULL)) goto fail;// BoxÀÇ ¹«°ÔÁß½ÉÁ¡ TSWordData *srcWordData; // °¢°¢ÀÇ ¶óÀÎÀ» ÀúÀåÇϰí ÀÖ´Â ºÎºÐÀ» Copy TLineTextBox *tempTLineTextBox; data->ListOfAllLine = new TWordList; if (!ReadFile(fh, &linecount, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iSelected, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->PPoint, sizeof(POINT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->LFont, sizeof(LOGFONT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, srcWordData->Word, sizeof(char)*2, &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->UsedByte, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->Interval, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->HeightGap, sizeof(float), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->WidthGap, sizeof(float), &dwRead, NULL)) goto fail; //====Combo Version 130 Ãß°¡ (05.03.09) if (Version >= 130){ if (!ReadFile(fh, &srcWordData->bNameChanged, sizeof(bool), &dwRead, NULL)) goto fail; } else { srcWordData->bNameChanged = false; } tempTLineTextBox->LineDataList->Add(srcWordData); } if (!ReadFile(fh, &lineheight, sizeof(int), &dwRead, NULL)) goto fail; tempTLineTextBox->lineHeight = lineheight; // lineHeight ÀúÀå data->ListOfAllLine->Add(tempTLineTextBox); } data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*5); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, 1); if (!ReadFile(fh, data->pList, sizeof(DPOINT)*5, &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; break; } if (!ReadFile(fh, &data->isSameColor, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->isSameImage, sizeof(int), &dwRead, NULL)) goto fail; list->Add(data); } return true; fail: return false; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ReloadStyleInForm(int ImageWidth, int ImageHeight, int StyleNum, double Zoom, TStatusProgress *stProgress) { TRegIniFile *RegIniFile; String DirectoryBin; String DirectoryName; String FileName; int ShapeHeight = ImageHeight + 8; int ShapeWidth = ImageWidth + 8; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw DirectoryBin = RegIniFile->ReadString("Directory", "Bin", DefaultDir + "\\Bin"); DirectoryName = DirectoryBin + "\\TexStylist\\StyleNo\\"; for (int i=0; iParent = ComboScrollBox; comboShape->Parent = ComboScrollBox; comboImage->Parent = ComboScrollBox; pScrollBox->Parent = ComboScrollBox; comboShape->SendToBack(); comboShape->Pen->Color = Graphics::clSkyBlue; comboShape->Height = ShapeHeight; comboShape->Width = ShapeWidth; comboShape->Top = 5 + i/3 * (ShapeHeight + 83); comboShape->Left = 5 + i%3 * (ShapeWidth + 5); comboImage->Height = ImageHeight; comboImage->Width = ImageWidth; comboImage->Top = comboShape->Top + 4; comboImage->Left = comboShape->Left + 4; comboImage->OnDblClick = tempLayerImageDblClick; comboImage->OnMouseDown = tempLayerImageMouseDown; comboImage->OnMouseMove = tempLayerImageMouseMove; comboImage->OnMouseLeave = tempLayerImageMouseLeave; comboImage->PopupMenu = ImagePopupMenu; sbImageNum->Width = 33; sbImageNum->Height = 33; sbImageNum->Top = comboImage->Top + 4; sbImageNum->Left = comboImage->Left + 4; FileName = IntToStr(i+1) + ".bmp"; sbImageNum->Glyph->LoadFromFile(DirectoryName+FileName); sbImageNum->NumGlyphs = 1; sbImageNum->AllowAllUp = true; sbImageNum->GroupIndex = i+1; sbImageNum->Flat = true; sbImageNum->OnClick = tempSpButtonClick; sbImageNum->BringToFront(); sbImageNum->Hint = IDS_COMBOMSGBOX12; // IDS_COMBOMSGBOX12: ¹öư ´©·ç¸é °íÁ¤ sbImageNum->ShowHint = true; pScrollBox->Width = comboShape->Width; pScrollBox->Height = 81; pScrollBox->Top = comboShape->Top + comboShape->Height + 1; pScrollBox->Left = comboShape->Left; pScrollBox->DoubleBuffered = true; pScrollBox->BorderStyle = Forms::bsNone; pScrollBox->VertScrollBar->Visible = false; pScrollBox->OnMouseMove = patternScrollBoxMouseMove; for (int j=0; jParent = pScrollBox; smallImage->Bitmap->Create(50, 60, 24); smallImage->Width = 50; smallImage->Height = 60; smallImage->Top = 2; smallImage->Left = 5 + j*55; smallImage->OnMouseDown = tempSmallStImageMouseDown; smallShape->Parent = pScrollBox; smallShape->Width = 52; smallShape->Height = 62; smallShape->Top = smallImage->Top-1; smallShape->Left = smallImage->Left-1; smallShape->Brush->Color = clWhite; smallShape->Brush->Style = bsSolid; smallShape->Pen->Color = (TColor)0xB5B5B5; smallShape->Pen->Style = psSolid; smallImage->BringToFront(); sPatternList->Add(smallImage); sClassList->Add(sImageData); sShapeList->Add(smallShape); } S_IMAGE->Add(sPatternList); S_DATA->Add(sClassList); S_SHAPE->Add(sShapeList); comboImage->uBitmap->Create(ImageWidth, ImageHeight, 24); comboImage->uBitmap->FillRect(Rect(0, 0, ImageWidth, ImageHeight), clWhite); TTexpiaBitmap *tempImage = new TTexpiaBitmap; tempImage->Create(comboImage->uBitmap->Width, comboImage->uBitmap->Height, comboImage->uBitmap->BitsPerPixel, comboImage->uBitmap->RGB); comboImage->uBitmap->CopyToTexpia(tempImage, 0, 0, comboImage->uBitmap->Width, comboImage->uBitmap->Height, 0, 0, SRCCOPY); HDC dcDst = tempImage->CreateDC(); VecDataList = (TList *)V_DATA->Items[i]; VecReDrawInCombo(dcDst, VecDataList, ImageWidth, ImageHeight, MainImageForm->Number, Zoom ,i, stProgress); tempImage->DeleteDC(dcDst); comboImage->uBitmap->Copy(tempImage, SRCCOPY); delete tempImage; ListOfImage->Add(comboImage); ListOfShape->Add(comboShape); ListOfButton->Add(sbImageNum); ListOfScrollBox->Add(pScrollBox); } delete RegIniFile; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::VecReDrawInCombo(HDC dcDst, TList *list, double CWidth, double CHeight, int number, double Zoom, int nowImageNum, TStatusProgress *stProgress) { HPEN hOldPen = NULL , hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int cenx, ceny, width, height; TVecData *data; int randPatternNum=0, StartX, StartY; RECT rect; gdp::Graphics graphics(dcDst); gdp::Point *pPoints = NULL; for (int i = 0; i < list->Count; i++) // objectÀ§Ä¡ º¸Á¤ { stProgress->Position += 1; data = (TVecData *)list->Items[i]; if (data->bAntialiasing) graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); if (data->Kind == V_TEXTBOX || data->ChildList) { VecDraw->GetRectForMouseMove(data, rect); minx = min(minx, rect.left); maxx = max(maxx, rect.right); miny = min(miny, rect.top); maxy = max(maxy, rect.bottom); } else if (data->Kind == V_TEXT || data->Kind == V_ELLIPSE) { // Font°¡ ÀÖÀ» ¶§ Error°¡ ¹ß»ýÇØ¼­ ÀÌ·¸°Ô ó¸®Çß´Ù. // V_ELLIPSE¿¡¼­ ¿¡·¯°¡ ¹ß»ýÇØ¼­ Ãß°¡Çß´Ù. minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); } else { SET_RECT; minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); } } cenx = (minx+maxx)/2; ceny = (miny+maxy)/2; // center Á¡ width = maxx-minx; height = maxy-miny; // zoom º¸Á¤À§ÇØ if (Zoom == 0.0) { Zoom = CWidth/width < CHeight/height ? CWidth/width : CHeight/height; Zoom *= 0.95; // ¿©¹éÁÖ±â Zoom = Zoom > 1.0 ? 1.0 : Zoom; Zoom = Zoom < 4.0/8.0 ? 4.0/8.0 : Zoom; }else { Zoom *= 0.95; // ¿©¹éÁÖ±â } ZoomValue = Zoom; WidthValue = CWidth; HeightValue = CHeight; CenterX = cenx; CenterY = ceny; int sPatternNum = 0, check = 0, ccheck = 0; randPatternNum=0; TList *spList, *sdList; // Small Pattern Image List spList = (TList *)S_IMAGE->Items[nowImageNum]; sdList = (TList *)S_DATA->Items[nowImageNum]; TPStretchImage *sImage; TPStretchImage *smallImage; HDC sImageDC = NULL, smallImageDC = NULL; int sW, sH, PlusNum=0; double textCenterX, textCenterY; int OffsetX,OffsetY; //by linuxjun for CurvedVectorText int *checkColor, *checkImage; checkColor = new int[cNumInMainImage]; checkImage = new int[pNumInMainImage]; int sColorNum=0; int sImageNum=0; bool first=true, cfirst=true; for (int i = 0; i < list->Count; i++) { stProgress->Position += 1; data = (TVecData *)list->Items[i]; int FirstX = (data->First.x - cenx) * Zoom + CWidth/2 + 0.5; int FirstY = (data->First.y - ceny) * Zoom + CHeight/2 + 0.5; int SecondX = (data->Second.x - cenx) * Zoom + CWidth/2 + 0.5; int SecondY = (data->Second.y - ceny) * Zoom + CHeight/2 + 0.5; int pw = data->PenThick/2; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick*Zoom); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::Point[5]; } else { if (data->bClosed){ pPoints = new gdp::Point[(data->nCount+1)*3+1]; } else { pPoints = new gdp::Point[data->nCount*3+1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount*3 +1; i++) { // pTemp[i].x = (data->pList[i].x - cenx) * Zoom + CWidth/2 + 0.5; // pTemp[i].y = (data->pList[i].y - ceny) * Zoom + CHeight/2 + 0.5; pPoints[i].X = (data->pList[i].x - cenx) * Zoom + CWidth/2 + 0.5; pPoints[i].Y = (data->pList[i].y - ceny) * Zoom + CHeight/2 + 0.5; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - cenx) * Zoom + CWidth/2 + 0.5; StartY = (data->StartPoint.y - ceny) * Zoom + CHeight/2 + 0.5; textCenterX = (data->CenterPoint.x - cenx) * Zoom + CWidth/2 + 0.5; textCenterY = (data->CenterPoint.y - ceny) * Zoom + CHeight/2 + 0.5; OffsetX = cenx; //by linuxjun for CurvedVectorText OffsetY = ceny; //by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { // pTemp[i].x = (data->pList[i].x - cenx) * Zoom + CWidth/2 + 0.5; // pTemp[i].y = (data->pList[i].y - ceny) * Zoom + CHeight/2 + 0.5; pPoints[i].X = (data->pList[i].x - cenx) * Zoom + CWidth/2 + 0.5; pPoints[i].Y = (data->pList[i].y - ceny) * Zoom + CHeight/2 + 0.5; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { // pTemp[data->nCount*3] = pTemp[0]; // pTemp[data->nCount*3+1] = pTemp[1]; // pTemp[data->nCount*3+2] = pTemp[2]; // pTemp[data->nCount*3+3] = pTemp[3]; pPoints[data->nCount*3] = pPoints[0]; pPoints[data->nCount*3+1] = pPoints[1]; pPoints[data->nCount*3+2] = pPoints[2]; pPoints[data->nCount*3+3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù { logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) // PatternFill À϶§ { // °°Àº PatternÀ» ³Ö¾î¾ß ÇÏ´ÂÁö È®ÀÎÇÏ´Â ºÎºÐ--------------------------- if (!first) { for(int k=0; kisSameImage) goto paintPattern; } } SmallPatternImagePaint(sPatternNum, spList, sdList, data->TBitmapSource, data->isSameImage); checkImage[sImageNum]=data->isSameImage; sPatternNum++; sImageNum++; first=false; //---------------------------------------------------------------------- paintPattern: // Image¿¡ PatternÀ» ±×·ÁÁÖ´Â ºÎºÐ-------------------------------------- int bltwidth = SecondX - FirstX; int bltheight = SecondY - FirstY; HDC dcPattern = NULL, dcMask = NULL; if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC())==NULL) goto patternfail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0,0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) // ColorFill À϶§ { // °°Àº PatternÀ» ³Ö¾î¾ß ÇÏ´ÂÁö È®ÀÎÇÏ´Â ºÎºÐ--------------------------- if (!cfirst) { for(int k=0; kisSameColor) goto ColorNext; } } checkColor[sColorNum]=data->isSameColor; SmallColorImagePaint(sPatternNum, spList, sdList, data->Brush, data->isSameColor); sPatternNum++; sColorNum++; cfirst=false; //---------------------------------------------------------------------- ColorNext: logbrush.lbColor = data->Brush; hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch (data->PenStyle) { case 0: nPenStyle = int (PS_SOLID); break; case 1: nPenStyle = int (PS_DASH); break; case 2: nPenStyle = int (PS_DOT); break; case 3: nPenStyle = int (PS_DASHDOT); break; case 4: nPenStyle = int (PS_DASHDOTDOT);break; } if (VecDraw->osVERSION < 2) // 3.1, 95, 98 { hPen = CreatePen(psSolid, int(data->PenThick*Zoom+0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } /* if (data->bRound) // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(data->PenThick*Zoom+0.5), &logbrush, 0, NULL ); else hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(data->PenThick*Zoom+0.5), &logbrush, 0, NULL ); */ } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight * Zoom + 0.5; data->Font.lfHeight = data->Font.lfHeight; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (data->ChildList) { VecDrawInComboForMotive(dcDst, data, CWidth, CHeight, number, Zoom, nowImageNum, cenx, ceny); } else { PAINT_VECTOR; } if (pPoints) delete []pPoints; pPoints = NULL; if (data->Kind == V_TEXTBOX) DrawTextBox(dcDst, data, StartX, StartY, textCenterX, textCenterY, Zoom, PlusNum, OffsetX, OffsetY); //by linuxjun for CurvedVectorText if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } } pPoints = NULL; delete[] checkColor; delete[] checkImage; return; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::SelectAllClick(TObject *Sender) { TShape *comboShape; if (SelectAllShape) { for (int i=0; iCount; i++) { comboShape = (TShape *)ListOfShape->Items[i]; comboShape->Pen->Color = Graphics::clSkyBlue; } SelectAllShape=false; SelectAll->Caption = "Select All"; } else { for (int i=0; iCount; i++) { comboShape = (TShape *)ListOfShape->Items[i]; comboShape->Pen->Color = clRed; } SelectAllShape=true; SelectAll->Caption = "Deselect All"; } } //--------------------------------------------------------------------------- // For Test void __fastcall TStyleComboForm::LayerImageMouseDownForChanging(int imageNum, int X, int Y) { HDC ImageDC; TList *list; // Vector Object List TVecData *data; list = (TList *)V_DATA->Items[imageNum]; TPLayerImage *comboImage; TPatternDATA *patterndata; comboImage = (TPLayerImage *)ListOfImage->Items[imageNum]; long minx, miny, maxx, maxy; int MouseX = X / ZoomValue; int MouseY = Y / ZoomValue; for (int i = 0; i < list->Count; i++) { // ¿ì¼± Range ±¸ÇØÁÖ°í data = (TVecData *)list->Items[i]; minx = MaxInt; miny = MaxInt; maxx = 0; maxy = 0; minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); if ( minx <= MouseX && MouseX <= maxx && miny <= MouseY && MouseY <= maxy) { if (data->bPatternFill) { int GetNumber=0; PatternLibrary->GetSelectedPanelNumber(GetNumber); patterndata = (TPatternDATA *)PatternLibrary->ListOfpData->Items[GetNumber]; if (patterndata->kindOfPattern != 0) return; TTexpiaBitmap *tempImage = new TTexpiaBitmap; tempImage->Create(comboImage->uBitmap->Width, comboImage->uBitmap->Height, comboImage->uBitmap->BitsPerPixel, comboImage->uBitmap->RGB); comboImage->uBitmap->CopyToTexpia(tempImage, 0, 0, comboImage->uBitmap->Width, comboImage->uBitmap->Height, 0, 0, SRCCOPY); ImageDC = tempImage->CreateDC(); VecDrawAtMouseUp(ImageDC, list, i, GetNumber); tempImage->DeleteDC(ImageDC); comboImage->uBitmap->Copy(tempImage, SRCCOPY); delete tempImage; break; } else if (data->bFill) { int GetNumber=0; PatternLibrary->GetSelectedPanelNumber(GetNumber); patterndata = (TPatternDATA *)PatternLibrary->ListOfpData->Items[GetNumber]; if (patterndata->kindOfPattern != 1) return; TTexpiaBitmap *tempImage = new TTexpiaBitmap; tempImage->Create(comboImage->uBitmap->Width, comboImage->uBitmap->Height, comboImage->uBitmap->BitsPerPixel, comboImage->uBitmap->RGB); comboImage->uBitmap->CopyToTexpia(tempImage, 0, 0, comboImage->uBitmap->Width, comboImage->uBitmap->Height, 0, 0, SRCCOPY); ImageDC = tempImage->CreateDC(); VecDrawAtMouseUp(ImageDC, list, i, GetNumber); tempImage->DeleteDC(ImageDC); comboImage->uBitmap->Copy(tempImage, SRCCOPY); delete tempImage; break; } } } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::VecDrawAtMouseUp(HDC dcDst, TList *list, int chNumber, int GetNumber) { HPEN hOldPen = NULL , hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int StartX, StartY, PlusNum=0; double textCenterX, textCenterY; int OffsetX,OffsetY; //by linuxjun for CurvedVectorText TVecData *data; TPatternDATA *patternData; gdp::Graphics graphics(dcDst); // using GDI+ gdp::Point *pPoints = NULL; for (int i = 0; i < list->Count; i++) { data = (TVecData *)list->Items[i]; if (data->bAntialiasing) graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); int FirstX = (data->First.x - CenterX) * ZoomValue + WidthValue/2 + 0.5; int FirstY = (data->First.y - CenterY) * ZoomValue + HeightValue/2 + 0.5; int SecondX = (data->Second.x - CenterX) * ZoomValue + WidthValue/2 + 0.5; int SecondY = (data->Second.y - CenterY) * ZoomValue + HeightValue/2 + 0.5; int pw = data->PenThick/2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick*ZoomValue); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::Point[5]; } else { if (data->bClosed){ pPoints = new gdp::Point[(data->nCount+1)*3+1]; } else { pPoints = new gdp::Point[data->nCount*3+1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int is = 0; is < data->nCount*3 +1; is++) { pPoints[is].X = (data->pList[is].x - CenterX) * ZoomValue + WidthValue/2 + 0.5; pPoints[is].Y = (data->pList[is].y - CenterY) * ZoomValue + HeightValue/2 + 0.5; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - CenterX) * ZoomValue + WidthValue/2 + 0.5; StartY = (data->StartPoint.y - CenterY) * ZoomValue + HeightValue/2 + 0.5; textCenterX = (data->CenterPoint.x - CenterX) * ZoomValue + WidthValue/2 + 0.5; textCenterY = (data->CenterPoint.y - CenterY) * ZoomValue + HeightValue/2 + 0.5; OffsetX = CenterX; //by linuxjun for CurvedVectorText OffsetY = CenterY; //by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - CenterX) * ZoomValue + WidthValue/2 + 0.5; pPoints[i].Y = (data->pList[i].y - CenterY) * ZoomValue + HeightValue/2 + 0.5; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount*3] = pPoints[0]; pPoints[data->nCount*3+1] = pPoints[1]; pPoints[data->nCount*3+2] = pPoints[2]; pPoints[data->nCount*3+3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) // PatternFill À϶§ { if (chNumber == i) { patternData = (TPatternDATA *)PatternLibrary->ListOfpData->Items[GetNumber]; // Image¿¡ PatternÀ» ±×·ÁÁÖ´Â ºÎºÐ-------------------------------------- delete data->TBitmapSource; data->TBitmapSource = new TTexpiaBitmap; data->TBitmapSource->Create(patternData->RealImageBitmap->Width, patternData->RealImageBitmap->Height, patternData->RealImageBitmap->BitsPerPixel); data->TBitmapSource->Copy(patternData->RealImageBitmap, SRCCOPY); } VecDraw->MakePatternBitmap(data); int bltwidth = SecondX - FirstX; int bltheight = SecondY - FirstY; HDC dcPattern = NULL, dcMask = NULL; if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC())==NULL) goto patternfail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0,0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) // ColorFill À϶§ { if (chNumber == i) { patternData = (TPatternDATA *)PatternLibrary->ListOfpData->Items[GetNumber]; data->Brush = (TColor)patternData->selectedColor; } logbrush.lbColor = data->Brush; hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch (data->PenStyle) { case 0: nPenStyle = int (PS_SOLID); break; case 1: nPenStyle = int (PS_DASH); break; case 2: nPenStyle = int (PS_DOT); break; case 3: nPenStyle = int (PS_DASHDOT); break; case 4: nPenStyle = int (PS_DASHDOTDOT);break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0}; VecDraw->CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 /* case 5: // 2005 Vector upgrade shin 0303 nPenStyle = P_USERSTYLE; int count = data->DashValues[0]; dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = data->DashValues[i+1]; } //ObjectPen.GetCompoundArray(dashValues, count); ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 */ } if (VecDraw->osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick*ZoomValue+0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } /* if (data->bRound) // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(data->PenThick*ZoomValue+0.5), &logbrush, 0, NULL ); else hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(data->PenThick*ZoomValue+0.5), &logbrush, 0, NULL ); */ } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * ZoomValue + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } PAINT_VECTOR; if (pPoints) delete []pPoints; pPoints = NULL; if (dashValues) delete []dashValues; dashValues = NULL; if (data->Kind == V_TEXTBOX) DrawTextBox(dcDst, data, StartX, StartY, textCenterX, textCenterY, ZoomValue, PlusNum, OffsetX, OffsetY); //by linuxjun for CurvedVectorText if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } } return; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::tempLayerImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { // int i; // just test // if (PatternLibrary->GetSelectedShapeNumber(i)) // Screen->Cursor = TCursor(crDrag); if (Item == C_SELECTCOLOR) Screen->Cursor = TCursor(crArrow); //-----------------------------------For Whell Mouse Control onComboScrollBox = true; onPatternLibraryScrollBox = false; //---------------------------------------------------------- } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::tempLayerImageMouseLeave(TObject *Sender) { Screen->Cursor = TCursor(crDefault); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::patternScrollBoxMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { PushScrollBox = true; ScrollBoxNum = ListOfScrollBox->IndexOf(Sender); //-----------------------------------For Whell Mouse Control onComboScrollBox = true; onPatternLibraryScrollBox = false; //---------------------------------------------------------- } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::tempSmallStImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (!PushScrollBox) return; int GetNumber=0, i=0; Byte *byte; TColor newBrushColor; HDC ImageDC; TPatternDATA *patternData; TList *spList, *sdList; TList *VecDataList; // Vector Object List TSmallImageData *sImageData; TPLayerImage *comboImage; spList = (TList *)S_IMAGE->Items[ScrollBoxNum]; sdList = (TList *)S_DATA->Items[ScrollBoxNum]; i = spList->IndexOf(Sender); if (i < 0) return; //À̺¥Æ®°¡ ¹ß»ýÇßÀ½¿¡µµ ¿Ö -1ÀÌ µé¾î°¡´ÂÁö ¸ð¸£°Ú´Ù. sImageData = (TSmallImageData *)sdList->Items[i]; VecDataList = (TList *)V_DATA->Items[ScrollBoxNum]; comboImage = (TPLayerImage *)ListOfImage->Items[ScrollBoxNum]; PatternLibrary->GetSelectedPanelNumber(GetNumber); if (GetNumber < 0) return; // ¼±ÅÃµÈ ÆÐÅÏÀ̳ª Ä÷¯°¡ ¾øÀ» °æ¿ì patternData = (TPatternDATA *)PatternLibrary->ListOfpData->Items[GetNumber]; if ( sImageData->kind==1 && patternData->kindOfPattern==1) { newBrushColor=(TColor)patternData->selectedColor; // Small Image¸¦ ±×·ÁÁÖ´Â ºÎºÐ---------------------------------------------- SmallColorImagePaint(i, spList, sdList, newBrushColor, sImageData->isSameColor); //-------------------------------------------------------------------------- TTexpiaBitmap *tempImage = new TTexpiaBitmap; tempImage->Create(comboImage->uBitmap->Width, comboImage->uBitmap->Height, comboImage->uBitmap->BitsPerPixel, comboImage->uBitmap->RGB); comboImage->uBitmap->CopyToTexpia(tempImage, 0, 0, comboImage->uBitmap->Width, comboImage->uBitmap->Height, 0, 0, SRCCOPY); ImageDC = tempImage->CreateDC(); VecDrawAtMouseUpinSmallImage(ImageDC, VecDataList, GetNumber, newBrushColor, sImageData); tempImage->DeleteDC(ImageDC); comboImage->uBitmap->Copy(tempImage, SRCCOPY); delete tempImage; comboImage->Repaint(); } else if ( sImageData->kind==0 && patternData->kindOfPattern==0) { // Small Image¸¦ ±×·ÁÁÖ´Â ºÎºÐ------------------------------------------ TPStretchImage *smallImage; smallImage = (TPStretchImage *)PatternLibrary->GetPatternImage(GetNumber); SmallPatternImagePaint(i, spList, sdList, smallImage->Bitmap, sImageData->isSameImage); //---------------------------------------------------------------------- TTexpiaBitmap *tempImage = new TTexpiaBitmap; tempImage->Create(comboImage->uBitmap->Width, comboImage->uBitmap->Height, comboImage->uBitmap->BitsPerPixel, comboImage->uBitmap->RGB); comboImage->uBitmap->CopyToTexpia(tempImage, 0, 0, comboImage->uBitmap->Width, comboImage->uBitmap->Height, 0, 0, SRCCOPY); ImageDC = tempImage->CreateDC(); VecDrawAtMouseUpinSmallImage(ImageDC, VecDataList, GetNumber, (TColor)0, sImageData, patternData->RealImageBitmap); tempImage->DeleteDC(ImageDC); comboImage->uBitmap->Copy(tempImage, SRCCOPY); delete tempImage; comboImage->Repaint(); } else { PushScrollBox = false; ScrollBoxNum = 0; return; } PushScrollBox = false; ScrollBoxNum = 0; } //--------------------------------------------------------------------------- // Small Image¸¦ ¼±ÅÃÇØ¼­ Pattern ¹× Color¸¦ º¯°æÇÒ ¶§ »ç¿ëÇÏ´Â ÇÔ¼öÀÌ´Ù. void __fastcall TStyleComboForm::VecDrawAtMouseUpinSmallImage(HDC dcDst, TList *list, int GetNumber, TColor newBrushColor, TSmallImageData *sImageData, TTexpiaBitmap *realImageBitmap) { HPEN hOldPen = NULL , hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int StartX, StartY, PlusNum=0; double textCenterX, textCenterY; int OffsetX,OffsetY; //by linuxjun for CurvedVectorText TVecData *data; gdp::Graphics graphics(dcDst); // using GDI+ gdp::Point *pPoints = NULL; //graphics.SetPageUnit(gdp::UnitPixel); //graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing for (int i = 0; i < list->Count; i++) { data = (TVecData *)list->Items[i]; if (data->bAntialiasing) graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); int FirstX = (data->First.x - CenterX) * ZoomValue + WidthValue/2 + 0.5; int FirstY = (data->First.y - CenterY) * ZoomValue + HeightValue/2 + 0.5; int SecondX = (data->Second.x - CenterX) * ZoomValue + WidthValue/2 + 0.5; int SecondY = (data->Second.y - CenterY) * ZoomValue + HeightValue/2 + 0.5; int pw = data->PenThick/2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick*ZoomValue); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::Point[5]; } else { if (data->bClosed){ pPoints = new gdp::Point[(data->nCount+1)*3+1]; } else { pPoints = new gdp::Point[data->nCount*3+1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int is = 0; is < data->nCount*3 +1; is++) { pPoints[is].X = (data->pList[is].x - CenterX) * ZoomValue + WidthValue/2 + 0.5; pPoints[is].Y = (data->pList[is].y - CenterY) * ZoomValue + HeightValue/2 + 0.5; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - CenterX) * ZoomValue + WidthValue/2 + 0.5; StartY = (data->StartPoint.y - CenterY) * ZoomValue + HeightValue/2 + 0.5; textCenterX = (data->CenterPoint.x - CenterX) * ZoomValue + WidthValue/2 + 0.5; textCenterY = (data->CenterPoint.y - CenterY) * ZoomValue + HeightValue/2 + 0.5; OffsetX = CenterX; //by linuxjun for CurvedVectorText OffsetY = CenterY; //by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - CenterX) * ZoomValue + WidthValue/2 + 0.5; pPoints[i].Y = (data->pList[i].y - CenterY) * ZoomValue + HeightValue/2 + 0.5; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount*3] = pPoints[0]; pPoints[data->nCount*3+1] = pPoints[1]; pPoints[data->nCount*3+2] = pPoints[2]; pPoints[data->nCount*3+3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) // PatternFill À϶§ { if (sImageData->kind==0 && data->isSameImage==sImageData->isSameImage) { // Image¿¡ PatternÀ» ±×·ÁÁÖ´Â ºÎºÐ-------------------------------------- delete data->TBitmapSource; data->TBitmapSource = new TTexpiaBitmap; data->TBitmapSource->Create(realImageBitmap->Width, realImageBitmap->Height, realImageBitmap->BitsPerPixel); data->TBitmapSource->Copy(realImageBitmap, SRCCOPY); } VecDraw->MakePatternBitmap(data); int bltwidth = SecondX - FirstX; int bltheight = SecondY - FirstY; HDC dcPattern = NULL, dcMask = NULL; if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC())==NULL) goto patternfail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0,0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) // ColorFill À϶§ { if (sImageData->kind==1 && data->isSameColor==sImageData->isSameColor) { data->Brush = newBrushColor; // ¼±ÅÃÇÑ »öÀ¸·Î º¯°æ unsigned long nColor = RGB(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); FillColor.SetFromCOLORREF(nColor); ObjectBrush.SetColor(FillColor); } logbrush.lbColor = data->Brush; hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch (data->PenStyle) { case 0: nPenStyle = int (PS_SOLID); break; case 1: nPenStyle = int (PS_DASH); break; case 2: nPenStyle = int (PS_DOT); break; case 3: nPenStyle = int (PS_DASHDOT); break; case 4: nPenStyle = int (PS_DASHDOTDOT);break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0}; VecDraw->CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 /* case 5: // 2005 Vector upgrade shin 0303 nPenStyle = P_USERSTYLE; int count = data->DashValues[0]; dashValues = new float[count]; for (int i = 0; i < count; i++){ dashValues[i] = data->DashValues[i+1]; } //ObjectPen.GetCompoundArray(dashValues, count); ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 */ } if (VecDraw->osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick*ZoomValue+0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } /* if (data->bRound) // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(data->PenThick*ZoomValue+0.5), &logbrush, 0, NULL ); else hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(data->PenThick*ZoomValue+0.5), &logbrush, 0, NULL ); */ } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * ZoomValue + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } PAINT_VECTOR; if (pPoints) delete []pPoints; pPoints = NULL; if (dashValues) delete []dashValues; dashValues = NULL; if (data->Kind == V_TEXTBOX) DrawTextBox(dcDst, data, StartX, StartY, textCenterX, textCenterY, ZoomValue, PlusNum, OffsetX, OffsetY); //by linuxjun for CurvedVectorText if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } } pPoints = NULL; return; } //--------------------------------------------------------------------------- // nPr (n Permutation r) int __fastcall TStyleComboForm::NumOfPermutation(int n, int r) { if (n=r À̾î¾ß Çϱ⠶§¹® int denominator=1; //ºÐ¸ð int numerator=1; //ºÐÀÚ int i, j; for(i=n; i>n-r; i--) numerator*=i; // n! return numerator; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::Change(int *x, int *y) { int t; t = *y; *y = *x; *x = t; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::InitPermutation() { int i; pPermutationNum = 0; cPermutationNum = 0; pPermutationNum = NumOfPermutation(PatternLibrary->PatternNumber, pNumInMainImage); cPermutationNum = NumOfPermutation(PatternLibrary->ColorNumber, cNumInMainImage); iPermutationArray = new int*[pPermutationNum]; cPermutationArray = new int*[cPermutationNum]; for (i=0; iPatternNumber, pNumInMainImage, pNumInMainImage); delete[] tempArray; tempArray = new int[cNumInMainImage]; cPermutationNum = 0; colorPermutation(PatternLibrary->ColorNumber, cNumInMainImage, cNumInMainImage); delete[] tempArray; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::DelPermutationArray() { int i; for (i=0; i=0; i--) { Change(&PatternArr[i], &PatternArr[n-1]); tempArray[r-1] = PatternArr[n-1]; imagePermutation(n-1, r-1, q); Change(&PatternArr[i], &PatternArr[n-1]); } } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::colorPermutation(int n, int r, int q) { int i; if (r==0) Save_ColorPermutationArray(q); else { for (i=n-1; i>=0; i--) { Change(&ColorArr[i], &ColorArr[n-1]); tempArray[r-1] = ColorArr[n-1]; colorPermutation(n-1, r-1, q); Change(&ColorArr[i], &ColorArr[n-1]); } } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::Save_ImagePermutationArray(int q) { while(q) { iPermutationArray[pPermutationNum][--q]=tempArray[q]; } pPermutationNum++; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::Save_ColorPermutationArray(int q) { while(q) { cPermutationArray[cPermutationNum][--q]=tempArray[q]; } cPermutationNum++; } //--------------------------------------------------------------------------- // Style Size¸¦ ¾ò±â À§Çؼ­ added by maxleo21c (2004/05/25) void __fastcall TStyleComboForm::GetStyleSize(TList *DataList, int &Width, int &Height) { TVecData *vData = NULL; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; RECT rect; for (int i = 0; i < DataList->Count; i++) { vData = (TVecData *)DataList->Items[i]; minx = min(minx, vData->First.x); minx = min(minx, vData->Second.x); maxx = max(maxx, vData->First.x); maxx = max(maxx, vData->Second.x); miny = min(miny, vData->First.y); miny = min(miny, vData->Second.y); maxy = max(maxy, vData->First.y); maxy = max(maxy, vData->Second.y); if (vData->ChildList) { VecDraw->GetRectForMouseMove(vData, rect); minx = min(minx, rect.left); maxx = max(maxx, rect.right); miny = min(miny, rect.top); maxy = max(maxy, rect.bottom); } } Width = maxx - minx; Height = maxy - miny; CenterX = (maxx + minx)/2 - Width/2; CenterY = (maxy + miny)/2 - Height/2; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::psImageDblClick(TObject *Sender) { isDblClick = true; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::psImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (!isDblClick) return; int i = PatternLibrary->ListOfImage->IndexOf(Sender); PatternLibrary->psImageMouseDown(i); isDblClick = false; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::psImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int i = PatternLibrary->ListOfImage->IndexOf(Sender); if (i<0) return; PatternLibrary->psImageMouseUp(i); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbSelectPatternClick(TObject *Sender) { UpdateMenu(); Item = C_SELECTIMAGE; // Menu shSelectPattern->Pen->Color = clRed; TFileManagerForm *Form; if ((Form = new TFileManagerForm(this)) == NULL) goto fail; if (MainImageForm) Form->Extension = 9;//DefaultExtensionIndex; else Form->Extension = MainImageForm->iMainImage->uBitmap->BitsPerPixel; Form->CompressCheckBox->Checked = (CompressMethod == cmNone) ? false: true; Form->FilterComboBox->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex|" "Texpro Textile Full Colors File (*.tfc)|*.tfc|" // "Texpro Textile 3D File (*.t3d)|*.t3d|" "Texpro Weave File (*.wea)|*.wea|" // "Texpro Weave File - V7.01 (*.wav)|*.wav|" "Texpro Knit File (*.knt)|*.knt|" "Texpro Vector File (*.vst)|*.vst|" "Microsoft Windows Bitmap (*.bmp)|*.bmp|" "JPEG (*.jpg)|*.jpg|" "Macintosh PICT (*.pct)|*.pct|" "PC Paintbrush File Format (*.pcx)|*.pcx|" "PNG (*.png)|*.png|PSD (*.psd)|*.psd|" "SUN Raster (*.ras)|*.ras|" "Targa Image File (*.tga)|*.tga|" "TIFF uncomp (*.tif)|*.tif|" "Encapsulated PostScript File (*.eps)|*.eps|" "Drawing Interchange File Format (*.dxf)|*.dxf|" "ALL Files (*.*)|*.*|"; //================================================================= Form->OnRead = FMOnRead; Form->OnFileName = MainForm->FMOnFileName; Form->rztbSave->Enabled = false; Form->rztbSaveAs->Enabled = false; Form->ShowModal(); delete Form; UpdateMenu(); return; fail: UpdateMenu(); EXCEPTION_MESSAGE_OK(EC_FORM_NOT_CREATE); } //--------------------------------------------------------------------------- TPException __fastcall TStyleComboForm::FMOnRead(TFMReadParameter rp, bool changeFileFormat) { TCursor cur; TPException ec = EC_NONE; cur = Screen->Cursor; Screen->Cursor = crHourGlass; // PatternLibraryForm¿¡ µé¾î °¥ StyleÀ» ¿Å±â´Â ºÎºÐ if (rp.ExtIndex == gffVST || rp.ExtIndex == gffDXF) // IDS_COMBOMSGBOX5 : Vector FileÀº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. Application->MessageBox(IDS_COMBOMSGBOX5.c_str(), L"Information", MB_ICONINFORMATION | MB_OK); else { if ( (ec=PatternLibrary->InitOpenFile(rp.DirName, rp.FileName, rp.ExtIndex, rp.bpp)) != EC_NONE) goto fail; } Screen->Cursor = cur; return EC_NONE; fail: Screen->Cursor = cur; return ec; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbSelectColorClick(TObject *Sender) { if (Item == C_SELECTCOLOR){ UpdateMenu(); } else { Item = C_SELECTCOLOR; PaletteForm->Visible = true; PaletteForm->BringToFront(); shSelectColor->Pen->Color = clRed; } // PaletteForm->Visible = !PaletteForm->Visible; // if (PaletteForm->Visible) // { // Item = C_SELECTCOLOR; // PaletteForm->BringToFront(); // shSelectColor->Pen->Color = clRed; // } // else { // UpdateMenu(); // } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbSaveFileClick(TObject *Sender) { UpdateMenu(); Item = C_FILEOPEN; // Menu shSaveFile->Pen->Color = clRed; HANDLE hFile = INVALID_HANDLE_VALUE; String filename; TCursor cur; cur = Screen->Cursor; PChar s; int FileNameLength, last1, last2, last3, last4; char FileIndex1, FileIndex2, FileIndex3, FileIndex4; if (SaveDialog1->Execute()) { //=============================================================== FileNameLength = SaveDialog1->FileName.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; FileIndex1 = '.'; FileIndex2 = 's'; FileIndex3 = 'c'; FileIndex4 = 'f'; if((FileIndex1 == SaveDialog1->FileName[last1])&&(FileIndex2 == SaveDialog1->FileName[last2]) && (FileIndex3 == SaveDialog1->FileName[last3])&&(FileIndex4 == SaveDialog1->FileName[last4])){ s = L"PASS"; }else s=NULL; }else s=NULL; //=============================================================== if (s==NULL) filename = SaveDialog1->FileName + ".scf"; else filename = SaveDialog1->FileName; if (FileExists(filename)) { int btn = EXCEPTION_MESSAGE2_OKCANCEL(EC_FILE_EXIST_ALREADY, (IDS_MESSAGE_REALLYFILESAVE).c_str()); if (btn == mrOk) { if ((hFile = CreateFile(filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } Screen->Cursor = crHourGlass; StyleComboForm->SaveToFile(hFile); CloseHandle(hFile); isSaved = true; goto next; } else { goto next; } } if ((hFile = CreateFile(filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } Screen->Cursor = crHourGlass; SaveToFile(hFile); CloseHandle(hFile); isSaved = true; next: } Screen->Cursor = cur; UpdateMenu(); return; fail: UpdateMenu(); EXCEPTION_MESSAGE_OK(EC_FORM_NOT_CREATE); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbOpenFileClick(TObject *Sender) { UpdateMenu(); Item = C_FILESAVE; // Menu shOpenFile->Pen->Color = clRed; // ÀúÀå Àü º¯È­ À¯¹« ÆÇ´Ü - by monkman if (FirstRun) isSaved = false; if (isSaved) goto Next; if (ListOfShape->Count > 0) { int returnNum; // IDS_COMBOMSGBOX7 : ÇöÀç Data°¡ »èÁ¦µË´Ï´Ù. ÀúÀåÇϽðڽÀ´Ï±î? if ((returnNum=(Application->MessageBox(IDS_COMBOMSGBOX7.c_str(), L"Information", MB_ICONINFORMATION | MB_YESNOCANCEL))) == IDYES) { sbSaveFileClick(this); UpdateMenu(); return; } else if (returnNum == IDNO) goto Next; else { UpdateMenu(); return; } } Next: // // ÃʱâÈ­¸¦ ÇÏ´Â ºÎºÐ--------------- // ResetV_DATAList(); // ResetS_IMAGEList(); // ResetS_DATAList(); // for test // ResetV_HEADER(); // ResetShape(); // //---------------------------------- HANDLE hFile = INVALID_HANDLE_VALUE; String filename; TCursor cur; cur = Screen->Cursor; if (OpenDialog1->Execute()) { // ÃʱâÈ­¸¦ ÇÏ´Â ºÎºÐ--------------- ResetV_DATAList(); ResetS_IMAGEList(); ResetS_DATAList(); // for test ResetV_HEADER(); ResetShape(); //---------------------------------- if (FileExists(OpenDialog1->FileName)) { } filename = OpenDialog1->FileName; if ((hFile = CreateFile(filename.c_str(), GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } Screen->Cursor = crHourGlass; LoadFromFile(hFile); CloseHandle(hFile); } Screen->Cursor = cur; UpdateMenu(); return; fail: UpdateMenu(); EXCEPTION_MESSAGE_OK(EC_FORM_NOT_CREATE); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::FormResize(TObject *Sender) { OpenedStyleGBox->Top = 10; OpenedStyleGBox->Left = ClientWidth - OpenedStyleGBox->Width - 5; ComboMenuGBox->Top = OpenedStyleGBox->Top + OpenedStyleGBox->Height + 10; ComboMenuGBox->Left = OpenedStyleGBox->Left; PatterLibraryGBox->Top = ComboMenuGBox->Top + ComboMenuGBox->Height + 10; PatterLibraryGBox->Left = OpenedStyleGBox->Left; PatterLibraryGBox->Height = ClientHeight - PatterLibraryGBox->Top - 82; PatternLibraryScrollBox->Height = PatterLibraryGBox->Height - 55; sbDeletePattern->Top = PatterLibraryGBox->Height - 35; sbLoadPatternFile->Top = PatterLibraryGBox->Height - 35; StyleGroupBox->Top = PatterLibraryGBox->Top + PatterLibraryGBox->Height + 5; StyleGroupBox->Left = PatterLibraryGBox->Left; ComboScrollBox->Top = 1; ComboScrollBox->Left = 1; ComboScrollBox->Width = OpenedStyleGBox->Left - 10; ComboScrollBox->Height = ClientHeight-1; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbPrintClick(TObject *Sender) { UpdateMenu(); Item = C_PRINT; // Menu shPrint->Pen->Color = clRed; if (!PrinterAvailable()) { Application->MessageBox(IDS_MESSAGE_NO_PRINTER.c_str(), L"Warning", MB_OK); return; } if (Printer() && Printer()->Printing) { Application->MessageBox(IDS_COMMON_PRINTSPOOLING.c_str(), L"Information", MB_OK); return; } HDC hWnd; hWnd = (HDC)((TWinControl *)Owner)->Handle; ComboPrintForm = new TComboPrintForm(this); ComboPrintForm->ShowModal(); if ( ComboPrintForm->Print_OKBtn == true) { if(ComboPrintForm->RealSize->Checked) sbRealSizeClicked(); else sbThumbNailClicked(); } delete ComboPrintForm; UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbRealSizeClicked() { TShape *tShape; int NumOfSeleted=0; for (int i=0; iCount; i++) { tShape=(TShape *)ListOfShape->Items[i]; if (tShape->Pen->Color != Graphics::clSkyBlue) NumOfSeleted++; } if (NumOfSeleted<1) { // IDS_COMBOMSGBOX2 : StyleÀ» ¼±ÅÃÇϽʽÿä. Application->MessageBox(IDS_COMBOMSGBOX2.c_str(), L"Information", MB_ICONINFORMATION); return; } RealSizePrint(); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbThumbNailClicked() { TShape *tShape; int NumOfSeleted=0; for (int i=0; iCount; i++) { tShape=(TShape *)ListOfShape->Items[i]; if (tShape->Pen->Color != Graphics::clSkyBlue) NumOfSeleted++; } if (NumOfSeleted<1) { // IDS_COMBOMSGBOX2: StyleÀ» ¼±ÅÃÇϽʽÿä. Application->MessageBox(IDS_COMBOMSGBOX2.c_str(), L"Information", MB_ICONINFORMATION); return; } ThumbNailPrint(); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbDeletePatternClick(TObject *Sender) { PatternLibrary->sbClearLibraryClick(); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbLoadPatternFileClick(TObject *Sender) { PatternLibraryScrollBox->Visible = false; PatternLibrary->sbBeforeLibraryClick(); PatternLibraryScrollBox->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::spPatternNumRunClick(TObject *Sender) { UpdateMenu(); TCursor cur; cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (PatternLibrary->ListOfNumber->Count < 1) { // IDS_COMBOMSGBOX1 : patternÀÌ ¾ø½À´Ï´Ù. Application->MessageBox(IDS_COMBOMSGBOX1.c_str(), L"Information", MB_ICONINFORMATION); Screen->Cursor = cur; return; } if (cNumInMainImage==0 && PatternLibrary->PatternNumber==0) { // IDS_COMBOMSGBOX4 : PatternÀ» ¼±ÅÃÇϽʽÿä. Application->MessageBox(IDS_COMBOMSGBOX4.c_str(), L"Information", MB_ICONINFORMATION); Screen->Cursor = cur; return; } else if (pNumInMainImage==0 && PatternLibrary->ColorNumber==0) { // IDS_COMBOMSGBOX3 : ColorÀ» ¼±ÅÃÇϽʽÿä. Application->MessageBox(IDS_COMBOMSGBOX3.c_str(), L"Information", MB_ICONINFORMATION); Screen->Cursor = cur; return; } else if (pNumInMainImage > PatternLibrary->PatternNumber && PatternLibrary->ColorNumber==0) { // IDS_COMBOMSGBOX9 : PatternÀÌ ºÎÁ·ÇÕ´Ï´Ù. Application->MessageBox(IDS_COMBOMSGBOX9.c_str(), L"Information", MB_ICONINFORMATION); Screen->Cursor = cur; return; } else if (cNumInMainImage > PatternLibrary->ColorNumber && PatternLibrary->PatternNumber==0) { // IDS_COMBOMSGBOX10 : Color°¡ ºÎÁ·ÇÕ´Ï´Ù. Application->MessageBox(IDS_COMBOMSGBOX10.c_str(), L"Information", MB_ICONINFORMATION); Screen->Cursor = cur; return; } else if ((cNumInMainImage > PatternLibrary->ColorNumber && PatternLibrary->ColorNumber > 0 && pNumInMainImage <= PatternLibrary->PatternNumber) || (cNumInMainImage <= PatternLibrary->ColorNumber && PatternLibrary->PatternNumber > 0 && pNumInMainImage > PatternLibrary->PatternNumber) || (cNumInMainImage > PatternLibrary->ColorNumber && PatternLibrary->PatternNumber > 0 && pNumInMainImage > PatternLibrary->PatternNumber && PatternLibrary->PatternNumber > 0)) { // IDS_COMBOMSGBOX11 : Pattern or Color°¡ ºÎÁ·ÇÕ´Ï´Ù. Application->MessageBox(IDS_COMBOMSGBOX11.c_str(), L"Information", MB_ICONINFORMATION); Screen->Cursor = cur; return; } if (FirstRun) { ResetV_DATAList(); ResetS_IMAGEList(); ResetS_DATAList(); ResetV_HEADER(); ResetShape(); runNum = 0; } if (PSpatternNum->Text.Length()==0) PSpatternNum->Value=6; if (PSpatternNum->Value < 3 ) PSpatternNum->Value=3; if (PSpatternNum->Value > 30 ) PSpatternNum->Value=30; //if (PSpatternNum->Value != ListOfImage->Count) { //ComboScrollBox->Visible = false; StatusProgress->Maximum = MainVecData->Count * (1+PSpatternNum->Value*2); InitStyleInForm(PSpatternNum->Value, StatusProgress); StatusProgress->End(); //ComboScrollBox->Visible = true; //} //else InitStyleInForm(PSpatternNum->Value, NULL); if (FirstRun || PatternLibrary->anyChanged) PatternLibrary->SavePatternLibrary(); runNum++; // RunÀ» ´©¸¥ Ƚ¼ö isSaved = false; NotChanged = false; Screen->Cursor = cur; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::FormClose(TObject *Sender, TCloseAction &Action) { Visible = false; // ExitForm(); PaletteForm->Left = MainForm->PaletteFormPos.x; PaletteForm->Top = MainForm->PaletteFormPos.y; PaletteForm->BringToFront(); PaletteForm->Visible = true; // MainMenu¸¦ ¼±ÅÃÇØ¼­ ½ÇÇàÇϸé Combo FormÀÌ »ç¶óÁö±â ¶§¹®¿¡ ¸·À½ for (int i=0; i < MainForm->MainMenu1->Items->Count; i++) { MainForm->MainMenu1->Items->Items[i]->Enabled = true; } // Action = caFree; // º¤ÅÍÆûÀÌ ´ÝÇôÀÖÀ¸¹Ç·Î ¼±ÅÃµÈ °ÍµéÀ» ÇØÁ¦ÇÑ´Ù - by monkman (2004.10.13) VecDraw->NVector->bSelected = false; // Combo ¸Þ´º¸¦ ³¡³¾ ¶§ (Item == T_COMBO¿Í ´Ù¸§) - by monkman (2004.10.26) MainMenuForm->bCombo = false; HWND hWnd = ((TWinControl *)Owner)->Handle; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::FormCloseQuery(TObject *Sender, bool &CanClose) { if (ListOfImage->Count < 1) {CanClose = true; return;} if (!NotChanged && !isSaved) { int returnNum; // IDS_COMBOMSGBOX6 : Combo°á°ú¸¦ ÀúÀåÇϽðڽÀ´Ï±î? if ((returnNum=(Application->MessageBox(IDS_COMBOMSGBOX6.c_str(), L"Information",MB_ICONINFORMATION | MB_YESNOCANCEL))) == IDYES) { sbSaveFileClick(this); if (isSaved) CanClose = true; else CanClose = false; } else if (returnNum == IDNO) CanClose = true; else CanClose = false; } else CanClose = true; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::sbExitClick(TObject *Sender) { bool canClose; FormCloseQuery(this, canClose); if (canClose) { Visible = false; // ExitForm(); PaletteForm->Left = MainForm->PaletteFormPos.x; PaletteForm->Top = MainForm->PaletteFormPos.y; PaletteForm->BringToFront(); PaletteForm->Visible = true; // MainMenu¸¦ ¼±ÅÃÇØ¼­ ½ÇÇàÇϸé Combo FormÀÌ »ç¶óÁö±â ¶§¹®¿¡ ¸·À½ for (int i=0; i < MainForm->MainMenu1->Items->Count; i++) { MainForm->MainMenu1->Items->Items[i]->Enabled = true; } } // º¤ÅÍÆûÀÌ ´ÝÇôÀÖÀ¸¹Ç·Î ¼±ÅÃµÈ °ÍµéÀ» ÇØÁ¦ÇÑ´Ù - by monkman (2004.10.13) VecDraw->NVector->bSelected = false; // Combo ¸Þ´º¸¦ ³¡³¾ ¶§ (Item == T_COMBO¿Í ´Ù¸§) - by monkman (2004.10.26) MainMenuForm->bCombo = false; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::spLeftBtnClick(TObject *Sender) { TTexpiaBitmap *tBitmap; HDC dcDst = NULL, dcSrc = NULL; spRightBtn->Enabled = true; OpenedStyleNum--; if (OpenedStyleNum == ListOfOpenedStyle->Count-1) OpenedStyleNum--; if (OpenedStyleNum < 0) {OpenedStyleNum=0; return;} tBitmap = (TTexpiaBitmap *)ListOfOpenedStyle->Items[OpenedStyleNum]; // IstStyleLabel->Font->Size = 10; // IstStyleLabel->Font->Color = clMenuHighlight; // IstStyleLabel->Font->Style = TFontStyles()<< fsBold; IstStyleLabel->Caption = IDS_IstStyleLabel + " ("+ IntToStr(OpenedStyleNum+1) +"/" + IntToStr(ListOfOpenedStyle->Count) + ")"; if ((dcDst = OpenedStretchImage->Bitmap->CreateDC())==NULL) goto fail; if ((dcSrc = tBitmap->CreateDC())==NULL) goto fail; SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, 0,0, OpenedStretchImage->Bitmap->Width, OpenedStretchImage->Bitmap->Height, dcSrc, 0,0, tBitmap->Width, tBitmap->Height, SRCCOPY); if(dcSrc) tBitmap->DeleteDC(dcSrc); dcSrc = NULL; if(dcDst) OpenedStretchImage->Bitmap->DeleteDC(dcDst); dcDst = NULL; OpenedStretchImage->Repaint(); if (OpenedStyleNum < 1) spLeftBtn->Enabled = false; fail: if(dcSrc) tBitmap->DeleteDC(dcSrc); dcSrc = NULL; if(dcDst) OpenedStretchImage->Bitmap->DeleteDC(dcDst); dcDst = NULL; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::spRightBtnClick(TObject *Sender) { TTexpiaBitmap *tBitmap; HDC dcDst = NULL, dcSrc = NULL; spLeftBtn->Enabled = true; OpenedStyleNum++; if (OpenedStyleNum >= ListOfOpenedStyle->Count) {OpenedStyleNum=ListOfOpenedStyle->Count; return;} tBitmap = (TTexpiaBitmap *)ListOfOpenedStyle->Items[OpenedStyleNum]; // IstStyleLabel->Font->Size = 10; // IstStyleLabel->Font->Color = clMenuHighlight; // IstStyleLabel->Font->Style = TFontStyles()<< fsBold; IstStyleLabel->Caption = IDS_IstStyleLabel + " ("+ IntToStr(OpenedStyleNum+1) +"/" + IntToStr(ListOfOpenedStyle->Count) + ")"; if ((dcDst = OpenedStretchImage->Bitmap->CreateDC())==NULL) goto fail; if ((dcSrc = tBitmap->CreateDC())==NULL) goto fail; SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, 0,0, OpenedStretchImage->Bitmap->Width, OpenedStretchImage->Bitmap->Height, dcSrc, 0,0, tBitmap->Width, tBitmap->Height, SRCCOPY); if(dcSrc) tBitmap->DeleteDC(dcSrc); dcSrc = NULL; if(dcDst) OpenedStretchImage->Bitmap->DeleteDC(dcDst); dcDst = NULL; OpenedStretchImage->Repaint(); if (OpenedStyleNum == ListOfOpenedStyle->Count-1) spRightBtn->Enabled = false; fail: if(dcSrc) tBitmap->DeleteDC(dcSrc); dcSrc = NULL; if(dcDst) OpenedStretchImage->Bitmap->DeleteDC(dcDst); dcDst = NULL; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::UpdateMenu() { switch(Item) { case C_NONE: case C_SELECTIMAGE: shSelectPattern->Pen->Color = clBlack; break; case C_SELECTCOLOR: shSelectColor->Pen->Color = clBlack; break; case C_FILEOPEN: shSaveFile->Pen->Color = clBlack; break; case C_FILESAVE: shOpenFile->Pen->Color = clBlack; break; case C_PRINT: shPrint->Pen->Color = clBlack; break; } Item = C_NONE; PaletteForm->SendToBack(); PaletteForm->Visible = false; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ComboFormMouseWheel(TShiftState Shift, int WheelDelta) { if (WheelDelta < 0) { if (onComboScrollBox) ComboScrollBox->VertScrollBar->Position+=HeightValue; else if (onPatternLibraryScrollBox) PatternLibraryScrollBox->VertScrollBar->Position+=pnPattern->Height; } else { if (onComboScrollBox) ComboScrollBox->VertScrollBar->Position-=HeightValue; else if (onPatternLibraryScrollBox) PatternLibraryScrollBox->VertScrollBar->Position-=pnPattern->Height; } } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::ComboScrollBoxMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { onComboScrollBox = true; onPatternLibraryScrollBox = false; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::PatternLibraryScrollBoxMouseMove( TObject *Sender, TShiftState Shift, int X, int Y) { onComboScrollBox = false; onPatternLibraryScrollBox = true; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::psImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { // For Whell Mouse Control onComboScrollBox = false; onPatternLibraryScrollBox = true; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::pnPatternMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { // For Whell Mouse Control onComboScrollBox = false; onPatternLibraryScrollBox = true; } //--------------------------------------------------------------------------- /// Gradient°¡ ¼³Á¤µÈ object¸¦ item¿¡ µû¶ó dcDst¿¡ ±×·ÁÁØ´Ù. GDI+ void __fastcall TStyleComboForm::DrawGradientFill(HDC dcDst, TVecData *data, gdp::Point *Points, int PointCount, int FirstX, int FirstY, int SecondX, int SecondY) { int sx, sy, ex, ey, sx2, sy2, ex2, ey2; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) sx = FirstX; ex = SecondX; sy = FirstY; ey = SecondY; if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID){ pPoints = new POINT[(data->nCount+1)*3+1]; } else { pPoints = new POINT[data->nCount*3+1]; } } for (int i = 0; i < PointCount; i++) { pPoints[i].x = Points[i].X; pPoints[i].y = Points[i].Y; } switch(data->gradientItem){ case G_LINEAR_SIMPLE : VecDraw->DrawGradientLinearSimple(dcDst, data, pPoints, PointCount, sx, sy, ex, ey); break; case G_LINEAR_CENTER : VecDraw->DrawGradientLinearCenter(dcDst, data, pPoints, PointCount, sx, sy, ex, ey); break; case G_CORNER : VecDraw->DrawGradientCorner(dcDst, data, pPoints, PointCount, sx, sy, ex, ey); break; case G_CENTER : VecDraw->DrawGradientCenter(dcDst, data, pPoints, PointCount, sx, sy, ex, ey); break; } if (pPoints) delete []pPoints; pPoints = NULL; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::FormDestroy(TObject *Sender) { //ExitForm(); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::PSpatternNumMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PSpatternNum->SetFocus(); PSpatternNum->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::pnPatternMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int i = PatternLibrary->ListOfPanel->IndexOf(Sender); if (i<0) return; PatternLibrary->psImageMouseUp(i); } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::pnPatternDblClick(TObject *Sender) { isDblClick = true; } //--------------------------------------------------------------------------- void __fastcall TStyleComboForm::pnPatternMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (!isDblClick) return; int i = PatternLibrary->ListOfPanel->IndexOf(Sender); PatternLibrary->psImageMouseDown(i); isDblClick = false; } //---------------------------------------------------------------------------