//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Layer_F.h" #include "Dialog_F.h" #include "MainImage.h" #include "Palette.h" #include "undo.h" #include "MainMenu.h" #include "Repeat_F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPStretchImage" #pragma resource "*.dfm" #pragma resource "*.res" //--------------------------------------------------------------------------- #define IDS_EXCHANGE StringTable[0] #define IDS_FLATTEN StringTable[1] #define IDS_VIEW StringTable[2] #define IDS_IMAGE StringTable[3] #define IDS_LAYER StringTable[4] #define IDS_INSERT StringTable[5] #define IDS_NEWLAYER StringTable[6] TLayerForm *LayerForm; //--------------------------------------------------------------------------- __fastcall TLayerForm::TLayerForm(TComponent* Owner) : TForm(Owner) { //======================== 2001.9.11 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è StringTable.Create(DirectoryItem, Language, "Layer_F"); SetSmallFont(Font); Caption = IDS_LAYER; sbNew->Hint = IDS_NEWLAYER; sbInsert->Hint = IDS_INSERT; sbCopy->Hint = IDS_COMMON_COPY; sbExchange->Hint = IDS_EXCHANGE; sbDelete->Hint = IDS_COMMON_DELETE; sbMerge->Hint = IDS_COMMON_MERGE; sbFlatten->Hint = IDS_FLATTEN; sbRename->Hint = IDS_COMMON_RENAME; New1->Caption = IDS_NEWLAYER; Insert1->Caption = IDS_INSERT; Copy1->Caption = IDS_COMMON_COPY; Exchange1->Caption = IDS_EXCHANGE; Delete1->Caption = IDS_COMMON_DELETE; Merge1->Caption = IDS_COMMON_MERGE; Flatten1->Caption = IDS_FLATTEN; Rename1->Caption = IDS_COMMON_RENAME; //======================== 2001.9.11 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è } //--------------------------------------------------------------------------- void __fastcall TLayerForm::FormCreate(TObject *Sender) { //======================== 2001.9.11 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è } //--------------------------------------------------------------------------- void __fastcall TLayerForm::FormResize(TObject *Sender) { int w = Panel->Width / 8; sbNew->Width = w; sbInsert->Width = w; sbCopy->Width = w; sbExchange->Width = w; sbRename->Width = w; sbDelete->Width = w; sbMerge->Width = w; sbFlatten->Width = w; sbNew->Left = 3; sbInsert->Left = sbNew->Left + w; sbCopy->Left = sbInsert->Left + w; sbExchange->Left = sbCopy->Left + w; sbRename->Left = sbExchange->Left + w; sbDelete->Left = sbRename->Left + w; sbMerge->Left = sbDelete->Left + w; sbFlatten->Left = sbMerge->Left + w; } //--------------------------------------------------------------------------- void __fastcall TLayerForm::LayerGridDrawCell(TObject *Sender, int Col, int Row, TRect &Rect, TGridDrawState State) { MainImageForm->iMainImage->OnLayerGridRectPaint=LayerGridRectPaint;//by jeegeo double ratio; HDC dcDst; HDC dcSrc = NULL; HPALETTE hpaintpal = NULL, holdpal = NULL; int pw, ph, vw, vh; int x, y, w, h; dcDst=LayerGrid->Canvas->Handle; AnsiString str = ""; TPLayer *lay; w = Rect.Right - Rect.Left; h = Rect.Bottom - Rect.Top; if (MainImageForm == NULL) return; if(w<=0||h<=0)return; if (Row) { if (Row <= MainImageForm->iMainImage->LayerList->Count) { lay = (TPLayer *) MainImageForm->iMainImage->LayerList->Items[Row - 1]; if (Col == 0) { // if (Row-1==MainImageForm->iMainImage->Index) // createÇÏ´Â ºñÆ®¸ÊÀÌ °¡·ÁÁ® ÀÖÀ» °æ¿ì ¹ß»ýÇÏ´Â ¿¡·¯ ¶§¹®¿¡.. by celberus ((TPLayer *) MainImageForm->iMainImage->LayerList->Items[MainImageForm->iMainImage->Index]) ->UpdateMiniBitmap(MainImageForm->iMainImage->Frgb); static TColor oldbgcolor = (TColor)PaletteForm->BGColor->Brush->Color; // if(oldbgcolor!=(TColor)PaletteForm->BGColor->Brush->Color){ // for(int i=0;iiMainImage->LayerList->Count;i++){ // if(i==MainImageForm->iMainImage->Index)continue; // ((TPLayer *) MainImageForm->iMainImage->LayerList->Items[i]) // // ->LoadFromLayerFile(MainImageForm->iMainImage->Frgb); need-conversion // ((TPLayer *) MainImageForm->iMainImage->LayerList->Items[i]) // block by celberus // ->UpdateMiniBitmap(MainImageForm->iMainImage->Frgb); // ((TPLayer *) MainImageForm->iMainImage->LayerList->Items[i]) // ->MiniBitmap->PutColors(0, 256, MainImageForm->iMainImage->Frgb); // // ((TPLayer *) MainImageForm->iMainImage->LayerList->Items[i]) // // ->LightWeight(); need-conversion } } // oldbgcolor = (TColor)PaletteForm->BGColor->Brush->Color; // ¹ÙÅÁ»öÀÌ ´Þ¶óÁö¸é ·¹ÀÌ¾î ¾÷µ¥ÀÌÆ® if(lay->Visible){ LayerGrid->Canvas->Brush->Style = bsClear; // by jeegeo LayerGrid->Canvas->Pen->Color = clBlue; LayerGrid->Canvas->Pen->Width = 1; LayerGrid->Canvas->Rectangle(Rect.Left+1, Rect.Top+1, Rect.Right-1, Rect.Bottom-1); } ///////////////////////////////////¿©±â¼­ ºÎÅÍ ·¹À̾îÀÇ Ãà¼Ò±×¸²À» ±×¸°´Ù //by jeegeo vw = lay->MiniBitmap->Width; vh = lay->MiniBitmap->Height; if(vw<=0||vh<=0) { return; } /* if(vw>vh) { ratio=(double)vw/(double)w; } else { ratio=(double)vh/(double)h; } pw = (int)((double)vw /ratio); ph = (int)((double)vh /ratio);*/ pw=w;ph=h; if (lay->MiniBitmap->BitsPerPixel==8) { hpaintpal = L_CreatePaintPalette(dcDst, lay->MiniBitmap->Handle); if (hpaintpal) holdpal = SelectPalette(dcDst, hpaintpal, false); } if ((dcSrc = lay->MiniBitmap->CreateDC()) == NULL) { if (dcSrc) lay->MiniBitmap->DeleteDC(dcSrc); if (hpaintpal) { if (holdpal) SelectPalette(dcDst, holdpal, false); DeleteObject(hpaintpal); } } else { SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst,Rect.Left+(w-pw)/2+2,Rect.Top+(h-ph)/2+2,pw-4,ph-4,dcSrc, 0, 0, vw, vh, SRCCOPY); lay->MiniBitmap->DeleteDC(dcSrc); if (hpaintpal) { if (holdpal) SelectPalette(dcDst, holdpal, false); DeleteObject(hpaintpal); } } //////////////////////////////////////·¹À̾îÀÇ Ãà¼Ò±×¸² ³¡ } else { if (Row - 1 == MainImageForm->iMainImage->Index) { LayerGrid->Canvas->Brush->Style = bsClear; LayerGrid->Canvas->Pen->Color = clRed; LayerGrid->Canvas->Pen->Width = 2; LayerGrid->Canvas->Rectangle(Rect.Left + 1, Rect.Top + 1, Rect.Right, Rect.Bottom); } LayerGrid->Canvas->Font->Color = clBlue; str = lay->Name; } } } else { switch (Col) { case 0: str = IDS_VIEW; break; case 1: str = IDS_IMAGE; } } if (str != "") { x = (w - LayerGrid->Canvas->TextWidth(str)) / 2; y = (h - LayerGrid->Canvas->TextHeight(str)) / 2; LayerGrid->Canvas->TextOut(Rect.Left + x, Rect.Top + y, str); } } //--------------------------------------------------------------------------- void __fastcall TLayerForm::LayerGridMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int col, row, cnt = MainImageForm->iMainImage->LayerList->Count; TPLayer *lay; POINT cursor, pt; if (cnt > 1) { LayerGrid->MouseToCell(X, Y, col, row); if (row > 0 && row <= MainImageForm->iMainImage->LayerList->Count/* && col == 0*/) { if (col == 0) { lay = (TPLayer *) MainImageForm->iMainImage->LayerList->Items[row -1]; lay->Visible = !lay->Visible; MainImageForm->iMainImage->LayerVisibleChange(row - 1, lay->Visible); LayerGrid->Repaint(); ::RepaintImage(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false, false); } if (col) { MainImageForm->LayerCNT = row; MainImageForm->iMainImage->Index = row - 1; MainImageForm->ChangeLayer(); ::RepaintImage(); if (row > 1) { //by k3dogs(20001107)µå·¡±×·Î ·¡ÀÌ¾î ¿Å±â±â. LayerGrid->BeginDrag(false,false); // ExchangeRow = row; //ExchangeRow = ±³È¯µÉ ·¹À̾î } // } } } } //--------------------------------------------------------------------------- void __fastcall TLayerForm::LayerGridClick(TObject *Sender) //by k3dogs(20001107) { /* //µå·¡±×·Î ·¡ÀÌ¾î ¿Å±â±â. Çϸ鼭 int col, row; //DownÀ¸·Î ¿Å±â°í ¸·¾ÒÀ½. // TPLayer *lay; POINT cursor, pt; GetCursorPos(&cursor); pt = LayerGrid->ScreenToClient(cursor); LayerGrid->MouseToCell(pt.x, pt.y, col, row); if (row > 0 && row <= MainImageForm->iMainImage->LayerList->Count) { if (col) { MainImageForm->iMainImage->Index = row - 1; MainImageForm->ChangeLayer(); // Undo->SetLayerOrder(); ::RepaintImage(); } } */ } //--------------------------------------------------------------------------- void __fastcall TLayerForm::sbNewClick(TObject *Sender) { AnsiString name; int w, h, bpp, i, j; RGBQUAD rgb[256]; COLORREF bg; TDialogForm *Form = NULL; TPItemImage *Image = MainImageForm->iMainImage; Form = new TDialogForm(this); Form->Caption = IDS_NEWLAYER; Form->PanelCopy->BringToFront(); i = Image->LayerList->Count; j = MainImageForm->LayerListCount++; name = IDS_LAYER + Format(" %d", OPENARRAY(TVarRec, (j))); Form->InitForm(1, name, 1); if (Form->ShowModal() == mrOk) { MainMenuForm->ExitForm(); TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; name = Form->EditCopy->Text; w = Image->uBitmap->Width; h = Image->uBitmap->Height; bpp = Image->uBitmap->BitsPerPixel; bg = PaletteForm->DIB256Palette->GetBGCOLORREF(bpp); MainImageForm->LayerCNT = i+1; if (bpp == 8) { Image->uBitmap->GetColors(0, 256, rgb); if (Image->AddLayer(name, w, h, 8, bg, rgb) == false) goto fail; } else { if (Image->AddLayer(name, w, h, 24, bg) == false) goto fail; } LayerGrid->RowCount++; ChangeFormSize(); // LayerGrid->Row++; LayerGrid->Repaint(); // Undo->SetLayerOrder(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainMenuForm->AutoRepUpdateItem(); else MainMenuForm->UpdateItem(); ::RepaintImage(); Screen->Cursor = cursor; } delete Form; return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TLayerForm::sbCopyClick(TObject *Sender) { TDialogForm *Form = NULL; AnsiString str = IDS_COMMON_COPY + " " + IDS_LAYER; Form = new TDialogForm(this); Form->Caption = str; Form->PanelCopy->BringToFront(); Form->InitForm(5, str, 1); if (Form->ShowModal() == mrOk) { MainMenuForm->ExitForm(); TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->iMainImage->CopyLayer(Form->EditCopy->Text) == false) goto fail; LayerGrid->RowCount++; MainImageForm->LayerCNT = LayerGrid->RowCount-1; ChangeFormSize(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainMenuForm->AutoRepUpdateItem(); else MainMenuForm->UpdateItem(); ::RepaintImage(); Screen->Cursor = cursor; } delete Form; return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TLayerForm::sbExchangeClick(TObject *Sender) { int dst, src; TDialogForm *Form = NULL; Form = new TDialogForm(this); Form->Caption = IDS_EXCHANGE + " " + IDS_LAYER; Form->PanelExchange->BringToFront(); Form->InitForm(MainImageForm->iMainImage->LayerList->Count, "", 2); if (Form->ShowModal() == mrOk) { if (Form->spSrc->Value < 2) Form->spSrc->Value = 2; if (Form->spDst->Value < 2) Form->spDst->Value = 2; if (Form->spSrc->Value > MainImageForm->iMainImage->LayerList->Count) Form->spSrc->Value = MainImageForm->iMainImage->LayerList->Count; if (Form->spDst->Value > MainImageForm->iMainImage->LayerList->Count) Form->spDst->Value = MainImageForm->iMainImage->LayerList->Count; MainMenuForm->ExitForm(); TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; src = Form->spSrc->Value - 1; dst = Form->spDst->Value - 1; if(Form->spSrc->Value == MainImageForm->ARLayerCnt){ MainImageForm->ARLayerCnt = Form->spDst->Value; }else if(Form->spDst->Value == MainImageForm->ARLayerCnt){ MainImageForm->ARLayerCnt = Form->spSrc->Value; } if(Form->spSrc->Value == MainImageForm->LayerCNT){ MainImageForm->LayerCNT = Form->spDst->Value; }else if(Form->spDst->Value == MainImageForm->LayerCNT){ MainImageForm->LayerCNT = Form->spSrc->Value; } MainImageForm->iMainImage->ExchangeLayer(src, dst); ::RepaintImage(); Screen->Cursor = cursor; } delete Form; } //--------------------------------------------------------------------------- void __fastcall TLayerForm::sbDeleteClick(TObject *Sender) { int cnt = MainImageForm->iMainImage->LayerList->Count; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)){ ShowMessage(IDS_MESSAGE_AUTOREPEATCLOSE); return; } if (cnt > 1) { if (MainImageForm->iMainImage->Index <= cnt) { if (EXCEPTION_MESSAGE_OKCANCEL(EC_DELETELAYER_REALLY) == mrOk) { MainMenuForm->ExitForm(); if(MainImageForm->LayerCNT <= MainImageForm->ARLayerCnt) MainImageForm->ARLayerCnt -= 1; MainImageForm->LayerCNT -= 1 ; TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; int LayerCount = ((TPLayer *) MainImageForm->iMainImage->LayerList-> Items[MainImageForm->iMainImage->Index])->GetLayerOrder(); MainImageForm->Undo->RemoveOneLayerInfo(LayerCount ); MainImageForm->iMainImage->DeleteLayer(); LayerGrid->RowCount--; ChangeFormSize(); LayerGrid->Repaint(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainMenuForm->AutoRepUpdateItem(); else MainMenuForm->UpdateItem(); ::RepaintImage(); Screen->Cursor = cursor; } } } } //--------------------------------------------------------------------------- void __fastcall TLayerForm::sbMergeClick(TObject *Sender) { TPLayer *lay; int cnt, j, n = 0; // int i, j, numOfVisibleLayer, numOfFirstVL,cnt, w, h; int numOfFirstVL; int LayerCount; // TPLayer *lay=NULL, *dstLayer = NULL; TPLayer *dstLayer = NULL; MainMenuForm->ExitForm(); TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->AutoRepeat){ ShowMessage(IDS_MESSAGE_AUTOREPEATCLOSE); return; } ////////////////////////////////////// Layer Change before merge the layer cnt = MainImageForm->iMainImage->LayerList->Count; numOfFirstVL = -1; for (j = 0; j < cnt; j++) { lay = (TPLayer *) MainImageForm->iMainImage->LayerList->Items[j]; if (lay->Visible) { if (numOfFirstVL == -1) numOfFirstVL=j; break; } } dstLayer = (TPLayer *) MainImageForm->iMainImage->LayerList->Items[numOfFirstVL]; MainImageForm->Undo->LayerChange(MainImageForm->iMainImage->uBitmap->getLayerOrder(),dstLayer->LBitmap->getLayerOrder()); MainImageForm->UndoSave(UK_PATTERN); ////////////////////////////////////// if (MainImageForm->iMainImage->MergeVisibleLayer()) { cnt = MainImageForm->iMainImage->LayerList->Count; for (j = 0; j < cnt; j++) { lay = (TPLayer *) MainImageForm->iMainImage->LayerList->Items[j]; if (!lay->Visible){ n++; // LayerCount = ((TPLayer *) MainImageForm->iMainImage->LayerList-> // Items[j])->GetLayerOrder(); // MainImageForm->Undo->RemoveOneLayerInfo(LayerCount ); } } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainMenuForm->AutoRepUpdateItem(); else MainMenuForm->UpdateItem(); LayerGrid->RowCount = n + 2; ChangeFormSize(); // MainImageForm->RemoveUndoAll(); //by linuxjun Undo_Method MainImageForm->LayerCNT = cnt; ::RepaintImage(); } else { EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TLayerForm::sbFlattenClick(TObject *Sender) { int cnt; MainMenuForm->ExitForm(); TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->AutoRepeat){ ShowMessage(IDS_MESSAGE_AUTOREPEATCLOSE); return; } if (MainImageForm->iMainImage->FlattenLayer()) { cnt = MainImageForm->iMainImage->LayerList->Count; LayerGrid->RowCount = 2; ChangeFormSize(); // MainImageForm->RemoveUndoAll(); //by linuxjun Undo_Method MainImageForm->LayerCNT = cnt; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainMenuForm->AutoRepUpdateItem(); else MainMenuForm->UpdateItem(); ::RepaintImage(); } else { EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TLayerForm::InitForm() { LayerGrid->ColWidths[0] = 40; LayerGrid->ColWidths[1] = LayerGrid->Width-46;//185; LayerGrid->RowHeights[0] = 24; LayerGrid->RowCount = MainImageForm->iMainImage->LayerList->Count + 1 ; //·¹ÀÌ¾î °¹¼ö ±¸ÇÔ ChangeFormSize(); // ·¹ÀÌ¾î ÆûÀÇ Å©±â if (MainImageForm) { sbNew->Enabled = true; sbCopy->Enabled = true; New1->Enabled = true; Copy1->Enabled = true; sbExchange->Enabled = false; Exchange1->Enabled = false; if (MainImageForm->iMainImage->LayerList->Count > 1) { if (MainImageForm->iMainImage->LayerList->Count >2) { sbExchange->Enabled = true; Exchange1->Enabled = true; } if (MainImageForm->iMainImage->Index == 0) { sbDelete->Enabled = false; Delete1->Enabled = false; } else { sbDelete->Enabled = true; Delete1->Enabled = true; } sbMerge->Enabled = true; Merge1->Enabled = true; sbFlatten->Enabled = true; Flatten1->Enabled = true; } else { sbExchange->Enabled = false; Exchange1->Enabled = false; sbDelete->Enabled = false; Delete1->Enabled = false; sbMerge->Enabled = false; sbFlatten->Enabled = false; Merge1->Enabled = false; Flatten1->Enabled = false; } LayerGrid->Repaint(); } else { sbNew->Enabled = false; sbCopy->Enabled = false; sbDelete->Enabled = false; sbExchange->Enabled = false; sbMerge->Enabled = false; sbFlatten->Enabled = false; New1->Enabled = false; Copy1->Enabled = false; Exchange1->Enabled = false; Delete1->Enabled = false; Merge1->Enabled = false; Flatten1->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TLayerForm::sbInsertClick(TObject *Sender) { AnsiString name; int w, h, bpp, i, j; RGBQUAD rgb[256]; COLORREF bg; TDialogForm *Form = NULL; TUnionBitmap *bmp = MainImageForm->iMainImage->uBitmap; // convert by celberus if (MainImageForm->iMainImage->Index == 0) { EXCEPTION_MESSAGE_OK(EC_UNABLE_INSERT); return; } Form = new TDialogForm(this); Form->Caption = IDS_INSERT + " " + IDS_LAYER; Form->PanelCopy->BringToFront(); i = MainImageForm->iMainImage->LayerList->Count; j = MainImageForm->LayerListCount++; name = IDS_LAYER + Format(" %d", OPENARRAY(TVarRec, (j))); Form->InitForm(1, name, 1); if (Form->ShowModal() == mrOk) { MainMenuForm->ExitForm(); if(MainImageForm->LayerCNT <= MainImageForm->ARLayerCnt) MainImageForm->ARLayerCnt += 1; TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; name = Form->EditCopy->Text; w = bmp->Width; h = bmp->Height; bpp = bmp->BitsPerPixel; bg = PaletteForm->DIB256Palette->GetBGCOLORREF(bpp); if (bpp == 8) { bmp->GetColors(0, 256, rgb); MainImageForm->iMainImage->InsertLayer(name, w, h, 8, bg, rgb); } else { MainImageForm->iMainImage->InsertLayer(name, w, h, 24, bg); } LayerGrid->RowCount++; ChangeFormSize(); LayerGrid->Repaint(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainMenuForm->AutoRepUpdateItem(); else MainMenuForm->UpdateItem(); ::RepaintImage(); Screen->Cursor = cursor; } delete Form; } //--------------------------------------------------------------------------- void __fastcall TLayerForm::sbRenameClick(TObject *Sender) { TDialogForm *Form = NULL; TPLayer *lay; lay = (TPLayer *) MainImageForm->iMainImage->LayerList->Items[MainImageForm->iMainImage->Index]; AnsiString str = IDS_COMMON_RENAME + " " + IDS_LAYER; Form = new TDialogForm(this); Form->Caption = str; Form->PanelCopy->BringToFront(); Form->InitForm(1, lay->Name, 1); if (Form->ShowModal() == mrOk) { TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; lay->Name = Form->EditCopy->Text; LayerGrid->Repaint(); Screen->Cursor = cursor; } delete Form; } //--------------------------------------------------------------------------- void __fastcall TLayerForm::FormClose(TObject *Sender, TCloseAction &Action) { Visible = false; if (FOnUpdateMenu) FOnUpdateMenu(Sender); } //--------------------------------------------------------------------------- void __fastcall TLayerForm::ChangeFormSize() // ·¹ÀÌ¾î ÆûÀÇ Å©±â¸¦ { // ±¸ÇÏ´Â ÇÔ¼ö int sysDependHeight = GetSystemMetrics(SM_CYSMCAPTION) + GetSystemMetrics(SM_CYMENU); OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); int osVERSION = osvi.dwMajorVersion; int sysDependMaxRowNum = osVERSION >= 5? 6 : 7; if(LayerGrid->RowCount <= sysDependMaxRowNum) //<---LayerGrid->RowCount <= 5 ÇØ»óµµ°¡ ÀÛÀ» ¶§´Â ¹®Á¦°¡ »ý±âÁö ¾ÊÀ»·±Áö.. Height = 27 +24 + (LayerGrid->RowCount -1)*(40 + GetSystemMetrics(SM_CYBORDER)) + sysDependHeight; //<---37 //SM_CYBORDER°ªÀÌ ½Ã½ºÅÛ¸¶´Ù ´Ù¸¥°ÍÀº ¾Æ´Ï´Ù. ÀÌ °ªÀº 98°ú xp¿¡¼­ ¸ðµÎ 1ÀÇ °ªÀ» °¡Áø´Ù. ±×·¯³ª 98¿¡¼­ ÀÌ °ªÀ» ´õÇѰͰú ±×·¸Áö ¾ÊÀº°ÍÀÇ ¸ð¾çÀÌ °°°Ô ³ªÅ¸³­´Ù. else //by k3dogs ·¹ÀÌ¾î ÆûÀ» ´Ã¸° °ÍÀÌ´Ù. Height = 27 +24 + (sysDependMaxRowNum-1)*(40 + GetSystemMetrics(SM_CYBORDER)) + sysDependHeight; //<---Height = 27 +24 + 4*40 + 37; LayerGrid->Row = MainImageForm->iMainImage->Index + 1; } //--------------------------------------------------------------------------- void __fastcall TLayerForm::LayerGridDragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept) { if (Sender == LayerGrid && Source == LayerGrid) Accept = true; else Accept = false; } //--------------------------------------------------------------------------- void __fastcall TLayerForm::LayerGridDragDrop(TObject *Sender, TObject *Source, int X, int Y) { TCursor cursor; int dst, src; int col, row; cursor = Screen->Cursor; LayerGrid->MouseToCell(X, Y, col, row); if(row == 1 || ExchangeRow == 1) return; MainImageForm->LayerCNT = row; if(ExchangeRow>row){ if(MainImageForm->ARLayerCnt == ExchangeRow){ MainImageForm->ARLayerCnt = row; }else if(MainImageForm->ARLayerCnt < ExchangeRow){ if(MainImageForm->ARLayerCnt >= row) MainImageForm->ARLayerCnt += 1; } //by lhskys 2001.03.05. for(ExchangeRow;ExchangeRow > row;ExchangeRow--){ //layer À§Ä¡¸¦ À̵¿ if (Sender == Source) { //À§Ä¡°¡ À̵¿ ÇÒ¶§ src = ExchangeRow - 1; //±× À§Ä¡±îÁö Çϳª¾¿ dst = src - 1; //±³È¯ Çϵµ·Ï Çß´Ù. if ( dst > 0 && src > 0) { Screen->Cursor = crHourGlass; MainImageForm->iMainImage->ExchangeLayer(src, dst); Screen->Cursor = cursor; } } } }else if(ExchangeRowARLayerCnt == ExchangeRow){ MainImageForm->ARLayerCnt = row; }else if(MainImageForm->ARLayerCnt > ExchangeRow){ if(MainImageForm->ARLayerCnt <= row) MainImageForm->ARLayerCnt -= 1; } for(ExchangeRow;ExchangeRow < row;ExchangeRow++){ if (Sender == Source) { src = ExchangeRow; dst = src - 1; if ( dst > 0 && src > 0) { Screen->Cursor = crHourGlass; MainImageForm->iMainImage->ExchangeLayer(src, dst); Screen->Cursor = cursor; } } } } ::RepaintImage(); } //--------------------------------------------------------------------------- void __fastcall TLayerForm::LayerGridRectPaint(HDC dcMemV,int sx,int sy,int pw,int ph){//layergrid ¾÷µ¥ÀÌÆ® TPLayer *lay=(TPLayer *) MainImageForm->iMainImage->LayerList->Items[MainImageForm->iMainImage->Index]; int lmw=lay->MiniBitmap->Width; int lmh=lay->MiniBitmap->Height; int lw=MainImageForm->iMainImage->uBitmap->Width; int lh=MainImageForm->iMainImage->uBitmap->Height; int msx=sx*lmw/lw; int msy=sy*lmh/lh; int mw=pw*lmw/lw; int mh=ph*lmh/lh; if(lmw == 0)lmw = 1; if(lmh == 0)lmh = 1; RECT rc=LayerGrid->CellRect(0,1+MainImageForm->iMainImage->Index); int lgx=(rc.left+2) + ((rc.right-rc.left)-4)*msx/lmw; int lgy=(rc.top+2) + ((rc.bottom-rc.top)-4)*msy/lmh; int lgw=((rc.right-rc.left)-4)*mw/lmw; int lgh=((rc.bottom-rc.top)-4)*mh/lmh; if(lgw==0)lgw=1; if(lgh==0)lgh=1; HPALETTE hpaintpal = NULL, holdpal = NULL; HDC dcSrc = lay->MiniBitmap->CreateDC(); ////////////minibitmap update // if (lay->LBitmap->BitsPerPixel==8) { // hpaintpal = L_CreatePaintPalette(dcSrc, MainImageForm->iMainImage->uBitmap->Handle); // if (hpaintpal) holdpal = SelectPalette(dcSrc, hpaintpal, false); // } SetStretchBltMode(dcSrc, COLORONCOLOR); if(ph==0||pw==0)return; // StretchBlt(dcSrc, msx, msy, mw, mh, dcMemV, sx, sy, pw, ph, SRCCOPY); lay->LBitmap->UnionStretchBlt(dcSrc, msx, msy, mw, mh, sx, sy, pw, ph, SRCCOPY); // convert by celberus // if (hpaintpal) { // if (holdpal) SelectPalette(dcSrc, holdpal, false); // DeleteObject(hpaintpal); // } ////////////minibitmap update ////////////LayerGrid update HDC dcDst = LayerGrid->Canvas->Handle; if (lay->LBitmap->BitsPerPixel==8) { hpaintpal = L_CreatePaintPalette(dcDst, lay->MiniBitmap->Handle); if (hpaintpal) holdpal = SelectPalette(dcDst, hpaintpal, false); } SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst,lgx,lgy,lgw,lgh,dcSrc, msx, msy, mw, mh, SRCCOPY); if (hpaintpal) { if (holdpal) SelectPalette(dcDst, holdpal, false); DeleteObject(hpaintpal); } ////////////LayerGrid update lay->MiniBitmap->DeleteDC(dcSrc); } //--------------------------------------------------------------------------- void __fastcall TLayerForm::SetFont() { SetSmallFont(Font); } //----------------------------------------------------------------------------