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

📄 apfpdeng.pas

📁 Async Professional 4.07
💻 PAS
📖 第 1 页 / 共 4 页
字号:
(* ***** 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 ***** *)
{*********************************************************}
{*                   APFPDENG.PAS 4.06                   *}
{*********************************************************}

{Global defines potentially affecting this unit}
{$I AwDefine.Inc}

{$IFDEF Win32}
  !! Compile for 16-bit DLL only !!
{$ENDIF}

{$C MOVEABLE DISCARDABLE DEMANDLOAD}
{$X+,I-,T-,Q-,B-}

unit ApfPdEng;
  {- APF printer mini-driver engine (based on Bitmap sample from Win95 DDK) }

interface

uses  
  WinTypes,
  WinProcs,
  OoMisc;

{-------------------------------------------------------}
{ routines which the custom printer driver must define  }
{-------------------------------------------------------}

type
  TStartJobCallback = function (var uiData : Pointer;
                                JobDescription : PChar;
                                Filename : PChar) : Boolean;
  TEndJobCallback   = function (var uiData : Pointer;
                                JobCompletedNormally : Boolean) : Boolean;

var
  StartJobCallback : TStartJobCallback;
  EndJobCallback   : TEndJobCallback;

  ModuleName       : array[0..13] of Char;

{-------------------------------------------------------}
{ types used in functions exported to UniDrv.DLL        }
{-------------------------------------------------------}

type
  { C SDK/DDK to Pascal type equivilances }
  PPBrush             = Pointer;      { physical brush pointer }
  PPPen               = Pointer;      { physical pen pointer }
  DWord               = LongInt;
  PDWord              = ^DWord;

const
  cchFormName     = 32;
  orientPortrait  = 1;
  orientLandscape = 2;

