Sub-groups – Crunch CRiSP File Editor 6 User Manual

Page 64

Advertising
background image

Page 64

dialog box.

There is a solution to this, and it is called object-grouping. Object-grouping is a mechanism where you
create a collection of objects as if they were a single object. More precisely, you create a bounding rectangle
which encompasses the sub-objects, and you use the existing layout attributes to lay out the container
object.

CRiSP provides a variety of mechanisms to achieve this, mostly as a result of historical evolution, so the
different mechanisms will be described in the order they were implemented. This gives a better
understanding of when or how to use these attributes.

Conceptually, when you create a dialog box, you are creating a list, rather than a tree of objects contained in
the dialog box. This list corresponds in order to the order you create your objects in the create_object()
statement.

As CRiSP evolved, a mechanism for creating a sub-list evolved, in which instead of having a primitive object
type as the basis of the nodes in the list, a T-bar junction was created. This T-bar effectively gives rise to a
tree. The T-bar is known as a group object as it acts as a way of grouping a collection of sub-objects, for the
purposes of the layout semantics.

For example, suppose we want a layout like this:

----- -----
| A | | C |
----- | |
----- | |
| B | -----
-----

(where A, B and C represent three different objects, without different sizes). We normally would have to
layout things left to right, top to bottom. With these rules we cannot possibly layout the above set of objects.

By using the grouping, what we can do is treat objects A and B as a single object, and now what we want to
achieve is a layout of the two objects AB and C. To do this, we need to group object A and object B
together.

This is achieved by using a pair of brackets, DBOX_GROUP_START and DBOX_GROUP_END.
DBOX_GROUP_STARTs a level of grouping, and all objects declared up to the matching
DBOX_GROUP_END are treated as part of the group. Groups can be nested, so arbitrarily complex layouts
can be achieved this way. The above diagram might be implemented by doing something like:

obj_id = create_object(make_list(
...
DBOX_GROUP_START,
DBOX_BUTTON, "Object A",
DBOX_BUTTON, "Object B",
DBOX_GROUP_END,

DBOX_LIST, quote_list("object C"),
DBOX_NEXT_COLUMN, TRUE,
...));

The DBOX_GROUP_START declaration actually declares a new object, much the same way as
DBOX_BUTTON or DBOX_LIST does. (The object created is called a DBOX_CHILD object). The syntax of
the DBOX_GROUP_START and DBOX_GROUP_END words is pretty much like a set of parenthesis, so
you can nest them.

The DBOX_CHILD object created as a result of a nested grouping can have attributes associated with it in
much the same way as any other object. For example, you can center a grouping or place a grouping in the
next space in the row.

Sub-groups

The DBOX_GROUP mechanism is explicitly designed to make it possibly to achieve certain types of layouts.
By specifying DBOX_GROUP_START, you are effectively creating a new object, called a DBOX_CHILD. It
is possible to create a branch off of the current object, without creating a place-holder object
(DBOX_CHILD), by use of the attribute DBOX_SUB_GROUP_START ... DBOX_GROUP_END. A sub-

Advertising