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

📄 psetup.pas

📁 suite component ace report
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit PSetup;

{ ----------------------------------------------------------------
  Ace Reporter
  Copyright 1995-1998 SCT Associates, Inc.
  Written by Kevin Maher, Steve Tyrakowski
  ---------------------------------------------------------------- }

interface
{$I ace.inc}

{$IFDEF WIN32}
uses classes, windows, sysutils,extctrls, sctutil, printers, forms, acesetup,
     aceprev, acetypes;
{$ELSE}
uses print, classes, wintypes, winprocs, sysutils,extctrls, sctutil, printers,
     forms, acesetup, aceprev, acetypes;
{$ENDIF}

type

{ TSctDestination }
TSctDestination = (destPrinter, destScreen, destFile);

{ TSctPaperOrientation }
TSctPaperOrientation = (poPortrait, poLandscape, poUseCurrent);
{ TSctPaperSize }
TSctPaperSize = (psLetter, psExecutive, psLegal, psA4, psCustom
           ,psLetterSmall,psTabloid,psLedger,psStatement,psA3
           ,psA4Small,psA5,psB4,psB5,psFolio,psQuarto,ps10x14,ps11x17
           ,psNote,psEnv_9,psEnv_10,psEnv_11,psEnv_12,psEnv_14,psCSheet
           ,psDSheet,psESheet,psUseCurrent);

{ TSctPaperSource }
TSctPaperSource = (psUpper, psLower, psAuto, psManual
               , psEnvelope, psEnvelopeManual, psCassette, psMiddle
               , psSmallFmt, psLargeCapacity
               , psTractor, psLargeFmt, ppsUseCurrent);

{ TSctPaperDuplex }
TSctPaperDuplex = (pdSimplex, pdDuplexLongEdge, pdDuplexShortEdge, pdUseCurrent);

{ TSctPaperCopies }
TSctPaperCopies = 0..9999;

{ TSctPreviewStream }
TSctPreviewStream = (psFile, psMemory);

{ TSctPrintQuality }
TSctPrintQuality = (pqHigh, pqMedium, pqLow, pqDraft, pqCustom, pqUseCurrent);

{ TSctTrueTypeOption }
TSctTrueTypeOption = (ttBitmap, ttDownLoad, ttSubDev, ttDownLoadOutline, ttUseCurrent);

{ TSctModalPreview }
TSctModalPreview = (mpModal, mpNonModal, mpDefault);
{ TSctPreviewOwner }
TSctPreviewOwner = (poFormOwned, poAppOwned, poDefault);
{ TSctFormStyle }
TSctFormStyle = (pfsNormal, pfsMDIChild, pfsStayOnTop, pfsDefault);

{ TSctPreviewSettings }
TSctPreviewSettings = class(TPersistent)
private
  FModalPreview: TSctModalPreview;
  FPreviewOwner: TSctPreviewOwner;
  FFormStyle: TSctFormStyle;
  FWindowState: TWindowState;
  FZoom: TAceZoom;
protected
public
  constructor Create; virtual;
  procedure Assign(Source: TPersistent); override;
published
  property ModalPreview: TSctModalPreview read FModalPreview write FModalPreview default mpDefault;
  property PreviewOwner: TSctPreviewOwner read FPreviewOwner write FPreviewOwner default poDefault;
  property FormStyle: TSctFormStyle read FFormStyle write FFormStyle default pfsDefault;
  property WindowState: TWindowState read FWindowState write FWindowState default wsMaximized;
  property Zoom: TAceZoom read FZoom write FZoom default az100;
end;

{ TSctPageSetup }
TSctPageSetup = class(TPersistent)
private
  FPage: TComponent;
  FOrientation: TSctPaperOrientation;
  FSize: TSctPaperSize;
  FSource: TSctPaperSource;
  FDuplex: TSctPaperDuplex;
  FCopies: TSctPaperCopies;

  FHeight, FWidth: Double;
  FPixelsPerUnit: Double;
  FLeftMargin, FTopMargin, FBottomMargin, FRightMargin: Double;
  FColor: Boolean;
  FUnits: TSctUnits;
  FUM: TSctUnitMaster;
  FRangeStart, FRangeEnd: Integer;
  FDestination: TSctDestination;
  FAnyPrinters: Boolean;
  FPreviewStream: TSctPreviewStream;
  FPrintQuality: TSctPrintQuality;
  FTrueTypeOption: TSctTrueTypeOption;

  FLeftPrint, FTopPrint, FBottomPrint, FRightPrint: Double;

  FAdjustMargin: Boolean;
  FPreviewSettings: TSctPreviewSettings;
  FAcePrinterSetup: TAcePrinterSetup;
  FTextDriverCompatibility: Boolean;
  FDirectPrinter: Boolean;
  FCollatedCopies: Boolean;
  FFormName: String;
  StoreHW: Boolean;
