Boxes (XForms (Forms Library) - Version 1.2 (Rev. 4) A Graphical User Interface Toolkit for X)

Next: Texts, Previous: Starting and Ending a Form Definition, Up: Part I Defining Forms [Contents][Index]

### 3.2 Boxes

The probably simplest type of objects are boxes. Boxes are used to give the forms and objects a nicer appearance. They can be used to visually group other objects together. The background of each form is a box. To add a box to a form you use the routine

    FL_OBJECT *fl_add_box(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label);

where `type` indicates the shape of the box. The Forms Library at the moment supports the following types of boxes:

`FL_NO_BOX`

  No box at all (it’s transparent), just a label

`FL_UP_BOX`

  A box that comes out of the screen

`FL_DOWN_BOX`

  A box that goes down into the screen

`FL_BORDER_BOX`

  A flat box with a border

`FL_SHADOW_BOX`

  A flat box with a shadow

`FL_FRAME_BOX`

  A flat box with an engraved frame

`FL_ROUNDED_BOX`

  A rounded box

`FL_EMBOSSED_BOX`

  A flat box with an embossed frame

`FL_FLAT_BOX`

  A flat box without a border (normally invisible unless given a different color than the surroundings)

`FL_RFLAT_BOX`

  A rounded box without a border (normally invisible unless given a different color than the surroundings)

`FL_RSHADOW_BOX`

  A rounded box with a shadow

`FL_OVAL_BOX`

  A box shaped like an ellipse

`FL_ROUNDED3D_UPBOX`

  A rounded box coming out of the screen

`FL_ROUNDED3D_DOWNBOX`

  A rounded box going into the screen

`FL_OVAL3D_UPBOX`

  An oval box coming out of the screen

`FL_OVAL3D_DOWNBOX`

  An oval box going into the screen

The arguments `x` and `y` in the call of `fl_add_box()`indicate the upper left corner of the box in the form while `w` and `h` are its width and height. `label` is a text that is placed in the center of the box. If you don’t want a label in the box use an empty string or a `NULL` pointer. The label can be either one line or multiple lines. To obtain multi-line labels, insert newline characters (`\n`) in the label string. It is also possible to underline the label or one of the characters in the label. This is accomplished by embedding `<CNTRL> H` (`\010` or `'\b'`) after the letter that needs to be underlined. If the very first character of the label is `<Ctrl>H`, the entire label is underlined.

The routine `fl_add_box()` returns a pointer to the box object. (All routines that add objects return a pointer to the object.) This pointer can be used for later references to the object.

It is possible to change the appearance of a box in a form. First of all, it is possible to change the color of the box and secondly, it is possible to change color, size and position of the label inside the box. Details on changing attributes of objects can be found in Changing Attributes. Just a simple example has to suffice here. Assume we want to create a red box, coming out of the screen with the large words "I am a Box" in green in the center:

    FL_OBJECT *thebox;

    thebox = fl_add_box(FL_UP_BOX, 20, 20, 100, 100, "I am a Box");
    fl_set_object_color(thebox, FL_RED, 0 );    /* make box red     */
    fl_set_object_lcolor(thebox, FL_GREEN );    /* make label green */
    fl_set_object_lsize(thebox, FL_LARGE_SIZE); /* make label large */

Of course, this has to be placed inside a form definition (but the functions for changing the object attributes can also used anywhere else within the program).

Next: Texts, Previous: Starting and Ending a Form Definition, Up: Part I Defining Forms [Contents][Index]