//--------------------------------------------------------------------------- #include #include "Define.h" //2001.4.23. by lhskys RegFilename¸¦ ¾²±â À§ÇØ.. #pragma hdrstop #include "Environment.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPSpin" #pragma link "CurrEdit" #pragma link "ToolEdit" #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_OPTION StringTable[9] #define IDS_SIZETYPE StringTable[10] #define IDS_SIZE StringTable[11] //--------------------------------------------------------------------- TEnvironmentForm *EnvironmentForm; //--------------------------------------------------------------------------- __fastcall TEnvironmentForm::TEnvironmentForm(TComponent* Owner) : TForm(Owner) { //============================================ StringTable.Create(DirectoryCommon, Language, "Environment"); SetSmallFont(Font); rgUnit->Caption = IDS_COMMON_UNIT; TabSheet1->Caption = IDS_GRID; TabSheet2->Caption = IDS_OPTION; TabSheet3->Caption = IDS_COMMON_AUTOSAVE; 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; Label7->Caption = IDS_MAX_UNDO_COUNT; Label8->Caption = IDS_LIMIT; Label9->Caption = IDS_DPI; Label10->Caption = IDS_COMMON_MINUTES; btnOK->Caption = IDS_COMMON_BUTTONOK; btnCancel->Caption = IDS_COMMON_BUTTONCANCEL; CheckBox1->Caption = IDS_COMMON_AUTOSAVE; SizeType->Caption = IDS_SIZETYPE; RadioGroup2->Caption = IDS_SIZE; //============================================ } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::FormCreate(TObject *Sender) { TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { seDPI->Value = IniFile->ReadInteger("CanvasInfor", "DPI", 160); rgUnit->ItemIndex = IniFile->ReadInteger("Grid", "Unit", 0); rceGapX->Value = IniFile->ReadFloat("Grid", "GapX", 1.0); rceGapY->Value = IniFile->ReadFloat("Grid", "GapY", 1.0); int Count = IniFile->ReadInteger("Grid", "Catalog-Count", 0); for (int i=0; iItems->Add(IniFile->ReadString("Grid", "Catalog-"+AnsiString(i), "")); } shGridColor->Brush->Color = (TColor) IniFile->ReadInteger("Grid", "Color", clBlack); seSectionNumber->Value = IniFile->ReadInteger("Grid", "LinesPerSection", 0); shSectionColor->Brush->Color = (TColor) IniFile->ReadInteger("Grid", "SectionColor", clBlack); spEditUndo->Value = IniFile->ReadInteger("Window", "MaxUndo", 100); RadioGroup1->ItemIndex = IniFile->ReadInteger("MainImage", "Unit", 0); CheckBox1->Checked = IniFile->ReadBool("AutoSave", "Check", false); spMinute->Value = IniFile->ReadInteger("AutoSave", "Min", 5); //=============================== 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; } FUnit = uDot; View(NULL); } //--------------------------------------------------------------------------- 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::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::sbCatalogAddClick(TObject *Sender) { lbGrid->Items->Add(GridToStr(FUnit, rceGapX->Value, rceGapY->Value)); } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::sbCatalogDeleteClick(TObject *Sender) { lbGrid->Items->Delete(lbGrid->ItemIndex); } //--------------------------------------------------------------------------- void __fastcall TEnvironmentForm::lbGridDblClick(TObject *Sender) { TGrid Grid = StrToGrid(lbGrid->Items->Strings[lbGrid->ItemIndex]); rgUnit->ItemIndex = Grid.Unit; rceGapX->Value = Grid.X; rceGapY->Value = Grid.Y; } //--------------------------------------------------------------------------- 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::btnOKClick(TObject *Sender) { TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { IniFile->WriteInteger("CanvasInfor", "DPI", seDPI->Value); IniFile->WriteInteger("Grid", "Unit", rgUnit->ItemIndex); IniFile->WriteFloat("Grid", "GapX", rceGapX->Value); IniFile->WriteFloat("Grid", "GapY", rceGapY->Value); int Count = IniFile->ReadInteger("Grid", "Catalog-Count", 0); IniFile->WriteInteger("Grid", "Catalog-Count", lbGrid->Items->Count); int i = 0; while (true) { if (iItems->Count) { IniFile->WriteString("Grid", "Catalog-"+AnsiString(i), lbGrid->Items->Strings[i]); } else if (iDeleteKey("Grid", "Catalog-"+AnsiString(i)); } else break; i++; } IniFile->WriteInteger("Grid", "Color", shGridColor->Brush->Color); IniFile->WriteInteger("Grid", "LinesPerSection", seSectionNumber->Value); IniFile->WriteInteger("Grid", "SectionColor", shSectionColor->Brush->Color); IniFile->WriteInteger("Window", "MaxUndo", spEditUndo->Value); IniFile->WriteInteger("MainImage", "Unit", RadioGroup1->ItemIndex); IniFile->WriteInteger("MainImage","Size",RadioGroup2->ItemIndex); //2001.4.2 by lhskys ȯ°æ¼³Á¤ -> Á¾ÀÌ Size //=============================================== 2001.4.23. by lhskys Á¾ÀÌ size ¹× ´ÜÀ§... TRegIniFile *RegIniFile; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename,true); if(RadioGroup2->ItemIndex == 0)TREG_Size = "cstA4"; else if(RadioGroup2->ItemIndex == 1)TREG_Size = "cstA3"; else if(RadioGroup2->ItemIndex == 2)TREG_Size = "cstA2"; else if(RadioGroup2->ItemIndex == 3)TREG_Size = "cstA1"; else if(RadioGroup2->ItemIndex == 4)TREG_Size = "cstA0"; else if(RadioGroup2->ItemIndex == 5)TREG_Size = "cstLetter"; else if(RadioGroup2->ItemIndex == 6)TREG_Size = "cstLegal"; else if(RadioGroup2->ItemIndex == 7)TREG_Size = "cstTabloid"; RegIniFile->WriteString("Common", "TREG_Size", TREG_Size); if(RadioGroup1->ItemIndex == 0)TUnits = "uCm"; else if(RadioGroup1->ItemIndex == 1)TUnits = "uInch"; else if(RadioGroup1->ItemIndex == 2)TUnits = "uDot"; RegIniFile->WriteString("Common", "TUnits", TUnits); //=============================================== IniFile->WriteBool("AutoSave", "Check", CheckBox1->Checked); IniFile->WriteInteger("AutoSave", "Min", spMinute->Value); delete IniFile; } } //---------------------------------------------------------------------------