Next: Texts, Previous: Starting and Ending a Form Definition, Up: Part I Defining Forms [Contents][Index]
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_BOXFL_UP_BOXFL_DOWN_BOXFL_BORDER_BOXFL_SHADOW_BOXFL_FRAME_BOXFL_ROUNDED_BOXFL_EMBOSSED_BOXFL_FLAT_BOXA flat box without a border (normally invisible unless given a different color than the surroundings)
FL_RFLAT_BOXA rounded box without a border (normally invisible unless given a different color than the surroundings)
FL_RSHADOW_BOXFL_OVAL_BOXFL_ROUNDED3D_UPBOXFL_ROUNDED3D_DOWNBOXFL_OVAL3D_UPBOXFL_OVAL3D_DOWNBOXAn 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]