//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "common.h" #include "Editor.h" #include "Design.h" #include "Main_F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "Rulers" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_EDITOR StringTable[0] #define IDS_LOAD StringTable[1] #define IDS_SAVE StringTable[2] #define IDS_CUT StringTable[3] #define IDS_COPY StringTable[4] #define IDS_PASTE StringTable[5] //--------------------------------------------------------------------------- TEditorForm *EditorForm; //--------------------------------------------------------------------------- __fastcall TEditorForm::TEditorForm(TComponent* Owner) : TForm(Owner) { tex=NULL; } //--------------------------------------------------------------------------- void __fastcall TEditorForm::SetFont(){ SetSmallFont(Font); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::Init(){ tex = (Tex *)Main->texlayer->TexList->Items[Main->LayerNum]; mmData->Clear(); for(int i=0;iCurve->Count;i++){ KO *ko=(KO *)tex->Curve->Items[i]; AnsiString s = IntToStr(ko->in)+" "+IntToStr(ko->via); if(s.Length()==3) s+=" "; if(s.Length()==4) s+=" "; if(s.Length()==5) s+=" "; s=s+"("+IntToStr(i+1)+")"; mmData->Lines->Add(s); } } //--------------------------------------------------------------------------- void __fastcall TEditorForm::UpdateTex(){ try{ for(int i=0;iCurve->Count;i++){ KO *ko=(KO *)tex->Curve->Items[i]; sscanf(mmData->Lines->Strings[i].c_str(), "%d %d", &(ko->in), &(ko->via)); } } catch(...){ return; } tex->Correction(); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::sbOKClick(TObject *Sender) { Main->Undo->do_(Main->texlayer); UpdateTex(); DesignForm->DrawChart(); Close(); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::pmLoadClick(TObject *Sender) { OpenDialog->InitialDir=BaseDir + "\\layer"; OpenDialog->DefaultExt="lay"; OpenDialog->Filter="Layer Files(*.lay)|*.lay"; if(OpenDialog->Execute()){ mmData->Lines->LoadFromFile(OpenDialog->FileName); } } //--------------------------------------------------------------------------- void __fastcall TEditorForm::pmSaveClick(TObject *Sender) { SaveDialog->InitialDir=BaseDir + "\\layer"; SaveDialog->DefaultExt="lay"; SaveDialog->Filter="Layer Files(*.lay)|*.lay"; if(SaveDialog->Execute()){ mmData->Lines->SaveToFile(SaveDialog->FileName); } } //--------------------------------------------------------------------------- void __fastcall TEditorForm::mmDataKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { StatusBar->Panels->Items[0]->Text = "Line : "+IntToStr(mmData->CaretPos.y+1); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::mmDataMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { StatusBar->Panels->Items[0]->Text = "Line : "+IntToStr(mmData->CaretPos.y+1); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::FormCreate(TObject *Sender) { mmData->Font->Size=12; StringTable.Create(BaseDir, Language, "PathData"); Caption = IDS_EDITOR; pmLoad->Caption = IDS_LOAD; pmSave->Caption = IDS_SAVE; pmCut->Caption = IDS_CUT; pmCopy->Caption = IDS_COPY; pmPaste->Caption = IDS_PASTE; SetFont(); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::FormResize(TObject *Sender) { mmData->Top=2; mmData->Height=ClientHeight-StatusBar->Height-sbOK->Height-6; sbOK->Top=mmData->Top+mmData->Height+2; StatusBar->Top=ClientHeight-StatusBar->Height; sbOK->Left=2; sbOK->Width=ClientWidth-4; StatusBar->Width=ClientWidth; StatusBar->Left=0; mmData->Width=ClientWidth-4; mmData->Left=2; } //--------------------------------------------------------------------------- void __fastcall TEditorForm::mmDataKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { StatusBar->Panels->Items[0]->Text = "Line : "+IntToStr(mmData->CaretPos.y+1); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::pmCutClick(TObject *Sender) { mmData->CutToClipboard(); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::pmCopyClick(TObject *Sender) { mmData->CopyToClipboard(); } //--------------------------------------------------------------------------- void __fastcall TEditorForm::pmPasteClick(TObject *Sender) { mmData->PasteFromClipboard(); } //---------------------------------------------------------------------------