type
  { as defined/extended in Print.H instead of WinTypes.Pas }
  PDevMode = ^TDevMode;
  TDevMode =  record
    dmDeviceName        : array[0..cchDeviceName-1] of Char;
    dmSpecVersion       : Word;
    dmDriverVersion     : Word;
    dmSize              : Word;
    dmDriverExtra       : Word;
    dmFields            : LongInt;
    dmOrientation       : Integer;
    dmPaperSize         : Integer;
    dmPaperLength       : Integer;
    dmPaperWidth        : Integer;
    dmScale             : Integer;
    dmCopies            : Integer;
    dmDefaultSource     : Integer;
    dmPrintQuality      : Integer;
    dmColor             : Integer;
    dmDuplex            : Integer;
    { additional fields (not defined in WinTypes.Pas / defined in Print.H) }
    dmYResolution       : Integer;
    dmTTOption          : Integer;
    dmCollate           : Integer;
    dmFormName          : array[0..pred(cchFormName)] of Char;
    dmLogPixels         : Word;
    dmBitsPerPel        : DWord;
    dmPelsWidth         : DWord;
    dmPelsHeight        : DWord;
    dmDisplayFlags      : DWord;
    dmDisplayFrequency  : DWord;
    dmICMMethod         : DWord;
    dmICMIntent         : DWord;
    dmMediaType         : DWord;
    dmDitherType        : DWord;
    dmReserved1         : DWord;
    dmReserved2         : DWord;
  end;

  PBitmap = ^TBitmap;
  TBitmap =
    record
      { as defined/extended in GdiDefs.Inc instead of WinTypes.Pas }
      bmType        : Integer;
      bmWidth       : Integer;
      bmHeight      : Integer;
      bmWidthBytes  : Integer;
      bmPlanes      : Byte;
      bmBitsPixel   : Byte;
      bmBits        : Pointer;
      bmWidthPlanes : DWord;    { product of bmWidthBytes and bmHeight }
      bmlpPDevice   : Pointer;  { pointer to next associated PDEVICE }
      bmSegmentIndex: Word;     { index to planes next segment (if <> 0) }
      bmScanSegment : Word;     { number of scans per segment }
      bmFillBytes   : Word;     { number of unused bytes per segment }
      futureUse4    : Word;     { reserved }
      futureUse5    : Word;     { reserved }
    end;

  pScanNode = ^tScanNode;
  tScanNode =
    record
      {used for landscape orientation only}
      ScanLines : array[1..8] of pointer;
      slIndex   : byte;
      NextNode  : pScanNode;
    end;

  PDevExt = ^TDevExt;
  TDevExt =
    record
      { our mini-driver specific extensions, pointed at by lpMD in TDev }
      cvtLastError      : Integer;
      cvtEndPageWritten : Boolean;
      cvtSomeDataWritten: Boolean;
      apfConverter      : PAbsFaxCvt;
      hAppDC            : HDC;
      IsLandscape       : Boolean;
      slDataSize        : Word;
      slBitWidth        : Word;
      FirstScanNode     : pScanNode;
      CurrentScanNode   : pScanNode;                             
      UserInstanceData  : Pointer;  { ptr to user record of instanced data }
    end;

  PDev = ^TDev;
  TDev =
    record
      iType       : Integer; { 0 iff memory bitmap, <> 0 iff our device }
      oBitmapHdr  : Integer; { pdev + oBitmapHdr points to shadow BitmapHdr }

      { unidrv never touches the following 3 words -- they are reserved for
        mini-driver use only and can be used/defined as our minidrv sees fit.}
      hMD         : THandle;
      lpMD        : PDevExt; { pointer to extended driver-specific info }
    end;

  PDrawMode = ^TDrawMode;
  TDrawMode =
    record
      Rop2              : Integer;  { 16-bit logical op }
      bkMode            : Integer;  { background mode (for text only) }
      TextColor         : DWord;    { physical background color }
      TBreakExtra       : Integer;  { total pixels to stuff into a line }
      BreakExtra        : Integer;  { TBreakExtra div BreakCount }
      BreakErr          : Integer;  { running error term }
      BreakRem          : Integer;  { TBreakExtra mod BreakCount }
      BreakCount        : Integer;  { count of breaks in the line }
      CharExtra         : Integer;  { extra pixels to stuff after each char }
      LbkColor          : DWord;    { logical background color }
      LTextColor        : DWord;    { transform for DIC image color matches }
      StretchBltMode    : Integer;  { stretch blt mode }
      eMiterLimit       : DWord;    { miter limit (single prec. IEEE float) }
    end;

  TFnOemDump = function(lpdv : PDev; lppoint : PPoint; word : Word) : Integer;
  TFnOemOutputChar = function(lpdv : PDev; lpstr : PStr; word : Word) : Integer;
  TFnEnumDFonts = function(lplogfont : PLogFont; lptextmetric : PTextMetric;
                           word : Word; lpvoid : Pointer) : Word;

  PCustomData = ^TCustomData;
  TCustomData =
    record
      cbSize          : Integer;            { size of this structure }
      hMD             : THandle;            { handle to mini-driver }
      fnOEMDump       : TFnOemDump;         { nil or pointer to OEMDump() }
      fnOEMOutputChar : TFnOemOutputChar;   { nil or pointer to OEMOutputChar() }
    end;

  PTextXForm = ^TTextXForm;
  TTextXForm =
    record
      ftHeight        : Integer;
      ftWidth         : Integer;
      ftEscapement    : Integer;
      ftOrientation   : Integer;
      ftWeight        : Integer;
      ftItalic        : Byte;
      ftUnderline     : Byte;
      ftStikeOut      : Byte;
      ftOutPrecision  : Byte;
      ftClipPrecision : Byte;
      ftAccelerator   : Word;
      ftOverhang      : Integer;
    end;

  PFontInfo = ^TFontInfo;
  TFontInfo =
    record
      dfType            : Integer;  { type field for the font }
      dfPoints          : Integer;  { point size of font }
      dfVertRes         : Integer;  { vertical digitization }
      dfHorizRes        : Integer;  { horizontal digitization }
      dfAscent          : Integer;  { baseline offset from char cell top }
      dfInternalLeading : Integer;  { internal leading included in font }
      dfExternalLeading : Integer;  { external leading included in font }
      dfItalic          : Byte;     { flag specifying if italic }
      dfUnderline       : Byte;     { flag specifying if underlined }
      dfStrikeOut       : Byte;     { flag specifying if struck out }
      dfWeight          : Integer;  { weight of font }
      dfCharSet         : Byte;     { character set of font }
      dfPixWidth        : Integer;  { width field for the font }
      dfPixHeight       : Integer;  { height field for the font }
      dfPitchAndFamily  : Byte;     { flag specifying variable pitch, family }
      dfAvgWidth        : Integer;  { average character width }
      dfMaxWidth        : Integer;  { maximum character width }
      dfFirstChar       : Byte;     { first character in the font }
      dfLastChar        : Byte;     { last character in the font }
      dfDefaultChar     : Byte;     { default character for out of range }
      dfBreakChar       : Byte;     { character to define wordbreaks }
      dfWidthBytes      : Integer;  { number of bytes in each row }
      dfDevice          : DWord;    { offset to device name }
      dfFace            : DWord;    { offset to face name }
      dfBitsPointer     : DWord;    { bits pointer }
      dfBitsOffset      : DWord;    { offset to the begining of the bitmap }
                                    { (On the disk, this is relative to the }
                                    { begining of the file. In memory this is }
                                    { relative to the begining of this struct) }
      dfReservedByte    : Byte;     { filler byte to WORD-align charoffset }
      dfCharOffset      : Word;     { area for storing the character offsets, }
                                    { facename, device name (opt), and bitmap. }
    end;

    HPropSheetPage = Pointer;
    TFnAddPropSheetPage = function(hpsp : HPropSheetPage; lparam : Longint) : WordBool;

{-------------------------------------------------------}
{ declarations for functions exported to UniDrv.DLL     }
{-------------------------------------------------------}

function  DevBitBlt(lpdv : PDev; DstxOrg : Integer; DstyOrg : Integer;
                    lpSrcDev : PBitmap; SrcxOrg : Integer; SrcyOrg : Integer;
                    xExt : Word; yExt : Word; lRop : Longint;
                    lpPBrush : PPBrush; lpDrawMode : PDrawMode) : WordBool;
                    export; {index 1}
