Next Previous Contents

2. Forms: Container objects

Dialog are built by creating forms which are containers. You start by creating a MainForm and then filling it with fields or sub-forms. There are various types of forms available. After having defined the field and sub-form part of a form, you must use the End directive.

2.1 Form hierarchy

There are various types of forms. Here is a graph presenting the hierarchy of forms as defined in the wxXt version of redadmin. This tree was created by looking at the diawxxt/diawxxt.h header and finding out which object are derived from the FORMBASE class. Note that the Combo object was implemented using a form, but should not be considered a form itself.

            |       |         |     |       |
        Mainform  Group     Book  Page  Formbutton

2.2 Commands to create forms

Here are the commands with the numeric code in parentheses.

(22) Book ID

Create a notebook. The notebook is a limited form. I only accept Page items.

(24) End

Terminate a form or sub-form or book.

When used to end a main form, the variable nopopup may be used to prevent the form from showing ($nopopup=1). This is mainly used when you create a framework which will be populated (using setcontext) later by other sub-form. nopopup will prevent the initial framework from showing (and potentially be mapped in a small area of your desktop, then grow outside).

Extra parameters:

(20) Form ID

This create a sub form inside the current form. A sub form counts as one component in the disposition of the current form. Using sub-form is useful to achieve some special layouts.

Extra parameters:

(31) Formbutton ID

This is a special form for button. This form will place a Fill around each button, so the buttons at the bottom of the dialog appear evenly spaced.

(19) Group ID text

This is a special sub-form which place a 3D border. The text is used to create a title embedded in the 3D border, near the top left corner. The text is optional.

(32) Groupfit ID text

A Groupfit is like a Group except that it will try to expand horizontally if there is space available.

(23) MainForm ID Title type

Create a new independent dialog (pop-up). The text will be used for the title bar. Many Mainform may be active at once.

The optional type may have the following values:

(21) Page ID text ...

Place a new sub-page to the current book. The text will be used to draw in the finger pad of the page.

2.3 Inserting something into an existing form

A dialog is built by issuing a set of nested command like this:

        Mainform id "this is the title"
            Book bookid
                Page id "page title"
                    Label "Some text"
                Form formid

Sometime, we need to add new fields or component to an existing dialog. Some application are using notebook objects to manage multiple document for example. Linuxconf is doing the same with its "treemenu" interface.

The "Setcontext" primitive jumps into a give context. For example, if we want to add a page to the dialog above, we would do

        Setcontext id.bookid
            Mainform page2 "This is the second page"
                Label "Just a label"

The Setcontext also requires a End to close the nesting. Mainform are managed in a particular way. When inserting a Mainform in a notebook the Mainform is interpreted as a Page. When inserted in some other objects (Group, Form, ...), they behave as a form and the title is not used.

The Setcontext primitive does not control the insertion position. It sets the context and everything is added to the end of the items already there.

Note that items added this way must be deleted (if needed) using the full absolute path. In the example above, the page2 item is deleted using:

        Delete id.bookid.page2

Next Previous Contents