//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Library_F.h" #include "MainImage.h" #include "MainMenu.h" #include "VecDraw.h" #include "LibraryFile_F.h" #include "PenManager.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzPanel" #pragma link "RzSplit" #pragma link "RzTreeVw" #pragma link "RzButton" #pragma link "RzEdit" #pragma link "RzFilSys" #pragma link "RzShellCtrls" #pragma link "RzCmboBx" #pragma link "RzLabel" #pragma link "RzRadChk" #pragma link "TNumEdit" #pragma link "RzStatus" #pragma resource "*.dfm" #define IDS_ALLVIEW StringTable[0] #define IDS_BITMAPVIEW StringTable[1] #define IDS_VECTORVIEW StringTable[2] #define IDS_SEARCH StringTable[3] #define IDS_PROPORTION StringTable[4] #define IDS_GRAYSCALE StringTable[5] #define IDS_NAME StringTable[6] #define IDS_TAG StringTable[7] #define IDS_SUBFOLDERINCLUDE StringTable[8] #define IDS_SIZE StringTable[9] #define IDS_PERCENTAGE StringTable[10] #define IDS_SAMESIZE StringTable[11] #define IDS_MSG_01 StringTable[12] // º¤ÅÍÆÄÀÏÀº ¿­ ¼ö ¾ø½À´Ï´Ù. #define IDS_MSG_02 StringTable[13] // Full Color ImageÀÔ´Ï´Ù. #define IDS_MSG_03 StringTable[14] // È®´ë/Ãà¼Ò Å©±â¸¦ ´Ù½ÃÀÔ·ÂÇϽʽÿÀ. TLibraryForm *LibraryForm; //--------------------------------------------------------------------------- __fastcall TLibraryForm::TLibraryForm(TComponent* Owner) : TForm(Owner) { StringTable.Create(DirectoryItem, Language, "Library"); rztbRead->Hint = IDS_COMMON_READ; rztbMerge->Hint = IDS_COMMON_MERGE; rztbSave->Hint = IDS_COMMON_SAVEAS; rztbNewFolder->Hint = IDS_COMMON_NEWDIR; rztbDelete->Hint = IDS_COMMON_DELETE; rztbRename->Hint = IDS_COMMON_RENAME; rztbViewOption->Hint = IDS_ALLVIEW; rztbSearch->Hint = IDS_SEARCH; rzlbSearch->Caption = IDS_SEARCH; rztbProportion->Hint = IDS_PROPORTION; rzcbGrayscale->Hint = IDS_GRAYSCALE; GrayscaleImage->Hint = IDS_GRAYSCALE; rzcbSearchOption->Items->Clear(); rzcbSearchOption->Add(IDS_NAME); rzcbSearchOption->Add(IDS_TAG); rzcbSearchOption->Add(IDS_NAME + " + " + IDS_TAG); rzcbSearchOption->ItemIndex = 0; rzcbSubInclude->Caption = IDS_SUBFOLDERINCLUDE; rzlbWidth->Caption = IDS_COMMON_WIDTH; rzlbHeight->Caption = IDS_COMMON_HEIGHT; sbSameSize->Hint = IDS_SAMESIZE; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::FormCreate(TObject *Sender) { FileInfoList = new TList; FileList = new TList; DirectoryLibrary = LibraryInstallPath; //FullPathName(LibraryInstallPath, "Library"); if (!DirectoryExists(DirectoryLibrary)){ CreateDir(DirectoryLibrary); } RzShellTree->BaseFolder->PathName = DirectoryLibrary; DirName = DirectoryLibrary; CurrentUnit = uDot; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::FormDestroy(TObject *Sender) { if (FileInfoList){ ClearFileInfoList(); delete FileInfoList; } if (FileList){ ClearFileList(); delete FileList; FileList = NULL; } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::InitForm() { if (!FileInfoList) FileInfoList = new TList; InitItem(L_READ); FIntoFunction = false; bSearch = false; bSizeChange = false; bMakeGray = false; //bProportion = false; ToolbarHeightChange(); UnitChange(); SetSearch(); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::ClearFileInfoList() { if (FileInfoList){ for (int i = 0; i < FileInfoList->Count; i++){ LibraryData::FileInfo *info = (LibraryData::FileInfo *)FileInfoList->Items[i]; if (info) { delete info; info = NULL; } } FileInfoList->Clear(); } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::UpdateDirectory() { ClearFileInfoList(); if (!FileList) FileList = new TList; GetFileList(DirName, String("*.tlf")); //FileListBox->Update(); LibraryData::FileInfo *info = NULL; for (int i = 0; i < FileList->Count; i++){ String *strTemp = (String *)FileList->Items[i]; String fn = *strTemp; info = LoadDataFromFile(FullPathName(DirName, fn)); if (info){ if (ViewOption == 0){ FileInfoList->Add(info); } else if (ViewOption == 1){ if (info->Kind == LibraryData::BMP) FileInfoList->Add(info); else delete info; } else if (ViewOption == 2){ if (info->Kind == LibraryData::VEC) FileInfoList->Add(info); else delete info; } } } RightPanelChange(); // if (FileInfoList && (FileInfoList->Count > 0) && // (MotiveDrawGrid->ColCount * MotiveDrawGrid->RowCount < FileInfoList->Count)){ // MotiveDrawGrid->RowCount = FileInfoList->Count/MotiveDrawGrid->ColCount + 1; // } MotiveDrawGrid->Repaint(); } //--------------------------------------------------------------------------- LibraryData::FileInfo *__fastcall TLibraryForm::LoadDataFromFile(String fn) { LibraryData::FileInfo *info; LibraryData::LibKind tempKind; DWORD dwRead; HANDLE hFile = INVALID_HANDLE_VALUE; if ((hFile = CreateFile(fn.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) goto fail; ReadFile(hFile, &tempKind, sizeof(LibraryData::LibKind), &dwRead, NULL); if (tempKind == LibraryData::BMP){ info = new LibraryData::BitmapInfo(); } else if (tempKind == LibraryData::VEC){ info = new LibraryData::VectorInfo(); } info->Name = fn; info->LoadFromFile(hFile); CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return info; fail: if (hFile) CloseHandle(hFile); hFile = NULL; return NULL; } //--------------------------------------------------------------------------- bool __fastcall TLibraryForm::ModifyLibraryFile(String fn, TStrings *Tags) { LibraryData::LibData *Data = NULL; Data = LoadLibraryFile(fn); if (Data->Info->Tag) Data->Info->Tag->Clear(); if (Tags){ if (Tags->Count > 0){ for (int i = 0; i < Tags->Count; i++){ String strtag = Tags->Strings[i]; Data->Info->AddTag(strtag); } } } Data->SaveToFile(fn); delete Data; } //--------------------------------------------------------------------------- bool __fastcall TLibraryForm::SaveLibraryFile(String fn, bool BitmapSave, TStrings *Tags) { TPException ec = EC_NONE; DWORD dwWrite; HANDLE hFile = INVALID_HANDLE_VALUE; if ((hFile = CreateFile(fn.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) return false; LibraryData::LibData *Data; if (BitmapSave){ Data = new LibraryData::LibraryBitmapData(); LibraryData::LibKind tempKind = LibraryData::BMP; WriteFile(hFile, &tempKind, sizeof(LibraryData::LibKind), &dwWrite, NULL); } else { Data = new LibraryData::LibraryVectorData(); LibraryData::LibKind tempKind = LibraryData::VEC; WriteFile(hFile, &tempKind, sizeof(LibraryData::LibKind), &dwWrite, NULL); } Data->Info->Name = fn; if (Tags && Tags->Count > 0){ for (int i = 0; i < Tags->Count; i++){ String strtag = Tags->Strings[i]; Data->Info->AddTag(strtag); } } if ((ec = Data->SaveToFile(hFile)) != EC_NONE) goto fail; CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; delete Data; return true; fail: if (hFile != INVALID_HANDLE_VALUE){ CloseHandle(hFile); DeleteFile(fn.c_str()); //À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } EXCEPTION_MESSAGE_OK(ec); return false; } //--------------------------------------------------------------------------- LibraryData::LibData * __fastcall TLibraryForm::LoadLibraryFile(String fn) { DWORD dwRead; HANDLE hFile = INVALID_HANDLE_VALUE; LibraryData::LibKind tempKind = LibraryData::NONE; LibraryData::LibData *Data = NULL; if ((hFile = CreateFile(fn.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) goto fail; ReadFile(hFile, &tempKind, sizeof(LibraryData::LibKind), &dwRead, NULL); if (tempKind == LibraryData::BMP){ Data = new LibraryData::LibraryBitmapData(); } else if (tempKind == LibraryData::VEC){ Data = new LibraryData::LibraryVectorData(); } Data->LoadFromFile(hFile); CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return Data; fail: if (hFile) CloseHandle(hFile); hFile = NULL; return NULL; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::OpenNewCanvas(String fn) { TPException ec = EC_NONE; LibraryData::FileInfo *Info = LoadDataFromFile(fn); if (Info){ TCursor cur; TMainImageForm *Child = NULL; cur = Screen->Cursor; Screen->Cursor = crHourGlass; TPCanvasInfor canvasInfor; if (Info->Kind == LibraryData::BMP){ PenManagerForm->spread_sw[4] = 0; PenManagerForm->aspread = false; PenManagerForm->acolor = 0; MainMenuForm->ExitForm(1); LibraryData::LibData *Data = NULL; Data = LoadLibraryFile(fn); if (Data){ LibraryData::LibraryBitmapData *BitmapData = (LibraryData::LibraryBitmapData *)Data; LibraryData::BitmapInfo *BitmapInfo = (LibraryData::BitmapInfo *)(Data->Info); canvasInfor.Orientation = BitmapData->tpfh.CanvasInfor.Orientation; canvasInfor.DotsPerInch = BitmapData->tpfh.CanvasInfor.DotsPerInch; if ((bSizeChange && changewidth > 0 && changeheight > 0) || bMakeGray){ int bitmapWidth = BitmapData->Bitmap->Width; int bitmapHeight = BitmapData->Bitmap->Height; if (bSizeChange && changewidth > 0 && changeheight > 0){ bitmapWidth = changewidth; bitmapHeight = changeheight; canvasInfor.SetSize(cstFree, bitmapWidth, bitmapHeight); // ĵ¹ö½º »çÀÌÁî º¯°æ } else { canvasInfor.SetSize(cstFree, Info->Width, Info->Height); } TUnionBitmap *tempBitmap = new TUnionBitmap; if (BitmapData->Bitmap->BitsPerPixel == 8){ RGBQUAD rgb[256]; BitmapData->Palette->ToRGBQUAD(rgb, 256); tempBitmap->Create(bitmapWidth, bitmapHeight, 8, rgb); tempBitmap->UnionStretchBlt(0, 0, bitmapWidth, bitmapHeight, BitmapData->Bitmap, 0, 0, BitmapData->Bitmap->Width, BitmapData->Bitmap->Height, SRCCOPY); if (bMakeGray){ BitmapData->Palette->ToRGBQUAD(rgb, 256); for(int i = 0; i < 256; i++){ int r = rgb[i].rgbRed; int g = rgb[i].rgbGreen; int b = rgb[i].rgbBlue; int avg = (r + g + b)/3; rgb[i].rgbRed = avg; rgb[i].rgbGreen = avg; rgb[i].rgbBlue = avg; } tempBitmap->PutColors(0, 256, rgb); } } else { tempBitmap->Create(bitmapWidth, bitmapHeight, 24); tempBitmap->UnionStretchBlt(0, 0, bitmapWidth, bitmapHeight, BitmapData->Bitmap, 0, 0, BitmapData->Bitmap->Width, BitmapData->Bitmap->Height, SRCCOPY); if (bMakeGray){ if (!tempBitmap->StartScanLine()) goto fail; Byte *pp; for (int y=0; y < tempBitmap->Height; y++) { pp = tempBitmap->GetScanLine(y); for (int x=0; x < tempBitmap->Width; x++) { int avg = (pp[x*3] + pp[x*3+1] + pp[x*3+2])/3; pp[x*3] = avg; pp[x*3+1] = avg; pp[x*3+2] = avg; } tempBitmap->PutScanLine(y); } tempBitmap->StopScanLine(); } } if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FILE_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } if ((ec = Child->InitFormImage(canvasInfor, tempBitmap, BitmapData->Palette->UseColor))!=EC_NONE) goto fail; if (!bMakeGray){ Child->Palette->SetPalette(BitmapData->Palette); PaletteForm->InitForm(Child->Palette); ::RepaintColor(); } delete tempBitmap; } else { canvasInfor.SetSize(cstFree, Info->Width, Info->Height); if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FILE_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } //if ((ec = Child->InitFormImage(canvasInfor, BitmapData->Bitmap, BitmapData->Palette->UseColor))!=EC_NONE) goto fail; if ((ec = Child->InitForm(canvasInfor, 8))!=EC_NONE) goto fail; RGBQUAD rgb[256]; BitmapData->Palette->ToRGBQUAD(rgb, 256); Child->iMainImage->uBitmap->PutColors(0, 256, rgb); Child->iMainImage->uBitmap->Copy(0, 0, Child->iMainImage->uBitmap->Width, Child->iMainImage->uBitmap->Height, BitmapData->Bitmap, 0, 0, SRCCOPY); Child->Palette->SetPalette(BitmapData->Palette); PaletteForm->InitForm(Child->Palette); ::RepaintColor(); } if (Data) delete Data; Data = NULL; } } else if (Info->Kind == LibraryData::VEC){ canvasInfor.Orientation = coPortrait; canvasInfor.DotsPerInch = 160; // ¸Â°Ô¹Ù²Ü°Í canvasInfor.SetSize(cstFree, Info->Width, Info->Height); if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FILE_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm) MainImageForm->AutoRepUpdateMenu(true); //lhskys »õ·Î¿î MainMenu »ý¼º if ((ec = Child->InitForm(canvasInfor, 24))!=EC_NONE) goto fail; LibraryData::LibData *Data = NULL; Data = LoadLibraryFile(fn); if (Data){ LibraryData::LibraryVectorData *VectorData = (LibraryData::LibraryVectorData *)Data; while (VectorData->DataList->Count > 0){ TVecData *vec = (TVecData *)VectorData->DataList->First(); VectorData->DataList->Remove(vec); Child->V_DATA->Add(vec); } if (Data) delete Data; Data = NULL; } } Screen->Cursor = cur; delete Info; Info = NULL; } return; fail: if (Info) delete Info; if (ec != EC_NONE) EXCEPTION_MESSAGE_OK(ec); return; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::MergeToCanvas(String fn) { LibraryData::LibData *Data = NULL; Data = LoadLibraryFile(fn); if (Data){ PenManagerForm->spread_sw[4] = 0; PenManagerForm->aspread = false; PenManagerForm->acolor = 0; MainMenuForm->ExitForm(1); if (Data->Info->Kind == LibraryData::BMP){ LibraryData::LibraryBitmapData *BitmapData = (LibraryData::LibraryBitmapData *)Data; LibraryData::BitmapInfo *BitmapInfo = (LibraryData::BitmapInfo *)(Data->Info); MainImageForm->iMainImage->SubEnabled = true; int bitmapWidth = BitmapData->Bitmap->Width; int bitmapHeight = BitmapData->Bitmap->Height; if (bitmapWidth > MainImageForm->iMainImage->uBitmap->Width || bitmapHeight > MainImageForm->iMainImage->uBitmap->Height){ TPException ec = EC_BIG_SIZE; EXCEPTION_MESSAGE_OK(ec); goto fail; } if (bSizeChange && changewidth > 0 && changeheight > 0){ bitmapWidth = changewidth; bitmapHeight = changeheight; } if (BitmapInfo->BitsPerPixel == 8){ RGBQUAD rgb[256]; BitmapData->Bitmap->GetColors(0, 256, rgb); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8){ if (MainImageForm->Palette->UseColor + BitmapData->Palette->UseColor > 250){ TPException ec = EC_COLOR_OVERFLOW; EXCEPTION_MESSAGE_OK(ec); goto fail; } if (!MainImageForm->TempBitmap) MainImageForm->TempBitmap = new TUnionBitmap; if (!MainImageForm->TempMask) MainImageForm->TempMask = new TUnionBitmap; MainImageForm->TempBitmap->Create(bitmapWidth, bitmapHeight, 8, rgb); MainImageForm->TempMask->Create(bitmapWidth, bitmapHeight, 8, rgb); if (bSizeChange) { MainImageForm->TempBitmap->UnionStretchBlt(0, 0, bitmapWidth, bitmapHeight, BitmapData->Bitmap, 0, 0, BitmapData->Bitmap->Width, BitmapData->Bitmap->Height, SRCCOPY); } else { MainImageForm->TempBitmap->Copy(BitmapData->Bitmap, SRCCOPY); } int start = MainImageForm->Palette->UseColor; if (!MainImageForm->TempBitmap->StartScanLine()) goto fail; if (!MainImageForm->TempMask->StartScanLine()) goto fail; Byte *pp, *mp; for (int y=0; y < MainImageForm->TempBitmap->Height; y++) { pp = MainImageForm->TempBitmap->GetScanLine(y); mp = MainImageForm->TempMask->GetScanLine(y); for (int x=0; x < MainImageForm->TempBitmap->Width; x++, pp++, mp++) { *pp += start; *mp = 0; // if (*pp < 2) { // *pp = 0; // *mp = 0xFF; // } // else { // *pp += start; // *mp = 0; // } } MainImageForm->TempBitmap->PutScanLine(y); MainImageForm->TempMask->PutScanLine(y); } MainImageForm->TempBitmap->StopScanLine(); MainImageForm->TempMask->StopScanLine(); for (int i = start+1, j = 1; i < BitmapData->Palette->UseColor + 1 + start; i++, j++){ MainImageForm->Palette->ColorData[i]->Copy(BitmapData->Palette->ColorData[j]); if (bMakeGray) { int r = MainImageForm->Palette->ColorData[i]->RGB.rgbRed; int g = MainImageForm->Palette->ColorData[i]->RGB.rgbGreen; int b = MainImageForm->Palette->ColorData[i]->RGB.rgbBlue; int avg = (r+g+b)/3; MainImageForm->Palette->ColorData[i]->RGB.rgbRed = avg; MainImageForm->Palette->ColorData[i]->RGB.rgbGreen = avg; MainImageForm->Palette->ColorData[i]->RGB.rgbBlue = avg; } } MainImageForm->Palette->UseColor += BitmapData->Palette->UseColor; MainImageForm->Palette->ToRGBQUAD(rgb, 256); MainImageForm->iMainImage->SubBitmap->Create(bitmapWidth, bitmapHeight, 8, rgb); MainImageForm->iMainImage->SubMask->Create(bitmapWidth, bitmapHeight, 8, rgb); MainImageForm->iMainImage->SubMask->FillRect(Rect(0, 0, bitmapWidth, bitmapHeight), PALETTEINDEX(0)); MainImageForm->ApplyPalette(); } else { TUnionBitmap *tempBitmap = new TUnionBitmap; tempBitmap->Create(bitmapWidth, bitmapHeight, 8, rgb); if (bSizeChange) { tempBitmap->UnionStretchBlt(0, 0, bitmapWidth, bitmapHeight, BitmapData->Bitmap, 0, 0, BitmapData->Bitmap->Width, BitmapData->Bitmap->Height, SRCCOPY); } else { tempBitmap->Copy(BitmapData->Bitmap, SRCCOPY); } tempBitmap->ColorResolution(24, CRF_OPTIMIZEDPALETTE, NULL, 250); if (bMakeGray){ if (!tempBitmap->StartScanLine()) goto fail; Byte *pp; for (int y=0; y < tempBitmap->Height; y++) { pp = tempBitmap->GetScanLine(y); for (int x=0; x < tempBitmap->Width; x++) { int avg = (pp[x*3] + pp[x*3+1] + pp[x*3+2])/3; pp[x*3] = avg; pp[x*3+1] = avg; pp[x*3+2] = avg; } tempBitmap->PutScanLine(y); } tempBitmap->StopScanLine(); } if (!MainImageForm->TempBitmap) MainImageForm->TempBitmap = new TUnionBitmap; if (!MainImageForm->TempMask) MainImageForm->TempMask = new TUnionBitmap; MainImageForm->TempBitmap->Create(bitmapWidth, bitmapHeight, 24); MainImageForm->TempMask->Create(bitmapWidth, bitmapHeight, 1); MainImageForm->TempBitmap->Copy(tempBitmap, SRCCOPY); MainImageForm->TempMask->FillRect(Rect(0, 0, bitmapWidth, bitmapHeight), PALETTEINDEX(0)); MainImageForm->iMainImage->SubBitmap->Create(tempBitmap->Width, tempBitmap->Height, 24); MainImageForm->iMainImage->SubMask->Create(tempBitmap->Width, tempBitmap->Height, 1); MainImageForm->iMainImage->SubMask->FillRect(Rect(0, 0, tempBitmap->Width, tempBitmap->Height), PALETTEINDEX(0)); delete tempBitmap; } } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 24){ if (!MainImageForm->TempBitmap) MainImageForm->TempBitmap = new TUnionBitmap; if (!MainImageForm->TempMask) MainImageForm->TempMask = new TUnionBitmap; MainImageForm->TempBitmap->Create(bitmapWidth, bitmapHeight, 24); MainImageForm->TempMask->Create(bitmapWidth, bitmapHeight, 1); if (bSizeChange) { MainImageForm->TempBitmap->UnionStretchBlt(0, 0, bitmapWidth, bitmapHeight, BitmapData->Bitmap, 0, 0, BitmapData->Bitmap->Width, BitmapData->Bitmap->Height, SRCCOPY); } else { MainImageForm->TempBitmap->Copy(BitmapData->Bitmap, SRCCOPY); } if (bMakeGray){ if (!MainImageForm->TempBitmap->StartScanLine()) goto fail; Byte *pp; for (int y=0; y < MainImageForm->TempBitmap->Height; y++) { pp = MainImageForm->TempBitmap->GetScanLine(y); for (int x=0; x < MainImageForm->TempBitmap->Width; x++) { int avg = (pp[x*3] + pp[x*3+1] + pp[x*3+2])/3; pp[x*3] = avg; pp[x*3+1] = avg; pp[x*3+2] = avg; } MainImageForm->TempBitmap->PutScanLine(y); } MainImageForm->TempBitmap->StopScanLine(); } MainImageForm->TempMask->FillRect(Rect(0, 0, bitmapWidth, bitmapHeight), PALETTEINDEX(0)); MainImageForm->iMainImage->SubBitmap->Create(bitmapWidth, bitmapHeight, 24); MainImageForm->iMainImage->SubMask->Create(bitmapWidth, bitmapHeight, 1); MainImageForm->iMainImage->SubMask->FillRect(Rect(0, 0, bitmapWidth, bitmapHeight), PALETTEINDEX(0)); } } MainImageForm->iMainImage->SubVisible = true; MainMenuForm->Item = T_MERGE; MainMenuForm->SubItem = 0; MainImageForm->iMainImage->InitBackGround(0x01); MainImageForm->Center.x = MainImageForm->iMainImage->SubBitmap->Width / 2; MainImageForm->Center.y = MainImageForm->iMainImage->SubBitmap->Height / 2; if (Data){ delete Data; Data = NULL; } MainImageForm->UndoSave(UK_ALL, Rect(0, 0, 0, 0)); } else if (Data->Info->Kind == LibraryData::VEC){ if (MainMenuForm->Item != T_VECTOR) MainMenuForm->InitVectorForm(true); VecDraw->deSelect(); LibraryData::LibraryVectorData *VectorData = (LibraryData::LibraryVectorData *)Data; RECT Range = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); VectorData->SetVectorPasteRange(Range); while (VectorData->DataList->Count > 0){ TVecData *data = (TVecData *)VectorData->DataList->First(); VectorData->DataList->Remove(data); data->bSelected = true; VecDraw->NVector->DataList->Add(data); } VecDraw->PasteRange.left = Range.left; VecDraw->PasteRange.top = Range.top; VecDraw->PasteRange.right = Range.right; VecDraw->PasteRange.bottom = Range.bottom; VecDraw->MaxThick = 5; MainImageForm->NVector->bSelected = true; MainImageForm->NVector->bMergeMode = true; if (Data){ delete Data; Data = NULL; } } } return; fail: if (Data) delete Data; if (MainImageForm->TempBitmap){ MainImageForm->TempBitmap->StopScanLine(); delete MainImageForm->TempBitmap; MainImageForm->TempBitmap = NULL; } if (MainImageForm->TempMask){ MainImageForm->TempMask->StopScanLine(); delete MainImageForm->TempMask; MainImageForm->TempMask = NULL; } MainImageForm->iMainImage->SubEnabled = false; MainImageForm->iMainImage->SubVisible = false; return; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::InputKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key != VK_RETURN) return; String strInput = Input->Text; int SearchOption = rzcbSearchOption->ItemIndex; bool SearchSubInclude = rzcbSubInclude->Checked; if (!strInput.IsEmpty() && strInput != L" "){ Search(strInput, SearchOption, SearchSubInclude); } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::Search(String SearchKey, int SearchOption, bool SubInclude) { String SelectFolder = DirName; //°Ë»öÇÒ ÆÄÀÏ ¸ñ·Ï TStringList *SearchFileList = new TStringList; FindFiles(SelectFolder, NULL, SearchFileList, SubInclude, ".tlf"); if (FileList->Count > 0){ TStringList *ResultList = new TStringList; SearchFiles(SearchKey, SearchFileList, ResultList, SearchOption); // SearchOption 0: FileName 1: Tag 2: FileName + Tag if (ResultList->Count > 0){ ClearFileInfoList(); LibraryData::FileInfo *info = NULL; for (int i = 0; i < ResultList->Count; i++){ String fn = ResultList->Strings[i]; info = LoadDataFromFile(fn); if (info) FileInfoList->Add(info); } MotiveDrawGrid->Repaint(); } ResultList->Clear(); delete ResultList; } SearchFileList->Clear(); delete SearchFileList; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::SearchFiles(String SearchKey, TStringList *SearchFileList, TStringList *ResultList, int SearchOption) { int allCount = SearchFileList->Count; for (int i = 0; i < allCount; i++){ String fileName = SearchFileList->Strings[i]; if (SearchOption == 0 || SearchOption == 2){ String name = ExtractFileName(fileName); if (name.Pos(SearchKey) > 0){ if (!ResultList) ResultList = new TStringList; ResultList->Add(fileName); continue; } } if (SearchOption == 1 || SearchOption == 2){ LibraryData::FileInfo *info = NULL; info = LoadDataFromFile(fileName); if (info) { if (info->Tag && info->Tag->Count > 0){ bool tagFind = info->Tag->Find(SearchKey); if (tagFind){ if (!ResultList) ResultList = new TStringList; ResultList->Add(fileName); } } delete info; } } } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbSaveAsClick(TObject *Sender) { InitItem(L_SAVEAS); TLibraryFileForm *FileForm = new TLibraryFileForm(this); FileForm->InitForm(Item); if (FileForm->ShowModal() == mrOk){ TCursor cur; String wfn; cur = Screen->Cursor; Screen->Cursor = crHourGlass; wfn = FileForm->rzedFileName->Text + ".tlf"; bool bitmapSave = FileForm->IsBitmap; int tagCount = FileForm->rzMemoTag->Lines->Count; TStrings *Tags = NULL; if (tagCount > 0){ Tags = new TStringList; for (int i = 0; i < tagCount; i++){ String strAdd = FileForm->rzMemoTag->Lines->Strings[i]; if (!strAdd.IsEmpty() && strAdd != L" "){ Tags->Add(strAdd); } } } for (int i=0; iCount; i++) { LibraryData::FileInfo *info = (LibraryData::FileInfo *)FileInfoList->Items[i]; String cmfn = WideLowerCase(ExtractFileName(info->Name)); String cmfn2 = WideLowerCase(wfn); if (cmfn == cmfn2) { int btn = EXCEPTION_MESSAGE2_OKCANCEL(EC_FILE_EXIST_ALREADY, (IDS_MESSAGE_REALLYFILESAVE).c_str()); if (btn == mrOk) { SaveLibraryFile(FullPathName(DirName, wfn), bitmapSave, Tags); goto next; } else { goto next; } } } SaveLibraryFile(FullPathName(DirName, wfn), bitmapSave, Tags); next: UpdateDirectory(); Screen->Cursor = cur; } delete FileForm; InitItem(L_READ); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbReadClick(TObject *Sender) { InitItem(L_READ); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbMergeClick(TObject *Sender) { InitItem(L_MERGE); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::MotiveDrawGridDblClick(TObject *Sender) { int n = MotiveDrawGrid->ColCount * MotiveDrawGrid->Row + MotiveDrawGrid->Col; if (FileInfoList && n < FileInfoList->Count) { LibraryData::FileInfo *info = (LibraryData::FileInfo *)FileInfoList->Items[n]; if (FOnRead) { if (info->Kind == LibraryData::BMP){ FSelectedFileName = info->Name; FOnRead(this); } else { Application->MessageBox(IDS_MSG_01.c_str(), L"Information", MB_OK); } } else { if (Item == L_MERGE){ if (MainImageForm){ if (info->Kind == LibraryData::BMP){ LibraryData::BitmapInfo *bitmapInfo = (LibraryData::BitmapInfo *)info; if (bitmapInfo->BitsPerPixel == 24 && MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8){ Application->MessageBox(IDS_MSG_02.c_str(), L"Information", MB_OK); return; } int dpi = MainImageForm->CanvasInfor.DotsPerInch; if (ApplyOption(bitmapInfo->Width, bitmapInfo->Height, dpi) == false) return; } MergeToCanvas(info->Name); } } else if (Item == L_READ){ // ĵ¹ö½º·Î ¿­±â if (info->Kind == LibraryData::BMP){ LibraryData::BitmapInfo *bitmapInfo = (LibraryData::BitmapInfo *)info; if (ApplyOption(bitmapInfo->Width, bitmapInfo->Height, bitmapInfo->DotsPerInch) == false) return; } OpenNewCanvas(info->Name); } else if (Item == L_DELETE){ FileDelete(info->Name); UpdateDirectory(); } else if (Item == L_RENAME){ int n = ExtractFileName(info->Name).Pos(".tlf"); String orgName = ExtractFileName(info->Name).SubString(0, n-1); String str = InputBox(IDS_COMMON_RENAME, IDS_MESSAGE_INPUTFILE, orgName); if (str.Compare(orgName) != 0){ String newName = ExtractFilePath(info->Name) + str + ".tlf"; if (FileExists(newName)){ EXCEPTION_MESSAGE_OK(EC_FILE_EXIST_ALREADY); } else { if (RenameFile(info->Name, newName)){ info->Name = newName; } } } } InitItem(L_READ); } } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::FormResize(TObject *Sender) { ToolbarHeightChange(); MotiveDrawGrid->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::RzSizePanelRightResize(TObject *Sender) { RightPanelChange(); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::RightPanelChange() { MotiveDrawGrid->Width = RzSizePanelRight->ClientWidth; MotiveDrawGrid->Height = RzSizePanelRight->ClientHeight; if (FileInfoList && FileInfoList->Count > 0){ int dataCount = FileInfoList->Count; int colCount = MotiveDrawGrid->Width/MotiveDrawGrid->DefaultColWidth; if (colCount < 0) colCount = 1; int rowCount = dataCount/colCount; if (dataCount%colCount > 0) rowCount += 1; if (rowCount * MotiveDrawGrid->DefaultRowHeight > MotiveDrawGrid->Height){ if (MotiveDrawGrid->Width - colCount * MotiveDrawGrid->DefaultColWidth < 20){ if (colCount > 1) { colCount -= 1; rowCount = dataCount/colCount; if (dataCount%colCount > 0) rowCount += 1; } } } MotiveDrawGrid->ColCount = colCount; MotiveDrawGrid->RowCount = rowCount; } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::MotiveDrawGridDrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State) { int width = MotiveDrawGrid->DefaultColWidth; int height = MotiveDrawGrid->DefaultRowHeight; int n = ARow * MotiveDrawGrid->ColCount + ACol; if (FileInfoList && n < FileInfoList->Count) { LibraryData::FileInfo *info = (LibraryData::FileInfo *)FileInfoList->Items[n]; try { if (info){ TRect r; // Bitmap, vector ±¸ºÐ r.Left = Rect.Left + 5; r.Top = Rect.Top + 2; int dpi = 160; Graphics::TBitmap *tempbmp = new Graphics::TBitmap; if (info->Kind == LibraryData::BMP){ ImageList->GetBitmap(0, tempbmp); dpi = ((LibraryData::BitmapInfo *)info)->DotsPerInch; } else { ImageList->GetBitmap(1, tempbmp); } HDC dctemp = tempbmp->Canvas->Handle; BitBlt(MotiveDrawGrid->Canvas->Handle, r.left, r.top, tempbmp->Width, tempbmp->Height, dctemp, 0, 0, SRCCOPY); delete tempbmp; // Thumbnail HDC dcThumb = info->ThumbImage->CreateDC(); if (dcThumb){ StretchBlt(MotiveDrawGrid->Canvas->Handle, Rect.Left+10, Rect.Top+20, 100, 100, dcThumb, 0, 0, info->ThumbImage->Width, info->ThumbImage->Height ,SRCCOPY); info->ThumbImage->DeleteDC(dcThumb); } String fname = ExtractFileName(info->Name); String comment = info->Info(CurrentUnit, dpi); // Filename MotiveDrawGrid->Canvas->Font->Size = 8; MotiveDrawGrid->Canvas->Font->Style = TFontStyles(); MotiveDrawGrid->Canvas->Font->Color = clBlack; int textH1 = MotiveDrawGrid->Canvas->TextHeight(fname); //int textH2 = MotiveDrawGrid->Canvas->TextHeight(comment); r.Left = Rect.Left + 5; r.Right = Rect.Left + width; r.Top = Rect.Top + height - textH1; //(textH1 + textH2); r.Bottom = Rect.Top + height; // - textH2; MotiveDrawGrid->Canvas->TextRect(r, r.left, r.top, fname); // Info // r.Top = Rect.Top + height - textH2; // r.Bottom = Rect.Top + height; // MotiveDrawGrid->Canvas->TextRect(r, r.left, r.top, comment); } } catch (...){ // } } } //--------------------------------------------------------------------------- bool __fastcall TLibraryForm::IsBitmapData(String fn) { DWORD dwRead; HANDLE hFile = INVALID_HANDLE_VALUE; LibraryData::LibKind tempKind = LibraryData::NONE; bool rtn = false; LibraryData::LibData *Data = NULL; if ((hFile = CreateFile(fn.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) return NULL; ReadFile(hFile, &tempKind, sizeof(LibraryData::LibKind), &dwRead, NULL); if (tempKind == LibraryData::BMP){ rtn = true; } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return rtn; } //--------------------------------------------------------------------------- TUnionBitmap * __fastcall TLibraryForm::GetBitmapData(String fn) { DWORD dwRead; HANDLE hFile = INVALID_HANDLE_VALUE; LibraryData::LibKind tempKind = LibraryData::NONE; LibraryData::LibData *Data = NULL; TUnionBitmap *rtnBitmap = new TUnionBitmap; if ((hFile = CreateFile(fn.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) return NULL; ReadFile(hFile, &tempKind, sizeof(LibraryData::LibKind), &dwRead, NULL); if (tempKind == LibraryData::BMP){ Data = new LibraryData::LibraryBitmapData(); Data->LoadFromFile(hFile); LibraryData::LibraryBitmapData *BitmapData = (LibraryData::LibraryBitmapData *)Data; if (BitmapData->Bitmap->BitsPerPixel == 8){ RGBQUAD rgb[256]; BitmapData->Bitmap->GetColors(0, 256, rgb); rtnBitmap->Create(BitmapData->Bitmap->Width, BitmapData->Bitmap->Height, 8, rgb); } else { rtnBitmap->Create(BitmapData->Bitmap->Width, BitmapData->Bitmap->Height, 24); } rtnBitmap->Copy(BitmapData->Bitmap, SRCCOPY); delete BitmapData; Data = NULL; } else if (tempKind == LibraryData::VEC){ // } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return rtnBitmap; } //--------------------------------------------------------------------------- TTexpiaBitmap * __fastcall TLibraryForm::GetThumbImage(String fn) { LibraryData::FileInfo *info = NULL; TTexpiaBitmap *rtnBitmap = new TTexpiaBitmap; info = LoadDataFromFile(fn); rtnBitmap->Create(info->ThumbImage->Width, info->ThumbImage->Height, 24); rtnBitmap->Copy(info->ThumbImage, SRCCOPY); delete info; return rtnBitmap; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::SetIntoFunction(bool Value) { FIntoFunction = Value; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::RzShellTreeChange(TObject *Sender, TTreeNode *Node) { if (!DirectoryExists(DirectoryLibrary)){ CreateDir(DirectoryLibrary); } TRzShellTree *dir = (TRzShellTree *)Sender; DirName = dir->SelectedPathName; if (!bSearch){ RightPanelChange(); UpdateDirectory(); } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::MotiveDrawGridMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (Button==mbRight){ TGridCoord Coord = MotiveDrawGrid->MouseCoord(X, Y); if (Coord.X >= 0 && Coord.Y >= 0){ MotiveDrawGrid->Col = Coord.X; MotiveDrawGrid->Row = Coord.Y; int n = MotiveDrawGrid->ColCount * MotiveDrawGrid->Row + MotiveDrawGrid->Col; if (n >= 0 && FileInfoList && n < FileInfoList->Count) { TLibraryFileForm *FileForm = new TLibraryFileForm(this); FileForm->IsModify = true; LibraryData::FileInfo *info = (LibraryData::FileInfo *)FileInfoList->Items[n]; if (info->Kind == LibraryData::BMP){ LibraryData::BitmapInfo *bitmapInfo = (LibraryData::BitmapInfo *)info; if (bitmapInfo->BitsPerPixel == 8){ FileForm->strColorInfo = "256 Color - ColorCount : " + IntToStr(bitmapInfo->ColorCount); } else { FileForm->strColorInfo = "Full Color"; } FileForm->IsBitmap = true; } else if (info->Kind == LibraryData::VEC){ LibraryData::VectorInfo *vectorInfo = (LibraryData::VectorInfo *)info; FileForm->strColorInfo = "Full Color"; FileForm->IsBitmap = false; } String strSize = IntToStr(info->Width) + L" x " + IntToStr(info->Height); FileForm->strSizeInfo = strSize; FileForm->strPath = ExtractFilePath(info->Name); FileForm->rzedFileName->Text = ExtractFileName(info->Name); FileForm->rzMemoTag->Clear(); if (info->Tag){ for (int i = 0; i < info->Tag->Count; i++){ String tag = info->Tag->Item[i]; FileForm->rzMemoTag->Lines->Add(tag); } } FileForm->View(); if (FileForm->ShowModal() == mrOk){ int tagCount = FileForm->rzMemoTag->Lines->Count; TStrings *Tags = new TStringList; if (Tags){ if (tagCount > 0){ for (int i = 0; i < tagCount; i++){ String strAdd = FileForm->rzMemoTag->Lines->Strings[i]; if (!strAdd.IsEmpty() && strAdd != L" "){ Tags->Add(strAdd); } } } ModifyLibraryFile(info->Name, Tags); delete Tags; } UpdateDirectory(); } delete FileForm; } } } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbNewFolderClick(TObject *Sender) { RzShellTree->SetFocus(); RzShellTree->CreateNewFolder(true); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbDeleteClick(TObject *Sender) { InitItem(L_DELETE); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::FileDelete(String FileName) { SHFILEOPSTRUCT shfile; String asFrom; Char *ucFrom; memset(&shfile, 0, sizeof(SHFILEOPSTRUCT)); shfile.hwnd = Handle; shfile.wFunc = FO_DELETE; asFrom = FileName; if ((ucFrom = (Char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Char)*(asFrom.Length()+2))) == NULL) goto fail; _tcscpy(ucFrom, asFrom.c_str()); shfile.pFrom = ucFrom; shfile.fFlags = FOF_ALLOWUNDO ; SHFileOperation(&shfile); HeapFree(GetProcessHeap(), 0, ucFrom); return; fail: } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::InputClick(TObject *Sender) { Input->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbSearchClick(TObject *Sender) { bSearch = !bSearch; SetSearch(); if (bSearch){ ClearFileInfoList(); MotiveDrawGrid->Repaint(); } else { UpdateDirectory(); } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::SetSearch() { if (bSearch){ rztbSearch->Down = true; ToolbarSearch->Visible = true; } else { rztbSearch->Down = false; ToolbarSearch->Visible = false; } Input->Text = ""; ToolbarHeightChange(); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::ViewProportion(bool showOption) { if (showOption){ rzedWidth->Text = ""; rzedHeight->Text = ""; ToolbarProportion->Visible = true; } else { ToolbarProportion->Visible = false; } ToolbarHeightChange(); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::InitItem(LItem item) { Item = item; if (Item == L_READ) rztbRead->Down = true; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbProportionClick(TObject *Sender) { // if (rztbProportion->Down) bProportion = true; // else bProportion = false; // // ViewProportion(bProportion); ViewProportion(rztbProportion->Down); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::ToolbarHeightChange() { int height = Toolbar->Height; if (ToolbarSearch->Visible) height += ToolbarSearch->Height; if (ToolbarProportion->Visible) height += ToolbarProportion->Height; TopPanel->Height = height; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::NumEditClick(TObject *Sender) { TNumEdit *edit = (TNumEdit *)Sender; edit->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::sbSameSizeClick(TObject *Sender) { if (sbSameSize->Down){ rzlbHeight->Enabled = false; rzedHeight->Enabled = false; } else { rzlbHeight->Enabled = true; rzedHeight->Enabled = true; } } //--------------------------------------------------------------------------- bool __fastcall TLibraryForm::ApplyOption(int width, int height, int dpi) { changewidth = 0; changeheight = 0; if (rzcbGrayscale->Checked) bMakeGray = true; else bMakeGray = false; bSizeChange = false; if (ToolbarProportion->Visible && rztbProportion->Down){ if ((sbSameSize->Down && !rzedWidth->Text.IsEmpty()) || (!rzedWidth->Text.IsEmpty() && !rzedHeight->Text.IsEmpty())){ int inputW = 0, inputH = 0; if (sbSameSize->Down){ inputW = StrToInt(rzedWidth->Text); inputH = inputW; } else { inputW = StrToInt(rzedWidth->Text); inputH = StrToInt(rzedHeight->Text); } if (inputW == 0 || inputH == 0){ Application->MessageBox(IDS_MSG_03.c_str(), L"Warning", MB_OK); return false; } if (rzcbUnit->ItemIndex == 0){ // % changewidth = width*((double)inputW/100); changeheight = height*((double)inputH/100); } else if (rzcbUnit->ItemIndex == 2){ // inch changewidth = inputW*dpi; changeheight = inputH*dpi; } else if (rzcbUnit->ItemIndex == 3){ // cm changewidth = ((double)inputW*dpi)/2.54; changeheight = ((double)inputH*dpi)/2.54; } else { // dot changewidth = inputW; changeheight = inputH; } bSizeChange = true; } else { Application->MessageBox(IDS_MSG_03.c_str(), L"Warning", MB_OK); return false; } } return true; } //--------------------------------------------------------------------------- //bool __fastcall TLibraryForm::ApplyOption(int width, int height) //{ // changewidth = 0; // changeheight = 0; // // if (rzcbGrayscale->Checked) bMakeGray = true; // else bMakeGray = false; // // if (ToolbarProportion->Visible){ // if (rztbProportion->Down){ // if ((sbSameSize->Down && !rzedWidth->Text.IsEmpty()) // || (!rzedWidth->Text.IsEmpty() && !rzedHeight->Text.IsEmpty())){ // if (rztbProportionUnit->Down){ // % // // int pw = 0, ph = 0; // if (sbSameSize->Down){ // pw = StrToInt(rzedWidth->Text); // ph = pw; // } // else { // pw = StrToInt(rzedWidth->Text); // ph = StrToInt(rzedHeight->Text); // } // if (pw == 0 || ph == 0){ // Application->MessageBox(IDS_MSG_03.c_str(), L"Warning", MB_OK); // return false; // } // changewidth = width*((double)pw/100); // changeheight = height*((double)ph/100); // } // else { // size // int inputW = 0, inputH = 0; // double dw = 0, dh = 0; // if (sbSameSize->Down){ // dw = StrToFloat(rzedWidth->Text); // dh = dw; // } // else { // dw = StrToFloat(rzedWidth->Text); // dh = StrToFloat(rzedHeight->Text); // } // // if (CurrentUnit == uInch){ // inputW = dw*MainImageForm->CanvasInfor.DotsPerInch; // inputH = dh*MainImageForm->CanvasInfor.DotsPerInch; // } // else if (CurrentUnit == uCm){ // inputW = (double)(dw*MainImageForm->CanvasInfor.DotsPerInch)/2.54; // inputH = (double)(dh*MainImageForm->CanvasInfor.DotsPerInch)/2.54; // } // else { // inputW = dw; // inputH = dh; // } // // changewidth = inputW; // changeheight = inputH; // // if (changewidth == 0 || changeheight == 0){ // Application->MessageBox(IDS_MSG_03.c_str(), L"Warning", MB_OK); // return false; // } // } // bSizeChange = true; // } // else { // Application->MessageBox(IDS_MSG_03.c_str(), L"Warning", MB_OK); // return false; // } // } // } // // return true; //} //--------------------------------------------------------------------------- void __fastcall TLibraryForm::MotiveDrawGridMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (FileInfoList && FileInfoList->Count > 0){ TGridCoord Coord = MotiveDrawGrid->MouseCoord(X, Y); RzStatusPane1->Caption = ""; RzStatusPane2->Caption = ""; if (Coord.X >= 0 && Coord.Y >= 0){ int col = Coord.X; int row = Coord.Y; int n = MotiveDrawGrid->ColCount * row + col; if (n < FileInfoList->Count) { LibraryData::FileInfo *info = (LibraryData::FileInfo *)FileInfoList->Items[n]; if (info){ String fname = ExtractFileName(info->Name); int dpi = 160; if (info->Kind == LibraryData::BMP){ LibraryData::BitmapInfo *bitmapInfo = (LibraryData::BitmapInfo *)info; dpi = bitmapInfo->DotsPerInch; } String comment = info->Info(CurrentUnit, dpi); RzStatusPane1->Caption = fname; RzStatusPane2->Caption = comment; } } } } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::UnitChange() { if (MainImageForm) CurrentUnit = MainImageForm->CurrentUnit; if (CurrentUnit == uInch){ rzedWidth->Decimals = 2; rzedHeight->Decimals = 2; rzedWidth->IntegerOnly = false; rzedHeight->IntegerOnly = false; //rzlbUnit->Caption = "Inch"; } else if (CurrentUnit == uCm){ rzedWidth->Decimals = 2; rzedHeight->Decimals = 2; rzedWidth->IntegerOnly = false; rzedHeight->IntegerOnly = false; //rzlbUnit->Caption = "Cm"; } else { rzedWidth->Decimals = 0; rzedHeight->Decimals = 0; rzedWidth->IntegerOnly = true; rzedHeight->IntegerOnly = true; //rzlbUnit->Caption = "Dot"; } } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbViewOptionMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { ViewOption++; if (ViewOption > 2){ ViewOption = 0; } if (ViewOption == 0){ // all rztbViewOption->Hint = IDS_ALLVIEW; rztbViewOption->ImageIndex = 5; rztbViewOption->Down = true; } else if (ViewOption == 1){ // bitmap only rztbViewOption->Hint = IDS_BITMAPVIEW; rztbViewOption->ImageIndex = 6; rztbViewOption->Down = false; } else if (ViewOption == 2){ // vector only rztbViewOption->Hint = IDS_VECTORVIEW; rztbViewOption->ImageIndex = 7; rztbViewOption->Down = false; } UpdateDirectory(); } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::GetFileList(String Path, String Filter) { BEGIN_LOG(""); HANDLE hSrch = INVALID_HANDLE_VALUE; WIN32_FIND_DATAW wfd; Char fname[MAX_PATH]; BOOL bResult=TRUE; ClearFileList(); if (Path == NULL || Path == "") { END_LOG; return; } String wPath = String(Path+"\\"+Filter); hSrch=FindFirstFile(wPath.c_str(),&wfd); if (hSrch != INVALID_HANDLE_VALUE){ while(bResult){ if (/*wfd.dwFileAttributes && */ !(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && !(wfd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && !(wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)){ //&& !(wfd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY)){ String* filename = new String(wfd.cFileName); FileList->Add(filename); } bResult = FindNextFile(hSrch,&wfd); } } else { wPath = Path + String("\\*.*"); hSrch=FindFirstFile(wPath.c_str(),&wfd); if (hSrch != INVALID_HANDLE_VALUE){ while(bResult){ if (/*wfd.dwFileAttributes && */ !(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && !(wfd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && !(wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)){ //!(wfd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY)){ if (SameText(ExtractFileExt(wfd.cFileName), ExtractFileExt(String(Filter)))){ String* filename = new String(wfd.cFileName); FileList->Add(filename); } } bResult = FindNextFile(hSrch,&wfd); } } } FindClose(hSrch); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::ClearFileList() { BEGIN_LOG("APTable_F"); String* file = NULL; if (FileList) { while (FileList->Count > 0) { file = (String*) FileList->Last(); if (file) { FileList->Remove(file); delete file; file = NULL; } } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TLibraryForm::rztbRenameClick(TObject *Sender) { InitItem(L_RENAME); } //---------------------------------------------------------------------------