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

📄 adfaxprn.pas

📁 测试用例
💻 PAS
📖 第 1 页 / 共 3 页
字号:
(***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is TurboPower Async Professional
 *
 * The Initial Developer of the Original Code is
 * TurboPower Software
 *
 * Portions created by the Initial Developer are Copyright (C) 1991-2002
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** *)

{*********************************************************}
{*                   ADFAXPRN.PAS 4.06                   *}
{*********************************************************}
{* TApdFaxPrinter component                              *}
{*********************************************************}

{
  Converts an APF file into bitmaps, then sends them to
  the printer.
  Has known problems with some video cards which render
  either black or blank pages. Updating video drivers or
  reducing hardware acceleration usually fixes it.
}

{Global defines potentially affecting this unit}
{$I AWDEFINE.INC}

{Options required for this unit}
{$G+,X+,F+}

unit AdFaxPrn;
  { Apro Fax printer component}

interface

uses
  WinTypes,
  WinProcs,
  SysUtils,
  Classes,
  Graphics,
  Forms,
  Dialogs,
  Printers,
  ooMisc,
  AdFaxCvt;

type
  { Fax Printer Log Codes }
  TFaxPLCode = (lcStart, lcFinish, lcAborted, lcFailed);

  { Fax Printer Property Types }
  TFaxPrintScale    = (psNone, psFitToPage);
  TFaxPrintProgress = (ppIdle, ppComposing, ppRendering, ppSubmitting, ppConverting);

  { Fax Printer Events }
  TFaxPrnNextPageEvent = procedure(Sender: TObject; CP, TP: Word) of object;
  TFaxPLEvent = procedure(Sender: TObject; FaxPLCode: TFaxPLCode) of object;
  TFaxPrintStatusEvent = procedure(Sender: TObject;
    StatusCode: TFaxPrintProgress) of object;
const
  { Fax Printer Log Defaults }
  afpDefFPLFileName      = 'FAXPRINT.LOG';

  { Fax Printer Margin Defaults }
  afpDefFaxHeaderCaption = 'FILE: $F';
  afpDefFaxHeaderEnabled = True;
  afpDefFaxFooterCaption = 'PAGE: $P of $N';
  afpDefFaxFooterEnabled = True;

  { Fax Printer Defaults }
  afpDefFaxPrnCaption    = 'APro Fax Printer';
  afpDefFaxPrintScale    = psFitToPage;
  afpDefFaxMultiPage     = False;

