//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "Define.h" #include "Exception.h" #include "ZigZagDialog_F.h" #include "LogData.h" #include "Main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TNumEdit" #pragma link "RzButton" #pragma link "RzRadChk" #pragma resource "*.dfm" TZigZagDialog *ZigZagDialog; //--------------------------------------------------------------------------- #define IDS_ZIGZAG StringTable[0] #define IDS_ZIGZAGSIZE StringTable[1] #define IDS_ZIGZAGSEGMENT StringTable[2] #define IDS_ZIGZAGOK StringTable[3] #define IDS_ZIGZAGCLOSE StringTable[4] #define IDS_ZIGZAGSMOOTH StringTable[5] #define IDS_ZIGZAGCORNER StringTable[6] #define IDS_FLOWER StringTable[7] //--------------------------------------------------------------------------- __fastcall TZigZagDialog::TZigZagDialog(TComponent* Owner) : TForm(Owner) { BEGIN_LOG(""); StringTable.Create(DirectoryItem, Language, "ZigZag"); SetSmallFont(Font); gbZigZag->Caption = IDS_ZIGZAG; lbZigZagSize->Caption = IDS_ZIGZAGSIZE; lbZigZagSegment->Caption = IDS_ZIGZAGSEGMENT; btZigZagOK->Caption = IDS_ZIGZAGOK; btZigZagClose->Caption = IDS_ZIGZAGCLOSE; rbtnZigZagSmooth->Caption = IDS_ZIGZAGSMOOTH; rbtnZigZagCorner->Caption = IDS_ZIGZAGCORNER; rbtnFlower->Caption = IDS_FLOWER; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::FormCreate(TObject *Sender) { bFirst = true; TagNum = 0; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::FormDestroy(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::FormActivate(TObject *Sender) { // ÀÌ ºÎºÐÀº Ȥ½Ã³ªÇؼ­ ¸¸µé¾ú´Ù if (bFirst) { bFirst = false; } } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::InitForm(double nMaxSize) { BEGIN_LOG(""); VecDraw->InitZigZag(&nClosed); if (nClosed == 0) { ZigZagPanel->Visible = true; edZigZagSize->Value = 0; trbZigZagSize->Position = 0; trbZigZagSize->Max = nMaxSize; edZigZagSegment->Value = 0; trbZigZagSegment->Position = 0; } else { ZigZagPanel->Visible = true; edZigZagSize->Value = 0; trbZigZagSize->Position = 0; trbZigZagSize->Max = nMaxSize; edZigZagSegment->Value = 4; trbZigZagSegment->Position = 4; } // Æû À§Ä¡ ¹× »çÀÌÁî Á¶Àý nOldVectorFormHeight = VectorForm->Height; // Parent = MainForm; VectorForm->EditPanel->Visible = false; Top = VectorForm->Top + VectorForm->VectorMenuPanel->Height + VectorForm->RzSeparator->Height + 65; // ¿Ö 42À» ´õÇØ¾ßÇÏ´ÂÁö ¾Ë¼ö ¾øÀ½..;; Left = VectorForm->Left + (VectorForm->Width - VectorForm->ClientWidth)/2; VectorForm->ClientHeight = VectorForm->VectorMenuPanel->Top + VectorForm->VectorMenuPanel->Height + VectorForm->RzSeparator->Height + ZigZagPanel->Height; //MainMenuForm->Height = VectorForm->ParentHeight + VectorForm->ClientHeight; ClientHeight = ZigZagPanel->Height; ClientWidth = ZigZagPanel->Width; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::ExitForm() { VectorForm->Height = nOldVectorFormHeight; VectorForm->EditPanel->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::trbZigZagSizeChange(TObject *Sender) { BEGIN_LOG(""); int nType; if (rbtnZigZagSmooth->Checked) nType = 0; else if (rbtnZigZagCorner->Checked) nType = 1; else if (rbtnFlower->Checked) nType = 2; // TrackBarÀÇ º¯È­¿¡ µû¶ó EditÀÇ ¼öÄ¡°¡ º¯ÇÑ´Ù edZigZagSize->Value = trbZigZagSize->Position; VecDraw->DrawZigZag(trbZigZagSize->Position, trbZigZagSegment->Position, nType); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::trbZigZagSegmentChange(TObject *Sender) { BEGIN_LOG(""); // TrackBarÀÇ º¯È­¿¡ µû¶ó EditÀÇ ¼öÄ¡°¡ º¯ÇÑ´Ù int nType; if (rbtnZigZagSmooth->Checked) nType = 0; else if (rbtnZigZagCorner->Checked) nType = 1; else if (rbtnFlower->Checked) nType = 2; if (nClosed == 0) { if (trbZigZagSegment->Position <= 0) trbZigZagSegment->Position = 0; } else { if (trbZigZagSegment->Position <= 4) trbZigZagSegment->Position = 4; if (nClosed == 1 && trbZigZagSegment->Position%2) trbZigZagSegment->Position += 1; } edZigZagSegment->Value = trbZigZagSegment->Position; VecDraw->DrawZigZag(trbZigZagSize->Position, trbZigZagSegment->Position, nType); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::edZigZagSizeKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { BEGIN_LOG(""); // EditÀÇ ¼öÄ¡¿¡ µû¶ó TrackBarÀÇ PositionÀÌ º¯ÇÑ´Ù int nRet; int nType; if (Key == VK_RETURN) { trbZigZagSize->Position = edZigZagSize->Value; if (rbtnZigZagSmooth->Checked) nType = 0; else if (rbtnZigZagCorner->Checked) nType = 1; else if (rbtnFlower->Checked) nType = 2; VecDraw->DrawZigZag(trbZigZagSize->Position, trbZigZagSegment->Position, nType); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::edZigZagSegmentKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { BEGIN_LOG(""); // EditÀÇ ¼öÄ¡¿¡ µû¶ó TrackBarÀÇ PositionÀÌ º¯ÇÑ´Ù int nRet; int nType; if (Key == VK_RETURN) { nRet = edZigZagSegment->Value; if (nClosed == 0) { if (nRet <= 0) { nRet = 0; edZigZagSegment->Value = 0; } } else { if (nRet <= 4) { nRet = 4; edZigZagSegment->Value = 0; } } if (rbtnZigZagSmooth->Checked) nType = 0; else if (rbtnZigZagCorner->Checked) nType = 1; else if (rbtnFlower->Checked) nType = 2; if (nClosed == 1 && nRet%2) { nRet++; edZigZagSegment->Value = nRet; } trbZigZagSegment->Position = nRet; VecDraw->DrawZigZag(trbZigZagSize->Position, trbZigZagSegment->Position, nType); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::edZigZagSizeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { // Edit¿¡ Focus¸¦ ÁØ´Ù edZigZagSize->SetFocus(); edZigZagSize->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::edZigZagSegmentMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { // Edit¿¡ Focus¸¦ ÁØ´Ù edZigZagSegment->SetFocus(); edZigZagSegment->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::rbtnZigZagSmoothClick(TObject *Sender) { BEGIN_LOG(""); // Smooth·Î ZigZag °è»êÀ» ÇØÁÖ¸ç ±×·ÁÁØ´Ù int nType; rbtnZigZagSmooth->Checked = true; rbtnZigZagCorner->Checked = false; rbtnFlower->Checked = false; if (rbtnZigZagSmooth->Checked) nType = 0; else if (rbtnZigZagCorner->Checked) nType = 1; else if (rbtnFlower->Checked) nType = 2; VecDraw->DrawZigZag(trbZigZagSize->Position, trbZigZagSegment->Position, nType); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::rbtnZigZagCornerClick(TObject *Sender) { BEGIN_LOG(""); // Corner·Î ZigZag °è»êÀ» ÇØÁÖ¸ç ±×·ÁÁØ´Ù int nType; rbtnZigZagSmooth->Checked = false; rbtnZigZagCorner->Checked = true; rbtnFlower->Checked = false; if (rbtnZigZagSmooth->Checked) nType = 0; else if (rbtnZigZagCorner->Checked) nType = 1; else if (rbtnFlower->Checked) nType = 2; VecDraw->DrawZigZag(trbZigZagSize->Position, trbZigZagSegment->Position, nType); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::rbtnFlowerClick(TObject *Sender) { BEGIN_LOG(""); // Corner·Î ZigZag °è»êÀ» ÇØÁÖ¸ç ±×·ÁÁØ´Ù int nType; rbtnZigZagSmooth->Checked = false; rbtnZigZagCorner->Checked = false; rbtnFlower->Checked = true; if (rbtnZigZagSmooth->Checked) nType = 0; else if (rbtnZigZagCorner->Checked) nType = 1; else if (rbtnFlower->Checked) nType = 2; VecDraw->DrawZigZag(trbZigZagSize->Position, trbZigZagSegment->Position, nType); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::btZigZagOKClick(TObject *Sender) { BEGIN_LOG(""); // Preview·Î ±×·ÁÁØ ZigZag¸¦ ObjectÈ­ ÇØ¼­ ¹Ý¿µÇÑ´Ù VecDraw->ExitZigZag(true); TagNum = 1; ExitForm(); Close(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TZigZagDialog::btZigZagCloseClick(TObject *Sender) { BEGIN_LOG(""); // Preview·Î ±×·ÁÁØ ZigZag¸¦ »èÁ¦Çϸç Object¸¦ Áö¿î´Ù VecDraw->ExitZigZag(false); TagNum = 0; ExitForm(); Close(); END_LOG; } //--------------------------------------------------------------------------- // ZigZag ¹Ú½º´ÙÀ̾ó·Î±× int __fastcall ZigZagDialogFunc(double nMaxSize) { BEGIN_LOG(""); int TagNum; TagNum = 0; ZigZagDialog = new TZigZagDialog(Application); ZigZagDialog->InitForm(nMaxSize); ZigZagDialog->ShowModal(); TagNum = ZigZagDialog->TagNum; if (ZigZagDialog) { delete ZigZagDialog; ZigZagDialog = NULL; } END_LOG; return TagNum; } //---------------------------------------------------------------------------