Syntax
TextSetWrap(Text, Wrap)
Description
Sets the word wrapping behavior for the specified text object when its content exceeds the layout width (defined by TextSetWidth()).
Parameters
Text
The handle of the text object to modify.
Wrap
The word wrapping mode constant.
#PG_Text_Wrap_None : Text does not wrap and may extend beyond the layout width. (Default)
#PG_Text_Wrap_Wrap : Text wraps at character boundaries to fit the layout width.
#PG_Text_Wrap_EmergencyBreak : Similar to Wrap, but might allow breaking mid-word if necessary (behavior depends on underlying engine).
#PG_Text_Wrap_WholeWord : Text wraps only at word boundaries (e.g., spaces).
#PG_Text_Wrap_Character : Text wraps at any character boundary (similar to Wrap).
Return Value
This function does not return a value.
Remarks
Word wrapping requires a layout width to be set using TextSetWidth() or
during creation. #PG_Text_Wrap_WholeWord typically provides the most natural wrapping for
readable text.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
Global MyText
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw)
DrawClear(RGB(240, 240, 240), 1)
DrawBoxStroke(10,10,*EventData\width-20,*EventData\height-20,0) ; Show layout bounds
TextSetWidth(MyText, *EventData\width-20)
TextSetHeight(MyText, *EventData\height-20)
DrawTxt(MyText, 10, 10, 0)
EndProcedure
MyWindow = CreateWindow(0, 0, 200, 150, "Text Layout Width")
If MyWindow
MyText = CreateText("This is a line of text that will wrap because its layout width is constrained.", "Arial", 14)
TextSetWrap(MyText, #PG_Text_Wrap_Wrap) ; Enable word wrapping
AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat: Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow
FreeText(MyText)
EndIf
StopProGUI()
See Also
CreateText, TextGetWrap, TextSetWidth, TextSetTrimming
Supported OS
Windows, Linux