Documentation
¶
Overview ¶
Package forms reads and writes descriptions of Golphi forms. A document describes initial values, while application code supplies event handlers.
Index ¶
Constants ¶
const CurrentVersion = 1
CurrentVersion is the document version supported by this package.
Variables ¶
This section is empty.
Functions ¶
func IsFileDialog ¶
IsFileDialog reports whether kind names a nonvisual file dialog component.
Types ¶
type Control ¶
type Control struct {
ID string `json:"id"`
GoName string `json:"goName,omitempty"`
Kind string `json:"kind"`
Parent string `json:"parent,omitempty"`
Text string `json:"text,omitempty"`
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
Checked *bool `json:"checked,omitempty"`
Items []string `json:"items,omitempty"`
SelectedIndex *int `json:"selectedIndex,omitempty"`
Patterns []string `json:"patterns,omitempty"`
}
Control describes one component. For visual controls, Parent names a Panel by ID or is empty for the form. Bounds are relative to that parent in logical units. Items and SelectedIndex apply to ComboBox and ListBox. A nil SelectedIndex leaves the list unselected. A nil Checked means unchecked. For file dialogs, Parent is empty, bounds are zero, Text is the title, and Patterns optionally filters filenames.
type Document ¶
type Document struct {
Version int `json:"version"`
Title string `json:"title"`
Width int `json:"width"`
Height int `json:"height"`
Controls []Control `json:"controls"`
}
Document describes one form. The order of Controls is preserved when a document is saved and determines the order of siblings in the loaded form.
func (*Document) AssignGoNames ¶
AssignGoNames fills missing names with the first free names of the form KindN in document order. It retains existing names, including ones assigned to controls later in the document, and reports whether it changed the form.
func (*Document) Build ¶
Build validates and builds the form without opening a native window. It returns the form and an index of its controls by their document IDs. Callers use the concrete control types to set handlers, then call Form.Run.
func (*Document) ValidateGoNames ¶
ValidateGoNames checks that all controls can be exposed as distinct fields on a generated form. Legacy documents without names can still be read and built; use AssignGoNames before saving them for generation.