Guidance
指路人
g.yi.org
software / rapidq / Examples / Devices / Printer & Parallel Port / QMarginPrinter / qmarginprinter.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'QMARGINPRINTER object

     TYPE QMARGINPRINTER EXTENDS QOBJECT
      TopMargin AS INTEGER
      BottomMargin AS INTEGER
      LeftMargin AS INTEGER
      RightMargin AS INTEGER

      LineSpacing AS INTEGER

      PositionX AS INTEGER
      PositionY AS INTEGER

      SUB BeginDoc
       Printer.BeginDoc

       This.PositionX = 0
       This.PositionY = 0
      END SUB

      SUB NewPage
       Printer.NewPage
       This.PositionX = 0
       This.PositionY = 0
      END SUB

      SUB CheckForNewPage(OutputString AS STRING)
       IF This.PositionY + Printer.TextHeight(OutputString) > (Printer.PageHeight - This.TopMargin - This.BottomMargin) THEN
        This.NewPage
        This.PositionY = 0
       END IF
      END SUB

      SUB OutputLine(OutputString AS STRING)
       DIM Position AS INTEGER

       This.CheckForNewPage(OutputString)

       This.PositionX = 0

       FOR Position = 1 TO LEN(OutputString)
        Printer.TextOut(This.LeftMargin + This.PositionX, This.TopMargin + This.PositionY, MID$(OutputString, Position, 1), Printer.Font.COLOR, -1)

        This.PositionX = This.PositionX + Printer.TextWidth(MID$(OutputString, Position, 1))

        IF This.PositionX + Printer.TextWidth(MID$(OutputString, Position + 1, 1)) > (Printer.PageWidth - This.LeftMargin - This.RightMargin) THEN
         This.PositionY = This.PositionY + Printer.TextHeight(OutputString) + This.LineSpacing
         This.PositionX = 0

         This.CheckForNewPage(OutputString)
        END IF
       NEXT Position

       IF OutputString <> "" THEN
        This.PositionY = This.PositionY + Printer.TextHeight(OutputString) + This.LineSpacing
       ELSE
        This.PositionY = This.PositionY + Printer.TextHeight(" ") + This.LineSpacing
       END IF
      END SUB

      SUB EndDoc
       Printer.EndDoc
      END SUB
     END TYPE
掌柜推荐
 
 
¥287.00 ·
 
 
¥2,600.00 ·
 
 
¥289.00 ·
 
 
¥1,370.00 ·
 
 
¥289.00 ·
 
 
¥1,480.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-12-30 09:09:01