protected
  function GetPixelsPerInch: Integer;
  function GetPrintHeight: Double;
  function GetPrintWidth: Double;
  function GetAnyPrinters: Boolean;

  procedure DefineProperties(Filer: TFiler); override;
  procedure ReadPPU( Reader: TReader);
  procedure ReadLM( Reader: TReader);
  procedure WriteLM( Writer: TWriter);
  procedure ReadRM( Reader: TReader);
  procedure WriteRM( Writer: TWriter);
  procedure ReadTM( Reader: TReader);
  procedure WriteTM( Writer: TWriter);
  procedure ReadBM( Reader: TReader);
  procedure WriteBM( Writer: TWriter);

  procedure ReadFromAPS;
  procedure WriteToAPS;
public
  constructor Create; virtual;
  destructor Destroy; override;
  procedure Assign(Source: TPersistent); override;
  procedure LoadSettings; virtual;
  procedure CopySettings; virtual;

  procedure SetOrientation(O: TSctPaperOrientation); virtual;
  procedure SetSize( S: TSctPaperSize); virtual;
  procedure SetSource(S: TSctPaperSource); virtual;
  procedure SetDuplex(D: TSctPaperDuplex); virtual;
  procedure SetCopies(C: TSctPaperCopies); virtual;

  procedure SetHeight(h: Double); virtual;
  procedure SetWidth(w: Double); virtual;
  procedure SetPixelsPerUnit(ppu: Double); virtual;
  procedure SetPrintQuality(pq: TSctPrintQuality); virtual;
  procedure SetLeftMargin(l: Double); virtual;
  procedure SetTopMargin(t: Double); virtual;
  procedure SetBottomMargin(b: Double); virtual;
  procedure SetRightMargin(r: Double); virtual;
  procedure SetColor(c: Boolean); virtual;
  procedure SetUnits(u: TSctUnits); virtual;
  procedure SetTrueTypeOption(tt: TSctTrueTypeOption); virtual;

  procedure SetRangeStart(StartPage: Integer);
  procedure SetRangeEnd(EndPage: Integer);

  property Page: TComponent read FPage write FPage;
  procedure PageRefresh;
  property UM: TSctUnitMaster read FUM write FUM;

  property PixelsPerInch: Integer read GetPixelsPerInch;
  property PrintHeight: Double read GetPrintHeight;
  property PrintWidth: Double read GetPrintWidth;
  property AnyPrinters: Boolean read GetAnyPrinters write FAnyPrinters;


  property LeftPrint: Double read FLeftPrint write FLeftPrint;
  property RightPrint: Double read FRightPrint write FRightPrint;
  property TopPrint: Double read FTopPrint write FTopPrint;
  property BottomPrint: Double read FBottomPrint write FBottomPrint;

  property AcePrinterSetup: TAcePrinterSetup read FAcePrinterSetup write FAcePrinterSetup;
  procedure SetAcePrinterSetup(ps: TAcePrinterSetup);
  procedure GetAcePrinterSetup(ps: TAcePrinterSetup);
  { These properties are no longer needed }
  property PreviewStream: TSctPreviewStream read FPreviewStream write FPreviewStream stored False;
  property PixelsPerUnit: Double read FPixelsPerUnit write SetPixelsPerUnit stored False;
published
  property Orientation: TSctPaperOrientation read FOrientation write SetOrientation default poUseCurrent;
  property Size: TSctPaperSize read FSize write SetSize default psUseCurrent;
  property Source: TSctPaperSource read FSource write SetSource default ppsUseCurrent;
  property Duplex: TSctPaperDuplex read FDuplex write SetDuplex default pdUseCurrent;
  property Copies: TSctPaperCopies read FCopies write SetCopies default 1;

