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.HSplit begins a horizontal (left-right) split; GPAL.VSplit begins a vertical (top-bottom) one. Controls after the call go into the first pane. GPAL.SplitRight or GPAL.SplitBottom switches to the second pane. GPAL.EndSplit closes the split and returns to the parent container.

GPALForm myForm = GPAL.Form

.WithTitle("My Form")

.WithWidth(400).WithHeight(500)

// proportional split

.WithFormControl(GPAL.HSplit(0.40))

.WithFormControl(itemList) // left pane

.WithFormControl(GPAL.SplitRight)

.WithFormControl(nameInput) // right pane

.WithFormControl(saveButton) // right pane

.WithFormControl(GPAL.EndSplit)

.WithFormControl(statusBar) // back to full-width form

.ToGPALObject();


// Fixed pixel split

GPAL.Form

.WithFormControl(GPAL.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

Tabs and splits both work through the same WithFormControl chain, so they compose naturally. A split placed inside a tab's controls goes into that tab's layout area. GPAL.EndSplit returns to the tab's full-width area, where you can keep adding controls below the split. Each EndSplit pops exactly one level, so nested splits unwind cleanly too.

static GPALTab settingsTab = (GPALTab)GPAL.Tab

.WithName("settingsTab")

.WithText("Settings")

.ToGPALObject();


GPAL.Form

.WithTitle("My Form")

.WithWidth(400).WithHeight(500)

.WithFormControl(settingsTab)

.WithFormControl(GPAL.HSplit(0.55)) // split is inside the Settings tab

.WithFormControl(engineCombo) // left pane

.WithFormControl(browserCombo) // left pane

.WithFormControl(GPAL.SplitRight)

.WithFormControl(retryCount) // right pane

.WithFormControl(schedulePicker) // right pane

.WithFormControl(GPAL.EndSplit)

.WithFormControl(progressBar) // full-width, still inside the Settings tab

.ToGPALObject();

💬 Ask GPAL