Form Building

Tabs and Split Panes in GPAL Forms

Adding Tabs to a Form

Pass a GPALTab to WithFormControl and GPAL creates a tab container at that point in the layout. Controls added after it go into that tab until the next tab control is added. Pass a second GPALTab and GPAL adds a new tab to the same tab strip.

static GPALTab configTab = (GPALTab)GPAL.Tab

.WithName("configTab")

.WithText("Config")

.ToGPALObject();


static GPALTab resultsTab = (GPALTab)GPAL.Tab

.WithName("resultsTab")

.WithText("Results")

.ToGPALObject();


GPALForm myForm = GPAL.Form

.WithTitle("My Form")

.WithWidth(400).WithHeight(500)

.WithFormControl(menuBar) // above the tab strip

.WithFormControl(configTab)

.WithFormControl(urlInput) // goes into Config tab

.WithFormControl(runButton) // goes into Config tab

.WithFormControl(resultsTab)

.WithFormControl(outputArea) // goes into Results tab

.ToGPALObject();

WARNING

Be sure to add any form controls that should be available across all tabs before adding the first tab control.

Splitting a Pane Left and Right

GPAL.Splitter is a container holding two panes and the bar between them. HSplit gives a vertical bar with a left and a right pane; VSplit gives a horizontal bar with a top and a bottom. Add the controls of both panes in order with WithFormControl, and mark where the first pane ends by adding GPAL.SplitRight, or GPAL.SplitBottom for a VSplit. Everything before the marker belongs to the first pane and everything after it to the second. ToGPALObject hands back the splitter, which is then added to the form like any other control.

GPALSplitter panes = GPAL.Splitter

.HSplit(0.40) // proportional: left pane is 40% of the width

.WithFormControl(itemList) // left pane

.WithFormControl(GPAL.SplitRight) // everything after this is the right pane

.WithFormControl(nameInput)

.WithFormControl(saveButton)

.WithName("editorPanes")

.ToGPALObject();


GPALForm myForm = GPAL.Form

.WithTitle("My Form")

.WithWidth(400).WithHeight(500)

.WithFormControl(panes)

.WithFormControl(statusBar) // full width, below the split

.ToGPALObject();


// Fixed pixel split instead

GPAL.Splitter.HSplit(200);

NOTE

Pass an int to HSplit or VSplit for a fixed pixel distance. Pass a double (0.0 to 1.0) for a proportional split that recalculates automatically when the form is resized. The user can always drag the splitter bar to adjust.

Splits Inside Tabs

A splitter is a control, so it goes wherever a control goes, including inside a tab. Build it, then add it to the tab's controls. Because each splitter owns the controls of both its panes, there is nothing to close and nothing to unwind: a splitter added inside another splitter's pane nests exactly as far as you built it, and controls added to the form after the splitter sit below it at full width.

GPALSplitter settingsPanes = GPAL.Splitter

.HSplit(0.55)

.WithFormControl(engineCombo)

.WithFormControl(browserCombo)

.WithFormControl(GPAL.SplitRight)

.WithFormControl(retryCount)

.WithFormControl(schedulePicker)

.WithName("settingsPanes")

.ToGPALObject();


GPALTab settingsTab = GPAL.Tab

.WithName("settingsTab")

.WithText("Settings")

.ToGPALObject();


GPAL.Form

.WithTitle("My Form")

.WithWidth(400).WithHeight(500)

.WithFormControl(settingsTab)

.WithFormControl(settingsPanes) // inside the Settings tab

.WithFormControl(progressBar) // still inside the tab, below the split

.ToGPALObject();

💬 Ask GPAL