The code sequence below creates a graphical representation that includes the features that you mentioned
In the first block, the TEXT element displays a standard text (in this case "E5 Event"), the element TEXTBOX does not produce direct output to the drawing area, but it calculates the needed (rectangle) area for the TEXT element. The results are stored in the global variables textx1, texty1, textx2 and texty2 respectively. As these global variables will be overwritten by the element ATTRBOX in the second block, we save them in the local variables n_text1_x1, n_text1_x2, n_text1_y1, n_text1_y2 respectively.
1GRAPHREP
2SHADOW off
3FONT color: black
4
5TEXT "E5 Event" x: -0.95cm y: -0.4cm
6TEXTBOX "E5 Event" x: -0.95cm y: -0.4cm
7SET n_text1_x1: (textx1)
8SET n_text1_x2: (textx2)
9SET n_text1_y1: (texty1)
10SET n_text1_y2: (texty2)
The second block uses the elements ATTR and ATTRBOX to display the contents of the attribute "Name", calculate the needed rectangular area needed for the ATTR element and saves the results in the local variables n_text2_x1, n_text2_x2, n_text2_y1, n_text2_y2.
1ATTR "Name" x: -0.95cm y: (texty2 + 0.1cm) w:l
2ATTRBOX "Name" x: -0.95cm y: (texty2 + 0.1cm) w:l
3SET n_text2_x1: (textx1)
4SET n_text2_x2: (textx2)
5SET n_text2_y1: (texty1)
6SET n_text2_y2: (texty2)
The third block draws a rectabgle aroung the two texts displayed by the first two blocks and a line between the area needed for the TEXT element and the area needed by the ATTR element.For consistency reasons the dimensions of the rectangle are calculated as follows:
* the
x-coordinate of the upper left corner is the left-most upper-left corner of the two text areas
* the
y-coordinate of the upper-left corner is the y-coordinate of the upper-left corner of the first text area
* the
width is the difference between the right-most lower-right corner of the two text areas and the left-most upper-left corner of the two text areas
* the
height is the difference between the y-coordinate of the bottom-right corner of the second text area and the y-coordinate of the top-left corner of the first text area.
1RECTANGLE x: ( min(n_text1_x1, n_text2_x1) - 0.05cm ) y: (n_text1_y1)
2 w: (max(n_text1_x2, n_text2_x2) - min(n_text1_x1, n_text2_x1) + 0.1cm) h: (n_text2_y2 - n_text1_y1)
3LINE x1: (min(n_text1_x1, n_text2_x1) - 0.05cm ) y1: ((n_text1_y2 + n_text2_y1) / 2)
4 x2: (max(n_text1_x2, n_text2_x2) + 0.05cm) y2: ((n_text1_y2 + n_text2_y1) / 2)