//--------------------------------------------------------------------------- #include #pragma hdrstop #include "EnlargeCanvas.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TNumEdit" #pragma link "RzButton" #pragma link "RzPanel" #pragma link "RzRadGrp" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_CURRENTSIZE StringTable[0] #define IDS_NEWSIZE StringTable[1] #define IDS_ENLARGECANVAS StringTable[2] #define IDS_CANNOT_ENLARGE_CANVAS StringTable[3] //--------------------------------------------------------------------------- TEnlargeCanvasForm *EnlargeCanvasForm; //--------------------------------------------------------------------------- __fastcall TEnlargeCanvasForm::TEnlargeCanvasForm(TComponent* Owner) : TForm(Owner) { //=========================================================== StringTable.Create(DirectoryBin, Language, "EnlargeCanvas"); SetSmallFont(Font); Caption = IDS_ENLARGECANVAS; GroupBox1->Caption = IDS_CURRENTSIZE; gbNewSize->Caption = IDS_NEWSIZE; rgUnit->Caption = IDS_COMMON_UNIT ; lbCSWidth->Caption = IDS_COMMON_WIDTH ; lbCSHeight->Caption = IDS_COMMON_HEIGHT ; Label1->Caption = IDS_COMMON_WIDTH; Label2->Caption = IDS_COMMON_HEIGHT; lbNSWidthUnit->Caption = IDS_COMMON_CM; lbNSHeightUnit->Caption = IDS_COMMON_CM; OKBtn->Caption = IDS_COMMON_BUTTONOK; CancelBtn->Caption = IDS_COMMON_BUTTONCANCEL; rgUnit->Items->Strings[0] = IDS_COMMON_CM; rgUnit->Items->Strings[1] = IDS_COMMON_INCH; rgUnit->Items->Strings[2] = IDS_COMMON_DOT; //=========================================================== } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::FormActivate(TObject *Sender) { NewSize.cx = CanvasInfor.Width; NewSize.cy = CanvasInfor.Height; FUnit = uCm; View(); } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::edNSClick(TObject *Sender) { TEdit *ed = (TEdit *)Sender; ed->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::edNSDblClick(TObject *Sender) { TEdit *ed = (TEdit *)Sender; ed->SetFocus(); ed->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::edNSWidthChange(TObject *Sender) { /* // added by maxleo21c (05.05.01) - ¼ýÀÚ, "." = 190 ÀÌ¿ÜÀÇ ±ÛÀÚ°¡ µé¾î¿À¸é ¿¡·¯°¡ ¹ß»ýÇϱâ // ¶§¹®¿¡ Ãß°¡Âg´Ù. if (tempKey == VK_BACK || tempKey == VK_DELETE); else if (tempKey >= 48 && tempKey <= 57); // 0 ~ 9 else if (tempKey >= 96 && tempKey <= 105); // VK_NUMPAD0 ~ VK_NUMPAD9 else if (tempString.Length() && (tempKey == 190 || tempKey == VK_DECIMAL) && edNSWidth->Text.Length()) { int count=0; for (int i=0; iText.Length(); i++) { if (edNSWidth->Text.c_str()[i] == '.') count++; } if (count>1) { edNSWidth->Text = tempString; return; } } else if (tempString.Length() && tempKey!=0) { edNSWidth->Text = tempString; return; } */ //------------------------------------------------------------------------- if (edNSWidth->Value > 0) { switch (FUnit) { case uCm: NewSize.cx = edNSWidth->Value*CanvasInfor.DotsPerInch/2.54+0.5; break; case uInch: NewSize.cx = edNSWidth->Value*CanvasInfor.DotsPerInch+0.5; break; default: NewSize.cx = edNSWidth->IntValue; break; } } } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::edNSHeightChange(TObject *Sender) { if (edNSHeight->Value > 0) { switch (FUnit) { case uCm: NewSize.cy = edNSHeight->Value*CanvasInfor.DotsPerInch/2.54+0.5; break; case uInch: NewSize.cy = edNSHeight->Value*CanvasInfor.DotsPerInch+0.5; break; default: NewSize.cy = edNSHeight->IntValue; break; } } } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::rgUnitClick(TObject *Sender) { switch (rgUnit->ItemIndex) { case 0: FUnit = uCm; lbNSWidthUnit->Caption = "Cm"; lbNSHeightUnit->Caption = "Cm"; break; case 1: FUnit = uInch; lbNSWidthUnit->Caption = "Inch"; lbNSHeightUnit->Caption = "Inch"; break; case 2: FUnit = uDot; lbNSWidthUnit->Caption = "Dots"; lbNSHeightUnit->Caption = "Dots"; break; } View(); } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::View() { switch (FUnit) { case uCm: lbCSWidth->Caption = String(IDS_COMMON_WIDTH) + Format(" : %f Cm", OPENARRAY(TVarRec, (2.54*CanvasInfor.Width/CanvasInfor.DotsPerInch))); lbCSHeight->Caption = String(IDS_COMMON_HEIGHT) + Format(" : %f Cm", OPENARRAY(TVarRec, (2.54*CanvasInfor.Height/CanvasInfor.DotsPerInch))); edNSWidth->Value = 2.54*NewSize.cx/CanvasInfor.DotsPerInch; //Format("%f", OPENARRAY(TVarRec, (2.54*NewSize.cx/CanvasInfor.DotsPerInch))); edNSHeight->Value = 2.54*NewSize.cy/CanvasInfor.DotsPerInch; //Format("%f", OPENARRAY(TVarRec, (2.54*NewSize.cy/CanvasInfor.DotsPerInch))); break; case uInch: lbCSWidth->Caption = String(IDS_COMMON_WIDTH) + Format(" : %f Inch", OPENARRAY(TVarRec, ((double)CanvasInfor.Width/CanvasInfor.DotsPerInch))); lbCSHeight->Caption = String(IDS_COMMON_HEIGHT) + Format(" : %f Inch", OPENARRAY(TVarRec, ((double)CanvasInfor.Height/CanvasInfor.DotsPerInch))); edNSWidth->Value = (double)NewSize.cx/CanvasInfor.DotsPerInch; //Format("%f", OPENARRAY(TVarRec, ((double)NewSize.cx/CanvasInfor.DotsPerInch))); edNSHeight->Value = (double)NewSize.cy/CanvasInfor.DotsPerInch; //Format("%f", OPENARRAY(TVarRec, ((double)NewSize.cy/CanvasInfor.DotsPerInch))); break; case uDot: lbCSWidth->Caption = String(IDS_COMMON_WIDTH) + Format(" : %d Dots", OPENARRAY(TVarRec, (CanvasInfor.Width))); lbCSHeight->Caption = String(IDS_COMMON_HEIGHT) + Format(" : %d Dots", OPENARRAY(TVarRec, (CanvasInfor.Height))); edNSWidth->Value = (int)NewSize.cx; //Format("%d", OPENARRAY(TVarRec, ((int)NewSize.cx))); edNSHeight->Value = (int)NewSize.cy; //Format("%d", OPENARRAY(TVarRec, ((int)NewSize.cy))); break; } } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::edNSWHKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { tempKey = Key; tempString = FloatToStr(edNSWidth->Value); //edNSWidth->Text; if(Key == VK_RETURN) SelectNext((TWinControl *)Sender, true, true); } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::OKBtnClick(TObject *Sender) { A4SizeCheck(); } //--------------------------------------------------------------------------- void __fastcall TEnlargeCanvasForm::A4SizeCheck() { #ifdef TRIAL float pWidth = edNSWidth->Value; float pHeight = edNSHeight->Value; float A4Width, A4Height; switch (rgUnit->ItemIndex) { case 0: A4Width = 19.81; A4Height = 27.94; break; case 1: A4Width = 7.8; A4Height = 11; break; case 2: A4Width = 1248; A4Height = 1760; break; } if((pWidth > A4Height || pHeight > A4Height)) { ShowMessage(IDS_CANNOT_ENLARGE_CANVAS); ModalResult = mrCancel; } else if(!(pWidth <= A4Width || pHeight <= A4Width)) { ShowMessage(IDS_CANNOT_ENLARGE_CANVAS); ModalResult = mrCancel; } #endif } //---------------------------------------------------------------------------