Sage-ST ä

Gdiprint

Documentation

Global Declarations (Constants, Types, Variables)
AbortPrinting AsciiToGdl Close
ClosestPaper EndCurrentPage GetCharWidthAndHeight GetDefaultPaperData
GetDefaultPrinterDeviceName GetDeviceError GetErrorMessage GetLogStats
GetMaxTextChars GetNextBlockLine GetNextBufferLine GetPrintInfo
GetSizeOf GetStringWidthAndHeight GetTextBGColor GetTextColor
GetTypePaperData InchesToPixels InchesToPixelsY NumDefaultPapersAvailable
OpenLog OpenPrinter OpenWindow OutputBMPFile
PaintLog PixelsToInches PixelsToInchesY PrintEllipse
PrintFilledRect PrintLine PrintLog PrintRect
PrintText PrintTextPoint PrinterSetup SetBrushKind
SetFixedFont SetFont SetMargins SetPenKind
SetStandardPaper SetTextBGColor SetTextColor SetTextJustification
SetTextRotation StartNewPage UnderlineRect ViewLog





  (*
     There are two general types of routines in this package.  One set of routines
     is used during the creating of the output report.  That output can either be
     directly sent to an HWnd or it can be logged to a special type of file with
     a .GDL extension.  That file can later be used to bring the output report
     back up for viewing or printing.  The second set of routines deals with
     handling those already existing files.
  *)

  CONST
    Arial                = "Arial";
    BookmanOldStyle      = "Courier";
    ComicSansMS          = "Comic Sans MS";
    Courier              = "Courier";
    CourierNew           = "Courier New";
    Garamond             = "Garamond";
    Impact               = "Impact";
    MSSansSerif          = "MS Sans Serif";
    Tahoma               = "Tahoma";
    TimesNewRoman        = "Times New Roman";
    DeviceNoError        = 0;
    DeviceInvalidFont    = 1;    (* invalid font requested *)
    DeviceCancel         = 2;    (* user canceled print job *)
    DeviceNoDefault      = 3;    (* no default printer defined for PC *)
    DeviceAlreadyOpen    = 4;    (* there is already a device open *)
    DeviceInvalidLog     = 5;    (* file is not a valid log *)
    DeviceLogError       = 6;    (* error writing or reading log file *)
    DeviceOldLogVersion  = 7;    (* version of the log is old or invalid *)
    DeviceInvalidRequest = 8;    (* requested item out of range, etc. *)
    DeviceInvalidPaper   = 9;    (* requested paper structure was not filled *)

    (* Color constants *)
    DarkBlue    = 8388608;     (* RGB (0, 0, 128)     Low Intensity Blue *)
    DarkGreen   = 32768;       (* RGB (0, 128, 0)     Low Intensity Green *)
    DarkRed     = 128;         (* RGB (128, 0, 0)     Low Intensity Red *)
    DarkCyan    = 8421376;     (* RGB (0, 128, 128)   Low Intensity Cyan *)
    DarkMagenta = 8388736;     (* RGB (128, 0, 128)   Low Intensity Magenta *)
    DarkYellow  = 32896;       (* RGB (128, 128, 0)   Low Intensity Yellow *)
    DarkGray    = 8421504;     (* RGB (128, 128, 128) High Intensity Black *)
    Black       = 0;           (* RGB (0, 0, 0)       Low Intensity Black *)
    Gray        = 12632256;    (* RGB (192, 192, 192) Low Intensity White *)
    Blue        = 16711680;    (* RGB (0, 0, 255)     High Intensity Blue *)
    Green       = 65280;       (* RGB (0, 255, 0)     High Intensity Green *)
    Red         = 255;         (* RGB (255, 0, 0)     High Intensity Red *)
    Cyan        = 16776960;    (* RGB (0, 255, 255)   High Intensity Cyan *)
    Magenta     = 16711935;    (* RGB (255, 0, 255)   High Intensity Magenta *)
    Yellow      = 65535;       (* RGB (255, 255, 0)   High Intensity Yellow *)
    White       = 16777215;    (* RGB (255, 255, 255) High Intensity White *)
    Default     = MAX (INTEGER);

    (* Line Thickness constants *)
    UltraThinLine   = 0.0;
    ThinLine        = 0.0125;
    UltraFineLine   = 0.025;
    FineLine        = 0.0375;
    ThinMediumLine  = 0.05;
    MediumLine      = 0.0625;
    ThickMediumLine = 0.075;
    ThickLine       = 0.0875;
    UltraThickLine  = 0.1;
    LargeLine       = 0.1125;
    UltraLargeLine  = 0.125;

    (* pen styles *)
    SolidPen       = WINGDI.PS_SOLID;
    DashPen        = WINGDI.PS_DASH;
    DotPen         = WINGDI.PS_DOT;
    DashDotPen     = WINGDI.PS_DASHDOT;
    DashDotDotPen  = WINGDI.PS_DASHDOTDOT;
    NoPen          = WINGDI.PS_NULL;
    InsideFramePen = WINGDI.PS_INSIDEFRAME;

    (* brush styles *)
    HatchedBrush = WINGDI.BS_HATCHED;
    HollowBrush  = WINGDI.BS_HOLLOW;
    SolidBrush   = WINGDI.BS_SOLID;

    (* brush hatch kinds *)
    HorzHatch              = WINGDI.HS_HORIZONTAL;
    VertHatch              = WINGDI.HS_VERTICAL;
    FDiagonalHatch         = WINGDI.HS_FDIAGONAL;
    BDiagonalHatch         = WINGDI.HS_BDIAGONAL;
    CrossHatch             = WINGDI.HS_CROSS;
    DiagonalCrossHatch     = WINGDI.HS_DIAGCROSS;
    FDiagonal1Hatch        = WINGDI.HS_FDIAGONAL1;
    BDiagonal1Hatch        = WINGDI.HS_BDIAGONAL1;
    SolidHatch             = WINGDI.HS_SOLID;
    Dense1Hatch            = WINGDI.HS_DENSE1;
    Dense2Hatch            = WINGDI.HS_DENSE2;
    Dense3Hatch            = WINGDI.HS_DENSE3;
    Dense4Hatch            = WINGDI.HS_DENSE4;
    Dense5Hatch            = WINGDI.HS_DENSE5;
    Dense6Hatch            = WINGDI.HS_DENSE6;
    Dense7Hatch            = WINGDI.HS_DENSE7;
    Dense8Hatch            = WINGDI.HS_DENSE8;
    NoShadeHatch           = WINGDI.HS_NOSHADE;
    HalfToneHatch          = WINGDI.HS_HALFTONE;
    SolidClrHatch          = WINGDI.HS_SOLIDCLR;
    DitheredColorHatch     = WINGDI.HS_DITHEREDCLR;
    SolidTextColorHatch    = WINGDI.HS_SOLIDTEXTCLR;
    DitheredTextColorHatch = WINGDI.HS_DITHEREDTEXTCLR;
    SolidBkColorHatch      = WINGDI.HS_SOLIDBKCLR;
    DitheredBkColorHatch   = WINGDI.HS_DITHEREDBKCLR;
    Api_MaxHatch           = WINGDI.HS_API_MAX;

  TYPE
    OrientationType = (Portrait,
                       Landscape);

    VertJustifyType = (TopJustify,
                       VertCenterJustify,
                       BottomJustify);

    HorzJustifyType = (LeftJustify,
                       HorzCenterJustify,
                       RightJustify);

    LineThicknessType = REAL;

    FontFormatType = (Normal,
                      Bold,
                      Underline,
                      BoldUnderline,
                      Italics,
                      BoldItalic,
                      UnderlineItalic,
                      BoldUnderlineItalic,
                      Outline,
                      BoldOutline,
                      ItalicOutline,
                      BoldItalicOutline);

    RectType = RECORD
      left   : INTEGER;
      right  : INTEGER;
      top    : INTEGER;
      bottom : INTEGER;
    END;

    PointType = RECORD
      XVal : INTEGER;
      YVal : INTEGER;
    END;

    SizeType = RECORD
      width  : INTEGER;
      height : INTEGER;
    END;

    ColorType = WIN32.COLORREF;

    PrintInfoType = RECORD
      PrinterOpen      : BOOLEAN;            (* printer has been opened *)
      pageSize         : SizeType;           (* width and height of full page area *)
      PrintableOffset  : SizeType;           (* offset of printable area from full page edge *)
      PrintableRect    : RectType;           (* rectangle of printable area *)
      MarginRect       : RectType;           (* rect of printable area minus margins *)
      XPixelsPerInch   : INTEGER;            (* # of horz. pixels per inch *)
      YPixelsPerInch   : INTEGER;            (* # of vert. pixels per inch *)
      CurrentPageCount : CARDINAL;           (* current page count *)
      HorzJustify      : HorzJustifyType;    (* horz text justification *)
      VertJustify      : VertJustifyType;    (* vert text justification *)
      AvgCharWidth     : INTEGER;            (* average character width for font *)
      CharHeight       : INTEGER;            (* character height for font *)
      FontSize         : INTEGER;            (* font size *)
      FontFormat       : FontFormatType;     (* font format *)
      CharsPerLine     : INTEGER;            (* # characters per line (only valid with fixed font) *)
      LinesPerPage     : INTEGER;            (* # lines per page (only valid with fixed font) *)
      FixedFont        : BOOLEAN;            (* font is a fixed font *)
      FontName         : ARRAY [0 .. WINGDI.LF_FACESIZE - 1] OF CHAR;
      Orientation      : OrientationType;    (* Orientation of output *)
    END;

    StandardPrintType = RECORD
      ShowPrintDialog    : BOOLEAN;
      PrinterDialogTitle : ARRAY [0 .. 99] OF CHAR;    (* Title line of Printer dialog box *)
      ShowPrintSelected  : BOOLEAN;                    (* Show the Print Selected radio button *)
      ShowPrintPageNums  : BOOLEAN;                    (* Show the Print Page Nums radio button *)
      MarkAllPages       : BOOLEAN;                    (* Select the print all button *)
      MarkSelectedPages  : BOOLEAN;                    (* Select the print selected button *)
      MarkPageNums       : BOOLEAN;                    (* Select the print pages button *)
      StartingPageNum    : CARDINAL;                   (* Starting page num to show *)
      EndingPageNum      : CARDINAL;                   (* Ending page num to show *)
      MinPageNum         : CARDINAL;                   (* Min page number to allow *)
      MaxPageNum         : CARDINAL;                   (* Max page number to allow *)
      ShowPrintToFile    : BOOLEAN;                    (* Show the Print to file check box *)
      ShowPrintProgress  : BOOLEAN;                    (* While printing show a progress dialog *)
      UserPrinted        : BOOLEAN;                    (* Was printing completed? *)
      RangePrinted       : BOOLEAN;                    (* Did user select to print a range? *)
      RangeStart         : CARDINAL;                   (* Starting page of range print. *)
      RangeEnd           : CARDINAL;                   (* Ending page of range print. *)
    END;

    ViewRecordType = RECORD
      LogFile        : SageSpec.LongPathType;       (* Name of log file.  Must end in .GDL *)
      StartPage      : CARDINAL;                    (* Page to start on *)
      Title          : ARRAY [0 .. 99] OF CHAR;     (* Title to show on window *)
      ShowTitle      : BOOLEAN;                     (* Show the title bar? *)
      ShowMinMax     : BOOLEAN;                     (* Show the min and max buttons? *)
      ShowSystemMenu : BOOLEAN;                     (* Show the system menu? (upper left) *)
      ShowMenu       : BOOLEAN;                     (* Show the menu? *)
      ShowOpenFile   : BOOLEAN;                     (* Show an Open File menu option? *)
      ShowToolbar    : BOOLEAN;                     (* Show a toolbar? *)
      ZoomPercent    : CARDINAL;                    (* Zoom setting 100 = 1x, 110 = 1.1x (zoom in), 75 = .75x (zoom out) *)
      SkipFactor     : CARDINAL;                    (* Number of records to move when using skip buttons. *)
      BackgroundBmp  : ARRAY [0 .. 255] OF CHAR;    (* Name of BMP to show in background. *)
      WindowLoc      : PointType;                   (* Window starting location - Upper left *)
      XSize          : INTEGER;                     (* X size of the window *)
      YSize          : INTEGER;                     (* Y size of the window *)
      Sizeable       : BOOLEAN;                     (* Is window sizeable *)
      StandardPrint  : StandardPrintType;           (* Standard list of printer settings. *)
      CurrentHwnd    : WIN32.HWND;                  (* Hwnd of the current window to bring back to top *)
    END;

    PrintRecordType = RECORD
      LogFile       : SageSpec.LongPathType;
      StandardPrint : StandardPrintType;    (* Standard list of printer settings. *)
    END;

    PaintRecordType = RECORD
      LogFile    : SageSpec.LongPathType;
      hWnd       : WIN32.HWND;
      MinPageNum : CARDINAL;
      MaxPageNum : CARDINAL;
      ZoomFactor : REAL;
      XShift     : INTEGER;
      YShift     : INTEGER;
      PaintRect  : RectType;
    END;

    StatsRecordType = RECORD
      DevicePageXWidth       : INTEGER;            (* Full X width device is capable of *)
      DevicePageYWidth       : INTEGER;            (* Full Y width device is capable of *)
      DevicePrintableXOffset : INTEGER;            (* Offset of Printable area from page edge *)
      DevicePrintableYOffset : INTEGER;            (* Offset of Printable area from page edge *)
      DevicePrintableXWidth  : INTEGER;            (* Printable area X width of device *)
      DevicePrintableYWidth  : INTEGER;            (* Printable area Y width of device *)
      DeviceXRes             : INTEGER;            (* Pixels per inch in X device is capable of *)
      DeviceYRes             : INTEGER;            (* Pixels per inch in Y device is capable of *)
      DeviceTopMargin        : INTEGER;            (* Pixels used for top margin *)
      DeviceBottomMargin     : INTEGER;            (* Pixels used for bottom margin *)
      DeviceLeftMargin       : INTEGER;            (* Pixels used for left margin *)
      DeviceRightMargin      : INTEGER;            (* Pixels used for right margin *)
      NumPages               : CARDINAL;           (* Number of pages in log *)
      DeviceOrientation      : OrientationType;    (* Orientation of output *)
    END;

    (*
        Use of Paper, PaperWidth and PaperHeight fields:
          Paper - a unique type that represents a paper size.  This can be set from
          the types listed in the WINGDI spec (i.e. DMPAPER_LETTER) or can be found in
          the PaperData structure returned from either the GetDefaultPaperData or
          GetTypePaperData routines.  PaperWidth - is the inch measurement of a custom
          size you are setting.  PaperHeight - is the inch measurement of a custom height
          you are setting.

          if PaperNumber is <> WINGDI.DMPAPER_FIRST and <> WINGDI.DMPAPER_USER6 then PaperWidth
          and PaperHeight are ignored.  It is assumed that you are setting a valued PaperNumber.

          if PaperNumber is WINGDI.DMPAPER_FIRST and PaperWidth = 0 and PaperHeight = 0 then
          you are telling the printer to just use whatever is the default paper set for it.

          if Paper is WINGDI.DMPAPER_USER and PaperWidth > 0.0 and PaperHeight > 0.0 then the
          assumption is that you are trying to set a custom paper size.  That value
          will be passed on the the printer as the size to use.
    *)
    PrintSettingsRecordType = RECORD
      StandardPrint : StandardPrintType;
      Paper         : CARDINAL;           (* Paper type to use.  Use WINGDI.DMPAPER_FIRST to default. *)
      PaperWidth    : REAL;               (* Width of custom paper size in inches *)
      PaperHeight   : REAL;               (* Height of custom paper size in inches *)
      Orientation   : OrientationType;    (* Orientation of output *)
    END;

    PaperRecordType = RECORD
      PaperName : ARRAY [0 .. 63] OF CHAR;    (* Name used for this paper size *)
      Paper     : CARDINAL;                   (* Type used to represent papers, see list of WINGDI.DMPAPER_ values *)
      width     : REAL;                       (* Width in inches of this paper *)
      Length    : REAL;                       (* Length in inches of this paper *)
    END;

    GDLRecordType = RECORD
      AsciiFileName       : SageSpec.LongPathType;
      GDLFileName         : SageSpec.LongPathType;
      Paper               : CARDINAL;
      PageInchWidth       : REAL;
      PageInchHeight      : REAL;
      Orientation         : OrientationType;
      TopMargin           : REAL;
      BottomMargin        : REAL;
      LeftMargin          : REAL;
      RightMargin         : REAL;
      IgnoreFirstFF       : BOOLEAN;
      showProgress        : BOOLEAN;
      ProgressTitle       : ARRAY [0 .. 39] OF CHAR;
      ShowLineSizeWarning : BOOLEAN;
      PrinterUseOnly      : BOOLEAN;
    END;

    PenStyleType = INTEGER;

    BrushStyleType = WIN32.UINT;

    BrushHatchType = WIN32.LONG;

    (*
       When declaring a variable of type GDIHandleType ALWAYS initialize
       variable to EmptyGdiHandle.   (i.e. MyHandle : GDIPrint.GDIHandleType = GDIPrint.EmptyGdiHandle;)
    *)

  TYPE
    GDIRecPtrType;

  TYPE
    GDIHandleType = RECORD
      RecPtr      : GDIRecPtrType;
      DeviceError : CARDINAL;
    END;

    (* Callback routine to give you control when print is requested inside of viewer *)
    PrintProcType = PROCEDURE (VAR PrintRecordType,    (* Record passed to PrintLog routine *)
                               VAR BOOLEAN);           (* Forced user printed setting *)

  CONST
    EmptyStandardPrint = StandardPrintType {TRUE,
                                            ASCIIX.nul,
                                            FALSE,
                                            TRUE,
                                            TRUE,
                                            FALSE,
                                            FALSE,
                                            1,
                                            MAX (WIN32.WORD),
                                            1,
                                            MAX (WIN32.WORD),
                                            TRUE,
                                            TRUE,
                                            FALSE,
                                            FALSE,
                                            0,
                                            0};
    EmptyViewRec       = ViewRecordType {ASCIIX.nul,
                                         0,
                                         ASCIIX.nul,
                                         TRUE,
                                         TRUE,
                                         FALSE,
                                         TRUE,
                                         TRUE,
                                         TRUE,
                                         100,
                                         10,
                                         ASCIIX.nul,
                                         {0,
                                          0},
                                         0,
                                         0,
                                         TRUE,
                                         EmptyStandardPrint,
                                         WINX.NULL_HWND};
    EmptyPrintRec      = PrintRecordType {ASCIIX.nul,
                                          EmptyStandardPrint};
    EmptyPaintRec      = PaintRecordType {ASCIIX.nul,
                                          WINX.NULL_HWND,
                                          1,
                                          1,
                                          1.0,
                                          0,
                                          0,
                                          {0,
                                           0,
                                           0,
                                           0}};
    EmptyPrintSettings = PrintSettingsRecordType {EmptyStandardPrint,
                                                  WINGDI.DMPAPER_LETTER,
                                                  0.0,
                                                  0.0,
                                                  Portrait};
    EmptyGDLRec        = GDLRecordType {ASCIIX.nul,
                                        ASCIIX.nul,
                                        WINGDI.DMPAPER_LETTER,
                                        0.0,
                                        0.0,
                                        Portrait,
                                        0.3,
                                        0.0,
                                        0.0,
                                        0.0,
                                        TRUE,
                                        TRUE,
                                        ASCIIX.nul,
                                        TRUE,
                                        FALSE};
    EmptyGdiHandle     = GDIHandleType {NIL,
                                        DeviceNoError};




  PROCEDURE GetDeviceError
             (VAR   GdiHandle : GDIHandleType;
              VAR   Error     : CARDINAL);

  (* returns the device error *)




  PROCEDURE GetDefaultPrinterDeviceName
             (VAR   GdiHandle  : GDIHandleType;
              VAR   DeviceName : ARRAY OF CHAR;
              VAR   PortName   : ARRAY OF CHAR;
              VAR   Success    : BOOLEAN);

  (* Return the name of the default printer or an error if one is not set. *)




  PROCEDURE GetErrorMessage
             (CONST ErrorCode : CARDINAL;
              VAR   Message   : ARRAY OF CHAR);

  (* Returns a message corresponding to the error code. *)




  PROCEDURE GetPrintInfo
             (VAR   GdiHandle : GDIHandleType;
              VAR   info      : PrintInfoType);

  (* returns the print information record *)




  PROCEDURE NumDefaultPapersAvailable
             (VAR   GdiHandle : GDIHandleType;
              VAR   NumPapers : CARDINAL);

  (* Returns the number of paper sizes available for the default printer *)




  PROCEDURE GetDefaultPaperData
             (VAR   GdiHandle : GDIHandleType;
              CONST EntryNum  : CARDINAL;
              VAR   PaperData : PaperRecordType);

  (* Get data about default printer paper.  Entries are 1 .. NumDefaultPapersAvailable *)




  PROCEDURE GetTypePaperData
             (VAR   GdiHandle : GDIHandleType;
              CONST Paper     : CARDINAL;
              VAR   PaperData : PaperRecordType);

  (* Get data about printer paper using a paper type *)




  PROCEDURE OpenPrinter
             (VAR   GdiHandle       : GDIHandleType;
              VAR   PrinterSettings : PrintSettingsRecordType;
              VAR   OpenSuccess     : BOOLEAN);

  (* opens the printer and sets up the print information *)




  PROCEDURE OpenWindow
             (VAR   GdiHandle : GDIHandleType;
              CONST hWnd      : WIN32.HWND);

  (* opens a window for output (this hWnd must must have been created and showing) *)




  PROCEDURE OpenLog
             (VAR   GdiHandle : GDIHandleType;
              CONST LogFile   : ARRAY OF CHAR;
              CONST Execute   : BOOLEAN);

  (* opens a log file for output of print commands.  LogFile must end in .GDL *)




  PROCEDURE Close
             (VAR   GdiHandle : GDIHandleType);

  (* Closes the printer and cleans up any memory (printer/window/Log *)




  PROCEDURE PrinterSetup
             (VAR   GdiHandle : GDIHandleType;
              VAR   Success   : BOOLEAN);

  (* calls the Printer setup common dialog *)




  PROCEDURE StartNewPage
             (VAR   GdiHandle : GDIHandleType);

  (* Starts a new page on the printer (not required for first page) *)




  PROCEDURE EndCurrentPage
             (VAR   GdiHandle : GDIHandleType);

  (*
     Closes the current page (allowing the printer to print out that page) and
     increments the CurrentPageCount
  *)




  PROCEDURE AbortPrinting
             (VAR   GdiHandle : GDIHandleType);

  (* aborts the print job *)




  PROCEDURE SetFont
             (VAR   GdiHandle  : GDIHandleType;
              CONST FontName   : ARRAY OF CHAR;
              CONST FontSize   : INTEGER;
              CONST FontFormat : FontFormatType);

  (* sets the current font to the new defined parameters *)




  PROCEDURE SetFixedFont
             (VAR   GdiHandle    : GDIHandleType;
              CONST CharsPerLine : INTEGER;
              CONST LinesPerPage : INTEGER;
              CONST FontFormat   : FontFormatType);




  PROCEDURE SetMargins
             (VAR   GdiHandle : GDIHandleType;
              CONST Top       : REAL;
              CONST Bottom    : REAL;
              CONST Left      : REAL;
              CONST Right     : REAL);

  (* Sets the MarginRect (uses the PageRect for default settings) *)




  PROCEDURE PixelsToInches
             (VAR   GdiHandle  : GDIHandleType;
              CONST PixelValue : INTEGER;
              VAR   InchValue  : REAL);

  (* this is based upon the XPixelsPerInch value *)




  PROCEDURE InchesToPixels
             (VAR   GdiHandle  : GDIHandleType;
              CONST InchValue  : REAL;
              VAR   PixelValue : INTEGER);

  (* this is based upon the XPixelsPerInch value *)




  PROCEDURE PixelsToInchesY
             (VAR   GdiHandle  : GDIHandleType;
              CONST PixelValue : INTEGER;
              VAR   InchValue  : REAL);

  (* this is based upon the YPixelsPerInch value *)




  PROCEDURE InchesToPixelsY
             (VAR   GdiHandle  : GDIHandleType;
              CONST InchValue  : REAL;
              VAR   PixelValue : INTEGER);

  (* this is based upon the YPixelsPerInch value *)




  PROCEDURE SetTextJustification
             (VAR   GdiHandle   : GDIHandleType;
              CONST HorzJustify : HorzJustifyType;
              CONST VertJustify : VertJustifyType);

  (* Sets the justification of where the text will be printed in a rectangle *)




  PROCEDURE SetTextRotation
             (VAR   GdiHandle : GDIHandleType;
              CONST degree    : CARDINAL);

  (* Sets the direction (rotation) of the printed text  (0 - 360) counter clockwise *)




  PROCEDURE GetTextColor
             (CONST GdiHandle : GDIHandleType) : ColorType;




  PROCEDURE GetTextBGColor
             (CONST GdiHandle : GDIHandleType) : ColorType;




  PROCEDURE SetTextColor
             (VAR   GdiHandle : GDIHandleType;
              CONST Color     : ColorType);




  PROCEDURE SetTextBGColor
             (VAR   GdiHandle : GDIHandleType;
              CONST Color     : ColorType);




  PROCEDURE PrintText
             (VAR   GdiHandle : GDIHandleType;
              CONST RECT      : RectType;
              CONST Text      : ARRAY OF CHAR);

  (*
     Prints the text in the given rectangle area in the currently
     selected font, font size, and text justification
  *)




  PROCEDURE PrintTextPoint
             (VAR   GdiHandle : GDIHandleType;
              CONST Point     : PointType;
              CONST Text      : ARRAY OF CHAR);

  (* Prints the text at the selected point using the currently selected font *)




  PROCEDURE PrintLine
             (VAR   GdiHandle : GDIHandleType;
              CONST RECT      : RectType;
              CONST thickness : LineThicknessType);

  (* Prints a line with the given rectangle points and line thickness *)




  PROCEDURE PrintEllipse
             (VAR   GdiHandle : GDIHandleType;
              CONST RECT      : RectType;
              CONST thickness : LineThicknessType);

  (* Prints an ellipse inside the given rectangle points and line thickness *)




  PROCEDURE PrintRect
             (VAR   GdiHandle : GDIHandleType;
              CONST RECT      : RectType;
              CONST thickness : LineThicknessType);

  (* Prints a rectangle with the given rectangle points and line thickness *)




  PROCEDURE PrintFilledRect
             (VAR   GdiHandle : GDIHandleType;
              CONST RECT      : RectType);

  (* Prints a rectangle with the current pen and filled with current brush *)




  PROCEDURE SetPenKind
             (VAR   GdiHandle : GDIHandleType;
              CONST penStyle  : PenStyleType;
              CONST thickness : LineThicknessType;
              CONST Color     : ColorType);

  (* Sets the current pen style (used with PrintFilledRect) *)




  PROCEDURE SetBrushKind
             (VAR   GdiHandle  : GDIHandleType;
              CONST brushStyle : BrushStyleType;
              CONST brushHatch : BrushHatchType;
              CONST Color      : ColorType);

  (* Sets the current brush style (used with PrintFilledRect) *)




  PROCEDURE GetCharWidthAndHeight
             (VAR   GdiHandle  : GDIHandleType;
              CONST ACharacter : CHAR;
              VAR   TextWidth  : INTEGER;
              VAR   TextHeight : INTEGER);

  (*
     Retrieves the width and height of a character in the current font
     and font size.
  *)




  PROCEDURE GetStringWidthAndHeight
             (VAR   GdiHandle  : GDIHandleType;
              CONST Str        : ARRAY OF CHAR;
              VAR   TextWidth  : INTEGER;
              VAR   TextHeight : INTEGER);

  (*
     Retrieves the width and height of a string in the current font
     and font size.
  *)




  PROCEDURE GetMaxTextChars
             (VAR   GdiHandle   : GDIHandleType;
              CONST Str         : ARRAY OF CHAR;
              CONST strLen      : INTEGER;
              CONST RECT        : RectType;
              VAR   numCharsFit : INTEGER);

  (*
      Retrieves the number of characters of the given string that will fit in
      the rectangle.  This is based upon the current font and font size.
  *)




  PROCEDURE OutputBMPFile
             (VAR   GdiHandle   : GDIHandleType;
              CONST bmpFileName : ARRAY OF CHAR;
              CONST rectArea    : RectType);

  (* Prints the given bitmap file in the defined rectangle. *)




  PROCEDURE ClosestPaper
             (VAR   GdiHandle     : GDIHandleType;
              CONST DesiredWidth  : REAL;
              CONST DesiredLength : REAL;
              VAR   Paper         : CARDINAL);

  (* Finds the closest paper matching the desired size. *)




  PROCEDURE SetStandardPaper;

  (* Sets the printer back to standard letter size paper 8.5 x 11.0 *)




  PROCEDURE PaintLog
             (VAR   PaintRec : PaintRecordType);

  (* Paints a portion of a log to an output device. LogFile must end in .GDL *)




  PROCEDURE ViewLog
             (VAR   ViewData  : ViewRecordType;
              CONST PrintProc : PrintProcType);

  (*
     Opens a log file for view.  This routine allows the user to view the
     data in the log in a window.  The user can choose to print the log
     while viewing.

     When this routine returns some of the values in the ViewData record have
     been updated to reflect the changes the user may have made.

     The PrintProc is called if the user decides to print from within the viewer.
     This gives you an interecept and allows you to do other things.  The two
     parameters are a PrintRec that has been set up so that if you simply want
     to let the system handle the printing for you then the following routine
     would work:

       PROCEDURE PrintCallbackProc
                  (VAR PrintRec : GDIPrint.PrintRecordType;
                   VAR ForcePrintedTrue : BOOLEAN);

       BEGIN
         GDIPrint.PrintLog (PrintRec);

       END PrintCallbackProc;


     If you wanted to do something different for printing then you can do the following:

       PROCEDURE PrintCallbackProc
                  (VAR PrintRec : GDIPrint.PrintRecordType;
                   VAR ForcePrintedTrue : BOOLEAN);

       BEGIN
         -----  whatever you want here  ----

         ---- Set the force flag to true to make the system think printing was done
         ForcePrintedTrue := TRUE;

       END PrintCallbackProc;


     Setting the ForcePrintedTrue value will cause the ViewRec that eventually comes back
     from this routine to show that printing was done.  If you call the GDIPrint.PrintLog
     routine you should NEVER set the value to true or it will override whatever the
     user actually did.
  *)




  PROCEDURE PrintLog
             (VAR   PrintData : PrintRecordType);

  (* opens a log file for printing. LogFile must end in .GDL *)




  PROCEDURE GetLogStats
             (CONST LogFile     : ARRAY OF CHAR;
              VAR   StatsRecord : StatsRecordType;
              VAR   DeviceError : CARDINAL);

  (**
      GetLogStats - Get some statistics about the log file.


      This procedure returns information about the original device that was
      opened for writing.  It also returns the number of pages present in
      the file.

      CALLING SEQUENCE -

        GetLogStats (LogFile, StatsRecord, DeviceError)

      ENTRY -

        LogFile : ARRAY OF CHAR
          The name of the file to check.  LogFile must end in .GDL

      EXIT -

        StatsRecord : StatsRecordType
          See the documentation of the record structure at top of file.

        DeviceError : CARDINAL
          Can be checked to see if an error occurred while getting the stats.
  *)




  PROCEDURE AsciiToGdl
             (CONST GDLRecord : GDLRecordType;
              VAR   Success   : BOOLEAN);

  (**
      AsciiToGdl - Converts an ASCII file to the equivalent GDL file.


      This procedure will convert an ASCII file to the equivalent GDL file.
      The GDL file can then be used to view or print the content.  To print the
      GDL file call the GDIPrint.PrintLog routine.   To use the GDL view to
      view and/or print the file call the GDIPrint.ViewLog routine.

      CALLING SEQUENCE -

        AsciiToGdl (GDLRecord, Success)

      ENTRY -

        GDLRecord : GDLRecordType
          Record containing the following fields -

        GDLRecord.AsciiFileName : ARRAY OF CHAR
          The name of a ASCII file containing the text to be converted.

        GDLRecord.GDLFileName : ARRAY OF CHAR
          The name of the file to contain the GDL commands to reproduce the
          ASCII file contents in a Windows environment.

        GDLRecord.Paper : CARDINAL
          Type type of paper to use.  Set to WINGDI.DMPAPER_USER if using a custom size.
          If and only if that value is set are the PageInchWidth and PageInchHeight
          params used.

        GDLRecord.PageInchWidth : REAL
          The width in inches of the paper this is to be placed on.

        GDLRecord.PageInchHeight : REAL
          The height in inches of the paper this is to be placed on.

        GDLRecord.Orientation : OrientationType
          Portrait - Pages will be in portrait orientation.
          Landscape - Pages will be in landscape orientation.

        GDLRecord.IgnoreFirstFF : boolean
          Some DOS style ASCII reports started the report with a FormFeed character
          to make sure that the first page was set to the top of form.  If your
          report has this and you don't set this flag you will end up with a blank
          page at the start of your report.   This flag has no effect if an ASCIIX.FF
          is not found in the first few bytes of the first line of the report.

        GDLRecord.ShowProgress : boolean
          Show a message stating that conversion is on what page.

        GDLRecord.PrinterUseOnly : BOOLEAN
          This field controls the granularity of the translation.  If going to a
          printer only then the text is converted a word (or solid line of characters)
          at a time.   However when using the viewer that can cause some items such
          as a long line of dashes to not be shown correctly, typically they will show
          as shorter in total length than they really are.   If those same dashes are
          converted a character at a time rather than as a single line then the viewer
          can show them very accurately placed on the page.  However the trade off is
          speed.  When this flag is FALSE so that the conversion is a character at a
          time it does take a bit longer and the converted file will be larger.  If
          you really are going to use the resultant file for printing only you should
          definately set this field to TRUE to gain speed on the translations.
          If you are going to the viewer you have the choice of setting this flag.
          Setting it to FALSE would be preferable in order to get a better WYSIWYG
          effect on screen.  Neither setting of this field has any effect on the final
          printed copy, only on the copy shown in the viewer.

      EXIT -

        Success : BOOLEAN
          TRUE - File was successfully converted to GDL.
          FALSE - An error prevented the files conversion.

      EXAMPLE -

        VAR
        ViewData : GDIPrint.ViewRecordType;

        BEGIN
          GDLRecord.AsciiFileName := "MyRpt.txt";
          GDLRecord.GDLFileName := "MyRpt.gdl";
          GDLRecord.Paper := GDIPrint.DMPAPER_USER;
          GDLRecord.PageInchWidth := 3.5;
          GDLRecord.PageInchHeight := 12.0;
          GDLRecord.Orientation := GDIPrint.Portrait;
          GDLRecord.TopMargin := 0.3;
          GDLRecord.BottomMargin := 0.0;
          GDLRecord.LeftMargin := 0.0;
          GDLRecord.RightMargin := 0.0;
          GDLRecord.IgnoreFirstFF := True;
          GDLRecord.ShowProgress := True;
          GDLRecord.ShowLineSizeWarning := True;
          GDLRecord.PrinterUseOnly := FALSE;

          GDIPrint.AsciiToGdl (GDLRecord,
                               Success);

          Also this routine will commonly be used in conjuction with the GDIPrint.ViewLog
          routine in order to build a Windows friendly file viewer/printer.  In order to
          view the just converted file the following code can be used to call the viewer.

          ViewData.LogFile           := "MyRpt.gdl";
          ViewData.StartPage         := 1;
          ViewData.Title             := "My Very Important Report";
          ViewData.ShowTitle         := TRUE;
          ViewData.ShowMinMax        := FALSE;
          ViewData.ShowSystemMenu    := FALSE;
          ViewData.ShowMenu          := TRUE;
          ViewData.ShowOpenFile      := FALSE;
          ViewData.ShowToolbar       := TRUE;
          ViewData.ZoomPercent       := 100;
          StringsX.InitStrToNull (
                            ViewData.BackgroundBmp);
          ViewData.WindowLoc.X       := 10;
          ViewData.WindowLoc.Y       := 10;
          ViewData.XSize             := 1024;
          ViewData.YSize             := 768;
          ViewData.Sizeable          := TRUE;
          ViewData.AllowPrintRange   := TRUE;
          ViewData.ShowPrintProgress := TRUE;
          ViewData.UserPrinted       := FALSE;

          GDIPrint.ViewLog (ViewData);

          IF (ViewData.UserPrinted) THEN
          ......
  *)




  PROCEDURE UnderlineRect
             (VAR   GdiHandle  : GDIHandleType;
              CONST SourceRect : RectType);

  (**
      UnderlineRect - Draw an underline for the given rect area.


      This procedure draws an underline in the given rect area.  This
      is useful for making text appear to be underlined.

      CALLING SEQUENCE -

        UnderlineRect (GdiHandle, SourceRect)

      ENTRY -

        GdiHandle : GDIHandleType
          A handle to the current GDI output.

        SourceRect : RectType
          A rect to use as the boundaries of the underline drawing.
  *)




  PROCEDURE GetSizeOf
             (VAR   GdiHandle : GDIHandleType;
              CONST Str       : ARRAY OF CHAR;
              VAR   StrSize   : ModSys.INT32);

  (**
      GetSizeOf - Get the width of the rect needed to contain the string.


      This procedure calculates the width needed for a rect to contain this
      text when it is drawn.

      CALLING SEQUENCE -

        GetSizeOf (GdiHandle, Str, StrSize)

      ENTRY -

        GdiHandle : GDIHandleType
          A handle to the current GDI output.

        Str : ARRAY OF CHAR
          The string to be used in the calculation.

      EXIT -

        StrSize : ModSys.INT32
          The width of a rect that will contain the given string.
  *)




  PROCEDURE GetNextBlockLine
             (VAR   GdiHandle : GDIHandleType;
              CONST Relation  : ARRAY OF CHAR;
              CONST Field     : ARRAY OF CHAR;
              CONST Reset     : BOOLEAN;
              CONST PrintRect : RectType;
              VAR   Value     : ARRAY OF CHAR;
              VAR   EndOfData : BOOLEAN);

  (**
      GetNextBlockLine - Get data for the rect from a block data field.


      This procedure gets data from a block data field using the given rect.
      The rect is used to control how much data is pulled out, in other words
      only as much data as will fit within the rect.

      CALLING SEQUENCE -

        GetNextBlockLine (GdiHandle, Relation, Field, Reset, PrintRect,
                          Value, EndOfData)

      ENTRY -

        GdiHandle : GDIHandleType
          A handle to the current GDI output.

        Relation : ARRAY OF CHAR
          The relation of the field to be used.

        Field : ARRAY OF CHAR
          The block field containing the data.

        Reset : BOOLEAN
          True - Reset and start at the first of the data again.
          False - Continue getting the data from the byte just
          past the last one read before this.

        PrintRect : RectType
          The rect that is used to contain the data.

      EXIT -

        Value : ARRAY OF CHAR
          The next string from the block data that will fit within the rect.

        EndOfData : BOOLEAN
          True - This is the last of the block data.
          False - There is more block data after this.
  *)




  PROCEDURE GetNextBufferLine
             (VAR   GdiHandle : GDIHandleType;
              CONST Buffer    : ARRAY OF CHAR;
              CONST Reset     : BOOLEAN;
              CONST PrintRect : RectType;
              VAR   Value     : ARRAY OF CHAR;
              VAR   EndOfData : BOOLEAN);

  (**
      GetNextBufferLine - Get data for the rect from a buffer.


      This procedure gets data from a buffer using the given rect.  The
      rect is used to control how much data is pulled out, in other words
      only as much data as will fit within the rect.

      CALLING SEQUENCE -

        GetNextBufferLine (GdiHandle, Buffer, Reset, PrintRect,
                           Value, EndOfData)

      ENTRY -

        GdiHandle : GDIHandleType
          A handle to the current GDI output.

        Buffer : ARRAY OF CHAR
          The buffer to be used.

        Reset : BOOLEAN
          True - Reset and start at the first of the data again.
          False - Continue getting the data from the byte just
          past the last one read before this.

        PrintRect : RectType
          The rect that is used to contain the data.

      EXIT -

        Value : ARRAY OF CHAR
          The next string from the block data that will fit within the rect.

        EndOfData : BOOLEAN
          True - This is the last of the block data.
          False - There is more block data after this.
  *)




Send mail to   warren.merrill@inl.gov with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance