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
|