//--------------------------------------------------------------------------- #include #include "Define.h" //2001.4.23. by lhskys RegFilename¸¦ ¾²±â À§ÇØ.. #pragma hdrstop #include "Environment.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "CurrEdit" #pragma link "ToolEdit" #pragma link "TPSpin" #pragma resource "*.dfm" //--------------------------------------------------------------------- #define IDS_GRID StringTable[0] #define IDS_DPI StringTable[1] #define IDS_GRIDCOLOR StringTable[2] #define IDS_SECTIONLINE StringTable[3] #define IDS_SECTIONCOLOR StringTable[4] #define IDS_CATALOG StringTable[5] #define IDS_MAX_UNDO_COUNT StringTable[6] #define IDS_LIMIT StringTable[7] #define IDS_YARNBRIGHTNESS StringTable[8] #define IDS_OPTION StringTable[9] #define IDS_SIZETYPE StringTable[10] #define IDS_SIZE StringTable[11] #define IDS_FORMULA StringTable[12] #define IDS_COFF StringTable[13] #define IDS_WARP StringTable[14] #define IDS_WEFT StringTable[15] #define IDS_CORRECTION StringTable[16] //--------------------------------------------------------------------- TEnvironmentForm *EnvironmentForm; //--------------------------------------------------------------------------- __fastcall TEnvironmentForm::TEnvironmentForm(TComponent* Owner) : TForm(Owner) { //============================================ StringTable.Create(DirectoryBin, Language, "Environment"); SetSmallFont(Font); rgUnit->Caption = IDS_COMMON_UNIT; tsGrid->Caption = IDS_GRID; tsYarnBrightness->Caption = IDS_YARNBRIGHTNESS; Label1->Caption = IDS_COMMON_HORIZONTAL; Label2->Caption = IDS_COMMON_VERTICAL; Label3->Caption = IDS_CATALOG; Label4->Caption = IDS_GRIDCOLOR; Label5->Caption = IDS_SECTIONLINE; Label6->Caption = IDS_SECTIONCOLOR; Label9->Caption = IDS_DPI; btnOK->Caption = IDS_COMMON_BUTTONOK; btnCancel->Caption = IDS_COMMON_BUTTONCANCEL; SizeType->Caption = IDS_SIZETYPE; RadioGroup2->Caption = IDS_SIZE; stWarp->Caption = IDS_WARP; stWeft->Caption = IDS_WEFT; GroupBox1->Caption = IDS_COFF; TabSheet3->Caption = IDS_CORRECTION; stFormula->Caption = IDS_FORMULA; //============================================ } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::FormCreate(TObject *Sender) { int i; AnsiString as; TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { seDPI->Value = IniFile->ReadInteger("CanvasInfor", "DPI", 160); // Grid rgUnit->ItemIndex = IniFile->ReadInteger("Grid", "Unit", 0); rceGapX->Value = IniFile->ReadFloat("Grid", "GapX", 1.0); rceGapY->Value = IniFile->ReadFloat("Grid", "GapY", 1.0); i = 0; while (true) { as = IniFile->ReadString("Grid", "Catalog-"+i, ""); if (as.Length()>0) { lbGrid->Items->Add(as); i++; } else break; } shGridColor->Brush->Color = IniFile->ReadInteger("Grid", "Color", clBlack); seSectionNumber->Value = IniFile->ReadInteger("Grid", "LinesPerSection", 0); shSectionColor->Brush->Color = IniFile->ReadInteger("Grid", "SectionColor", clBlack); // Yarn Brightness for (i=0; i<7; i++) { y[i] = IniFile->ReadFloat("YarnBrightness", AnsiString(i), -0.03+i*0.01); } // Window // spEditUndo->Value = IniFile->ReadInteger("Window", "MaxUndo", 5); RadioGroup1->ItemIndex = IniFile->ReadInteger("MainImage", "Unit", 0); spEditDPI->Value = IniFile->ReadInteger("Printing", "DPI", 480); edWarp->Text = IniFile->ReadFloat("Correction", "Warp", 1.1); edWeft->Text = IniFile->ReadFloat("Correction", "Weft", 1); //=============================== 2001.4.23 by lhskys ȯ°æ¼³Á¤ -> Á¾ÀÌ Size int Sizetype; Sizetype = IniFile->ReadInteger("MainImage", "Size", 0); if(Sizetype <5) RadioGroup2->ItemIndex = Sizetype; else RadioGroup2->ItemIndex = Sizetype - 1; //=============================== delete IniFile; } // Grid FUnit = uDot; View(NULL); // Yarn Brightness FNumber = -1; Image1->Canvas->Pen->Color = clBlack; Image1->Canvas->MoveTo(200, 0), Image1->Canvas->LineTo(200, 200); Image1->Canvas->MoveTo(0, 100), Image1->Canvas->LineTo(400, 100); Image1->Canvas->Pen->Color = clBlack; Image1->Canvas->MoveTo(20, 100), Image1->Canvas->LineTo(20, 95); Image1->Canvas->MoveTo(80, 100), Image1->Canvas->LineTo(80, 95); Image1->Canvas->MoveTo(140, 100), Image1->Canvas->LineTo(140, 95); Image1->Canvas->MoveTo(200, 100), Image1->Canvas->LineTo(200, 95); Image1->Canvas->MoveTo(260, 100), Image1->Canvas->LineTo(260, 95); Image1->Canvas->MoveTo(320, 100), Image1->Canvas->LineTo(320, 95); Image1->Canvas->MoveTo(380, 100), Image1->Canvas->LineTo(380, 95); Image1->Canvas->TextOut(14, 105, "-3"); Image1->Canvas->TextOut(74, 105, "-2"); Image1->Canvas->TextOut(134, 105, "-1"); Image1->Canvas->TextOut(190, 105, "0"); Image1->Canvas->TextOut(256, 105, "1"); Image1->Canvas->TextOut(316, 105, "2"); Image1->Canvas->TextOut(376, 105, "3"); Image1->Canvas->TextOut(190, 10, "Y"); Image1->Canvas->TextOut(390, 105, "X"); Image1->Canvas->Pen->Color = clBlue; Image1->Canvas->Pen->Mode = pmNotXor; Draw(); IsDraw = true; } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::rgUnitClick(TObject *Sender) { switch (FUnit) { case 1: rceGapX->Value *= seDPI->Value; rceGapY->Value *= seDPI->Value; break; case 2: rceGapX->Value *= seDPI->Value/2.54; rceGapY->Value *= seDPI->Value/2.54; break; } FUnit = TUnit(rgUnit->ItemIndex); //Assinging int to Tputils switch (FUnit) { case 1: rceGapX->Value /= seDPI->Value; rceGapY->Value /= seDPI->Value; break; case 2: rceGapX->Value /= seDPI->Value/2.54; rceGapY->Value /= seDPI->Value/2.54; break; } } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::sbCatalogAddClick(TObject *Sender) { char *unit[3] = { "Dot", "Inch", "Cm" }; lbGrid->Items->Add(Format("%s) %.6f x %.6f", OPENARRAY(TVarRec, (unit[(int)FUnit], rceGapX->Value, rceGapY->Value)))); } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::sbCatalogDeleteClick(TObject *Sender) { lbGrid->Items->Delete(lbGrid->ItemIndex); } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::lbGridDblClick(TObject *Sender) { char *Grid, *tok = ") ", *p; Grid = strdup(lbGrid->Items->Strings[lbGrid->ItemIndex].c_str()); p = strtok(Grid, tok); if (strcmp(p, "Cm")==0) rgUnit->ItemIndex = 2; else if (strcmp(p, "Inch")==0) rgUnit->ItemIndex = 1; else rgUnit->ItemIndex = 0; p = strtok(NULL, tok); rceGapX->Value = atof(p); strtok(NULL, tok); p = strtok(NULL, tok); rceGapY->Value = atof(p); free(Grid); } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::sbGridColorClick(TObject *Sender) { if (GridColorDialog->Execute()) { shGridColor->Brush->Color = GridColorDialog->Color; View(NULL); } } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::seSectionNumberChange(TObject *Sender) { if (seSectionNumber->Text.Length()>0) View(NULL); } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::sbSectionColorClick(TObject *Sender) { if (GridColorDialog->Execute()) { shSectionColor->Brush->Color = GridColorDialog->Color; View(NULL); } } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::View(TObject *Sender) { int p; Image->Canvas->Pen->Color = shGridColor->Brush->Color; for (p=0; pWidth; p+=5) { Image->Canvas->MoveTo(p, 0); Image->Canvas->LineTo(p, Image->Height); } for (p=0; pHeight; p+=5) { Image->Canvas->MoveTo(0, p); Image->Canvas->LineTo(Image->Width, p); } if (seSectionNumber->Value>0) { Image->Canvas->Pen->Color = shSectionColor->Brush->Color; for (p=0; pWidth; p+=5*seSectionNumber->Value) { Image->Canvas->MoveTo(p, 0); Image->Canvas->LineTo(p, Image->Height); } for (p=0; pHeight; p+=5*seSectionNumber->Value) { Image->Canvas->MoveTo(0, p); Image->Canvas->LineTo(Image->Width, p); } } } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::Image1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { for (int i=0; i<7; i++) { if (X>=17+i*60 && X<=23+i*60 && Y>=97-y[i]*800 && Y<=103-y[i]*800) { FNumber = i; break; } } } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::Image1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (FNumber>=0 && Y>=20 && Y<=180) { if (IsDraw) Draw(); y[FNumber] = -(Y-100)/800.0; Draw(); IsDraw = true; } } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::Image1MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (FNumber>=0) { //======================================== À§Ä¡°¡ Image¸¦ ¹þ¾î³ª´Â °æ¿ì if (Y < 20) Y = 20; if (Y > 180) Y = 180; //======================================== if (IsDraw) Draw(); y[FNumber] = -(Y-100)/800.0; Draw(); FNumber = -1; } } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::btnOKClick(TObject *Sender) { TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { IniFile->WriteInteger("CanvasInfor", "DPI", seDPI->Value); // Grid IniFile->EraseSection("Grid"); IniFile->WriteInteger("Grid", "Unit", rgUnit->ItemIndex); IniFile->WriteFloat("Grid", "GapX", rceGapX->Value); IniFile->WriteFloat("Grid", "GapY", rceGapY->Value); for (int i=0; iItems->Count; i++) { IniFile->WriteString("Grid", "Catalog-"+i, lbGrid->Items->Strings[i]); } IniFile->WriteInteger("Grid", "Color", shGridColor->Brush->Color); IniFile->WriteInteger("Grid", "LinesPerSection", seSectionNumber->Value); IniFile->WriteInteger("Grid", "SectionColor", shSectionColor->Brush->Color); // Yarn Brightness for (int i=0; i<7; i++) { IniFile->WriteFloat("YarnBrightness", AnsiString(i), y[i]); } // Window // IniFile->WriteInteger("Window", "MaxUndo", spEditUndo->Value); IniFile->WriteInteger("MainImage", "Unit", RadioGroup1->ItemIndex); IniFile->WriteInteger("MainImage","Size",RadioGroup2->ItemIndex); //2001.4.2 by lhskys ȯ°æ¼³Á¤ -> Á¾ÀÌ Size IniFile->WriteInteger("Printing", "DPI", spEditDPI->Value); //qe ¿ø¸®ÇÍÆû°ú ÇÁ¸°Æ®½Ã ÇØ»óµµ¼³Á¤ //=============================================== 2001.4.23. by lhskys test IniFile->WriteFloat("Correction", "Warp", StrToFloat(edWarp->Text)); IniFile->WriteFloat("Correction", "Weft", StrToFloat(edWeft->Text)); TRegIniFile *RegIniFile; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey("SOFTWARE\\YoungWoo\\Texpro\\8.01\\",true); if(RadioGroup2->ItemIndex == 0)WREG_Size = "cstA4"; else if(RadioGroup2->ItemIndex == 1)WREG_Size = "cstA3"; else if(RadioGroup2->ItemIndex == 2)WREG_Size = "cstA2"; else if(RadioGroup2->ItemIndex == 3)WREG_Size = "cstA1"; else if(RadioGroup2->ItemIndex == 4)WREG_Size = "cstA0"; else if(RadioGroup2->ItemIndex == 5)WREG_Size = "cstLetter"; else if(RadioGroup2->ItemIndex == 6)WREG_Size = "cstLegal"; else if(RadioGroup2->ItemIndex == 7)WREG_Size = "cstTabloid"; RegIniFile->WriteString("Common", "WREG_Size", WREG_Size); if(RadioGroup1->ItemIndex == 0)WUnits = "uCm"; else if(RadioGroup1->ItemIndex == 1)WUnits = "uInch"; RegIniFile->WriteString("Common", "WUnits", WUnits); //=============================================== delete IniFile; } } //--------------------------------------------------------------------------- // Private Method //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::DrawRectangle(int X, int Y) { Image1->Canvas->Rectangle(X-3, Y-3, X+3, Y+3); } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::Draw() { int i; Image1->Canvas->MoveTo(20, 100-y[0]*800); for (i=1; i<7; i++) { Image1->Canvas->LineTo(20+i*60, 100-y[i]*800); } for (i=0; i<7; i++) { DrawRectangle(20+i*60, 100-y[i]*800); } StaticText1->Caption = Format("%5.3f", OPENARRAY(TVarRec, (y[0]))); StaticText2->Caption = Format("%5.3f", OPENARRAY(TVarRec, (y[1]))); StaticText3->Caption = Format("%5.3f", OPENARRAY(TVarRec, (y[2]))); StaticText4->Caption = Format("%5.3f", OPENARRAY(TVarRec, (y[3]))); StaticText5->Caption = Format("%5.3f", OPENARRAY(TVarRec, (y[4]))); StaticText6->Caption = Format("%5.3f", OPENARRAY(TVarRec, (y[5]))); StaticText7->Caption = Format("%5.3f", OPENARRAY(TVarRec, (y[6]))); } //---------------------------------------------------------------------------