type
  TApdCustomFaxPrinter = class;

  TApdCustomFaxPrinterLog = class(TApdBaseComponent)
   protected
    { Protected declarations }
    FFaxPrinter    : TApdCustomFaxPrinter;
    FLogFileName   : String;
   public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    procedure UpdateLog(const LogCode: TFaxPLCode);

    property FaxPrinter : TApdCustomFaxPrinter
      read FFaxPrinter;
    property LogFileName : String
      read FLogFileName write FLogFileName;
  end;

  TApdCustomFaxPrinterMargin = class(TPersistent)
   protected
    { Protected declarations }
    FCaption : String;
    FEnabled : Boolean;
    FFont    : TFont;
    FHeight  : Word;
   public
    { Public declarations }
    constructor Create; virtual;
    destructor Destroy; override;
    procedure SetFont(const NewFont: TFont);

    property Caption : string
      read FCaption write FCaption;
    property Enabled : Boolean
      read FEnabled write FEnabled;
    property Font : TFont
      read FFont write SetFont;
    property Height : Word
      read FHeight write FHeight default 0;
  end;

  TApdAbstractFaxPrinterStatus = class(TApdBaseComponent)
   protected {private}
    FDisplay : TForm;
    FPosition: TPosition;
    FCtl3D   : Boolean;
    FVisible : Boolean;
    FCaption : String;                                            
   protected
    FFaxPrinter : TApdCustomFaxPrinter;
    procedure SetPosition(const Value: TPosition);
    procedure SetCtl3D(const Value: Boolean);
    procedure SetVisible(const Value: Boolean);
    procedure SetCaption(const Value: String);                     
    procedure GetProperties;
    procedure Show;

   public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure UpdateDisplay(First, Last: Boolean); virtual; abstract;
    procedure CreateDisplay; dynamic; abstract;
    procedure DestroyDisplay; dynamic; abstract;

    property Display: TForm
      read FDisplay write FDisplay;
    property FaxPrinter : TApdCustomFaxPrinter
      read FFaxPrinter;

   published
    property Position : TPosition
      read FPosition write SetPosition;
    property Ctl3D : Boolean
      read FCtl3D write SetCtl3D;
    property Visible : Boolean
      read FVisible write SetVisible;
    property Caption : String
      read FCaption write SetCaption;                            
  end;

  TApdFaxPrinterLog = class(TApdCustomFaxPrinterLog)
   published
    { Published declarations }
    property LogFileName;
  end;

  TApdFaxPrinterMargin = class(TApdCustomFaxPrinterMargin)
   published
    { Published declarations }
    property Caption;
    property Enabled;
    property Font;
  end;

  TApdCustomFaxPrinter = class(TApdBaseComponent)
  {private} public
    { Fax Filename }
    FFileName            : String;
    { Fax Page Counts }
    FTotalFaxPages       : Word;
    FCurrentPrintingPage : Word;
    FFirstPageToPrint    : Word;
    FLastPageToPrint     : Word;

    { Fax properties }
    FFaxResolution       : TFaxResolution;
    FFaxWidth            : TFaxWidth;
    FPrintScale          : TFaxPrintScale;
    FMultiPage           : Boolean;

    { Fax Print Status Dialog }
    FStatusDisplay       : TApdAbstractFaxPrinterStatus;
    FFaxPrintProgress    : TFaxPrintProgress;
    FFaxPrinterLog       : TApdFaxPrinterLog;

    { Fax Print Setup Dialog }
    FPrintDialog         : TPrintDialog;

    { Fax Unpacker }
    FFaxUnpack           : TApdFaxUnpacker;

    { page header/footer information }
    FFaxHeader           : TApdFaxPrinterMargin;
    FFaxFooter           : TApdFaxPrinterMargin;

    { fax printer events }
    FOnNextPage          : TFaxPrnNextPageEvent;
    FOnFaxPrintLog       : TFaxPLEvent;
    FOnFaxPrintStatus    : TFaxPrintStatusEvent;
  protected
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;

    procedure SetCaption(const Value: String);
    function GetCaption : String;
    procedure SetFaxFileName(const Value: String);
    procedure SetStatusDisplay(const Value: TApdAbstractFaxPrinterStatus);
    procedure SetFaxPrintLog(const Value: TApdFaxPrinterLog);

    function ReplaceHFParams(Value: String; Page: Word): String;
    procedure CreateFaxHeader(FaxCanvas : TCanvas; PN: Word; var AreaRect: TRect); virtual;
    procedure CreateFaxFooter(FaxCanvas : TCanvas; PN: Word; var AreaRect: TRect); virtual; 
    procedure SetFaxPrintProgress(const NewProgress : TFaxPrintProgress);
    procedure FaxPrintLog(LogCode: TFaxPLCode);
  public
    constructor Create(AOwner : TComponent); override;
    destructor Destroy; override;
    function PrintSetup : Boolean;                                   
    procedure PrintFax;
    procedure PrintAbort;

    { read only properties }
    property FaxWidth : TFaxWidth
      read FFaxWidth default afcDefFaxCvtWidth;                      
    property FaxResolution : TFaxResolution
      read FFaxResolution default afcDefResolution;
    property TotalFaxPages : Word
      read FTotalFaxPages default 0;
    property CurrentPrintingPage : Word
      read FCurrentPrintingPage default 0;
    property FirstPageToPrint: Word
      read FFirstPageToPrint write FFirstPageToPrint default 0;
    property LastPageToPrint : Word
      read FLastPageToPrint write FLastPageToPrint default 0;
    property PrintProgress : TFaxPrintProgress
      read FFaxPrintProgress write FFaxPrintProgress ;

  {published}
    property Caption : String
      read GetCaption write SetCaption;
    property FaxFooter : TApdFaxPrinterMargin
      read FFaxFooter write FFaxFooter;
    property FaxHeader : TApdFaxPrinterMargin
      read FFaxHeader write FFaxHeader;
    property FaxPrinterLog : TApdFaxPrinterLog
      read FFaxPrinterLog write SetFaxPrintLog;
    property FileName : String
      read FFileName write SetFaxFileName;
    property MultiPage : Boolean
      read FMultiPage write FMultiPage;
    property PrintScale : TFaxPrintScale
      read FPrintScale write FPrintScale default afpDefFaxPrintScale;
    property StatusDisplay : TApdAbstractFaxPrinterStatus
      read FStatusDisplay write SetStatusDisplay;

    property OnNextPage : TFaxPrnNextPageEvent
      read FOnNextPage write FOnNextPage;
    property OnFaxPrintLog : TFaxPLEvent
      read FOnFaxPrintLog write FOnFaxPrintLog;
    property OnFaxPrintStatus : TFaxPrintStatusEvent
      read FOnFaxPrintStatus write FOnFaxPrintStatus;
  end;

  TApdFaxPrinter = class(TApdCustomFaxPrinter)
  published
    property Caption;
    property FaxFooter;
    property FaxHeader;
    property FaxPrinterLog;
    property FileName;
    property MultiPage;
    property PrintScale;
    property StatusDisplay;

    property OnNextPage;
    property OnFaxPrintLog;
    property OnFaxPrintStatus;
  end;

implementation

{ Misc Stuff }

function SearchForDisplay(const Value: TComponent): TApdAbstractFaxPrinterStatus;

  function FindStatusDisplay(const Value: TComponent): TApdAbstractFaxPrinterStatus;
  var
    I: Integer;
  begin
    Result := nil;
    if not Assigned(Value) then
      exit;
    for I := 0 to Value.ComponentCount-1 do begin
      if Value.Components[I] is TApdAbstractFaxPrinterStatus then begin
        Result := TApdAbstractFaxPrinterStatus(Value.Components[I]);
        exit;
      end;
      Result := FindStatusDisplay(Value.Components[I]);
    end;
  end;

begin
  Result := FindStatusDisplay(Value);
end;

function SearchForPrinterLog(const Value: TComponent): TApdFaxPrinterLog;

  function FindPrinterLog(const Value: TComponent): TApdFaxPrinterLog;
  var
    I: Integer;
  begin
    Result := nil;
    if not Assigned(Value) then
      exit;
    for I := 0 to Value.ComponentCount-1 do begin
      if Value.Components[I] is TApdFaxPrinterLog then begin

⌨️ 快捷键说明

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