The only way to output text with word wrap to to create a function to do so. Here is the type I created to do word wrapping. Sorry, but I have no time to document it, but it is simple enough so hopefully you can grasp how to use it.
Also, it has not been optimized, so it might be a little slow.
Type SString
Field word_list:TList = New TList
Field datastring:String
Field x:Int
Field y:Int
Field width:Int
Method Print(in_string:String, in_x:Int, in_y:Int, in_width:Int = 600)
datastring = in_string.trim()
x = in_x
y = in_y
width = in_width
wrap()
End Method
Method wrap()
Local current_word:String
Local x:Int
word_list = New TList
For x = 0 To (datastring.length - 1)
If datastring[x] = 32
ListAddLast(word_list, current_word)
current_word = ""
ElseIf datastring[x] = 13
ListAddLast(word_list, current_word)
current_word = ""
ListAddLast(word_list, "[br]")
Else
current_word = current_word + Chr$(datastring[x])
EndIf
Next
ListAddLast(word_list, current_word)
End Method
Method draw()
Local current_word:String
Local current_line:String
Local current_y:Int = y
Local lineheight:Int = TextHeight("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG") + (TextHeight("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG") / 4)
For current_word = EachIn word_list
If current_word = "[br]"
DrawText(current_line, x, current_y)
current_y = current_y + lineheight
current_line = ""
ElseIf ( TextWidth(current_line) + TextWidth(" ") + TextWidth(current_word) ) > width
DrawText(current_line, x, current_y)
current_y = current_y + lineheight
current_line = current_word
Else
If current_line <> ""
current_line = current_line + " " + current_word
Else
current_line = current_word
EndIf
EndIf
Next
DrawText(current_line, x, current_y)
End Method
End Type
|