[futurebasic] Re: [FB] Carriage Returns in Edit Field

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2002 : Group Archive : Group : All Groups

From: Ian Mann <i.mann@...>
Date: Fri, 13 Dec 2002 09:45:45 +0000
Hi Bob,

I don't know if this is what you are looking for ?

Function draws multiline text in a rect justified vertically and 
horizontally. Hope constant/variable names are self explanatory...

CLEAR LOCAL
DIM tCol.rgbcolor
DIM Rect0 as Rect
DIM Lines$(_maxTextLines)
DIM NumLines%,FontHt%,l%,tp%,w%,x%,Count%
LOCAL FN iDrawtext 
(rPtr&,a$,tColPtr&,tfnt%,tsz%,tstyl%,hjust%,vjust%,graypen%)
Rect0;8 = rPtr&
tCol;_rgbcolor = tColPtr&
LONG IF a$ <> ""
LONG COLOR tCol.blue%,tCol.green% ,tCol.red%
IF graypen% = _True THEN FN SetPattern (3) ELSE CALL PENNORMAL
TEXT  tfnt%,tsz%,tstyl%, 1
FontHt%=USR FONTHEIGHT
l% = LEN(a$)
NumLines% = 1
FOR Count% = 1 TO l%
LONG IF MID$(a$,Count%,1) = CHR$(13)
IF Lines$(NumLines%) = "" THEN  Lines$(NumLines%) = " "
INC(NumLines%)
IF NumLines% > _maxTextLines THEN Count% = l%
XELSE
Lines$(NumLines%) = Lines$(NumLines%) + MID$(a$,Count%,1)
END IF
NEXT
SELECT CASE vjust%
CASE _topJust
tp%=Rect0.top%' + FontHt%
CASE _midJust
tp%=Rect0.bottom%-((Rect0.bottom%-Rect0.top%)/2)-(FontHt%* 
NumLines%/2)-(FontHt%/4)
CASE _botJust
tp% = Rect0.bottom% - (FontHt%+1)* NumLines%
END SELECT
FOR Count% = 1 TO NumLines%
w%=FN STRINGWIDTH(Lines$(Count%))
SELECT CASE hjust%
CASE _LeftJust
x%=Rect0.left%
CASE _CenterJust
x%=Rect0.left%+((Rect0.right%-Rect0.left%)/2)-w%/2
CASE _RightJust
x%=Rect0.right%-w%
END SELECT
tp% = tp% + FontHt%' + Count% * FontHt%
CALL MOVETO(x%,tp%)
CALL DRAWSTRING(Lines$(Count%))
NEXT
CALL PENNORMAL
COLOR _zBlack
END IF
END FN

Ian