function  ColorInfo(lpdv : PDev; ColorIn : DWord;
                    lpPhysBits : PDWord) : DWord; export; {index 2}
function  Control(lpdv : PDev; func : Word;
                  lpInData, lpOutData : Pointer) : Integer; export; {index 3}
procedure Disable(lpdv : PDev); export; {index 4}
function  Enable(lpdv : PDev; wStyle : Word; lpModel : PStr; lpPort : PStr;
                 lpStuff : PDevMode) : Integer; export; {index 5}
function  EnumDFonts(lpdv : PDev; lpFaceName : PStr;
                     lpCallbackFunc : TFnEnumDFonts;
                     lpClientData : Pointer) : Integer; export; {index 6}
function  EnumObj(lpdv : PDev; wStyle : Word; lpCallbackFunc : TFarProc;
                  lpClientData : Pointer) : Integer; export; {index 7}
function  Output(lpdv : PDev; wStyle : Word; wCount : Word; lpPoints : PPoint;
                 lpPPen : PPPen; lpPBrush : PPBrush; lpDrawMode : PDrawMode;
                 lpCR : PRect) : Integer; export; {index 8}
function  Pixel(lpdv : PDev; X, Y : Integer; Color : DWord;
                lpDrawMode : PDrawMode) : DWord; export; {index 9}
function  RealizeObject(lpdv : PDev; sStyle : Integer; lpInObj : PStr;
                        lpOutObj : PStr; lpTextXForm : PTextXForm) : DWord;
                        export; {index 10}
function  StrBlt(lpdv : PDev; X, Y : Integer; lpCR : PRect; lpStr : PStr;
                 Count : Integer; lpFontInfo : PFontInfo;
                 lpDrawMode : PDrawMode; lpXform : PTextXForm) : DWord;
                 export; {index 11}
function  ScanLR(lpdv : PDev; X, Y : Integer; Color : DWord;
                 DirStyle : Word) : Integer; export; {index 12}
procedure DeviceMode(hwnd : HWND; hInst : THandle; lpDevName : PStr;
                     lpPort : PStr); export; {index 13}
function  DevExtTextOut(lpdv : PDev; X, Y : Integer; lpCR : PRect;
                        lpStr : PStr; Count : Integer; lpFont : PFontInfo;
                        lpDrawMode : PDrawMode; lpXform : PTextXForm;
                        lpWidths : PInteger; lpOpaqRect : PRect;
                        Options : Word) : DWord; export; {index 14}
function  DevGetCharWidth(lpdv : PDev; lpBuf : PInteger; chFirst : Word;
                          chLast : Word; lpFont : PFontInfo;
                          lpDrawMode : PDrawMode;
                          lpXForm : PTextXForm) : Integer;
                          export; {index 15}
function  DeviceBitmap(lpdv : PDev; Command : Word; lpBitmap : PBitmap;
                       lpBits : PStr) : Integer; export; {index 16}
function  FastBorder(lpRect : PRect; Width : Integer; Depth : Integer;
                     lRop : Longint; lpdv : PDev; lpPBrush : PPBrush;
                     lpDrawMode : PDrawMode; lpCR : PRect) : Integer;
                     export; {index 17}
function  SetAttribute(lpdv : PDev; StateNum : Word; Index : Word;
                       Attribute : Word) : Integer; export; {index 18}
function  DIBBlt(lpBmp : PBitmap; wStyle : Word; iStart : Word; sScans : Word;
                 lpDIBits : PStr; lpBMI : PBitmapInfo;
                 lpDrawMode : PDrawMode;
                 lpConvInfo : PStr) : Integer; export; {index 19}
function  CreateDIBitmap : Integer; export; {index 20}
function  SetDIBitsToDevice(lpdv : PDev; DstXOrg, DstYOrg : Word;
                            StartScan, NumScans : Word; lpCR : PRect;
                            lpDrawMode : PDrawMode; lpDIBits : PStr;
                            lpDIBHdr : PBitmapInfoHeader;
                            lpConvInfo : PStr) : Integer; export; {index 21}
function StretchBlt(lpdv : PDev; DstX, DstY : Integer;
                    DstXE, DstYE : Integer; lpBitmaps : PBitmap;
                    SrcX, SrcY : Integer; SrcXE, SrcYE : Integer;
                    dwRop : DWord; lpbr : PPBrush; lpdm : PDrawMode;
                    lpClip : PRect) : Integer; export; {index 27}
function  StretchDIB(lpdv : PDev; wMode : Word; DstX, DstY : Integer;
                     DstXE, DstYE : Integer; SrcX, SrcY : Integer;
                     SrcXE, SrcYE : Integer; lpBits : PStr;
                     lpDIBHdr : PBitmapInfoHeader; lpConvInfo : PStr;
                     dwRop : DWord; lpbr : PPBrush; lpdm : PDrawMode;

⌨️ 快捷键说明

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