Text Object
Parents Children Properties Methods Events
Purpose: Writes text.

Description

The Text object is used to write arbitrary text. It can be used in a Form, SubForm or Group instead of a Label. The main difference is that a Label is implemented as a true window object (thus consuming Windows resources). A Text object is not a window and consumes no MS-Windows resources. However, a Label supports DragDrop events and has various useful properties that are not shared by the Text object.

The contents of the Text object are defined by its Text property. This is a character array containing one of the following :

Points is either a simple 2-column matrix of (y,x) co-ordinates, or a 2-element vector of y-coordinates and x-coordinates respectively.

There are two distinct cases:

  1. Points specifies a single point. In this case, Text may be a single scalar character, a simple vector, or a matrix containing a block of text. The result is that the character, string, or matrix is written at the specified point.
  2. Points specifies more than one point. There are three possibilities:
    1. If Text is a scalar, its contents are written at each of the points in Points. This means that by enclosing a vector or matrix, you can draw a string or block of text at several locations.
    2. If Text is a vector, each element of Text is written at the corresponding position in Points.
    3. If Text is a matrix, each row of Text is written at the corresponding position in Points.

FontObj specifies a single font to be used to write the Text. See a description of the FontObj property for details.

FCol specifies the colour of the Text. For a single text item, FCol may be a single number which specifies one of the standard MS-Windows colours, or a simple 3-element numeric vector of RGB colour intensities. If more than one text item is involved, FCol may be a vector which specifies the colour for each item separately. If so, its length must be the same as the number of points specified by Points.

BCol specifies the background colour of the text, that is, the colour for the part of the character cell that is blank. It is defined in the same way as FCol.

HAlign and VAlign specify the horizontal and vertical alignment of the text respectively. They may each be numeric scalars or vectors with the same length as the number of points specified in Points. See HAlign and VAlign for details.

When one or more of FCol, BCol, HAlign and VAlign are vectors, the different components of Text are drawn using the corresponding colours and alignments.

The value of the Dragable property specifies whether or not the Text object can be dragged by the user. The value of the AutoConf property determines whether or not the Text object is repositioned when its parent is resized.

Examples:

Write 'A' at (10,20)

      'g.t1' ⎕WC 'Text' 'A' (10 20)

Write 'h' at (10,20) in red

      'g.t1' ⎕WC 'Text' 'h' (10 20) ('FCol' 255 0 0)

Write 'Hello' at (10,20)

      'g.t1' ⎕WC 'Text' 'Hello' (10 20)
Write 'THIS IS A
       BLOCK OF
       TEXT     '   at (20,30)
      BLK←3 9⍴'THIS IS A BLOCK OF TEXT     '
      'g.t1' ⎕WC 'Text' BLK (10 20)

Write 'A' at (10,20) and at (30,40)

      'g.t1' ⎕WC 'Text' 'A' ((10 30)(20 40))

Write a red '+' at (10,20) and a green '+' at (20 40)

      'g.t1' ⎕WC 'Text' '+' ((10 30)(20 40))('FCol' (255 0 0)(0 255 0))

Write 'Hello' at (10,20) and at (30,40)

      'g.t1' ⎕WC 'Text' (⊂'Hello') ((10 30)(20 40))

Write 'A' at (10,20) and 'B' at (30,40)

      'g.t1' ⎕WC 'Text' 'AB' ((10 30)(20 40))

Write 'Hello' at (10,20) and 'World' at (30,40)

      'g.t1' ⎕WC 'Text' ('Hello' 'World')((10 30)(20 40))