Skip to content

glgui label wrapped

Chris Petersen edited this page Oct 16, 2014 · 1 revision

glgui-label-wrapped creates a wrapping Label widget from a string. It behaves just like glgui-label and takes the same parameters. The only difference is that this function wraps the text. It starts the text in the upper left corner and continues in rows if the string is longer, until the box is full. Other attributes of the widget that can be set after this procedure are listed below the example.

Parameter Description
g The Graphical User Interface (GUI) belonging to this widget
x The lower left corner along the x-axis in pixels
y The lower left corner along the y-axis in pixels
w The width of the element in pixels
h The height of the element in pixels
label The string for label
fnt The font used to render the label string
color The widget color
bgcolor Optional: The widget background color

Example

Example 1: Create a label to be used in a popup box,which wraps the text at appropriate positions to nicely fit into a given window.

(set! popup-text (glgui-label-wrapped gui:popup x (+ y 10) w (- h 25 12) "" ascii_16.fnt White))

Attributes

Besides the parameters set in the procedure, the widget has the following attributes that can be set using glgui-widget-set!:

Attribute Default Value Description
rounded False If true, the background rectangle has rounded corners.
aftercharcb False If set to a procedure and focus is true, then the procedure is called after each character is typed or deleted.
hidden False If true, the widget is not displayed.
direction GUI_LEFTTORIGHT If set to GUI_RIGHTTOLEFT then text is wrapped with the right end of the string on the top line and the left end on the bottom line.
password False If true, each character in the label is rendered as an *.
enableinput False If true, clicking on the label will set focus to true.
focus False If true, key events such as EVENT_KEYRELEASE and EVENT_KEYBACKSPACE change the contents of the label.
clearoninput False If true and focus is true, the next character entered while will replace the entire contents of the label and clearoninput will be set to false.
showstart False This controls which end of a label's text is visible if the content is too long for the dimensions. If true and align is GUI_ALIGNCENTER the label will show the start of the text instead of the end. If true, align is GUI_ALIGNLEFT, and focus is true, the label will show the start of the text instead of the end.
align GUI_ALIGNLEFT This controls the alignment of the text within the horizontal dimensions of the label. If set to GUI_ALIGNCENTER, the text is centered and if set to GUI_ALIGNRIGHT the text is aligned to the right.

Example

Example 2: Hides the widget popup-text that was created in Example 1.

(glgui-widget-set! gui:popup popup-text 'hidden #t)
Clone this wiki locally