Tabular IQ

BorderBoxLayout Class

Class Index By Category

Overview

Layout class that draws a box around controls that it positions and sizes automatically.

Base Class

BoxLayout

Constructor

BorderBoxLayout()
BorderBoxLayout(orientation : Integer, text : String)

Arguments

orientation
Determines the manner in which to position and size the layout object's components, depending on whether it's Layout.Horizontal or Layout.Vertical.
text
The text to use for the BorderBoxLayout label.

Inherited Methods

BoxLayout.add
Adds a form component or another layout object to the layout object for it to position and size automatically.
BoxLayout.addSpacer
Adds a pixel size spacer to the layout object.
BoxLayout.addStretchSpacer
Adds a stretch spacer to the layout object.
BoxLayout.clear
Removes all items from the Layout object.
BoxLayout.insert
Inserts a form component or another layout object into the layout object for it to position and size automatically.
BoxLayout.insertSpacer
Inserts a pixel size spacer into the layout object.
BoxLayout.insertStretchSpacer
Inserts a stretch spacer into the layout object.
Layout.layout
Positions and sizes the contents of the layout object.
Layout.show
Shows or hides the contents of the layout object.

Example

// BorderBoxLayout is a BoxLayout that draws a labelled frame around its
// contents -- the group box from settings dialogs.  The only difference
// is the constructor:
//
//     new BorderBoxLayout(orientation, text)
//
// Leave the text off for an unlabelled frame; leave both off and the
// orientation defaults to Layout.Horizontal.

class MyForm extends Form {
    server = null;
    use_ssl = null;
    advanced = null;

    main = null;
    shown = true;

    constructor() {
        super("BorderBoxLayout Example", 100, 100, 380, 280);

        this.server = new TextBox("localhost", 0, 0, 100, 22);
        this.use_ssl = new CheckBox("Use SSL", 0, 0, 150, 20);
        this.use_ssl.setValue(true);

        // a row inside a group is an ordinary nested BoxLayout
        const row = new BoxLayout(Layout.Horizontal);
        row.add(new Label("Server:", 0, 0, 50, 18), 0, Layout.Center, 0);
        row.add(this.server, 1, Layout.Center, 0);

        const connection = new BorderBoxLayout(Layout.Vertical, "Connection");
        connection.add(row, 0, Layout.Expand | Layout.All, 6);

        this.advanced = new BorderBoxLayout(Layout.Vertical, "Advanced");
        this.advanced.add(this.use_ssl, 0, Layout.Left | Layout.All, 6);

        const button = new Button("Hide Advanced", 0, 0, 120, 24);
        button.click.connect(this, this.onToggle);

        this.main = new BoxLayout(Layout.Vertical);
        this.main.add(connection, 0, Layout.Expand | Layout.All, 8);
        this.main.add(this.advanced, 0, Layout.Expand | Layout.All, 8);
        this.main.addStretchSpacer();
        this.main.add(button, 0, Layout.Center | Layout.All, 8);

        this.setLayout(this.main);
    }

    onToggle(sender, event_args) {
        this.shown = !this.shown;

        // show() is inherited from Layout, so frame, caption and
        // contents all disappear together
        this.main.show(this.advanced, this.shown);
        this.main.layout();

        sender.setLabel(this.shown ? "Hide Advanced" : "Show Advanced");
    }
}


const form = new MyForm();
form.show();
Application.run();