TextSetTrimming

Syntax

TextSetTrimming(Text, Trimming, Delimiter=#Null, DelimiterCount=#Null)

Description

Sets the method used to indicate that text has been trimmed because it exceeds the layout bounds (defined by TextSetWidth() and TextSetHeight()). Typically, this involves adding an ellipsis (...).

Parameters

Text
The handle of the text object to modify.

Trimming
The trimming mode constant.

#PG_Text_Trimming_None     : No trimming sign is added. Text is simply clipped. (Default)
#PG_Text_Trimming_Character: Trimming occurs at the character boundary closest to the edge, and an ellipsis is added.
#PG_Text_Trimming_Word     : Trimming occurs at the word boundary closest to the edge, and an ellipsis is added.

Delimiter (optional)
Reserved for future use (e.g., specifying a custom omission sign). Currently should be #Null.

DelimiterCount (optional)
Reserved for future use. Currently should be #Null.

Return Value

This function does not return a value.

Remarks

Trimming only occurs if the text content exceeds the layout bounds defined by TextSetWidth() and/or TextSetHeight(). Word trimming provides generally better readability than character trimming.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

Global MyText

Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw)
    DrawClear(RGB(240, 240, 240), 1)
    DrawBoxStroke(10,10,150,40,0) ; Show layout bounds
    DrawTxt(MyText, 10, 10, 0)
EndProcedure

MyWindow = CreateWindow(0, 0, 200, 100, "Text Trimming")

If MyWindow
    MyText = CreateText("This is a long line of text that will be trimmed.", "Arial", 14)
    TextSetWidth(MyText, 150) ; Constrain width
    TextSetHeight(MyText, 40) ; Constrain height (optional for trimming)
    TextSetTrimming(MyText, #PG_Text_Trimming_Word) ; Trim at word boundary with ellipsis

    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, TextGetTrimming, TextSetWidth, TextSetHeight, TextSetWrap

Supported OS

Windows, Linux