{  property Height: Double read FHeight write SetHeight stored StoreHW;
  property Width: Double read FWidth write SetWidth stored StoreHW;}
  property Height: Double read FHeight write SetHeight stored True;
  property Width: Double read FWidth write SetWidth stored True;
  property PrintQuality: TSctPrintQuality read FPrintQuality write FPrintQuality default pqUseCurrent;
  property TrueTypeOption: TSctTrueTypeOption read FTrueTypeOption write SetTrueTypeOption default ttUseCurrent;

  property LeftMargin: Double read FLeftMargin write SetLeftMargin stored False;
  property RightMargin: Double read FRightMargin write SetRightMargin stored False;
  property TopMargin: Double read FTopMargin write SetTopMargin stored False;
  property BottomMargin: Double read FBottomMargin write SetBottomMargin stored False;

  property Color: Boolean read FColor write SetColor default True;
  property Units: TSctUnits read FUnits write SetUnits default unitInches;

  property RangeStart: Integer read FRangeStart write SetRangeStart default 0;
  property RangeEnd: Integer read FRangeEnd write SetRangeEnd default 0;

  property Destination: TSctDestination read FDestination write FDestination default destScreen;

  property AdjustMargin: Boolean read FAdjustMargin write FAdjustMargin default True;
  property PreviewSettings: TSctPreviewSettings read FPreviewSettings write FPreviewSettings;

  property TextDriverCompatibility: Boolean
                         read FTextDriverCompatibility
                         write FTextDriverCompatibility default False;
  property DirectPrinter: Boolean read FDirectPrinter write FDirectPrinter default False;
  property CollatedCopies: Boolean read FCollatedCopies write FCollatedCopies default True;

  property FormName: String read FFormName write FFormName;
end;


implementation


uses sctrep;

{ TSctPreviewSettings }
constructor TSctPreviewSettings.Create;
begin
  FModalPreview := mpDefault;
  FPreviewOwner := poDefault;
  FFormStyle := pfsDefault;
  FWindowState := wsMaximized;
  FZoom := az100;
end;

procedure TSctPreviewSettings.Assign(Source: TPersistent);
var
  ps: TSctPreviewSettings;
begin
  if Source is TSctPreviewSettings Then
  begin
    ps := TSctPreviewSettings( Source );

    FModalPreview := ps.ModalPreview;
    FPreviewOwner := ps.PreviewOwner;
    FFormStyle := ps.FormStyle;
    FWindowState := ps.WindowState;

  end else Inherited Assign(Source);
end;


function OrientDtoW(o: TSctPaperOrientation): Integer;
begin
  case O of
    poPortrait:  result := DMORIENT_PORTRAIT;
    poLandScape: result := DMORIENT_LANDSCAPE;
  else result := DMORIENT_PORTRAIT;
  end;
end;
function OrientWtoD(o: Integer): TSctPaperOrientation;
begin
  case O of
    DMORIENT_PORTRAIT:  result := poPortrait;
    DMORIENT_LANDSCAPE: result := poLandScape;
  else result := poPortrait;
  end;
end;

function PaperSizeDtoW(p: TSctPaperSize): Integer;
begin
  case p of
    psLetter      :  result := DMPAPER_LETTER     ;
    psExecutive   :  result := DMPAPER_EXECUTIVE  ;
    psLegal       :  result := DMPAPER_LEGAL      ;
    psA4          :  result := DMPAPER_A4         ;
    psCustom      :  result := DMPAPER_USER       ;
    psLETTERSMALL :  result := DMPAPER_LETTERSMALL;
    psTABLOID     :  result := DMPAPER_TABLOID    ;
    psLEDGER      :  result := DMPAPER_LEDGER     ;
    psSTATEMENT   :  result := DMPAPER_STATEMENT  ;
    psA3          :  result := DMPAPER_A3         ;
    psA4SMALL     :  result := DMPAPER_A4SMALL    ;
    psA5          :  result := DMPAPER_A5         ;
    psB4          :  result := DMPAPER_B4         ;
    psB5          :  result := DMPAPER_B5         ;
    psFOLIO       :  result := DMPAPER_FOLIO      ;
    psQUARTO      :  result := DMPAPER_QUARTO     ;
    ps10X14       :  result := DMPAPER_10X14      ;
    ps11X17       :  result := DMPAPER_11X17      ;
    psNOTE        :  result := DMPAPER_NOTE       ;
    psENV_9       :  result := DMPAPER_ENV_9      ;
    psENV_10      :  result := DMPAPER_ENV_10     ;
    psENV_11      :  result := DMPAPER_ENV_11     ;
    psENV_12      :  result := DMPAPER_ENV_12     ;
    psENV_14      :  result := DMPAPER_ENV_14     ;
    psCSHEET      :  result := DMPAPER_CSHEET     ;
    psDSHEET      :  result := DMPAPER_DSHEET     ;
    psESHEET      :  result := DMPAPER_ESHEET     ;
  else Result := DMPAPER_LETTER;
  end;
