Skip to content

ATTRBOX ​

Sets specific variables with the space (rectangular area) it would take to write the value of an attribute.

Syntax ​

leo-grammar
ATTRBOX strValue [ x:measureValue ] [ y:measureValue ] [ w:measureValue ] [ h:measureValue ]
    [ line-height:measureValue ] [ line-break:modifier ]
    [ text:strValue ] [ format:strValue ] [ sep:strValue ] [ row:intValue col:strValue ] .

Parameters ​

  • <main-parameter> (strValue) - The name of the attribute for whose value to determine the necessary space.
  • x (measureValue / modifier, optional) - The x-coordinate for the position of the text. The default is 0cm.
  • y (measureValue / modifier, optional) - The y-coordinate for the position of the text. The default is 0cm.
  • w (measureValue / modifier, optional) - The horizontal alignment and the available width for the text. Possible alignments are l, c and r. The default is l and an unconstrained width.
  • h (measureValue / modifier, optional) - The vertical alignment and the available height for the text. Possible alignments are t, c and b. The default is t and an unconstrained height.
  • line-break (modifier, optional) - Setting for automatically adding line-breaks when the maximum width is reached. Possible values are words, rigorous and off. The default is words.
  • 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.
  • text (strValue, optional) - A value to show instead of the attribute's value. Can be specified as an expression.
  • format (strValue, optional) - The format to use when showing Inter-model references. The default is "%o (%c) - %m (%t)"
  • sep (strValue, optional) - A text used to separate multiple Inter-model references. This text is placed between them. The default is "\n".
  • row (intValue, optional) - Used for record type attributes to show the value of a specific cell. This defines in which row the cell is located, with row numbering starting at 1.
  • col (strValue, optional) - Used for record type attributes to show the value of a specific cell. This defines the name of the column where the cell is located.

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 attribute's value would be drawn and sets specific variables (see returns section). For details on the parameters see the ATTR command as they work the same.

The line-orientation of a FONT is not properly applied to any ATTRBOX command, so the returned values are not entirely correct.

See Also ​

Examples ​

Write the object's name and draw a rectangle around the text based on its size.
A text with a rectangle drawn around it

leo
GRAPHREP
SHADOW off

ATTRBOX "Name" w:c:3.6cm line-break:words
FILL color:"white"
RECTANGLE x:(textx1) y:(texty1) w:(textw) h:(texth)
# Value drawn at the end to be on top of the rectangle
ATTR "Name" w:c:3.6cm line-break:words

Write the description of an object as a seagreen text and below it the name of the object in a crimson font. Also a line separating the two texts is drawn.
A green text and then a red text underneath it separated by a black line

leo
GRAPHREP
SHADOW off

FONT color:"seagreen"
ATTR "Description" y:-1cm w:3cm h:t line-break:words
ATTRBOX "Description" y:-1cm w:3cm h:t line-break:words
# Now the variable texty2 has the y-coordinate of the ATTR above.
FONT color:"crimson"
ATTR "Name" 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