⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psetup.pas

📁 suite component ace report
💻 PAS
📖 第 1 页 / 共 3 页
字号:
        FHeight := um.MMTo(275, units);
      end;
      ps10X14:
      begin
        FWidth := um.InTo(10, units);
        FHeight := um.InTo(14, units);
      end;
      ps11X17:
      begin
        FWidth := um.InTo(11, units);
        FHeight := um.InTo(17, units);
      end;
      psNOTE:
      begin
        FWidth := um.InTo(8.5, units);
        FHeight := um.InTo(11, units);
      end;
      psENV_9:
      begin
        FWidth := um.InTo(3.875, units);
        FHeight := um.InTo(8.875, units);
      end;
      psENV_10:
      begin
        FWidth := um.InTo(4.125, units);
        FHeight := um.InTo(9.5, units);
      end;
      psENV_11:
      begin
        FWidth := um.InTo(4.5, units);
        FHeight := um.InTo(10.375, units);
      end;
      psENV_12:
      begin
        FWidth := um.InTo(4.5, units);
        FHeight := um.InTo(11, units);
      end;
      psENV_14:
      begin
        FWidth := um.InTo(5, units);
        FHeight := um.InTo(11.5, units);
      end;
      psCSHEET:
      begin
        FWidth := um.InTo(17, units);
        FHeight := um.InTo(22, units);
      end;
      psDSHEET:
      begin
        FWidth := um.InTo(22, units);
        FHeight := um.InTo(34, units);
      end;
      psESHEET:
      begin
        FWidth := um.InTo(34, units);
        FHeight := um.InTo(44, units);
      end;
      psUseCurrent:
      begin
      end;
    end;
    { reverse if the orientation is landscape }
    if Orientation = poLandScape then
    begin
      SVal := FWidth;
      FWidth := FHeight;
      FHeight := SVal;
    end;
    StoreHW := (FSize = psCustom);

    if (Page <> nil) And Not (csReading in TSctPage(Page).ComponentState) Then
    begin
      PageRefresh;
    end;
  end;
end;

procedure TSctPageSetup.SetSource(S: TSctPaperSource);
begin
  if FSource <> S Then
  begin
    FSource := S;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetDuplex(D: TSctPaperDuplex);
begin
  if FDuplex <> D Then
  begin
    FDuplex := D;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetCopies(C: TSctPaperCopies);
begin
  if FCopies <> C Then
  begin
    FCopies := C;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetHeight(H: Double);
begin
  if FHeight <> H Then
  begin
    FHeight := H;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetWidth(W: Double);
begin
  if FWidth <> W Then
  begin
    FWidth := W;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetPixelsPerUnit(ppu: Double);
begin
  if FPixelsPerUnit <> ppu Then
  begin
    FPixelsPerUnit := ppu;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetPrintQuality(pq: TSctPrintQuality);
begin
  if FPrintQuality <> pq then
  begin
    FPrintQuality := pq;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetTrueTypeOption(tt: TSctTrueTypeOption);
begin
  if FTrueTypeOption <> tt then FTrueTypeOption := tt;
end;

procedure TSctPageSetup.SetLeftMargin(L: Double);
begin
  if FLeftMargin <> L Then
  begin
    FLeftMargin := L;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetTopMargin(T: Double);
begin
  if FTopMargin <> T Then
  begin
    FTopMargin := T;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetBottomMargin(B: Double);
begin
  if FBottomMargin <> B Then
  begin
    FBottomMargin := B;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetRightMargin(R: Double);
begin
  if FRightMargin <> R Then
  begin
    FRightMargin := R;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.SetColor(C: Boolean);
begin
  FColor := C;
end;

procedure TSctPageSetup.SetRangeStart(startpage: Integer);
begin
  FRangeStart := startpage;
end;

procedure TSctPageSetup.SetRangeEnd(endpage: Integer);
begin
  FRangeEnd := endpage;