end;
function PaperSizeWtoD(p: Integer): TSctPaperSize;
begin
  case p of
    DMPAPER_LETTER:    result := psLetter;
    DMPAPER_EXECUTIVE: result := psExecutive;
    DMPAPER_LEGAL:     result := psLegal;
    DMPAPER_A4:        result := psA4;
    DMPAPER_USER:      result := psCustom;
    DMPAPER_LETTERSMALL         : result := psLETTERSMALL   ;
    DMPAPER_TABLOID             : result := psTABLOID       ;
    DMPAPER_LEDGER              : result := psLEDGER        ;
    DMPAPER_STATEMENT           : result := psSTATEMENT     ;
    DMPAPER_A3                  : result := psA3            ;
    DMPAPER_A4SMALL             : result := psA4SMALL       ;
    DMPAPER_A5                  : result := psA5            ;
    DMPAPER_B4                  : result := psB4            ;
    DMPAPER_B5                  : result := psB5            ;
    DMPAPER_FOLIO               : result := psFOLIO         ;
    DMPAPER_QUARTO              : result := psQUARTO        ;
    DMPAPER_10X14               : result := ps10X14         ;
    DMPAPER_11X17               : result := ps11X17         ;
    DMPAPER_NOTE                : result := psNOTE          ;
    DMPAPER_ENV_9               : result := psENV_9         ;
    DMPAPER_ENV_10              : result := psENV_10        ;
    DMPAPER_ENV_11              : result := psENV_11        ;
    DMPAPER_ENV_12              : result := psENV_12        ;
    DMPAPER_ENV_14              : result := psENV_14        ;
    DMPAPER_CSHEET              : result := psCSHEET        ;
    DMPAPER_DSHEET              : result := psDSHEET        ;
    DMPAPER_ESHEET              : result := psESHEET        ;
  else result := psUseCurrent;
  end;
end;

function SourceDtoW(S: TSctPaperSource): Integer;
begin
  case S of
    psUpper:          result := DMBIN_UPPER;
    psLower:          result := DMBIN_LOWER;
    psAuto:           result := DMBIN_AUTO;
    psManual:         result := DMBIN_MANUAL;
    psEnvelope:       result := DMBIN_ENVELOPE;
    psEnvelopeManual: result := DMBIN_ENVMANUAL;
    psCassette:       result := DMBIN_CASSETTE;
    psMiddle:         result := DMBIN_MIDDLE;
    psSmallFmt:       result := DMBIN_SMALLFMT;
    psLargeCapacity:  result := DMBIN_LARGECAPACITY;
    psTractor:        result := DMBIN_TRACTOR;
    psLargeFmt:       result := DMBIN_LARGEFMT;
  else result := DMBIN_AUTO;
  end;
end;

function SourceWtoD(S: Integer): TSctPaperSource;
begin
  case S of
    DMBIN_UPPER:     result := psUpper;
    DMBIN_LOWER:     result := psLower;
    DMBIN_AUTO:      result := psAuto;
    DMBIN_MANUAL:    result := psManual;
    DMBIN_ENVELOPE:  result := psEnvelope;
    DMBIN_ENVMANUAL: result := psEnvelopeManual;
    DMBIN_CASSETTE:       result := psCassette;
    DMBIN_MIDDLE:         result := psMiddle;
    DMBIN_SMALLFMT:       result := psSmallFmt;
    DMBIN_LARGECAPACITY:  result := psLargeCapacity;
    DMBIN_TRACTOR:        result := psTractor;
    DMBIN_LARGEFMT:       result := psLargeFmt;
  else result := ppsUseCurrent;
  end;
end;

⌨️ 快捷键说明

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