Mr Uwe
oPrn:SayText() is an improved version over earlier methods oPrn:Say(),etc., which handle only single line texts.
This method prints both single line and / or multiline text with word-wrapping depending on the size of text and size of the rectangle provided. This method is particulary intended to ease the programmers' work, by avoiding the need to break the text into individual lines and printing line by line.
Syntax:
SayText( nRow, nCol, cText, [nWidth], [nHeight], [oFont], [cAlign], [nClrText], [nClrBack] ) --> nLastRowInPixels
All coordinates are in pixels.
nWidth: It is desirable to provide nWidth parameter.
nHeight: If we do not now how much height the entire text requires to be printed, set nHeight to NIL.
cAlign: Values can be 'T','L','B','R','TL','TR','LB','BR'. Text is aligned within rectangle as specfied in the parameter. Default is TL (TopLeft)
Return Value: This method returns the Last Row in pixels used for printing the text. We can use this result to know the row from which we can continue printing the next text or images.
Here is a small sample:
- Code: Select all Expand view
#include "fivewin.ch"
func dbtest()
local oDlg, oGet, cText := ""
local oFont
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
DEFINE DIALOG oDlg SIZE 300,300 PIXEL TRUEPIXEL FONT oFont
@ 20,20 GET oGet VAR cText MEMO SIZE 260,220 PIXEL OF oDlg
@ 255,20 BUTTON "Print" SIZE 80,30 PIXEL OF oDlg ACTION PrintGet( cText, oFont )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
static function PrintGet( cText, oTextFont )
local oPrn, oFont, aPoint, nRow, nCol, nWidth
PRINT oPrn PREVIEW
DEFINE FONT oFont NAME oTextFont:cFaceName SIZE 0,-oTextFont:nHeight OF oPrn
PAGE
aPoint := oPrn:Cmtr2Pix( 2.6, 10.0 )
nRow := aPoint[ 1 ]
nCol := aPoint[ 2 ]
nRow := oPrn:SayText( nRow, nCol, cText, @nWidth, nil, oFont )
oPrn:Line( nRow, nCol, nRow, nCol + nWidth )
ENDPAGE
ENDPRINT
RELEASE FONT oFont
return nil
Note: The word wrapping of the printed text depends on the font size and width provided and may not exactly match the text in the Get. However if each line in the Get is terminated by CRLF then the printed text also honors the same CRLFs while word wrapping.