Syntax
TextSetAlign(Text, Align)
Description
Sets the vertical alignment of the text within its layout bounds (defined by TextSetHeight()).
Parameters
Text
The handle of the text object to modify.
Align
The vertical alignment mode constant.
#PG_Text_Align_Top : Aligns text to the top of the layout bounds. (Default)
#PG_Text_Align_Bottom : Aligns text to the bottom of the layout bounds.
#PG_Text_Align_Center : Centers text vertically within the layout bounds.
Return Value
This function does not return a value.
Remarks
This setting takes effect only if a layout height has been specified for the text object using TextSetHeight() or during creation, and the actual text height is less than the layout height. It controls the vertical placement of the text block within that defined height.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
Global MyText
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw)
DrawClear(RGB(240, 240, 240))
DrawBoxStroke(10,10,150,100,0) ; Draw layout bounds
DrawTxt(MyText, 10, 10, 0)
EndProcedure
MyWindow = CreateWindow(0, 0, 200, 150, "Text Alignment")
If MyWindow
MyText = CreateText("Center Me", "Arial", 14)
TextSetHeight(MyText, 100) ; Set layout height
TextSetAlign(MyText, #PG_Text_Align_Center) ; Center vertically
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, TextGetAlign, TextSetJustify, TextSetHeight
Supported OS
Windows, Linux