end;


procedure TSctPageSetup.SetUnits(u: TSctUnits);
begin
  if FUnits <> u then
  begin
    if (Page <> nil) And Not (csReading in TsctPage(Page).ComponentState) Then
    begin
      case FUnits of
        unitInches:
        begin
          FWidth := um.InTo(FWidth, u);
          FHeight := um.InTo(FHeight, u);
          FLeftMargin := um.InTo(FLeftMargin, u);
          FTopMargin := um.InTo(FTopMargin, u);
          FRightMargin := um.InTo(FRightMargin, u);
          FBottomMargin := um.InTo(FBottomMargin, u);
          FPixelsPerUnit := FPixelsPerUnit * um.ToIn(1, u);

          FLeftPrint := um.InTo(FLeftPrint, u);
          FTopPrint := um.InTo(FTopPrint, u);
          FRightPrint := um.InTo(FRightPrint, u);
          FBottomPrint := um.InTo(FBottomPrint, u);
        end;
        unitCentiMeters:
        begin
          FWidth := um.CMTo(FWidth, u);
          FHeight := um.CMTo(FHeight, u);
          FLeftMargin := um.CMTo(FLeftMargin, u);
          FTopMargin := um.CMTo(FTopMargin, u);
          FRightMargin := um.CMTo(FRightMargin, u);
          FBottomMargin := um.CMTo(FBottomMargin, u);
          FPixelsPerUnit := FPixelsPerUnit * um.ToCM(1, u);

          FLeftPrint := um.CMTo(FLeftPrint, u);
          FTopPrint := um.CMTo(FTopPrint, u);
          FRightPrint := um.CMTo(FRightPrint, u);
          FBottomPrint := um.CMTo(FBottomPrint, u);
        end;
        unitMiliMeters:
        begin
          FWidth := um.MMTo(FWidth, u);
          FHeight := um.MMTo(FHeight, u);
          FLeftMargin := um.MMTo(FLeftMargin, u);
          FTopMargin := um.MMTo(FTopMargin, u);
          FRightMargin := um.MMTo(FRightMargin, u);
          FBottomMargin := um.MMTo(FBottomMargin, u);
          FPixelsPerUnit := FPixelsPerUnit * um.ToMM(1, u);

          FLeftPrint := um.MMTo(FLeftPrint, u);
          FTopPrint := um.MMTo(FTopPrint, u);
          FRightPrint := um.MMTo(FRightPrint, u);
          FBottomPrint := um.MMTo(FBottomPrint, u);
        end;
      end;
    end;

    FUnits := u;
    PageRefresh;
  end;
end;

procedure TSctPageSetup.LoadSettings;
begin
  WriteToAPS;
{  if AnyPrinters Then
  begin}
    FAcePrinterSetup.SetData;
{  end;}
end;

procedure TSctPageSetup.WriteToAPS;
begin
  if Not AnyPrinters then
  begin
    if FSize = psUseCurrent then FSize := psLetter;
  end;
  if FOrientation <> poUseCurrent then FAcePrinterSetup.Orientation := OrientDtoW(FOrientation);
  if FSize <> psUseCurrent then
  begin
    FAcePrinterSetup.PaperSize := PaperSizeDtoW(FSize);
    if FSize = psCustom then
    begin
      FAcePrinterSetup.Length := um.ToIn(FHeight,units);
      FAcePrinterSetup.Width  := um.ToIn(FWidth,units);
    end else if Not AnyPrinters then
    begin
      FAcePrinterSetup.Length := 1;
      FAcePrinterSetup.Width  := 1;
      FAcePrinterSetup.Length := um.ToIn(FHeight,units);
      FAcePrinterSetup.Width  := um.ToIn(FWidth,units);
    end;
  end;
  if FCopies <> 0 then FAcePrinterSetup.Copies := FCopies;
  if FSource <> ppsUseCurrent then FAcePrinterSetup.Source := SourceDtoW(FSource);
  if FTrueTypeOption <> ttUseCurrent then FAcePrinterSetup.ttOption := TrueTypeOptionDtoW(FTrueTypeOption);

  FAcePrinterSetup.CollatedCopies := FCollatedCopies;
  if FFormName <> '' then FAcePrinterSetup.FormName := FFormName;
  if FPrintQuality <> pqUseCurrent then FAcePrinterSetup.PrintQuality := PrintQualityDtoW(FPrintQuality);
{    if afpi.PrintQuality = 0 then
      afpi.PrintQuality := Round(um.ToIn(PixelsPerUnit, units));}

  FAcePrinterSetup.Color := ColorDtoW(FColor);
  if FDuplex <> pdUseCurrent then FAcePrinterSetup.Duplex := DuplexDtoW(Duplex);
