//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "KnitPrint.h" #include "Common.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPSpin" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_FORM StringTable[0] #define IDS_HEADER StringTable[1] #define IDS_COLUMN StringTable[2] #define IDS_ROW StringTable[3] #define IDS_FREESIZE StringTable[4] #define IDS_IMAGE StringTable[5] #define IDS_MARK StringTable[6] #define IDS_YARN StringTable[7] #define IDS_MIX StringTable[8] #define IDS_FREE StringTable[9] #define IDS_YES StringTable[10] #define IDS_NO StringTable[11] //--------------------------------------------------------------------------- __fastcall TKnitPrintForm::TKnitPrintForm(TComponent* Owner) : TForm(Owner) { //=================================================================== StringTable.Create(DirectoryItem, Language, "KnitPrint"); SetSmallFont(Font); lbPrinter->Caption = IDS_COMMON_PRINTER + " : " + Printer()->Printers->Strings[Printer()->PrinterIndex]; for (int i = 0; i < 3; i++) { cbMethod->Items->Strings[i] = IDS_COMMON_PRINTMETHOD + " - " + AnsiString(i+1); } TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { cbMethod->ItemIndex = IniFile->ReadBool("Printer", "Method", 0); delete IniFile; } Label1->Caption = IDS_COMMON_PAGE; rgForm->Caption = IDS_FORM; rgSize->Caption = IDS_COMMON_SIZE; rgHeader->Caption = IDS_HEADER; gbRepeat->Caption = IDS_COMMON_REPEAT; gbFreeSize->Caption = IDS_FREESIZE; rgUnit->Caption = IDS_COMMON_UNIT; Label4->Caption = IDS_COLUMN; Label5->Caption = IDS_ROW; Label6->Caption = IDS_COMMON_WIDTH; Label7->Caption = IDS_COMMON_HEIGHT; btSetup->Caption = IDS_COMMON_SETUP; btOK->Caption = IDS_COMMON_BUTTONOK; btCancel->Caption = IDS_COMMON_BUTTONCANCEL; rgForm->Items->Strings[0] = IDS_IMAGE; rgForm->Items->Strings[1] = IDS_YARN; rgForm->Items->Strings[2] = IDS_MARK; rgForm->Items->Strings[3] = IDS_MIX; rgSize->Items->Strings[1] = IDS_FREE; rgHeader->Items->Strings[0] = IDS_YES; rgHeader->Items->Strings[1] = IDS_NO; //=================================================================== } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { IniFile->WriteBool("Printer", "Method", cbMethod->ItemIndex); delete IniFile; } } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::FormCreate(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::InitForm() { // Size = 0; unit = 0; Item = 0; bmp = 2; rgForm->ItemIndex = 0; rgSize->ItemIndex = 0; rgHeader->ItemIndex = 1; rgHeader->Enabled = true; rxRCol->Enabled = false; rxRRow->Enabled = false; rxFSWidth->Enabled = false; rxFSHeight->Enabled = false; rgUnit->Enabled = false; rxFSWidth->Value = FSWidth[bmp]; rxFSHeight->Value = FSHeight[bmp]; } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::rgFormClick(TObject *Sender) { TRadioGroup *rg = (TRadioGroup *)Sender; if (rgForm->ItemIndex == 0) { if (rgSize->ItemIndex == 0) { rxRCol->Enabled = false; rxRRow->Enabled = false; rxFSWidth->Enabled = false; rxFSHeight->Enabled = false; rgUnit->Enabled = false; } else { rxRCol->Enabled = true; rxRRow->Enabled = true; rxFSWidth->Enabled = true; rxFSHeight->Enabled = true; rgUnit->Enabled = true; } rgHeader->Enabled = true; bmp = 2; } else if (rgForm->ItemIndex == 2) { if (rgSize->ItemIndex == 0) { rxFSWidth->Enabled = false; rxFSHeight->Enabled = false; rgUnit->Enabled = false; } else { rxFSWidth->Enabled = true; rxFSHeight->Enabled = true; rgUnit->Enabled = true; } rxRCol->Enabled = false; rxRRow->Enabled = false; rgHeader->Enabled = false; bmp = 1; } else { if (rgSize->ItemIndex == 0) { rxFSWidth->Enabled = false; rxFSHeight->Enabled = false; rgUnit->Enabled = false; } else { rxFSWidth->Enabled = true; rxFSHeight->Enabled = true; rgUnit->Enabled = true; } rxRCol->Enabled = false; rxRRow->Enabled = false; rgHeader->Enabled = true; if (rgForm->ItemIndex == 1) bmp = 0; else bmp = 1; } if (rgUnit->ItemIndex == 0) { rxFSWidth->Value = FSWidth[bmp]; rxFSHeight->Value = FSHeight[bmp]; } if (rgUnit->ItemIndex == 1) { rxFSWidth->Value = FSWidth[bmp]*2.54/DPI; rxFSHeight->Value = FSHeight[bmp]*2.54/DPI; } else if (rgUnit->ItemIndex == 2) { rxFSWidth->Value = 1.0*FSWidth[bmp]/(DPI); rxFSHeight->Value = 1.0*FSHeight[bmp]/(DPI); } Item = rg->ItemIndex; } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::rgSizeClick(TObject *Sender) { TRadioGroup *rg = (TRadioGroup *)Sender; if (rgSize->ItemIndex == 0) { rxRCol->Enabled = false; rxRRow->Enabled = false; rxFSWidth->Enabled = false; rxFSHeight->Enabled = false; rgUnit->Enabled = false; } else { if (rgForm->ItemIndex == 0) { rxRCol->Enabled = true; rxRRow->Enabled = true; } else { rxRCol->Enabled = false; rxRRow->Enabled = false; } rxFSWidth->Enabled = true; rxFSHeight->Enabled = true; rgUnit->Enabled = true; rgUnit->ItemIndex = 0; rxFSWidth->Value = FSWidth[bmp]; rxFSHeight->Value = FSHeight[bmp]; } } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::btSetupClick(TObject *Sender) { PrinterSetupDialog->Execute(); lbPrinter->Caption = IDS_COMMON_PRINTER + " : " + Printer()->Printers->Strings[Printer()->PrinterIndex]; } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::rxRepClick(TObject *Sender) { TPSpinEdit *stp = (TPSpinEdit*)Sender; stp->SetFocus(); stp->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::rxFSClick(TObject *Sender) { TPSpinEdit *stp = (TPSpinEdit *)Sender; stp->SetFocus(); stp->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::rxFSChange(TObject *Sender) { TPSpinEdit *stp = (TPSpinEdit *)Sender; if (stp->Text.Length()>0) { if (stp->Tag) { //Height if (rgUnit->ItemIndex == 0){ if (stp->Value > BPHeight[bmp]-sp[bmp].y) stp->Value = BPHeight[bmp]-sp[bmp].y; } else if (rgUnit->ItemIndex == 1) { if (stp->Value*DPI/2.54 > BPHeight[bmp]-sp[bmp].y) stp->Value = (BPHeight[bmp]-sp[bmp].y)*2.54/DPI; } else { if ((int)(stp->Value*DPI) > BPHeight[bmp]-sp[bmp].y) stp->Value = 1.0*(BPHeight[bmp]-sp[bmp].y)/DPI; } } else { //Widht if (rgUnit->ItemIndex == 0){ if (stp->Value > BPWidth[bmp]-sp[bmp].x) stp->Value = BPWidth[bmp]-sp[bmp].x; } else if (rgUnit->ItemIndex == 1) { if (stp->Value*DPI/2.54 > BPWidth[bmp]-sp[bmp].x) stp->Value = (BPWidth[bmp]-sp[bmp].x)*2.54/DPI; } else { if ((int)(stp->Value*DPI) > BPWidth[bmp]-sp[bmp].x) stp->Value = 1.0*(BPWidth[bmp]-sp[bmp].x)/DPI; } } } } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::rgUnitClick(TObject *Sender) { if (unit != rgUnit->ItemIndex) { if (unit == 0) { if (rgUnit->ItemIndex == 1) { rxFSWidth->Value = rxFSWidth->Value*2.54/DPI; rxFSHeight->Value = rxFSHeight->Value*2.54/DPI; } else { rxFSWidth->Value = 1.0*rxFSWidth->Value/(DPI); rxFSHeight->Value = 1.0*rxFSHeight->Value/(DPI); } } else if (unit == 1) { if (rgUnit->ItemIndex == 0) { rxFSWidth->Value = (int)(rxFSWidth->Value*DPI/2.54); rxFSHeight->Value = (int)(rxFSHeight->Value*DPI/2.54); } else { rxFSWidth->Value = rxFSWidth->Value/2.54; rxFSHeight->Value = rxFSHeight->Value/2.54; } } else { if (rgUnit->ItemIndex == 0) { rxFSWidth->Value = (int)(rxFSWidth->Value*DPI); rxFSHeight->Value = (int)(rxFSHeight->Value*DPI); } else { rxFSWidth->Value = rxFSWidth->Value*2.54; rxFSHeight->Value = rxFSHeight->Value*2.54; } } unit = rgUnit->ItemIndex; } } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::btPreviewClick(TObject *Sender) { /* TODO : */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::RadioGroup1Click(TObject *Sender) { /* TODO : */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::UpDown1Changing(TObject *Sender, bool &AllowChange) { /* TODO : Set the AllowChange parameter to false to prevent a change to the current value of Position. */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::AllpartsClick(TObject *Sender) { /* TODO : */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::PanelMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { /* TODO : */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::PanelMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { /* TODO : */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::PanelMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { /* TODO : */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::ViewImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { /* TODO : */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::ViewImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { /* TODO : */ } //--------------------------------------------------------------------------- void __fastcall TKnitPrintForm::ViewImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { /* TODO : */ } //---------------------------------------------------------------------------