## Labels

### FUNCTIONS

      Control * new_label(Window *w, Rect r, char *text, int alignment);
      Control * add_label(Control *c, Rect r, char *text, int alignment);

### CONSTANTS

      enum {
        ALIGN_LEFT     = 1,
        ALIGN_RIGHT    = 2,
        ALIGN_JUSTIFY  = 3,
        ALIGN_CENTER   = 4,
        ALIGN_CENTRE   = 4,
        VALIGN_TOP     = 8,
        VALIGN_BOTTOM  = 16,
        VALIGN_JUSTIFY = 24,
        VALIGN_CENTER  = 32,
        VALIGN_CENTRE  = 32
      };

### NOTES

The new_label function creates on the specified window a text label which cannot be edited by the user. The text string is aligned within the rectangle according to the value of the alignment parameter. Values such as ALIGN_LEFT, ALIGN_RIGHT or ALIGN_CENTER can be specified. A value of zero corresponds to ALIGN_LEFT+VALIGN_TOP.

The add_label function works in the same way as new_label, except that it attaches the label to a control rather than directly to a window.

A label does not respond to mouse or keyboard events; in fact, these events pass straight through a label to the underlying parent control or window. The initial background colour of a label is transparent, so that only the text of the label is drawn against the background of the window.

It can be seen from the list of possible text alignments above, both American and British spellings of the the word 'centre' are legal.

The horizontal alignments are:

- ALIGN_LEFT (the default) makes the text start at the left hand edge of the rectangle.
- ALIGN_RIGHT causes the text to appear at the rightmost edge of the rectangle. This is useful in fill-in forms.
- ALIGN_JUSTIFY is similar to ALIGN_LEFT, except if the text spans more than one line, in which case the spaces between words will be enlarged so each line fills the rectangle horizontally.
- ALIGN_CENTER or ALIGN_CENTRE have the effect of horizontally centering the text within the rectangle.

The vertical alignments are explained below:

- VALIGN_TOP (the default) means the label's text will be drawn starting from the top of the label's rectangle.
- VALIGN_BOTTOM draws the text so that it fills the label from the bottom of its rectangle.
- VALIGN_JUSTIFY vertically justifies the text, so the inter-line spacing will be large enough for the text to fill the label's rectangle.
- VALIGN_CENTER or VALIGN_CENTRE vertically centers the text within the label's rectangle.

Either a vertical, or a horizontal alignment can be specified, or a combination of the two, using the plus or bitwise-or operators to combine the alignments.

### EXAMPLES

- scribble.c