end;

procedure TSctPageSetup.CopySettings;
begin
{  if AnyPrinters Then
  begin}
    FAcePrinterSetup.GetData;
{  end;}
  ReadFromAPS;
end;

procedure TSctPageSetup.ReadFromAPS;
var
  mysize: TSctPaperSize;
begin
  if Not AnyPrinters then
  begin
    if FSize = psUseCurrent then FSize := psLetter;
  end;

  if FOrientation <> poUseCurrent then FOrientation := OrientWtoD(FAcePrinterSetup.Orientation);
  if FSize <> psUseCurrent then
  begin
    mysize := PaperSizeWtoD(FAcePrinterSetup.PaperSize);
    if mysize <> psUseCurrent then FSize := mysize;
  end;
  if FSize <> psCustom then
  begin
    FHeight := um.Into(FAcePrinterSetup.Length, units);
    FWidth := um.Into(FAcePrinterSetup.Width, units);
  end;
  if FSource <> ppsUseCurrent then FSource := SourceWtoD(FAcePrinterSetup.Source);
  if FDuplex <> pdUseCurrent then FDuplex := DuplexWtoD(FAcePrinterSetup.Duplex);
  if FPrintQuality <> pqUseCurrent then FPrintQuality := PrintQualityWtoD(FAcePrinterSetup.PrintQuality);
  if AnyPrinters Then
  begin
    FPixelsPerUnit := Round(um.InTo(GetDeviceCaps(Printers.Printer.handle,LOGPIXELSX), units));
  end;
  FColor := (FAcePrinterSetup.Color = DMCOLOR_COLOR);
  if FCopies <> 0 then FCopies := FAcePrinterSetup.Copies;
  if FTrueTypeOption <> ttUseCurrent then FTrueTypeOption := TrueTypeOptionWtoD(FAcePrinterSetup.ttOption);

  FCollatedCopies := FAcePrinterSetup.CollatedCopies;
  FFormName := FAcePrinterSetup.FormName;

  FLeftPrint := um.Into(FAcePrinterSetup.LeftPrintArea,units);
  FTopPrint := um.Into(FAcePrinterSetup.TopPrintArea,units);
  FRightPrint := um.Into(FAcePrinterSetup.RightPrintArea,units);
  FBottomPrint := um.Into(FAcePrinterSetup.BottomPrintArea,units);

  if AdjustMargin And (FSize <> psCustom) then
  begin
    if LeftPrint > LeftMargin then LeftMargin := LeftPrint;
    if RightPrint > RightMargin then RightMargin := RightPrint;
    if TopPrint > TopMargin then TopMargin := TopPrint;
    if BottomPrint > BottomMargin then BottomMargin := BottomPrint;
  end;

end;


procedure TSctPageSetup.SetAcePrinterSetup(ps: TAcePrinterSetup);
begin
  FAcePrinterSetup.Assign(ps);
  ReadFromAPS;
end;

procedure TSctPageSetup.GetAcePrinterSetup(ps: TAcePrinterSetup);
begin
  ps.Assign( FAcePrinterSetup );
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -