TEXTBOX ​
Sets specific variables with the space (rectangular area) it would take to write a specific text.
Syntax ​
TEXTBOX strValue [ x:measureValue ] [ y:measureValue ] [ w:measureValue ] [ h:measureValue ]
[ line-break:modifier ] [ line-height:measureValue ] .
Parameters ​
<main-parameter>
(strValue) - The text for which to determine the necessary space.x
(measureValue / modifier, optional) - The x-coordinate for the position of the text. The default is0cm
.y
(measureValue / modifier, optional) - The y-coordinate for the position of the text. The default is0cm
.w
(measureValue / modifier, optional) - The horizontal alignment and the available width for the text. Possible alignments arel
,c
andr
. The default isl
and an unconstrained width.h
(measureValue / modifier, optional) - The vertical alignment and the available height for the text. Possible alignments aret
,c
andb
. The default ist
and an unconstrained height.line-break
(modifier, optional) - Setting for automatically adding line-breaks when the maximum width is reached. Possible values arewords
,rigorous
andoff
. The default isoff
.line-height
(measureValue, optional) - The height of a line, which is relevant when the text is split into multiple lines. The default is based on the used font size.
Returns ​
textx1
(measureValue) - The x-coordinate of the left margin of the text box.texty1
(measureValue) - The y-coordinate of the top margin of the text box.textx2
(measureValue) - The x-coordinate of the right margin of the text box.texty2
(measureValue) - The y-coordinate of the bottom margin of the text box.textw
(measureValue) - The width of the text box.texth
(measureValue) - The height of the text box.
Details ​
The style of this command is defined by the FONT
command.
The command does not display any text, but instead determines the space the text box will require if the text would be drawn and sets specific variables (see returns section). For details on the parameters see the TEXT
command as they work the same.
This is useful when the text box can change, either due to having a resizable notation or by using values loaded from attributes using for example the AVAL
command.
The line-orientation
of a FONT
is not properly applied to any TEXTBOX
command, so the returned values are not entirely correct.
See Also ​
Examples ​
Write a text and draw a rectangle around the text based on its size.
GRAPHREP
SHADOW off
TEXTBOX "Some more or less short text around which a rectangle will be drawn." w:c:3.6cm line-break:words
FILL color:"white"
RECTANGLE x:(textx1) y:(texty1) w:(textw) h:(texth)
# Text drawn at the end to be on top of the rectangle
TEXT "Some more or less short text around which a rectangle will be drawn." w:c:3.6cm line-break:words
Write two texts, one in seagreen and the other in crimson. The second text should start below the first text. Also a line separating the two texts is drawn.
GRAPHREP
SHADOW off
# Using SET to have the same text for both the TEXT and TEXTBOX command.
SET sText:("A value for the text that is longer than the available width")
FONT color:"seagreen"
TEXT (sText) y:-1cm w:3cm h:t line-break:words
TEXTBOX (sText) y:-1cm w:3cm h:t line-break:words
# Now the variable texty2 has the y-coordinate of the TEXT above.
FONT color:"crimson"
TEXT "Second text to write" y:(texty2 + 0.1cm) w:3cm h:t line-break:words
LINE x1:(textx1) y1:(texty2) x2:(textx2) y2:(texty2)
Versions and Changes ​
Available since ADOxx 1.3