Documentation
¶
Overview ¶
Package gowt builds native desktop windows in Go without cgo. The windows, buttons, tables and menus on screen are the operating system's own widgets: AppKit on macOS, Win32 on Windows, GTK 3 on Linux. The package is a small idiomatic layer over a Go translation of Eclipse SWT; no C compiler and no Java are needed, and the OS libraries are loaded at run time.
Hello ¶
package main
import (
"log"
"github.com/haiodo/gowt"
)
func main() {
err := gowt.Run(func(app *gowt.App) {
w := app.Window("Hello",
gowt.Label("Hello, gowt"),
gowt.Button("Quit", gowt.OnClick(app.Quit)))
w.Show()
})
if err != nil {
log.Fatal(err)
}
}
Concepts ¶
- Run owns the UI thread and the event loop. The setup function builds the windows; Run returns when the last window closes or App.Quit is called, with the error raised in setup. Errors in callbacks go to App.OnError.
- Constructors such as Label, Button and Table return an Option, a description. A description becomes a widget when it is passed to its parent: App.Window, a container, or Panel.Add. The nesting of the calls is the nesting on screen.
- Containers are VBox, HBox, Grid, Flow, Fill, Form, Pages, Tabs, Split and Scroll. Placement is options: GrowX, Span, Size, Gap, Padding.
- Everything else about a widget is an option too: events (OnClick, OnChange), initial values (Value, Checked) and bindings to state (Bind, BindText).
- State shared between widgets lives in package rx (rx.New, rx.Compute); widgets bind to it and callbacks Set it.
- Touch widgets only on the UI thread. App.Async and rx State.Post come back from a goroutine.
- Unwrap on any widget returns the underlying swt object for what the facade does not wrap.
Documentation ¶
The guide, one page and one runnable program per topic, starts at https://github.com/haiodo/gowt/blob/main/docs/README.md. The programs are in https://github.com/haiodo/gowt/tree/main/examples. The idioms on one page, for people and coding agents: https://github.com/haiodo/gowt/blob/main/docs/agents.md.
Related packages: look (window material, Liquid Glass, Mica, dark content), icons (system icons by name), rx (reactive state), webview (the system web view next to native widgets), qa and qa/qatest (driving an app from go test).
Platforms and requirements ¶
- macOS 13 or later.
- Windows 10 or later (the minimum is not verified); the manifest for visual styles and DPI awareness is linked by this package. The webview package needs the WebView2 Runtime.
- Linux: glibc (musl distributions such as Alpine are not supported), GTK 3 and a Wayland or X11 display; WebKitGTK 4.1 for webview.
- Go 1.27 or newer. Cross-compiling works from any host: GOOS=windows go build.
The SWT port ¶
Packages swt, jface and browser are the low-level port of SWT, JFace and SWT's Browser with their Java names, translated by a generator. They are for porting SWT code and for what this package does not wrap; start new programs here, not there.
Index ¶
- Constants
- Variables
- func Golden(total int) (small, large int)
- func Run(setup func(*App)) (err error)
- func Scaled(n int) int
- func SetAppName(name string)
- func SingleInstance(id string) (bool, error)
- func Watch[T any](w Widget, r rx.Reader[T], apply func(T))
- type Adaptive
- type Align
- type Answer
- type App
- func (a *App) After(d time.Duration, f func()) (cancel func())
- func (a *App) Appearance() Appearance
- func (a *App) Async(f func())
- func (a *App) AvatarImage(initials string, bg RGB, size int) *Image
- func (a *App) CircleImage(img *Image, size int) *Image
- func (a *App) Clipboard() *Clipboard
- func (a *App) Dark() bool
- func (a *App) Every(d time.Duration, f func()) (stop func())
- func (a *App) Flush()
- func (a *App) ImageFrom(r io.Reader) (img *Image, err error)
- func (a *App) ImageFromProvider(p swt.ImageDataProvider) *Image
- func (a *App) Job(name string, fn func(ctx context.Context, p *JobProgress) error, ...) *Job
- func (a *App) Jobs() []JobInfo
- func (a *App) LoadImage(path string) (img *Image, err error)
- func (a *App) OnAbout(f func()) bool
- func (a *App) OnError(f func(error))
- func (a *App) OnJobs(f func([]JobInfo))
- func (a *App) OnOpenFiles(f func(paths []string))
- func (a *App) OnPreferences(f func()) bool
- func (a *App) OnQuit(f func() bool)
- func (a *App) OnThemeChange(f func(dark bool))
- func (a *App) Pending() int
- func (a *App) Quit()
- func (a *App) ScreenSize() (width, height int)
- func (a *App) SetAppearance(m Appearance)
- func (a *App) SetBadge(text string)
- func (a *App) SetDensity(d Density)
- func (a *App) SetLinkColor(c *Adaptive)
- func (a *App) Sync(f func())
- func (a *App) SystemFont() Font
- func (a *App) Track(name string) (done func())
- func (a *App) Tray(tooltip string, onClick func()) *TrayIcon
- func (a *App) Unwrap() *swt.Display
- func (a *App) Window(title string, opts ...Option) *Window
- type Appearance
- type ButtonView
- func (b *ButtonView) Checked() bool
- func (w *ButtonView) Dispose()
- func (w *ButtonView) Enabled() bool
- func (w *ButtonView) Focus() bool
- func (b *ButtonView) OnClick(f func())
- func (w *ButtonView) OnDispose(f func())
- func (w *ButtonView) SetBackground(c Paint)
- func (b *ButtonView) SetChecked(v bool)
- func (w *ButtonView) SetEnabled(v bool)
- func (w *ButtonView) SetFont(f Font)
- func (w *ButtonView) SetForeground(c Paint)
- func (w *ButtonView) SetHeight(h int)
- func (b *ButtonView) SetImage(img *Image)
- func (w *ButtonView) SetMaxHeight(h int)
- func (w *ButtonView) SetSize(width, height int)
- func (b *ButtonView) SetText(s string)
- func (w *ButtonView) SetTooltip(s string)
- func (w *ButtonView) SetVisible(v bool)
- func (b *ButtonView) Unwrap() *swt.Button
- func (w *ButtonView) Visible() bool
- type Buttons
- type CTabsView
- func (t *CTabsView) Add(tabs ...Option)
- func (w *CTabsView) Dispose()
- func (w *CTabsView) Enabled() bool
- func (w *CTabsView) Focus() bool
- func (t *CTabsView) Index() int
- func (t *CTabsView) OnClose(f func(index int) bool)
- func (w *CTabsView) OnDispose(f func())
- func (t *CTabsView) OnSelect(f func(index int))
- func (t *CTabsView) Select(i int)
- func (w *CTabsView) SetBackground(c Paint)
- func (w *CTabsView) SetEnabled(v bool)
- func (w *CTabsView) SetFont(f Font)
- func (w *CTabsView) SetForeground(c Paint)
- func (w *CTabsView) SetHeight(h int)
- func (w *CTabsView) SetMaxHeight(h int)
- func (w *CTabsView) SetSize(width, height int)
- func (w *CTabsView) SetTooltip(s string)
- func (w *CTabsView) SetVisible(v bool)
- func (t *CTabsView) Unwrap() *swt.CTabFolder
- func (w *CTabsView) Visible() bool
- type CanvasView
- func (c *CanvasView) AddChild(opt Option) Widget
- func (w *CanvasView) Dispose()
- func (w *CanvasView) Enabled() bool
- func (w *CanvasView) Focus() bool
- func (w *CanvasView) OnDispose(f func())
- func (c *CanvasView) OnMouseDown(f func(Mouse))
- func (c *CanvasView) OnMouseMove(f func(Mouse))
- func (c *CanvasView) OnMouseUp(f func(Mouse))
- func (c *CanvasView) OnResize(f func(w, h int))
- func (c *CanvasView) Redraw()
- func (w *CanvasView) SetBackground(c Paint)
- func (c *CanvasView) SetChildBounds(child Widget, x, y, w, h int)
- func (w *CanvasView) SetEnabled(v bool)
- func (w *CanvasView) SetFont(f Font)
- func (w *CanvasView) SetForeground(c Paint)
- func (w *CanvasView) SetHeight(h int)
- func (w *CanvasView) SetMaxHeight(h int)
- func (w *CanvasView) SetSize(width, height int)
- func (w *CanvasView) SetTooltip(s string)
- func (w *CanvasView) SetVisible(v bool)
- func (c *CanvasView) Size() (w, h int)
- func (c *CanvasView) Unwrap() *swt.Canvas
- func (w *CanvasView) Visible() bool
- type Clipboard
- func (c *Clipboard) Clear()
- func (c *Clipboard) Files() []string
- func (c *Clipboard) HTML() (string, bool)
- func (c *Clipboard) Image() (img *Image, ok bool)
- func (c *Clipboard) SetFiles(paths []string) error
- func (c *Clipboard) SetHTML(html, plain string) (err error)
- func (c *Clipboard) SetImage(img *Image) error
- func (c *Clipboard) SetText(s string) error
- func (c *Clipboard) Text() (string, bool)
- func (c *Clipboard) Unwrap() *swt.Clipboard
- type Column
- type ComboView
- func (w *ComboView) Dispose()
- func (w *ComboView) Enabled() bool
- func (w *ComboView) Focus() bool
- func (c *ComboView) Index() int
- func (c *ComboView) Items() []string
- func (c *ComboView) OnChange(f func(text string))
- func (w *ComboView) OnDispose(f func())
- func (c *ComboView) OnSelect(f func(index int))
- func (c *ComboView) Select(i int)
- func (w *ComboView) SetBackground(c Paint)
- func (w *ComboView) SetEnabled(v bool)
- func (w *ComboView) SetFont(f Font)
- func (w *ComboView) SetForeground(c Paint)
- func (w *ComboView) SetHeight(h int)
- func (c *ComboView) SetItems(s []string)
- func (w *ComboView) SetMaxHeight(h int)
- func (w *ComboView) SetSize(width, height int)
- func (c *ComboView) SetText(s string)
- func (w *ComboView) SetTooltip(s string)
- func (w *ComboView) SetVisible(v bool)
- func (c *ComboView) Text() string
- func (c *ComboView) Unwrap() *swt.Combo
- func (w *ComboView) Visible() bool
- type CoolBarView
- type DateTimeView
- func (w *DateTimeView) Dispose()
- func (w *DateTimeView) Enabled() bool
- func (w *DateTimeView) Focus() bool
- func (d *DateTimeView) OnChange(f func(t time.Time))
- func (w *DateTimeView) OnDispose(f func())
- func (w *DateTimeView) SetBackground(c Paint)
- func (w *DateTimeView) SetEnabled(v bool)
- func (w *DateTimeView) SetFont(f Font)
- func (w *DateTimeView) SetForeground(c Paint)
- func (w *DateTimeView) SetHeight(h int)
- func (w *DateTimeView) SetMaxHeight(h int)
- func (w *DateTimeView) SetSize(width, height int)
- func (w *DateTimeView) SetTooltip(s string)
- func (d *DateTimeView) SetValue(t time.Time)
- func (w *DateTimeView) SetVisible(v bool)
- func (d *DateTimeView) Unwrap() *swt.DateTime
- func (d *DateTimeView) Value() time.Time
- func (w *DateTimeView) Visible() bool
- type Density
- type Drag
- type DragHandle
- type Drop
- type DropHandle
- type Edge
- type FileDialog
- type FileFilter
- type Font
- type FormCell
- type GC
- func (g *GC) FillOval(x, y, w, h int)
- func (g *GC) FillRect(x, y, w, h int)
- func (g *GC) Image(img *Image, x, y int)
- func (g *GC) Line(x1, y1, x2, y2 int)
- func (g *GC) Oval(x, y, w, h int)
- func (g *GC) Rect(x, y, w, h int)
- func (g *GC) SetColor(c RGB)
- func (g *GC) SetFill(c RGB)
- func (g *GC) SetFont(f Font)
- func (g *GC) SetLineWidth(w int)
- func (g *GC) Size() (w, h int)
- func (g *GC) Text(s string, x, y int)
- func (g *GC) TextSize(s string) (w, h int)
- func (g *GC) Unwrap() *swt.GC
- type GridCell
- type GroupView
- type Icon
- type Image
- type Job
- type JobInfo
- type JobOption
- type JobProgress
- type LabelView
- func (w *LabelView) Dispose()
- func (w *LabelView) Enabled() bool
- func (w *LabelView) Focus() bool
- func (w *LabelView) OnDispose(f func())
- func (w *LabelView) SetBackground(c Paint)
- func (w *LabelView) SetEnabled(v bool)
- func (w *LabelView) SetFont(f Font)
- func (w *LabelView) SetForeground(c Paint)
- func (w *LabelView) SetHeight(h int)
- func (l *LabelView) SetImage(img *Image)
- func (w *LabelView) SetMaxHeight(h int)
- func (w *LabelView) SetSize(width, height int)
- func (l *LabelView) SetText(s string)
- func (w *LabelView) SetTooltip(s string)
- func (w *LabelView) SetVisible(v bool)
- func (l *LabelView) Unwrap() *swt.Label
- func (w *LabelView) Visible() bool
- type LinkView
- func (w *LinkView) Dispose()
- func (w *LinkView) Enabled() bool
- func (w *LinkView) Focus() bool
- func (l *LinkView) OnClick(f func(href string))
- func (w *LinkView) OnDispose(f func())
- func (w *LinkView) SetBackground(c Paint)
- func (w *LinkView) SetEnabled(v bool)
- func (w *LinkView) SetFont(f Font)
- func (w *LinkView) SetForeground(c Paint)
- func (w *LinkView) SetHeight(h int)
- func (w *LinkView) SetMaxHeight(h int)
- func (w *LinkView) SetSize(width, height int)
- func (l *LinkView) SetText(s string)
- func (w *LinkView) SetTooltip(s string)
- func (w *LinkView) SetVisible(v bool)
- func (l *LinkView) Unwrap() *swt.Link
- func (w *LinkView) Visible() bool
- type ListView
- func (l *ListView) Add(s string)
- func (l *ListView) Clear()
- func (l *ListView) Deselect()
- func (w *ListView) Dispose()
- func (w *ListView) Enabled() bool
- func (w *ListView) Focus() bool
- func (l *ListView) Index() int
- func (l *ListView) Items() []string
- func (l *ListView) Len() int
- func (l *ListView) OnActivate(f func(index int))
- func (w *ListView) OnDispose(f func())
- func (l *ListView) OnSelect(f func(index int))
- func (l *ListView) Remove(i int)
- func (l *ListView) Select(i ...int)
- func (l *ListView) Selected() []int
- func (w *ListView) SetBackground(c Paint)
- func (w *ListView) SetEnabled(v bool)
- func (w *ListView) SetFont(f Font)
- func (w *ListView) SetForeground(c Paint)
- func (w *ListView) SetHeight(h int)
- func (l *ListView) SetItem(i int, s string)
- func (l *ListView) SetItems(s []string)
- func (w *ListView) SetMaxHeight(h int)
- func (w *ListView) SetSize(width, height int)
- func (w *ListView) SetTooltip(s string)
- func (w *ListView) SetVisible(v bool)
- func (l *ListView) Unwrap() *swt.List
- func (w *ListView) Visible() bool
- type Menu
- type MenuItem
- type Message
- type Mods
- type Mouse
- type NativeContext
- type Node
- func (n *Node) Checked() bool
- func (n *Node) Children() []*Node
- func (n *Node) Data() any
- func (n *Node) Expanded() bool
- func (n *Node) Node(text string) *Node
- func (n *Node) Remove()
- func (n *Node) SetChecked(v bool)
- func (n *Node) SetData(v any)
- func (n *Node) SetExpanded(v bool)
- func (n *Node) SetImage(img *Image)
- func (n *Node) SetImageAt(col int, img *Image)
- func (n *Node) SetText(s string)
- func (n *Node) SetTextAt(col int, s string)
- func (n *Node) Text() string
- func (n *Node) TextAt(col int) string
- func (n *Node) Unwrap() *swt.TreeItem
- type Op
- type Option
- func AccessibleLabel(s string) Option
- func Anchor(c FormCell) Option
- func AsCalendar() Option
- func AsTime() Option
- func AutoGrow(minHeight, maxHeight int) Option
- func Background(c Paint) Option
- func Bind[T string | bool | int](s *rx.State[T]) Option
- func BindEnabled(r rx.Reader[bool]) Option
- func BindText(r rx.Reader[string]) Option
- func BindVisible(r rx.Reader[bool]) Option
- func Border() Option
- func Borderless() Option
- func Bottom() Option
- func Boundary(opts ...Option) Option
- func Button(text string, opts ...Option) Option
- func CTabs(opts ...Option) Option
- func Canvas(onPaint func(g *GC), opts ...Option) Option
- func Cell(c GridCell) Option
- func CellSelect() Option
- func Center() Option
- func Check() Option
- func Checked(on bool) Option
- func Circle() Option
- func Closable() Option
- func Combo(items []string, opts ...Option) Option
- func CoolBar(opts ...Option) Option
- func Custom(f func(*swt.Control)) Option
- func DateTime(opts ...Option) Option
- func Destructive() Option
- func Disabled() Option
- func DropDown() Option
- func Failed(f func(err error, reset func()) Option) Option
- func Field(label string, control Option, opts ...Option) Option
- func FieldTop() Option
- func Fields(opts ...Option) Option
- func Fill(opts ...Option) Option
- func Fit() Option
- func Flat() Option
- func Flow(opts ...Option) Option
- func Focused() Option
- func Foreground(c Paint) Option
- func Form(opts ...Option) Option
- func Gap(points int) Option
- func Grid(columns int, opts ...Option) Option
- func Group(title string, opts ...Option) Option
- func Grow() Option
- func GrowX() Option
- func GrowY() Option
- func HBox(opts ...Option) Option
- func Hint(s string) Option
- func ID(id string) Option
- func Indent(x, y int) Option
- func Indeterminate() Option
- func Init[T Widget](f func(T)) Option
- func Inset(x, y int) Option
- func Items(list rx.Reader[[]string]) Option
- func Label(text string, opts ...Option) Option
- func LineNumbers() Option
- func Link(text string, opts ...Option) Option
- func List(items []string, opts ...Option) Option
- func MaxHeight(h int) Option
- func MultiSelect() Option
- func Multiline() Option
- func NoBorder() Option
- func Nodes[T, K comparable](list rx.Reader[[]T], key func(T) K, children func(T) []T, ...) Option
- func OnActivate[F func() | func(int) | func(*Node)](f F) Option
- func OnChange[F func(string) | func(bool) | func(int) | func(time.Time)](f F) Option
- func OnClick[F func() | func(string)](f F) Option
- func OnFocus(f func(focused bool)) Option
- func OnSelect[F func(int) | func(*Node)](f F) Option
- func Padding(points int) Option
- func Pages(opts ...Option) Option
- func Password() Option
- func Place(h, v Align) Option
- func Primary() Option
- func Progress(max int, opts ...Option) Option
- func Radio() Option
- func ReadOnly() Option
- func Ref[T Widget](p *T) Option
- func Right() Option
- func Rows[T, K comparable](list rx.Reader[[]T], key func(T) K, fill func(r *TableRow, item T)) Option
- func Sash(opts ...Option) Option
- func Scale(min, max int, opts ...Option) Option
- func Scroll(opts ...Option) Option
- func Scrollbars() Option
- func Search() Option
- func Section(opts ...Option) Option
- func Selected(i int) Option
- func Separator(opts ...Option) Option
- func Shortcut(keys string) Option
- func Simple() Option
- func Size(w, h int) Option
- func Slider(min, max int, opts ...Option) Option
- func Smooth() Option
- func Spacer(opts ...Option) Option
- func Span(cols int) Option
- func Spinner(min, max int, opts ...Option) Option
- func Split(opts ...Option) Option
- func StyledText(opts ...Option) Option
- func Switch(text string, opts ...Option) Option
- func Tab(title string, opts ...Option) Option
- func Table(opts ...Option) Option
- func Tabs(opts ...Option) Option
- func Text(opts ...Option) Option
- func ToolBar(opts ...Option) Option
- func Tooltip(s string) Option
- func Tree(opts ...Option) Option
- func Typeface(f Font) Option
- func VBox(opts ...Option) Option
- func Value[T string | int | time.Time](v T) Option
- func Vertical() Option
- func Wrap() Option
- type PagesView
- func (g *PagesView) Add(pages ...Option)
- func (g *PagesView) AsComposite() *swt.Composite
- func (g *PagesView) Current() int
- func (w *PagesView) Dispose()
- func (w *PagesView) Enabled() bool
- func (w *PagesView) Focus() bool
- func (w *PagesView) OnDispose(f func())
- func (w *PagesView) SetBackground(c Paint)
- func (w *PagesView) SetEnabled(v bool)
- func (w *PagesView) SetFont(f Font)
- func (w *PagesView) SetForeground(c Paint)
- func (w *PagesView) SetHeight(h int)
- func (w *PagesView) SetMaxHeight(h int)
- func (w *PagesView) SetSize(width, height int)
- func (w *PagesView) SetTooltip(s string)
- func (w *PagesView) SetVisible(v bool)
- func (g *PagesView) Show(i int)
- func (g *PagesView) Unwrap() *swt.Composite
- func (w *PagesView) Visible() bool
- type Paint
- type Panel
- type Popover
- func (p Popover) Add(children ...Option)
- func (p Popover) AsComposite() *swt.Composite
- func (p Popover) Clear()
- func (p *Popover) Close()
- func (p *Popover) Dispose()
- func (p *Popover) OnClose(f func())
- func (p *Popover) OnEscape(f func() bool)
- func (p Popover) Relayout()
- func (p *Popover) SetSize(width, height int)
- func (p *Popover) ShowAt(anchor Widget, edge PopoverEdge)
- func (p *Popover) ShowAtPoint(anchor Widget, x, y int, edge PopoverEdge)
- func (p *Popover) Shown() bool
- func (p *Popover) Unwrap() *swt.Shell
- type PopoverEdge
- type PrintArea
- type PrintJob
- type PrintOptions
- type PrintPage
- type ProgressView
- func (w *ProgressView) Dispose()
- func (w *ProgressView) Enabled() bool
- func (w *ProgressView) Focus() bool
- func (w *ProgressView) OnDispose(f func())
- func (w *ProgressView) SetBackground(c Paint)
- func (w *ProgressView) SetEnabled(v bool)
- func (w *ProgressView) SetFont(f Font)
- func (w *ProgressView) SetForeground(c Paint)
- func (w *ProgressView) SetHeight(h int)
- func (p *ProgressView) SetMax(v int)
- func (w *ProgressView) SetMaxHeight(h int)
- func (w *ProgressView) SetSize(width, height int)
- func (w *ProgressView) SetTooltip(s string)
- func (p *ProgressView) SetValue(v int)
- func (w *ProgressView) SetVisible(v bool)
- func (p *ProgressView) Unwrap() *swt.ProgressBar
- func (p *ProgressView) Value() int
- func (w *ProgressView) Visible() bool
- type RGB
- type SashView
- func (w *SashView) Dispose()
- func (w *SashView) Enabled() bool
- func (w *SashView) Focus() bool
- func (w *SashView) OnDispose(f func())
- func (s *SashView) OnMove(f func(x, y int))
- func (w *SashView) SetBackground(c Paint)
- func (w *SashView) SetEnabled(v bool)
- func (w *SashView) SetFont(f Font)
- func (w *SashView) SetForeground(c Paint)
- func (w *SashView) SetHeight(h int)
- func (w *SashView) SetMaxHeight(h int)
- func (w *SashView) SetSize(width, height int)
- func (w *SashView) SetTooltip(s string)
- func (w *SashView) SetVisible(v bool)
- func (s *SashView) Unwrap() *swt.Sash
- func (w *SashView) Visible() bool
- type ScaleView
- func (w *ScaleView) Dispose()
- func (w *ScaleView) Enabled() bool
- func (w *ScaleView) Focus() bool
- func (s *ScaleView) OnChange(f func(value int))
- func (w *ScaleView) OnDispose(f func())
- func (w *ScaleView) SetBackground(c Paint)
- func (w *ScaleView) SetEnabled(v bool)
- func (w *ScaleView) SetFont(f Font)
- func (w *ScaleView) SetForeground(c Paint)
- func (w *ScaleView) SetHeight(h int)
- func (w *ScaleView) SetMaxHeight(h int)
- func (w *ScaleView) SetSize(width, height int)
- func (w *ScaleView) SetTooltip(s string)
- func (s *ScaleView) SetValue(v int)
- func (w *ScaleView) SetVisible(v bool)
- func (s *ScaleView) Unwrap() *swt.Scale
- func (s *ScaleView) Value() int
- func (w *ScaleView) Visible() bool
- type ScrollView
- func (s *ScrollView) Add(children ...Option)
- func (s *ScrollView) Content() *Panel
- func (w *ScrollView) Dispose()
- func (w *ScrollView) Enabled() bool
- func (s *ScrollView) Fit()
- func (w *ScrollView) Focus() bool
- func (w *ScrollView) OnDispose(f func())
- func (s *ScrollView) OnScroll(f func(x, y int))
- func (s *ScrollView) Origin() (x, y int)
- func (w *ScrollView) SetBackground(c Paint)
- func (w *ScrollView) SetEnabled(v bool)
- func (w *ScrollView) SetFont(f Font)
- func (w *ScrollView) SetForeground(c Paint)
- func (w *ScrollView) SetHeight(h int)
- func (w *ScrollView) SetMaxHeight(h int)
- func (s *ScrollView) SetOrigin(x, y int)
- func (w *ScrollView) SetSize(width, height int)
- func (w *ScrollView) SetTooltip(s string)
- func (w *ScrollView) SetVisible(v bool)
- func (s *ScrollView) Unwrap() *swt.ScrolledComposite
- func (w *ScrollView) Visible() bool
- type SectionView
- func (s *SectionView) Add(rows ...Option)
- func (s *SectionView) AsComposite() *swt.Composite
- func (w *SectionView) Dispose()
- func (w *SectionView) Enabled() bool
- func (w *SectionView) Focus() bool
- func (w *SectionView) OnDispose(f func())
- func (w *SectionView) SetBackground(c Paint)
- func (w *SectionView) SetEnabled(v bool)
- func (w *SectionView) SetFont(f Font)
- func (w *SectionView) SetForeground(c Paint)
- func (w *SectionView) SetHeight(h int)
- func (w *SectionView) SetMaxHeight(h int)
- func (w *SectionView) SetSize(width, height int)
- func (w *SectionView) SetTooltip(s string)
- func (w *SectionView) SetVisible(v bool)
- func (s *SectionView) Unwrap() *swt.Composite
- func (w *SectionView) Visible() bool
- type SliderView
- func (w *SliderView) Dispose()
- func (w *SliderView) Enabled() bool
- func (w *SliderView) Focus() bool
- func (s *SliderView) OnChange(f func(value int))
- func (w *SliderView) OnDispose(f func())
- func (w *SliderView) SetBackground(c Paint)
- func (w *SliderView) SetEnabled(v bool)
- func (w *SliderView) SetFont(f Font)
- func (w *SliderView) SetForeground(c Paint)
- func (w *SliderView) SetHeight(h int)
- func (w *SliderView) SetMaxHeight(h int)
- func (w *SliderView) SetSize(width, height int)
- func (w *SliderView) SetTooltip(s string)
- func (s *SliderView) SetValue(v int)
- func (w *SliderView) SetVisible(v bool)
- func (s *SliderView) Unwrap() *swt.Slider
- func (s *SliderView) Value() int
- func (w *SliderView) Visible() bool
- type SortDir
- type SpacingScale
- type SpinnerView
- func (w *SpinnerView) Dispose()
- func (w *SpinnerView) Enabled() bool
- func (w *SpinnerView) Focus() bool
- func (s *SpinnerView) OnChange(f func(value int))
- func (w *SpinnerView) OnDispose(f func())
- func (w *SpinnerView) SetBackground(c Paint)
- func (w *SpinnerView) SetEnabled(v bool)
- func (w *SpinnerView) SetFont(f Font)
- func (w *SpinnerView) SetForeground(c Paint)
- func (w *SpinnerView) SetHeight(h int)
- func (w *SpinnerView) SetMaxHeight(h int)
- func (w *SpinnerView) SetSize(width, height int)
- func (w *SpinnerView) SetTooltip(s string)
- func (s *SpinnerView) SetValue(v int)
- func (w *SpinnerView) SetVisible(v bool)
- func (s *SpinnerView) Unwrap() *swt.Spinner
- func (s *SpinnerView) Value() int
- func (w *SpinnerView) Visible() bool
- type SplitView
- type StyleSpan
- type StyledTextView
- func (t *StyledTextView) Append(s string)
- func (t *StyledTextView) Caret() int
- func (t *StyledTextView) ClearStyles()
- func (t *StyledTextView) Copy()
- func (t *StyledTextView) Cut()
- func (w *StyledTextView) Dispose()
- func (w *StyledTextView) Enabled() bool
- func (w *StyledTextView) Focus() bool
- func (t *StyledTextView) Insert(s string)
- func (t *StyledTextView) LineAt(offset int) int
- func (t *StyledTextView) LineStart(line int) int
- func (t *StyledTextView) Lines() int
- func (t *StyledTextView) OnCaret(f func(offset int))
- func (t *StyledTextView) OnChange(f func(text string))
- func (w *StyledTextView) OnDispose(f func())
- func (t *StyledTextView) OnSelect(f func(start, length int))
- func (t *StyledTextView) OnStyle(f func(line string) []StyleSpan)
- func (t *StyledTextView) Paste()
- func (t *StyledTextView) Replace(start, length int, s string)
- func (t *StyledTextView) Reveal()
- func (t *StyledTextView) ScrollToEnd()
- func (t *StyledTextView) SelectedText() string
- func (t *StyledTextView) Selection() (start, length int)
- func (w *StyledTextView) SetBackground(c Paint)
- func (t *StyledTextView) SetCaret(offset int)
- func (t *StyledTextView) SetEditable(on bool)
- func (w *StyledTextView) SetEnabled(v bool)
- func (w *StyledTextView) SetFont(f Font)
- func (w *StyledTextView) SetForeground(c Paint)
- func (w *StyledTextView) SetHeight(h int)
- func (t *StyledTextView) SetLineBackground(line, count int, c RGB)
- func (t *StyledTextView) SetLineNumbers(on bool)
- func (w *StyledTextView) SetMaxHeight(h int)
- func (t *StyledTextView) SetParagraphSpacing(line, before int)
- func (t *StyledTextView) SetSelection(start, length int)
- func (w *StyledTextView) SetSize(width, height int)
- func (t *StyledTextView) SetStyle(start, length int, s TextStyle)
- func (t *StyledTextView) SetTabs(n int)
- func (t *StyledTextView) SetText(s string)
- func (w *StyledTextView) SetTooltip(s string)
- func (t *StyledTextView) SetTopLine(line int)
- func (w *StyledTextView) SetVisible(v bool)
- func (t *StyledTextView) SetWrap(on bool)
- func (t *StyledTextView) Styles() []StyleSpan
- func (t *StyledTextView) Text() string
- func (t *StyledTextView) TrimHead(keep int)
- func (t *StyledTextView) Unwrap() *swt.StyledText
- func (w *StyledTextView) Visible() bool
- type SwitchView
- func (s *SwitchView) Checked() bool
- func (w *SwitchView) Dispose()
- func (w *SwitchView) Enabled() bool
- func (w *SwitchView) Focus() bool
- func (s *SwitchView) OnChange(f func(on bool))
- func (w *SwitchView) OnDispose(f func())
- func (w *SwitchView) SetBackground(c Paint)
- func (s *SwitchView) SetChecked(v bool)
- func (w *SwitchView) SetEnabled(v bool)
- func (w *SwitchView) SetFont(f Font)
- func (w *SwitchView) SetForeground(c Paint)
- func (w *SwitchView) SetHeight(h int)
- func (w *SwitchView) SetMaxHeight(h int)
- func (w *SwitchView) SetSize(width, height int)
- func (s *SwitchView) SetText(t string)
- func (w *SwitchView) SetTooltip(s string)
- func (w *SwitchView) SetVisible(v bool)
- func (s *SwitchView) Unwrap() *swt.Button
- func (w *SwitchView) Visible() bool
- type TableClick
- type TableRow
- func (r *TableRow) Checked() bool
- func (r *TableRow) Data() any
- func (r *TableRow) SetChecked(v bool)
- func (r *TableRow) SetData(v any)
- func (r *TableRow) SetImageAt(col int, img *Image)
- func (r *TableRow) SetTextAt(col int, s string)
- func (r *TableRow) TextAt(col int) string
- func (r *TableRow) Unwrap() *swt.TableItem
- type TableView
- func (t *TableView) Batch(f func())
- func (t *TableView) CellAt(x, y int) (row, col int)
- func (t *TableView) Clear()
- func (t *TableView) Column(title string, width int, opts ...Option) *Column
- func (t *TableView) Deselect()
- func (w *TableView) Dispose()
- func (w *TableView) Enabled() bool
- func (t *TableView) FitColumns()
- func (w *TableView) Focus() bool
- func (t *TableView) Index() int
- func (t *TableView) Len() int
- func (t *TableView) OnActivate(f func(index int))
- func (t *TableView) OnCellClick(f func(TableClick))
- func (w *TableView) OnDispose(f func())
- func (t *TableView) OnSelect(f func(index int))
- func (t *TableView) Remove(i int)
- func (t *TableView) Row(cells ...string) *TableRow
- func (t *TableView) RowAt(i int) *TableRow
- func (t *TableView) Select(i ...int)
- func (t *TableView) Selected() []int
- func (w *TableView) SetBackground(c Paint)
- func (w *TableView) SetEnabled(v bool)
- func (w *TableView) SetFont(f Font)
- func (w *TableView) SetForeground(c Paint)
- func (w *TableView) SetHeight(h int)
- func (w *TableView) SetMaxHeight(h int)
- func (w *TableView) SetSize(width, height int)
- func (t *TableView) SetSort(col *Column, dir SortDir)
- func (w *TableView) SetTooltip(s string)
- func (w *TableView) SetVisible(v bool)
- func (t *TableView) ShowHeader(v bool)
- func (t *TableView) ShowLines(v bool)
- func (t *TableView) ShowRowLines(v bool)
- func (t *TableView) Unwrap() *swt.Table
- func (w *TableView) Visible() bool
- type TabsView
- func (t *TabsView) Add(tabs ...Option)
- func (w *TabsView) Dispose()
- func (w *TabsView) Enabled() bool
- func (w *TabsView) Focus() bool
- func (t *TabsView) Index() int
- func (w *TabsView) OnDispose(f func())
- func (t *TabsView) OnSelect(f func(index int))
- func (t *TabsView) Select(i int)
- func (w *TabsView) SetBackground(c Paint)
- func (w *TabsView) SetEnabled(v bool)
- func (w *TabsView) SetFont(f Font)
- func (w *TabsView) SetForeground(c Paint)
- func (w *TabsView) SetHeight(h int)
- func (w *TabsView) SetMaxHeight(h int)
- func (w *TabsView) SetSize(width, height int)
- func (w *TabsView) SetTooltip(s string)
- func (w *TabsView) SetVisible(v bool)
- func (t *TabsView) Unwrap() *swt.TabFolder
- func (w *TabsView) Visible() bool
- type TextStyle
- type TextView
- func (t *TextView) Append(s string)
- func (t *TextView) ContentHeight(width int) int
- func (w *TextView) Dispose()
- func (w *TextView) Enabled() bool
- func (w *TextView) Focus() bool
- func (t *TextView) Lines() int
- func (t *TextView) OnActivate(f func())
- func (t *TextView) OnChange(f func(text string))
- func (w *TextView) OnDispose(f func())
- func (t *TextView) ScrollToEnd()
- func (t *TextView) SetAutoGrow(minHeight, maxHeight int)
- func (w *TextView) SetBackground(c Paint)
- func (w *TextView) SetEnabled(v bool)
- func (w *TextView) SetFont(f Font)
- func (w *TextView) SetForeground(c Paint)
- func (w *TextView) SetHeight(h int)
- func (t *TextView) SetHint(s string)
- func (t *TextView) SetInset(x, y int)
- func (w *TextView) SetMaxHeight(h int)
- func (w *TextView) SetSize(width, height int)
- func (t *TextView) SetText(s string)
- func (w *TextView) SetTooltip(s string)
- func (w *TextView) SetVisible(v bool)
- func (t *TextView) Text() string
- func (t *TextView) TrimHead(keep int)
- func (t *TextView) Unwrap() *swt.Text
- func (w *TextView) Visible() bool
- type ToolBarView
- func (w *ToolBarView) Dispose()
- func (w *ToolBarView) Enabled() bool
- func (w *ToolBarView) Focus() bool
- func (t *ToolBarView) Item(text string, onClick func(), opts ...Option) *ToolItem
- func (w *ToolBarView) OnDispose(f func())
- func (t *ToolBarView) Separator()
- func (w *ToolBarView) SetBackground(c Paint)
- func (w *ToolBarView) SetEnabled(v bool)
- func (w *ToolBarView) SetFont(f Font)
- func (w *ToolBarView) SetForeground(c Paint)
- func (w *ToolBarView) SetHeight(h int)
- func (w *ToolBarView) SetMaxHeight(h int)
- func (w *ToolBarView) SetSize(width, height int)
- func (w *ToolBarView) SetTooltip(s string)
- func (w *ToolBarView) SetVisible(v bool)
- func (t *ToolBarView) Unwrap() *swt.ToolBar
- func (w *ToolBarView) Visible() bool
- type ToolItem
- func (i *ToolItem) Checked() bool
- func (i *ToolItem) OnClick(f func())
- func (i *ToolItem) SetChecked(v bool)
- func (i *ToolItem) SetEnabled(v bool)
- func (i *ToolItem) SetImage(img *Image)
- func (i *ToolItem) SetText(s string)
- func (i *ToolItem) SetTooltip(s string)
- func (i *ToolItem) Unwrap() *swt.ToolItem
- type TrayIcon
- type TreeClick
- type TreeView
- func (t *TreeView) Batch(f func())
- func (t *TreeView) CellAt(x, y int) (*Node, int)
- func (t *TreeView) Clear()
- func (t *TreeView) Column(title string, width int, opts ...Option) *Column
- func (t *TreeView) Deselect()
- func (w *TreeView) Dispose()
- func (w *TreeView) Enabled() bool
- func (t *TreeView) FitColumns()
- func (w *TreeView) Focus() bool
- func (t *TreeView) Node(text string) *Node
- func (t *TreeView) OnActivate(f func(n *Node))
- func (t *TreeView) OnCellClick(f func(TreeClick))
- func (t *TreeView) OnCollapse(f func(n *Node))
- func (w *TreeView) OnDispose(f func())
- func (t *TreeView) OnExpand(f func(n *Node))
- func (t *TreeView) OnSelect(f func(n *Node))
- func (t *TreeView) Roots() []*Node
- func (t *TreeView) Select(n *Node)
- func (t *TreeView) Selected() []*Node
- func (w *TreeView) SetBackground(c Paint)
- func (w *TreeView) SetEnabled(v bool)
- func (w *TreeView) SetFont(f Font)
- func (w *TreeView) SetForeground(c Paint)
- func (w *TreeView) SetHeight(h int)
- func (w *TreeView) SetMaxHeight(h int)
- func (w *TreeView) SetSize(width, height int)
- func (t *TreeView) SetSort(col *Column, dir SortDir)
- func (w *TreeView) SetTooltip(s string)
- func (w *TreeView) SetVisible(v bool)
- func (t *TreeView) ShowHeader(v bool)
- func (t *TreeView) ShowRowLines(v bool)
- func (t *TreeView) Unwrap() *swt.Tree
- func (w *TreeView) Visible() bool
- type TypeScale
- type Weight
- type Widget
- type Window
- func (p Window) Add(children ...Option)
- func (p Window) AsComposite() *swt.Composite
- func (p Window) Clear()
- func (w *Window) Close()
- func (w *Window) ColorDialog(initial RGB) (c RGB, ok bool)
- func (w *Window) Confirm(title, text string) bool
- func (w *Window) DirDialog(title, dir string) (path string, ok bool)
- func (w *Window) FileDialog(d FileDialog) []string
- func (w *Window) FontDialog(initial Font) (f Font, ok bool)
- func (w *Window) MenuBar() *Menu
- func (w *Window) MessageBox(m Message) Answer
- func (w *Window) OnClose(f func() bool)
- func (w *Window) OnKey(keys string, f func())
- func (w *Window) Popover(opts ...Option) *Popover
- func (w *Window) PrintDialog(o PrintOptions) (job *PrintJob, ok bool)
- func (p Window) Relayout()
- func (w *Window) SetMinSize(width, height int)
- func (w *Window) SetSize(width, height int)
- func (w *Window) SetTitle(s string)
- func (w *Window) SetTopInset(points int)
- func (w *Window) Show()
- func (w *Window) Unwrap() *swt.Shell
Examples ¶
Constants ¶
const SecondaryText systemPaint = 0
SecondaryText is the system colour of secondary text, such as the second line of an empty state: macOS secondaryLabelColor, Windows COLOR_GRAYTEXT, GTK the insensitive label colour. A widget given it takes the system's colour again when the system switches between light and dark.
Variables ¶
var ( // DensityNative sizes the tokens for the OS: the body is 13 px on macOS, 14 px on Windows 11 and // the GTK UI font on Linux, and Spacing is the macOS value times body/13, in steps of 4 px. DensityNative = Density{/* contains filtered or unexported fields */} // DensitySame is a 13 px body and the macOS Spacing on every OS. DensitySame = DensityFactor(1) )
var Spacing = defaultSpacing()
Spacing is the application-wide scale. Until App.SetDensity picks DensityNative or a factor, the values are the same on every OS (PageMargin 16 on macOS and 12 elsewhere); SetDensity replaces them with the values of density.go. The default Gap is Spacing.SM and the default Padding of a Window and a Tab is Spacing.PageMargin; Gap(gowt.Spacing.LG) picks another step. An application tunes it once at startup; a change applies to containers created afterwards, never to existing ones.
Functions ¶
func Golden ¶
Golden splits total into a smaller and a larger part in the golden ratio (about 38% and 62%); small+large == total.
func Run ¶
Run creates the display, calls setup on the UI thread, then runs the event loop until the last window is closed or App.Quit is called. An SWT exception raised by setup (a panic carrying an error, e.g. *swt.SWTException) is returned; a runtime error in setup propagates. Errors and panics in event handlers, Async and After callbacks do not end the loop: they go to App.OnError.
With GOWT_SNAP=<file.png> in the environment Run writes the first window as a PNG after the loop has run for GOWT_SNAP_DELAY milliseconds (default 800), then returns; see docs/screenshots.md.
Example ¶
A window with a field, a button and a label; Run returns when the window is closed.
package main
import (
"log"
"github.com/haiodo/gowt"
"github.com/haiodo/gowt/rx"
)
func main() {
err := gowt.Run(func(app *gowt.App) {
name, greet := rx.New(""), rx.New("")
w := app.Window("Hello gowt",
gowt.Text(gowt.GrowX(), gowt.Size(200, 0), gowt.Bind(name)),
gowt.Label("", gowt.GrowX(), gowt.BindText(greet)),
gowt.Button("Greet", gowt.OnClick(func() { greet.Set("Hello, " + name.Get() + "!") })))
w.Show()
})
if err != nil {
log.Fatal(err)
}
}
Output:
func Scaled ¶
Scaled returns n px multiplied by the density factor and rounded to a multiple of 4. It returns n unchanged without SetDensity. Use it for a width or height that is not a Spacing token.
func SetAppName ¶
func SetAppName(name string)
SetAppName sets the name the system shows for the process (macOS menu bar and Dock, Linux WM class). Call it before Run.
func SingleInstance ¶
SingleInstance makes the program a single instance per user under id, a reverse-DNS name such as "org.example.MyApp" (at least two dot-separated parts of letters, digits, "_" and "-"). Call it once, before Run. It returns true when this process is the running instance, and false when another one already holds id: this process then sent it the file arguments (see OnOpenFiles) or, with none, asked it to raise its window, and should exit without calling Run.
If the check cannot be done, it returns true and the error: a malformed id, or on Linux no session bus. The program then runs as an ordinary extra instance, getting command-line files only.
Linux: the id is the D-Bus name of the freedesktop Application interface; with DBusActivatable=true in the .desktop file the desktop calls Open on it. Windows: a Unix socket named after id in the user's temp folder; if two first launches start in the same instant both may win, and a crashed instance leaves a file that the next launch replaces. macOS: Launch Services already runs one instance, and the call does nothing. The instance holds id until the process ends.
Types ¶
type Adaptive ¶
type Adaptive struct{ Light, Dark RGB }
Adaptive is a colour for each system theme. A widget given one through Foreground, Background or their setters takes the other colour when the system switches between light and dark.
Example ¶
Colours for both themes and fonts relative to the system size: the card and its labels switch with the system theme, and the heading grows with the system font. Equal fonts share one native font.
package main
import (
"github.com/haiodo/gowt"
)
func main() {
var (
surface = gowt.Adaptive{Light: gowt.RGB{R: 255, G: 255, B: 255}, Dark: gowt.RGB{R: 30, G: 31, B: 34}}
muted = gowt.Adaptive{Light: gowt.RGB{R: 100, G: 106, B: 118}, Dark: gowt.RGB{R: 150, G: 155, B: 164}}
title = gowt.Typeface(gowt.Font{Scale: 1.15, Weight: gowt.Semibold})
small = gowt.Typeface(gowt.Font{Scale: 0.85})
)
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Status",
gowt.VBox(gowt.Background(surface), gowt.Padding(gowt.Spacing.MD), // labels inside show surface too
gowt.Label("Containers", title),
gowt.Label("3 running", small, gowt.Foreground(muted))))
w.Show()
})
}
Output:
type Answer ¶
type Answer int
Answer is the button that closed a message box. Closing the box with the window button gives AnswerCancel (or AnswerNo, AnswerOK if there is no Cancel).
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the handle to the UI thread, valid inside Run.
func (*App) After ¶
After runs f on the UI thread once, after d. A timer under one second counts in Pending until it fires or is cancelled; a longer one does not. The returned cancel stops f from running; it is safe from any goroutine, safe to call after f ran, and calling it again does nothing.
Example ¶
After runs a function on the UI thread once the delay has passed.
package main
import (
"time"
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Timer")
w.Show()
app.After(5*time.Second, app.Quit)
})
}
Output:
func (*App) Appearance ¶
func (a *App) Appearance() Appearance
Appearance returns what SetAppearance set.
func (*App) Async ¶
func (a *App) Async(f func())
Async queues f on the UI thread; safe from any goroutine. Once Run has returned, Async does nothing and f never runs; f queued while Run is ending may not run either.
Example ¶
Work off the UI thread reports back through Async; widgets are touched only on the UI thread.
package main
import (
"time"
"github.com/haiodo/gowt"
"github.com/haiodo/gowt/rx"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
status := rx.New("working...")
w := app.Window("Download", gowt.Label("", gowt.BindText(status)))
w.Show()
go func() {
time.Sleep(time.Second) // stands for slow work
app.Async(func() { status.Set("done") })
}()
})
}
Output:
func (*App) AvatarImage ¶
AvatarImage makes a round image size points wide: a disc of bg with the initials in white, the size of the text following size. The image is drawn at every zoom of the display, so it is sharp on a scaled screen; use it as the image of a Table or Tree cell, a Label or a Button.
func (*App) CircleImage ¶
CircleImage makes a round copy of img, size points wide: the middle square of img is scaled and clipped to a circle with a smooth edge. img stays as it is and may be disposed afterwards only when the copy is no longer shown, as the copy draws from it again at another zoom.
func (*App) Clipboard ¶
Clipboard returns the system clipboard of the App, creating it on first use.
Example ¶
The clipboard belongs to the App; a setter fails with an error when the system clipboard is busy.
package main
import (
"fmt"
"log"
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
if err := app.Clipboard().SetText("hello"); err != nil {
log.Print(err)
return
}
text, ok := app.Clipboard().Text()
fmt.Println(text, ok)
})
}
Output:
func (*App) Dark ¶
Dark reports whether the app is dark: the forced Appearance, else the system's dark mode (macOS appearance, Windows apps theme, Linux xdg-desktop-portal color-scheme). Run keeps the app following the system; call from the UI thread.
func (*App) Every ¶
Every runs f on the UI thread every d, the first time after d, until stop is called. stop is safe from any goroutine; called on the UI thread, f included, it keeps f from running again.
Example ¶
Every repeats a function on the UI thread until the returned stop is called.
package main
import (
"time"
"github.com/haiodo/gowt"
"github.com/haiodo/gowt/rx"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
clock := rx.New(time.Now().Format(time.TimeOnly))
w := app.Window("Clock", gowt.Label("", gowt.BindText(clock)))
stop := app.Every(time.Second, func() { clock.Set(time.Now().Format(time.TimeOnly)) })
w.OnClose(func() bool { stop(); return true })
w.Show()
})
}
Output:
func (*App) Flush ¶
func (a *App) Flush()
Flush applies pending changes now instead of on the next event-loop turn: it runs the stale rx effects and the layouts that bindings put off, such as BindText's. For timing one update or measuring widgets right after a change. UI thread only.
func (*App) ImageFromProvider ¶
func (a *App) ImageFromProvider(p swt.ImageDataProvider) *Image
ImageFromProvider creates an image from p, drawn at every zoom the provider answers for (for example svg.NewImageDataProvider).
func (*App) Job ¶
func (a *App) Job(name string, fn func(ctx context.Context, p *JobProgress) error, opts ...JobOption) *Job
Job runs fn in a goroutine. ctx is cancelled by Job.Cancel and when Run ends; fn should return then. A panic in fn goes to OnError and counts as fn's error. While fn runs, and until its Then callbacks have run on the UI thread, App.Pending counts the job, unless it is a BackgroundJob. Safe from any goroutine.
func (*App) Jobs ¶
Jobs lists the running Jobs and Tracks, background ones included, oldest first. Safe from any goroutine.
func (*App) OnAbout ¶
OnAbout runs f when the About item of the macOS application menu is chosen and reports true. Elsewhere there is no such menu: it reports false and the app puts its own About item in a normal menu. UI thread only.
if !app.OnAbout(showAbout) {
help.Item("About", showAbout)
}
func (*App) OnError ¶
OnError sets f to receive the errors and panics raised on the UI thread by event handlers, Async, Sync and After callbacks, and placement options that do not fit the parent's layout. The event loop goes on after f returns. Without OnError each one is logged with the stack where it was raised.
func (*App) OnJobs ¶
OnJobs sets f to be called on the UI thread with App.Jobs when a job or track starts or ends or a JobProgress changes, for a status spinner. Changes are coalesced: at most one call per event-loop turn. OnJobs(nil) removes it.
func (*App) OnOpenFiles ¶
OnOpenFiles registers f, called on the UI thread with the files the system or another process asks the app to open: Finder (double click, "Open With", a drop on the Dock icon) on macOS, the command line on every OS (Explorer and file managers start the program with the file as argument), and, with SingleInstance, a second launch forwarding its arguments to the running app. Paths are absolute and without duplicates within one call; URLs other than file: are ignored. Files that arrive before the first handler (a launch by double click) are kept and delivered to it once it is set. Several calls add several handlers. Users of Unwrap can still add an swt.OpenDocument listener. See docs/events.md and docs/packaging.md.
func (*App) OnPreferences ¶
OnPreferences is OnAbout for the Preferences item (Cmd+,), which macOS keeps in the application menu; elsewhere put the item in Edit or Tools.
func (*App) OnQuit ¶
OnQuit registers f, asked before the app quits in every way but Quit: Cmd+Q, the app menu and the Dock on macOS, the end of the session (logout, shutdown) on macOS and Windows, and the close of the last window. false cancels the quit. Several calls add several handlers, asked in order; the first false stops the rest.
On a quit that is not the close of the last window, the open windows are asked first, in creation order, through their OnClose handlers: the first refusal cancels the quit and no window or OnQuit handler after it is asked. No window closes before every answer is yes. Closing the last window asks that window's OnClose, then OnQuit.
f and the OnClose handlers may show a dialog (Window.MessageBox, Confirm): the question runs on the UI thread inside the system's quit request. To ask from your own Quit item call app.Unwrap().Close(), which does the same; app.Quit ends the loop without asking.
func (*App) OnThemeChange ¶
OnThemeChange runs f on the UI thread when the system switches between light and dark. Cached widget colors and the Adaptive and SecondaryText colours of widgets are already refreshed when f runs.
func (*App) Pending ¶
Pending counts the work the app has not finished: stale rx effects, posted values and layouts that bindings put off (Flush applies those), running Jobs and Tracks that are not BackgroundJob, and After timers under one second. Zero means nothing is left to wait for. UI thread only.
func (*App) Quit ¶
func (a *App) Quit()
Quit ends the event loop after the current event; safe from any goroutine, a no-op after Run.
func (*App) ScreenSize ¶
ScreenSize returns the size in points of the primary monitor's area for windows, without the menu bar, Dock or taskbar.
func (*App) SetAppearance ¶
func (a *App) SetAppearance(m Appearance)
SetAppearance makes the app dark or light whatever the OS is set to, or follows the OS again with AppearanceSystem. Dark reports the forced value, Adaptive colours switch and OnThemeChange runs. What changes:
- macOS: NSApp.appearance, so the whole UI (controls, title bars, sheets) switches live.
- Linux: gtk-application-prefer-dark-theme, and the portal no longer overrides it; the theme must have a dark variant (Adwaita and Yaru do). Switches live.
- Windows: title bars switch live. The content (scroll bars, tables, trees, buttons) is the dark controls theme, which does not switch live: call SetAppearance before creating the windows, as for look.SetDarkContent, which it replaces. Text fields, labels and the owner-drawn buttons, Progress and Scale of gowt follow the scheme; native controls that Windows themes itself may stay light.
Call it on the UI thread, usually first in the setup function.
func (*App) SetBadge ¶
SetBadge shows text on the application icon, such as an unread count; "" removes it. macOS: the badge of the app's Dock tile. Windows: the overlay of the taskbar button of every window, windows created later by App.Window too. Linux: the count on the launcher icon in Ubuntu Dock, dash-to-dock and KDE Plasma, which show a whole number only, so other text hides the count there. The launcher is the one of the desktop file named after the app name ("myapp.desktop" for SetAppName("myapp"), the executable name by default); see docs/packaging.md. UI thread only.
func (*App) SetDensity ¶
SetDensity sets how the Type and Spacing tokens are sized, see Density. Call it first in the setup function of Run, before any widget is built and before tuning a token: it replaces Type and Spacing as a whole, and widgets already built keep their sizes. With DensityNative or a DensityFactor, new widgets also get the body font, which differs from the system font on Windows (Segoe UI Variable Text, 14 px) and with DensitySame on Windows and Linux (13 px). The zero Density restores the default.
Example ¶
Native density: the body follows the system font, and the spacing, heights and widths scale with it, so the same code reads as native on macOS, Windows 11 and GNOME. SetDensity comes first in the setup function; DensitySame gives every OS the macOS layout instead.
package main
import (
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
app.SetDensity(gowt.DensityNative)
w := app.Window("Settings",
gowt.Label("Appearance", gowt.Typeface(gowt.Type.Title)),
gowt.Label("Applies to new windows", gowt.Typeface(gowt.Type.Caption)),
gowt.HBox(gowt.Gap(gowt.Spacing.MD),
gowt.Button("Cancel"),
gowt.Button("Save", gowt.OnClick(app.Quit))),
gowt.Label("gowt --version", gowt.Typeface(gowt.Type.Mono)))
w.Show()
})
}
Output:
func (*App) SetLinkColor ¶
SetLinkColor sets the colour of the anchors of every Link, light and dark, instead of the system link colour (on GNOME the theme accent). nil gives the system colour back, which is the default. It applies to the Links that exist and to those created later, and follows a theme switch.
func (*App) Sync ¶
func (a *App) Sync(f func())
Sync runs f on the UI thread and waits; safe from any goroutine except while the UI thread is blocked on you. Once Run has returned, Sync returns at once without running f.
func (*App) SystemFont ¶
SystemFont returns the family and size of the system UI font, which Font.Scale multiplies.
func (*App) Track ¶
Track counts work gowt does not start, a request through the app's own client or a callback of a core library, as outstanding for App.Pending and the QA driver's settle until done is called. done is safe from any goroutine and idempotent. Call it after the callback's result reached the UI: app.Async(func() { show(r); done() }).
func (*App) Tray ¶
Tray adds a tray icon, or returns nil where the platform has no system tray. onClick may be nil.
type Appearance ¶
type Appearance int
Appearance is the colour scheme of the app's windows and of the Adaptive colours.
const ( AppearanceSystem Appearance = iota AppearanceDark AppearanceLight )
The appearances. AppearanceSystem follows the OS and is the default.
type ButtonView ¶
type ButtonView struct {
// contains filtered or unexported fields
}
ButtonView is a push, check or radio button.
func (*ButtonView) Checked ¶
func (b *ButtonView) Checked() bool
Checked reports the state of a Check or Radio button.
func (*ButtonView) Dispose ¶
func (w *ButtonView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*ButtonView) Enabled ¶
func (w *ButtonView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*ButtonView) Focus ¶
func (w *ButtonView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*ButtonView) OnClick ¶
func (b *ButtonView) OnClick(f func())
OnClick runs f when the button is pressed (or toggled).
func (*ButtonView) OnDispose ¶
func (w *ButtonView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*ButtonView) SetBackground ¶
func (w *ButtonView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*ButtonView) SetChecked ¶
func (b *ButtonView) SetChecked(v bool)
SetChecked sets the state of a Check or Radio button.
func (*ButtonView) SetEnabled ¶
func (w *ButtonView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*ButtonView) SetFont ¶
func (w *ButtonView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*ButtonView) SetForeground ¶
func (w *ButtonView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*ButtonView) SetHeight ¶
func (w *ButtonView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*ButtonView) SetImage ¶
func (b *ButtonView) SetImage(img *Image)
SetImage sets the icon; the button does not own img. Lays the parents out when the size changes.
func (*ButtonView) SetMaxHeight ¶
func (w *ButtonView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*ButtonView) SetSize ¶
func (w *ButtonView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*ButtonView) SetText ¶
func (b *ButtonView) SetText(s string)
SetText replaces the button text. Lays the parents out when the size changes.
func (*ButtonView) SetTooltip ¶
func (w *ButtonView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*ButtonView) SetVisible ¶
func (w *ButtonView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*ButtonView) Unwrap ¶
func (b *ButtonView) Unwrap() *swt.Button
Unwrap returns the underlying swt.Button for the full API.
type CTabsView ¶
type CTabsView struct {
// contains filtered or unexported fields
}
CTabsView is the custom-drawn tab folder: closable tabs (Closable on the folder's Tab) and a flatter look.
func (*CTabsView) Dispose ¶
func (w *CTabsView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*CTabsView) Enabled ¶
func (w *CTabsView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*CTabsView) Focus ¶
func (w *CTabsView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*CTabsView) OnClose ¶
OnClose runs f with the index of the tab whose close button was pressed; false keeps the tab.
func (*CTabsView) OnDispose ¶
func (w *CTabsView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*CTabsView) SetBackground ¶
func (w *CTabsView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*CTabsView) SetEnabled ¶
func (w *CTabsView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*CTabsView) SetFont ¶
func (w *CTabsView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*CTabsView) SetForeground ¶
func (w *CTabsView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*CTabsView) SetHeight ¶
func (w *CTabsView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*CTabsView) SetMaxHeight ¶
func (w *CTabsView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*CTabsView) SetSize ¶
func (w *CTabsView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*CTabsView) SetTooltip ¶
func (w *CTabsView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*CTabsView) SetVisible ¶
func (w *CTabsView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*CTabsView) Unwrap ¶
func (t *CTabsView) Unwrap() *swt.CTabFolder
Unwrap returns the underlying swt.CTabFolder for the full API.
type CanvasView ¶
type CanvasView struct {
// contains filtered or unexported fields
}
CanvasView is a blank area drawn by the paint callback.
func (*CanvasView) AddChild ¶
func (c *CanvasView) AddChild(opt Option) Widget
AddChild creates the widget opt describes as a child of the canvas, over what the canvas paints; nil if opt is not a widget. The canvas has no layout: place the child with SetChildBounds.
func (*CanvasView) Dispose ¶
func (w *CanvasView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*CanvasView) Enabled ¶
func (w *CanvasView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*CanvasView) Focus ¶
func (w *CanvasView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*CanvasView) OnDispose ¶
func (w *CanvasView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*CanvasView) OnMouseDown ¶
func (c *CanvasView) OnMouseDown(f func(Mouse))
OnMouseDown runs f when a button is pressed.
func (*CanvasView) OnMouseMove ¶
func (c *CanvasView) OnMouseMove(f func(Mouse))
OnMouseMove runs f when the pointer moves over the canvas.
func (*CanvasView) OnMouseUp ¶
func (c *CanvasView) OnMouseUp(f func(Mouse))
OnMouseUp runs f when a button is released.
func (*CanvasView) OnResize ¶
func (c *CanvasView) OnResize(f func(w, h int))
OnResize runs f with the client size in points, as Size gives it, after layout gave the canvas a new size, and once for the first size known, also when the canvas has it already (f then runs on the next turn of the event loop). A size with a zero side is not reported.
func (*CanvasView) Redraw ¶
func (c *CanvasView) Redraw()
Redraw schedules a repaint, which calls the paint callback.
func (*CanvasView) SetBackground ¶
func (w *CanvasView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*CanvasView) SetChildBounds ¶
func (c *CanvasView) SetChildBounds(child Widget, x, y, w, h int)
SetChildBounds puts child, made by AddChild, at (x, y) with size w by h, in points of the canvas.
func (*CanvasView) SetEnabled ¶
func (w *CanvasView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*CanvasView) SetFont ¶
func (w *CanvasView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*CanvasView) SetForeground ¶
func (w *CanvasView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*CanvasView) SetHeight ¶
func (w *CanvasView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*CanvasView) SetMaxHeight ¶
func (w *CanvasView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*CanvasView) SetSize ¶
func (w *CanvasView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*CanvasView) SetTooltip ¶
func (w *CanvasView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*CanvasView) SetVisible ¶
func (w *CanvasView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*CanvasView) Size ¶
func (c *CanvasView) Size() (w, h int)
Size returns the drawable width and height.
func (*CanvasView) Unwrap ¶
func (c *CanvasView) Unwrap() *swt.Canvas
Unwrap returns the underlying swt.Canvas for the full API.
type Clipboard ¶
type Clipboard struct {
// contains filtered or unexported fields
}
Clipboard is the system clipboard. App.Clipboard creates it; the App disposes it when Run returns, so there is nothing to dispose. UI thread only (from another goroutine use App.Sync).
Getters return ok=false when the clipboard holds no such format. Setters return an error when the system clipboard cannot be written, which is routine on Windows while another process has it open. Setting one format clears the others; use SetHTML for HTML with a plain-text fallback. Other formats (RTF, URL, custom) and the X11 selection clipboard are reachable through Unwrap.
func (*Clipboard) Files ¶
Files returns the paths of the files copied in a file manager, nil if there are none.
func (*Clipboard) Image ¶
Image returns a copy of the image on the clipboard, owned by the App like every Image.
func (*Clipboard) SetHTML ¶
SetHTML replaces the clipboard content with html and, for applications that do not read HTML, plain.
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
Column is a column of a Table or a Tree.
func (*Column) OnClick ¶
func (c *Column) OnClick(f func())
OnClick runs f when the header is clicked, e.g. to sort.
func (*Column) SetResizable ¶
SetResizable allows or forbids resizing the column by dragging the header edge.
type ComboView ¶
type ComboView struct {
// contains filtered or unexported fields
}
ComboView is a drop-down (or Simple) list with an edit field; ReadOnly() makes it a pure chooser.
func (*ComboView) Dispose ¶
func (w *ComboView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*ComboView) Enabled ¶
func (w *ComboView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*ComboView) Focus ¶
func (w *ComboView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*ComboView) OnDispose ¶
func (w *ComboView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*ComboView) SetBackground ¶
func (w *ComboView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*ComboView) SetEnabled ¶
func (w *ComboView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*ComboView) SetFont ¶
func (w *ComboView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*ComboView) SetForeground ¶
func (w *ComboView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*ComboView) SetHeight ¶
func (w *ComboView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*ComboView) SetItems ¶
SetItems replaces the list entries. Lays the parents out when the size changes: the width follows the widest entry.
func (*ComboView) SetMaxHeight ¶
func (w *ComboView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*ComboView) SetSize ¶
func (w *ComboView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*ComboView) SetTooltip ¶
func (w *ComboView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*ComboView) SetVisible ¶
func (w *ComboView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
type CoolBarView ¶
type CoolBarView struct {
// contains filtered or unexported fields
}
CoolBarView is a tool bar area whose bands the user can rearrange.
func (*CoolBarView) Add ¶
func (b *CoolBarView) Add(bands ...Option)
Add appends bands, one per child.
func (CoolBarView) AsComposite ¶
AsComposite returns the underlying composite; unlike Unwrap it has the same type on Panel, Window, Group, Split and CoolBar, so one function can take any of them.
func (CoolBarView) Clear ¶
func (p CoolBarView) Clear()
Clear disposes every child and lays p out again, ready for new content.
func (CoolBarView) Relayout ¶
func (p CoolBarView) Relayout()
Relayout lays the children out again and recomputes their sizes, as needed after a change made through Unwrap, such as swt.Label.SetText. The facade setters that change a size (SetText, SetImage, SetFont, SetTitle of a Group, SetItems of a Combo) lay out by themselves. p keeps its own size: to let it grow too, Relayout the Window.
func (*CoolBarView) Unwrap ¶
func (b *CoolBarView) Unwrap() *swt.CoolBar
Unwrap returns the underlying swt.CoolBar for the full API.
type DateTimeView ¶
type DateTimeView struct {
// contains filtered or unexported fields
}
DateTimeView is a date field, a time field (AsTime) or a month calendar (AsCalendar).
func (*DateTimeView) Dispose ¶
func (w *DateTimeView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*DateTimeView) Enabled ¶
func (w *DateTimeView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*DateTimeView) Focus ¶
func (w *DateTimeView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*DateTimeView) OnChange ¶
func (d *DateTimeView) OnChange(f func(t time.Time))
OnChange runs f with the new value.
func (*DateTimeView) OnDispose ¶
func (w *DateTimeView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*DateTimeView) SetBackground ¶
func (w *DateTimeView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*DateTimeView) SetEnabled ¶
func (w *DateTimeView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*DateTimeView) SetFont ¶
func (w *DateTimeView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*DateTimeView) SetForeground ¶
func (w *DateTimeView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*DateTimeView) SetHeight ¶
func (w *DateTimeView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*DateTimeView) SetMaxHeight ¶
func (w *DateTimeView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*DateTimeView) SetSize ¶
func (w *DateTimeView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*DateTimeView) SetTooltip ¶
func (w *DateTimeView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*DateTimeView) SetValue ¶
func (d *DateTimeView) SetValue(t time.Time)
SetValue shows t's time of day for AsTime, its date otherwise.
func (*DateTimeView) SetVisible ¶
func (w *DateTimeView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*DateTimeView) Unwrap ¶
func (d *DateTimeView) Unwrap() *swt.DateTime
Unwrap returns the underlying swt.DateTime for the full API.
func (*DateTimeView) Value ¶
func (d *DateTimeView) Value() time.Time
Value is the shown date, or the shown time of day on today's date for AsTime, in the local zone.
type Density ¶
type Density struct {
// contains filtered or unexported fields
}
Density chooses how the Type and Spacing tokens are sized, see App.SetDensity. The zero value keeps the fixed Spacing of earlier releases; docs/cross-platform-look.md compares the choices.
func ChosenDensity ¶
func ChosenDensity() Density
ChosenDensity reports what App.SetDensity set; the zero Density without it.
func DensityFactor ¶
DensityFactor is DensitySame scaled by f: a body of 13*f px and f times the macOS Spacing.
type Drag ¶
type Drag struct {
Ops Op // allowed operations, zero means OpCopy
Text func() string // plain text
Files func() []string // file paths
Image func() *Image // not disposed by the facade
OnStart func() bool // false cancels this drag; may be nil
OnDone func(op Op) // after the drop; OpNone if nobody took it; may be nil
}
Drag describes what a widget offers when the user drags from it. Every non-nil getter adds its format; getters run when a target asks for the data. Custom formats need swt.DragSource through Unwrap.
type DragHandle ¶
type DragHandle struct {
// contains filtered or unexported fields
}
DragHandle is the drag source created by DragFrom.
func DragFrom ¶
func DragFrom(w Widget, d Drag) *DragHandle
DragFrom makes w a drag source. A control has at most one; a second call panics with an SWT error that Run returns. The source is disposed with the widget.
func (*DragHandle) Unwrap ¶
func (h *DragHandle) Unwrap() *swt.DragSource
Unwrap returns the underlying swt.DragSource for the full API.
type Drop ¶
type Drop struct {
Ops Op // accepted operations, zero means OpCopy
Text func(text string, op Op) // plain text dropped
Files func(paths []string, op Op) // files dropped
Image func(img *Image, op Op) // image dropped; the App owns img (Dispose may be called earlier)
Over func(x, y int) bool // x, y in widget coordinates; false rejects the drop at that point; may be nil
}
Drop describes what a widget accepts. Every non-nil callback adds its format. Custom formats need swt.DropTarget through Unwrap.
type DropHandle ¶
type DropHandle struct {
// contains filtered or unexported fields
}
DropHandle is the drop target created by DropOn.
func DropOn ¶
func DropOn(w Widget, d Drop) *DropHandle
DropOn makes w a drop target. A control has at most one; a second call panics with an SWT error that Run returns. The target is disposed with the widget.
Example ¶
Any widget can be a drag source and a drop target; callbacks run on the UI thread.
package main
import (
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
var zone *gowt.LabelView
w := app.Window("Drop", gowt.Label("drop files here", gowt.Ref(&zone)))
gowt.DropOn(zone, gowt.Drop{Files: func(paths []string, _ gowt.Op) { zone.SetText(paths[0]) }})
w.Show()
})
}
Output:
func (*DropHandle) Unwrap ¶
func (h *DropHandle) Unwrap() *swt.DropTarget
Unwrap returns the underlying swt.DropTarget for the full API.
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
Edge says where one side of a Form child sits. The zero Edge leaves the side free.
func Beside ¶
Beside attaches the side to the opposite side of the sibling *w, gap points away: a left edge sits right of it. *w is read when the child is placed, so a Ref of an earlier sibling fills it in time.
type FileDialog ¶
type FileDialog struct {
Title, Dir, Name string
Save, Multi bool
Filters []FileFilter
}
FileDialog describes an open or save dialog.
type FileFilter ¶
type FileFilter struct{ Name, Pattern string }
FileFilter is one entry of the file type chooser; Pattern is "*.png;*.jpg", "*" matches all.
type Font ¶
Font describes a typeface choice; Size is in points. Weight overrides Bold when set. SetFont keeps the control's current family for an empty Name, which for a default control is the system UI font (SF Pro, Segoe UI, the GTK UI font) at the given weight. Scale sizes the font relative to the system font when Size is 0: Font{Scale: 1.2, Weight: Semibold} is a heading that grows with the system font on every OS.
Px sizes the font in logical pixels with a fraction, the unit of Spacing: 13.5 is 13.5 pixels tall on every OS, converted to the native unit when the font is made (1 pt = 1 px on macOS, 3/4 pt on Windows, the screen resolution on GTK). It replaces Size and Scale; use the Type tokens rather than numbers, see docs/cross-platform-look.md.
type FormCell ¶
FormCell places one child of a Form. Width and Height are hints in points, zero is natural size. A child with no edge set sticks to the top left.
type GC ¶
type GC struct {
// contains filtered or unexported fields
}
GC draws on a Canvas. It is valid only inside the paint callback it was passed to. Colors and fonts are set per call and need no disposal.
func (*GC) SetFont ¶
SetFont sets the font of Text and TextSize for the rest of the paint callback. Empty Name, zero Size and Scale mean what they do for Widget.SetFont; Font{} is the canvas's font itself. The canvas shares the native fonts with the widgets and releases them when it is disposed.
func (*GC) SetLineWidth ¶
SetLineWidth sets the outline width in points.
func (*GC) Size ¶
Size returns the width and height of the canvas being painted, in points: what CanvasView.Size returns, read at paint time so a chart can follow a resize.
func (*GC) Text ¶
Text draws s with its top left at (x, y) over the fill color; tabs and newlines are honored.
type GridCell ¶
type GridCell struct {
Align, VAlign Align
GrowX, GrowY bool
SpanX, SpanY int
Width, Height int
IndentX, IndentY int // points the child sits right of and below the cell's top left
}
GridCell places one child inside a Grid. Zero value: natural size, top left, one cell. Align zero is AlignStart. Grow, GrowX, GrowY, Span, Size, Place and Indent set the common fields one at a time.
type GroupView ¶
type GroupView struct {
// contains filtered or unexported fields
}
GroupView is a container with a titled frame.
func (GroupView) Add ¶
func (p GroupView) Add(children ...Option)
Add creates children at the end of p, in order, and lays p out again when it is on screen, measuring only the new children. It is the way to fill a container after its creation, for content that changes; see Clear.
func (GroupView) AsComposite ¶
AsComposite returns the underlying composite; unlike Unwrap it has the same type on Panel, Window, Group, Split and CoolBar, so one function can take any of them.
func (GroupView) Clear ¶
func (p GroupView) Clear()
Clear disposes every child and lays p out again, ready for new content.
func (GroupView) Relayout ¶
func (p GroupView) Relayout()
Relayout lays the children out again and recomputes their sizes, as needed after a change made through Unwrap, such as swt.Label.SetText. The facade setters that change a size (SetText, SetImage, SetFont, SetTitle of a Group, SetItems of a Combo) lay out by themselves. p keeps its own size: to let it grow too, Relayout the Window.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image is a bitmap. The App owns every image, whichever call made it, and disposes the ones still alive when Run returns. Dispose frees one earlier, once nothing shows it: widgets that show an image (SetImage) neither copy nor own it.
func (*Image) Dispose ¶
func (i *Image) Dispose()
Dispose releases the image now instead of when Run returns; calling it again is a no-op.
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job is work App.Job runs in a goroutine.
func (*Job) Cancel ¶
func (j *Job) Cancel()
Cancel cancels the ctx of fn and returns; it does not wait for fn.
type JobInfo ¶
type JobInfo struct {
Name string
Background bool
Track bool // work from App.Track, not a Job
Started time.Time
Done int // JobProgress.Step so far
Total int // JobProgress.Total; 0 unknown
Text string
}
JobInfo is one running Job or Track as App.Jobs and App.OnJobs report it.
type JobOption ¶
type JobOption func(*Job)
JobOption changes how App.Job treats a job.
func BackgroundJob ¶
func BackgroundJob() JobOption
BackgroundJob marks perpetual work, a poll or a sync loop: it shows in Jobs but App.Pending and the QA driver's settle do not wait for it. (Background is the colour option.)
type JobProgress ¶
type JobProgress struct {
// contains filtered or unexported fields
}
JobProgress is how a Job reports itself to Jobs and OnJobs; its methods are safe from the job's goroutine.
func (*JobProgress) Text ¶
func (p *JobProgress) Text(s string)
Text sets what the job is doing now.
func (*JobProgress) Total ¶
func (p *JobProgress) Total(n int)
Total sets the number of steps the job has; 0 means unknown.
type LabelView ¶
type LabelView struct {
// contains filtered or unexported fields
}
LabelView is a static text.
func (*LabelView) Dispose ¶
func (w *LabelView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*LabelView) Enabled ¶
func (w *LabelView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*LabelView) Focus ¶
func (w *LabelView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*LabelView) OnDispose ¶
func (w *LabelView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*LabelView) SetBackground ¶
func (w *LabelView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*LabelView) SetEnabled ¶
func (w *LabelView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*LabelView) SetFont ¶
func (w *LabelView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*LabelView) SetForeground ¶
func (w *LabelView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*LabelView) SetHeight ¶
func (w *LabelView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*LabelView) SetImage ¶
SetImage sets the icon; the label does not own img. Lays the parents out when the size changes.
func (*LabelView) SetMaxHeight ¶
func (w *LabelView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*LabelView) SetSize ¶
func (w *LabelView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*LabelView) SetText ¶
SetText replaces the label text. Lays the parents out when the size changes.
func (*LabelView) SetTooltip ¶
func (w *LabelView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*LabelView) SetVisible ¶
func (w *LabelView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
type LinkView ¶
type LinkView struct {
// contains filtered or unexported fields
}
LinkView is a label with clickable parts: text uses <a href="...">anchor</a>.
func (*LinkView) Dispose ¶
func (w *LinkView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*LinkView) Enabled ¶
func (w *LinkView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*LinkView) Focus ¶
func (w *LinkView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*LinkView) OnDispose ¶
func (w *LinkView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*LinkView) SetBackground ¶
func (w *LinkView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*LinkView) SetEnabled ¶
func (w *LinkView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*LinkView) SetFont ¶
func (w *LinkView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*LinkView) SetForeground ¶
func (w *LinkView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*LinkView) SetHeight ¶
func (w *LinkView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*LinkView) SetMaxHeight ¶
func (w *LinkView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*LinkView) SetSize ¶
func (w *LinkView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*LinkView) SetText ¶
SetText replaces the text; anchors use <a href="...">. Lays the parents out when the size changes.
func (*LinkView) SetTooltip ¶
func (w *LinkView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*LinkView) SetVisible ¶
func (w *LinkView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
type ListView ¶
type ListView struct {
// contains filtered or unexported fields
}
ListView is a single or multi (MultiSelect) selection list of strings.
func (*ListView) Clear ¶
func (l *ListView) Clear()
Clear deletes all entries and with them the selection.
func (*ListView) Deselect ¶
func (l *ListView) Deselect()
Deselect clears the selection and calls no OnSelect, as SWT's deselectAll sends no Selection.
func (*ListView) Dispose ¶
func (w *ListView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*ListView) Enabled ¶
func (w *ListView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*ListView) Focus ¶
func (w *ListView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*ListView) OnActivate ¶
OnActivate runs f on double click or Enter.
func (*ListView) OnDispose ¶
func (w *ListView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*ListView) SetBackground ¶
func (w *ListView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*ListView) SetEnabled ¶
func (w *ListView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*ListView) SetFont ¶
func (w *ListView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*ListView) SetForeground ¶
func (w *ListView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*ListView) SetHeight ¶
func (w *ListView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*ListView) SetMaxHeight ¶
func (w *ListView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*ListView) SetSize ¶
func (w *ListView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*ListView) SetTooltip ¶
func (w *ListView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*ListView) SetVisible ¶
func (w *ListView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
type Menu ¶
type Menu struct {
// contains filtered or unexported fields
}
Menu is a menu bar, a popup menu or a submenu.
func PopupMenu ¶
PopupMenu creates the context menu of w. It is a function, not a method, because every wrapper would need its own copy; Show opens it by hand, right click opens it by itself.
func (*Menu) Item ¶
Item appends a push item (Check or Radio for other kinds). onClick may be nil. A "&" in text marks a mnemonic. Shortcut binds a key and shows it; text after "\t" is only shown. Options: Check, Radio, Shortcut.
func (*Menu) OnShow ¶
func (m *Menu) OnShow(f func())
OnShow runs f just before the menu opens, to refresh enabled states.
type MenuItem ¶
type MenuItem struct {
// contains filtered or unexported fields
}
MenuItem is a menu entry.
func (*MenuItem) OnClick ¶
func (i *MenuItem) OnClick(f func())
OnClick runs f when the item is chosen (or toggled).
func (*MenuItem) SetChecked ¶
SetChecked sets the state of a check or radio item.
func (*MenuItem) SetEnabled ¶
SetEnabled enables or greys out the item.
type Mods ¶
type Mods struct{ Ctrl, Shift, Alt, Cmd bool }
Mods are the modifier keys held during a mouse press. On macOS a Ctrl-click arrives as Button 1 with Ctrl set.
type Mouse ¶
type Mouse struct {
X, Y int
Button int // SWT's numbering: 1 left, 2 middle, 3 right; 0 for a move
Count int // 2 for the second press of a double click
Mods // keys held down; a macOS Ctrl-click is Button 1 with Ctrl
}
Mouse is a pointer event on a Canvas, in the canvas's coordinates.
type NativeContext ¶
type NativeContext struct {
// Handle is the cairo_t on Linux, the CGContextRef on macOS and the printer HDC on Windows. It is
// valid until the draw callback returns.
Handle uintptr
// UnitsPerPoint is how many units of the context make a point: the printer's dots per 72nd of
// an inch. The origin is the top left corner of the printable area, y down on Linux; macOS
// may give y up, then Height flips it.
UnitsPerPoint float64
Width, Height float64 // size of the printable area in those units
// GC is the same context as an SWT graphics context, without the point transform GC sets.
GC *swt.GC
}
NativeContext is the drawing context of a page as the platform has it, for a gfx page.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a tree item. Nodes are re-wrapped on every lookup: keep per-node state in SetData.
func (*Node) SetChecked ¶
SetChecked sets the check box of a Check tree.
func (*Node) SetExpanded ¶
SetExpanded shows or hides the children.
func (*Node) SetImageAt ¶
SetImageAt sets the icon of column col; the node does not own img.
type Op ¶
type Op int
Op is a drag and drop operation. In Drag.Ops and Drop.Ops the zero value means OpCopy.
const ( OpNone Op = Op(swt.DNDDROP_NONE) OpCopy Op = Op(swt.DNDDROP_COPY) OpMove Op = Op(swt.DNDDROP_MOVE) OpLink Op = Op(swt.DNDDROP_LINK) )
The operations a drag may offer and a drop may accept; OpNone reports a drag nobody accepted.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option describes a widget at construction: a style, common, placement or box option, Ref, Shortcut, or a child. Every widget constructor (Label, Button, VBox, ...) returns an Option that creates the widget when its parent is created or when it is passed to Add. Only this package makes Options. An option the widget cannot use goes to App.OnError and the widget is created without it; the "Options:" line of a constructor lists the style options it reads.
func AccessibleLabel ¶
AccessibleLabel names a widget for screen readers, which an icon-only Button has no text for. macOS: accessibilityLabel; GTK: the ATK name; Windows has no accessibility in the toolkit.
func AsTime ¶
func AsTime() Option
AsTime and AsCalendar turn a DateTime from a date field into a time field or a month calendar.
func AutoGrow ¶
AutoGrow makes a multi-line Text as high as its text, between minHeight and maxHeight points (0 is no limit), as SetAutoGrow does. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func Background ¶
Background sets the background colour of a widget, as SetBackground does.
func Bind ¶
Bind keeps the widget's value and s in step both ways, as Svelte's bind:value: a user's edit sets s, a Set of s changes the widget. The value is the text of a Text or Combo (string), the state of a Switch or a Check button (bool), the value of a Scale, Slider, Spinner or Progress (one way), or the selected index of a Combo or List (int). A Text is rewritten only when s differs from it, so typing keeps the caret.
func BindEnabled ¶
BindEnabled enables or disables the widget as r changes.
func BindText ¶
BindText shows r as the text of a Label, Button or Link. As with SetText, a text that changes the widget's size lays its parents out again on the next event-loop turn, so a text that grows is not cut.
func BindVisible ¶
BindVisible shows or hides the widget as r changes, with SetVisible's handling of the layouts.
func Borderless ¶
func Borderless() Option
Borderless draws a push Button without its frame (macOS: no bezel, GTK: "flat"); Windows keeps it.
func Boundary ¶
Boundary creates its children in a column, as a VBox does, and shows a fallback in their place when they fail: Svelte's <svelte:boundary>. Caught are panics and reported errors while the children are made (constructors, Ref, Init, misused options, Add on a container inside) and panics in their bindings and effects after a state change (Bind, BindText, Watch, Rows fill, ...). The children go with their effects. Event handlers, Async, After and Every are not caught. Every caught error also goes to App.OnError; the innermost boundary catches first, and an error in a fallback goes to the boundary above. Without Failed the fallback is the message and a Retry button. Options: Failed, Gap, Padding, Border, children.
func Button ¶
Button creates a push button (Check or Radio for other kinds); OnClick gives it an action. Options: Check, Radio, OnClick, OnChange and Checked (Check, Radio), Bind (bool), BindText.
Example ¶
A check box and a push button pushed to the right end of their row.
package main
import (
"fmt"
"github.com/haiodo/gowt"
"github.com/haiodo/gowt/rx"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
remember := rx.New(true)
w := app.Window("Buttons",
gowt.HBox(gowt.GrowX(),
gowt.Button("Remember me", gowt.Check(), gowt.Bind(remember)),
gowt.Spacer(),
gowt.Button("Sign in", gowt.OnClick(func() { fmt.Println("remember:", remember.Get()) }))))
w.Show()
})
}
Output:
func CTabs ¶
CTabs creates a custom tab folder whose children are Tab pages; Border() draws a frame and Closable() on a Tab adds a close button to it. Options: Bottom, Border, Selected, OnSelect, children (Tab only).
func Canvas ¶
Canvas creates a drawing area. onPaint draws the whole area (clipped to the damaged part) and must not keep g; it may be nil. Call Redraw after the model changes. Options: Border.
Example ¶
The paint callback draws the whole area; call Redraw after the model changes.
package main
import (
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Canvas",
gowt.Canvas(func(g *gowt.GC) {
g.SetFill(gowt.RGB{R: 30, G: 120, B: 220})
g.FillOval(10, 10, 100, 60)
}, gowt.Size(200, 100)))
w.Show()
})
}
Output:
func Cell ¶
Cell sets every field of the child's grid cell at once; placement options after it change single fields.
func CellSelect ¶
func CellSelect() Option
CellSelect makes a Tree select only the text of a node, as v0.1.0 did on Windows and Linux; then CellAt and OnCellClick find a node only where its text or icon is.
func Check ¶
func Check() Option
Check makes a Button a check box, and Table and Tree rows and ToolBar items checkable. Radio, Multiline, Password, ReadOnly and Border follow below.
func Circle ¶
func Circle() Option
Circle makes a push Button round: give it a square Size. With look.GlassButton on macOS 26 it is a glass circle, in either order. GTK: "circular". Windows keeps the rectangle.
func Combo ¶
Combo creates a combo box with the given items. Options: ReadOnly, Simple, Value, Selected, OnSelect, OnChange, Bind (string: text, int: index).
func CoolBar ¶
CoolBar creates a cool bar: each child, usually a ToolBar, becomes a band of its natural size. Options: common only, children.
func Custom ¶
Custom runs f on the widget right after it is created and sets no style bits. It lets a package outside gowt adjust the swt control.
func DateTime ¶
DateTime creates a date picker; DropDown() makes the date field a drop-down calendar. Options: DropDown, AsTime, AsCalendar, Value, OnChange.
func Destructive ¶
func Destructive() Option
Destructive marks a push Button whose action deletes or discards: macOS hasDestructiveAction (red), GTK "destructive-action" (red fill), Windows a standard button. With Primary it is also the default button, as for "Delete" in a confirmation.
func DropDown ¶
func DropDown() Option
DropDown makes a DateTime date field a drop-down calendar, or a ToolBar item a drop-down.
func Failed ¶
Failed sets what a Boundary shows when its children fail: f gets the error and reset, which disposes the fallback and creates the children again on the next event-loop turn. f returns one widget description, nil for nothing.
func Field ¶
Field is a row of Fields: a Label with the text label and the control beside it. opts go to the label (Foreground, Typeface, Tooltip), FieldTop moves it to the top of the row.
func FieldTop ¶
func FieldTop() Option
FieldTop, an option of Field, aligns the label with the top of a tall control (a multi-line Text, a List) instead of centring it on the control.
func Fields ¶
Fields creates a form: a two-column Grid in which every Field is a label and its control. The labels are aligned the way the OS does it, trailing on macOS and leading on Windows and GNOME, and centred on the control's row. Give the controls GrowX() to fill the second column; other options are those of Grid (Gap, Padding, GrowX) and may be mixed with the Field rows. Options: Gap, Padding, Border, Field.
func Fill ¶
Fill creates a container whose children share its whole width in equal parts, or its height with Vertical(); with one child, the child fills the container. Options: Vertical, Gap, Padding, Border, children.
func Fit ¶
func Fit() Option
Fit makes a Table or Tree column as wide as its header and its widest cell, again after the rows change (Row, Remove, Clear, Rows, Nodes, expand, collapse), once per event-loop turn. The width given to Column is only the first one. Every row is measured: for big data use Column.Pack once instead.
func Flow ¶
Flow creates a container that puts its children in a row at their natural size and wraps them to the next row when the width runs out; Vertical() makes it a column that wraps to the next column. Size sets the size of a child. Options: Vertical, Gap, Padding, Border, children.
func Focused ¶
func Focused() Option
Focused gives the widget the keyboard focus when its window is first shown, in place of the first control that SWT and the OS pick (with Full Keyboard Access on, macOS draws the focus ring on that control, often a button). Created into a window already on screen, the widget takes the focus on the next event-loop turn, or when that window is next activated. With several Focused in a window the last one created wins.
func Foreground ¶
Foreground sets the text colour of a widget, as SetForeground does.
func Form ¶
Form creates a container that positions each child by attaching its edges (see Anchor), which lets children stretch or follow siblings. Gap is the space Form leaves between attached siblings. Options: Gap, Padding, Border, children.
func Gap ¶
Gap sets the space in points between the children of a container, rows and columns of a Grid alike. The default is Spacing.SM; Gap(0) puts the children edge to edge.
func Grid ¶
Grid creates a container that lays its children out in columns columns, left to right, top to bottom, Gap apart in both directions: Grid(2, Label("Name"), Text(GrowX())) is a form row. Options: Gap, Padding, Border, children.
Example ¶
Grid places children in columns, a row of the form per line of code; placement options such as GrowX tune one child.
package main
import (
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Form",
gowt.Grid(2, gowt.Grow(),
gowt.Label("Name"), gowt.Text(gowt.GrowX()),
gowt.Label("Notes"), gowt.Text(gowt.Multiline(), gowt.Grow(), gowt.Size(0, 80))))
w.Show()
})
}
Output:
func Group ¶
Group creates a titled frame whose children stack as in a VBox, Padding(Spacing.SM) from the frame. Options: Gap, Padding, children.
func Grow ¶
func Grow() Option
Grow fills the cell and takes the free width and height of a VBox, HBox or Grid.
func GrowX ¶
func GrowX() Option
GrowX fills the width of the cell and takes the free width of an HBox or Grid row.
func GrowY ¶
func GrowY() Option
GrowY fills the height of the cell and takes the free height of a VBox or Grid column.
func HBox ¶
HBox creates a container that lines its children up left to right, Gap apart, one column per shown child. GrowX gives a child the free width; a Spacer takes it and pushes the rest to the end. Options: Gap, Padding, Border, children.
Example ¶
The tree of values reads like the screen: a header row, a form, a row of buttons at the right. Children whose callbacks use the window go in w.Add, after w exists.
package main
import (
"fmt"
"github.com/haiodo/gowt"
"github.com/haiodo/gowt/rx"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
name := rx.New("")
w := app.Window("Contacts")
w.Add(
gowt.HBox(gowt.GrowX(),
gowt.Label("Contacts"),
gowt.Spacer(),
gowt.Button("Add", gowt.OnClick(func() { name.Set("") }))),
gowt.Grid(2, gowt.GrowX(),
gowt.Label("Name"),
gowt.Text(gowt.GrowX(), gowt.Hint("Full name"), gowt.Bind(name))),
gowt.HBox(gowt.GrowX(),
gowt.Spacer(),
gowt.Button("Cancel", gowt.OnClick(w.Close)),
gowt.Button("Save", gowt.BindEnabled(rx.Compute(func() bool { return name.Get() != "" })),
gowt.OnClick(func() { fmt.Println("save", name.Peek()) }))))
w.Show()
})
}
Output:
func ID ¶
ID names a widget, a Panel or a Window for the QA driver, which picks controls by it. It is the same in every build and has no effect on the control. In an Each, take it from the row's data.
func Indent ¶
Indent moves the child x points right and y points down inside its cell; the cell grows by as much.
func Indeterminate ¶
func Indeterminate() Option
Indeterminate animates a Progress without a value.
func Init ¶
Init runs f on the widget once it and its children are created: a function that returns a description sets up its widget with it. A widget of another type than f takes goes to App.OnError.
func Inset ¶
Inset puts x points between the text and the left and right edge of a multi-line Text and y points above and below it, as SetInset does.
func Items ¶
Items shows the strings of list as the entries of a List or a Combo. Entries are matched by text, as Rows matches rows by key, so the selection stays on an entry that is still there. The binding owns the entries: give nil items to the constructor.
func LineNumbers ¶
func LineNumbers() Option
LineNumbers shows the line number of every line in a gutter at the left of the text. The numbers are SWT bullets drawn with the lines themselves, so they scroll with the text, keep the line spacing and the paragraph spacing of each line, stay level with wrapped lines (one number per line) and follow the font and the theme. The gutter widens with the digits of the last line number.
func Link ¶
Link creates a link label; OnClick gets the href of the clicked anchor (its text if there is no href). Options: OnClick, BindText.
func List ¶
List creates a list with the given items. Options: MultiSelect, NoBorder, Selected, OnSelect, OnActivate, Bind (int).
func MaxHeight ¶
MaxHeight keeps the natural height of a widget at most h points, as SetMaxHeight does.
func MultiSelect ¶
func MultiSelect() Option
MultiSelect allows several selected items in a List, Table or Tree.
func Multiline ¶
func Multiline() Option
Multiline makes a Text multi-line and wrapped. macOS and GTK scroll with an overlay bar that shows on overflow; Windows has no scroll bar unless Scrollbars() asks for one.
func NoBorder ¶
func NoBorder() Option
NoBorder removes the frame that List, Table and Tree have by default.
func Nodes ¶
func Nodes[T, K comparable](list rx.Reader[[]T], key func(T) K, children func(T) []T, fill func(n *Node, item T, created bool)) Option
Nodes shows one root node of a Tree per element of list and below each node one child per element of children(item), nil for a flat tree. It is Rows for a tree, level by level: siblings are matched by key, a surviving node keeps its expansion and selection, and a node whose key moved among its siblings is made again with its subtree and keeps the expansion and selection of every node in it. fill runs after the children of the node exist; created is true when the node is made, also again after a move, and false when its element changed: set the initial expansion when created.
func OnActivate ¶
OnActivate runs f on Enter in a single-line Text (func()), and on a double click or Enter on an item of a List or Table (func(int)) or a node of a Tree (func(*Node)).
func OnChange ¶
OnChange runs f with the new value after the user changed it: the text of a Text, Combo or StyledText (func(string)), the state of a Switch or a Check button (func(bool)), the value of a Scale, Slider or Spinner (func(int)), the value of a DateTime (func(time.Time)).
func OnClick ¶
OnClick runs f when a Button is pressed (func()), or with the href of the anchor a Link's user clicked (func(href string)).
func OnFocus ¶
OnFocus runs f with true when the widget gets keyboard focus and with false when it loses it. A container does not report the focus of its children: put the option on the widget that takes keys.
func OnSelect ¶
OnSelect runs f when the selection changes: with the index of the selected item of a Combo, List, Table, Tabs or CTabs (func(int)), with the selected node of a Tree (func(*Node)).
func Padding ¶
Padding sets the space in points between the edge of a container and its children. The default is Spacing.PageMargin for a Window and a Tab, Spacing.SM for a Group and 0 elsewhere.
func Pages ¶
Pages creates a container whose children are pages, one shown at a time; the first is shown until Show picks another. Options: Border, children.
Example ¶
Pages shows one child at a time; Current tells which.
package main
import (
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
var pages *gowt.PagesView
w := app.Window("Wizard",
gowt.Pages(gowt.Grow(), gowt.Ref(&pages),
gowt.Label("Step 1"),
gowt.Label("Step 2")))
w.Add(gowt.Button("Next", gowt.OnClick(func() { pages.Show((pages.Current() + 1) % 2) })))
w.Show()
})
}
Output:
func Place ¶
Place aligns the child inside its cell: Place(AlignEnd, AlignCenter) puts it at the right, centred vertically.
func Primary ¶
func Primary() Option
Primary marks a push Button as the main action of its window: it is the window's default button (Enter presses it) and has the system's prominent look: macOS the accent default button, GTK "suggested-action", Windows the WinUI accent button. The last Primary of a window is its default.
func Progress ¶
Progress creates a progress bar over [0, max]. Options: Vertical, Smooth, Indeterminate, Value.
func Ref ¶
Ref stores the widget in *p once it and its children are created, for the code after the Add that creates it, which calls its methods. A Ref to a type other than the widget's is reported to App.OnError.
func Rows ¶
func Rows[T, K comparable](list rx.Reader[[]T], key func(T) K, fill func(r *TableRow, item T)) Option
Rows shows one row of a Table per element of list, in the order of list: the {#each list as item (key)} of Svelte. fill sets up the row of a new element and runs again for a row whose element is no longer == to the one it showed. When list changes, rows are matched by key: a row whose key is gone is removed, a new key gets a new row, and the other rows stay as they are, selection included. A row whose key moved is made again at its new place (fill runs) and keeps its selection. Keys should be unique; a repeated key gets a row made again on every change.
The binding owns the rows: add the columns in Init and no rows by hand. fill runs untracked, after the Init options, whatever the order of the options.
func Sash ¶
Sash creates a sash; Vertical() makes a vertical bar that moves left and right. Options: Vertical.
func Scale ¶
Scale creates a scale over [min, max] at min; Value sets another start. Options: Vertical, Value, OnChange, Bind (int).
func Scroll ¶
Scroll creates a scrolled area whose children stack as in a VBox; Border() draws a frame. Options: Border, Gap, Padding, children.
func Scrollbars ¶
func Scrollbars() Option
Scrollbars gives a StyledText vertical and horizontal scroll bars (they appear when needed).
func Search ¶
func Search() Option
Search makes a Text a search field with a magnifier icon and a clear button.
func Section ¶
Section creates a grouped section whose children are its rows, separated by lines; a row fills the width unless it is placed otherwise. Pass GrowX() to stretch the section in its parent. docs/theme-look.md tells how each OS fills the card. Options: common only, children.
func Separator ¶
Separator creates a line across the width of its cell, or along its height with Vertical(). Span(n) stretches it over a Grid row of n columns. Options: Vertical.
func Shortcut ¶
Shortcut binds keys to a menu item and shows them next to its text: Shortcut("Cmd+O"), Shortcut("Cmd+Shift+S"), Shortcut("Alt+Left"). Cmd is Command on macOS and Ctrl elsewhere; Ctrl, Alt and Shift are the same keys on every OS. The last part is a letter, digit or punctuation mark, or one of Left, Right, Up, Down, Home, End, PageUp, PageDown, Enter, Esc, Tab, Space, Backspace, Delete, Insert, F1-F12, in any case. Shortcut panics on a name it does not know.
Example ¶
A menu item with Shortcut runs on Cmd+S (Ctrl+S on Windows and Linux) and shows the key.
package main
import (
"fmt"
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Editor")
file := w.MenuBar().Submenu("&File")
file.Item("&Save", func() { fmt.Println("saved") }, gowt.Shortcut("Cmd+S"))
w.Show()
})
}
Output:
func Size ¶
Size asks for a width and height in points, zero keeps the natural one. It works in a VBox, HBox, Grid, Flow and Form.
func Slider ¶
Slider creates a slider over [min, max] at min; Value sets another start. Options: Vertical, Value, OnChange, Bind (int).
func Spacer ¶
Spacer creates an empty cell that takes the free space along a VBox or an HBox, or the free width of a Grid row, pushing the cells after it to the end. Elsewhere it is an empty Label. Options: common only.
func Spinner ¶
Spinner creates a spinner over [min, max] at min; Value sets another start. Options: ReadOnly, Border, Value, OnChange, Bind (int).
func Split ¶
Split creates a sash form: its children side by side, or stacked with Vertical(), with draggable sashes between them. Every pane fills its part, sized by SetWeights; Grow on a pane is accepted and changes nothing, Size, Span and the other placement options are reported to App.OnError. Options: Vertical, children.
func StyledText ¶
StyledText creates a multi-line styled editor. Options: Scrollbars, Wrap, ReadOnly, Border, Value, OnChange, LineNumbers.
Example ¶
StyledText offsets are runes; spans style ranges of the text.
package main
import (
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Editor", gowt.StyledText(gowt.Scrollbars(), gowt.Grow(), gowt.Value("bold word"),
gowt.Init(func(ed *gowt.StyledTextView) { ed.SetStyle(0, 4, gowt.TextStyle{Bold: true}) })))
w.Show()
})
}
Output:
func Switch ¶
Switch creates an on/off toggle for a setting that takes effect at once. It is a check box on every OS, the same control as Button(text, Check()), which reads as one choice of a form applied later: SWT has no switch control, and NSSwitch on macOS or GtkSwitch on Linux would need a view that the toolkit does not create. Options: OnChange, Checked, Bind (bool), BindText.
func Tab ¶
Tab creates a tab page of a Tabs or CTabs; its children stack as in a VBox, Padding(Spacing.PageMargin) from the edge. Ref gives the page as a *Panel; its Dispose removes the tab too, and a CTabs tab closed by its button disposes the page. Options: Closable (CTabs), Gap, Padding, children.
func Table ¶
Table creates a table with a visible header and grid lines. Options: Check, MultiSelect, NoBorder, Selected, OnSelect, OnActivate.
Example ¶
A table that fills the window: columns first, then one row per record; SetData keeps an application value with a row.
package main
import (
"fmt"
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
var t *gowt.TableView // OnActivate reads the rows
w := app.Window("Processes", gowt.Table(gowt.Grow(), gowt.MultiSelect(), gowt.Ref(&t),
gowt.OnActivate(func(i int) { fmt.Println("open", t.RowAt(i).TextAt(0), t.RowAt(i).Data()) }),
gowt.Init(func(t *gowt.TableView) { // fills the table once it exists
t.Column("Name", 160)
t.Column("CPU", 60, gowt.Right())
t.Row("gowt", "1.5").SetData("pid-1")
t.Row("docker", "12.0")
})))
w.Show()
})
}
Output:
func Tabs ¶
Tabs creates a tab folder whose children are Tab pages; Bottom() moves the tabs below the pages. Options: Bottom, Selected, OnSelect, children (Tab only).
func Text ¶
Text creates an edit field. Options: Multiline, Password, ReadOnly, Search, Border, NoBorder, Scrollbars, Hint, Value, OnChange, OnActivate, Bind (string). Windows 11: a Text has the WinUI 3 text box frame (4 px radius, hairline, accent line on focus) unless NoBorder.
Example ¶
A field that takes the free width, a password field and a search field with a hint.
package main
import (
"fmt"
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Fields",
gowt.Grid(2, gowt.GrowX(),
gowt.Label("User"), gowt.Text(gowt.GrowX(), gowt.Size(200, 0), gowt.OnChange(func(s string) { fmt.Println("user:", s) })),
gowt.Label("Password"), gowt.Text(gowt.Password(), gowt.GrowX()),
gowt.Text(gowt.Search(), gowt.GrowX(), gowt.Span(2), gowt.Hint("Search"))))
w.Show()
})
}
Output:
func ToolBar ¶
ToolBar creates a tool bar; Flat() and Wrap() change its look. Its items come from Item. Options: Flat, Wrap.
func Tree ¶
Tree creates a tree. Rows select as a whole (CellSelect() opts out) so that a click in any column finds its node. With Column, the first column holds the tree and the header is shown until ShowHeader(false). Options: Check, MultiSelect, NoBorder, CellSelect, OnSelect, OnActivate.
Example ¶
Nodes nest under the tree and under each other; callbacks get the node.
package main
import (
"fmt"
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Files", gowt.Tree(gowt.Grow(),
gowt.OnSelect(func(n *gowt.Node) { fmt.Println(n.Text()) }),
gowt.Init(func(t *gowt.TreeView) {
docs := t.Node("Documents")
docs.Node("report.pdf")
docs.SetExpanded(true)
})))
w.Show()
})
}
Output:
func VBox ¶
VBox creates a container that stacks its children top to bottom, Gap apart. A child takes its natural size unless GrowX, GrowY or Grow stretch it; a Spacer takes the free height. Options: Gap, Padding, Border, children.
func Value ¶
Value sets the starting value: the text of a Text, Combo or StyledText (string), the value of a Scale, Slider, Spinner or Progress (int; without it the minimum), the date or time of a DateTime.
type PagesView ¶
type PagesView struct {
// contains filtered or unexported fields
}
PagesView shows one page at a time at the full size of the container, like a tab folder without tabs.
func (*PagesView) AsComposite ¶
AsComposite returns the underlying composite, as Panel does, for the look package.
func (*PagesView) Dispose ¶
func (w *PagesView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*PagesView) Enabled ¶
func (w *PagesView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*PagesView) Focus ¶
func (w *PagesView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*PagesView) OnDispose ¶
func (w *PagesView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*PagesView) SetBackground ¶
func (w *PagesView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*PagesView) SetEnabled ¶
func (w *PagesView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*PagesView) SetFont ¶
func (w *PagesView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*PagesView) SetForeground ¶
func (w *PagesView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*PagesView) SetHeight ¶
func (w *PagesView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*PagesView) SetMaxHeight ¶
func (w *PagesView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*PagesView) SetSize ¶
func (w *PagesView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*PagesView) SetTooltip ¶
func (w *PagesView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*PagesView) SetVisible ¶
func (w *PagesView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*PagesView) Show ¶
Show makes page i, counted from 0 in the order the pages were added, the visible one. Dispose on a page removes it: the pages after it move down by one, and when it was shown the page before it is shown, or the next one when it was the first.
type Paint ¶
type Paint interface {
// contains filtered or unexported methods
}
Paint is a widget colour: an RGB, the same in both themes, an Adaptive with one per theme, or SecondaryText. Only this package implements it.
type Panel ¶
type Panel struct {
// contains filtered or unexported fields
}
Panel is a container: VBox, HBox, Grid, Flow, Fill, Form and Tab create one. Window, Group, Split and CoolBar embed its methods.
func (Panel) Add ¶
func (p Panel) Add(children ...Option)
Add creates children at the end of p, in order, and lays p out again when it is on screen, measuring only the new children. It is the way to fill a container after its creation, for content that changes; see Clear.
Example ¶
Add fills a container after its creation; Clear empties it for new content.
package main
import (
"time"
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
var list *gowt.Panel
w := app.Window("Log", gowt.VBox(gowt.Grow(), gowt.Ref(&list)))
w.Add(gowt.Button("More", gowt.OnClick(func() { list.Add(gowt.Label(time.Now().Format(time.TimeOnly))) })))
w.Add(gowt.Button("Clear", gowt.OnClick(func() { list.Clear() })))
w.Show()
})
}
Output:
func (Panel) AsComposite ¶
AsComposite returns the underlying composite; unlike Unwrap it has the same type on Panel, Window, Group, Split and CoolBar, so one function can take any of them.
func (Panel) Clear ¶
func (p Panel) Clear()
Clear disposes every child and lays p out again, ready for new content.
func (Panel) Relayout ¶
func (p Panel) Relayout()
Relayout lays the children out again and recomputes their sizes, as needed after a change made through Unwrap, such as swt.Label.SetText. The facade setters that change a size (SetText, SetImage, SetFont, SetTitle of a Group, SetItems of a Combo) lay out by themselves. p keeps its own size: to let it grow too, Relayout the Window.
type Popover ¶
type Popover struct {
// contains filtered or unexported fields
}
Popover is a floating panel next to a control or a point: a quick panel, an operation box, a "go to" search. Its children are ordinary widgets, added as in a Window. It closes by a click outside, Esc and loss of the application focus. A closed popover keeps its content and can be shown again.
macOS shows an NSPopover with the arrow and the system material. Windows and Linux show a borderless window with a frame, placed so that it stays on the screen of the anchor.
func (Popover) Add ¶
func (p Popover) Add(children ...Option)
Add creates children at the end of p, in order, and lays p out again when it is on screen, measuring only the new children. It is the way to fill a container after its creation, for content that changes; see Clear.
func (Popover) AsComposite ¶
AsComposite returns the underlying composite; unlike Unwrap it has the same type on Panel, Window, Group, Split and CoolBar, so one function can take any of them.
func (Popover) Clear ¶
func (p Popover) Clear()
Clear disposes every child and lays p out again, ready for new content.
func (*Popover) Close ¶
func (p *Popover) Close()
Close hides the popover as the user's click outside would, and runs OnClose. It does nothing when the popover is not shown.
func (*Popover) Dispose ¶
func (p *Popover) Dispose()
Dispose destroys the popover and its content; a shown popover closes first.
func (*Popover) OnClose ¶
func (p *Popover) OnClose(f func())
OnClose registers f, called each time the popover closes, however it closed.
func (*Popover) OnEscape ¶
OnEscape registers f, called on Esc in the popover before it closes; returning true keeps the popover open (the search clears its text first, say). Enter is not handled: use the OnActivate of the text field or the list.
func (Popover) Relayout ¶
func (p Popover) Relayout()
Relayout lays the children out again and recomputes their sizes, as needed after a change made through Unwrap, such as swt.Label.SetText. The facade setters that change a size (SetText, SetImage, SetFont, SetTitle of a Group, SetItems of a Combo) lay out by themselves. p keeps its own size: to let it grow too, Relayout the Window.
func (*Popover) SetSize ¶
SetSize fixes the content size in points; without it the popover takes its preferred size at Show.
func (*Popover) ShowAt ¶
func (p *Popover) ShowAt(anchor Widget, edge PopoverEdge)
ShowAt opens the popover next to the control anchor on the given edge. A gfx view is an anchor through its Canvas.
func (*Popover) ShowAtPoint ¶
func (p *Popover) ShowAtPoint(anchor Widget, x, y int, edge PopoverEdge)
ShowAtPoint opens the popover at the point (x, y) of the control anchor, in the control's points. Over a gfx view the caller converts a scene point to the canvas point first.
type PopoverEdge ¶
type PopoverEdge int
PopoverEdge is the side of the anchor on which a Popover prefers to open.
const ( PopoverBelow PopoverEdge = iota PopoverAbove PopoverRight PopoverLeft )
The zero value is PopoverBelow. A popover that does not fit on its edge opens on the opposite one.
type PrintArea ¶
type PrintArea struct{ X, Y, W, H float64 }
PrintArea is a rectangle on a page in points (1/72 inch), y down.
type PrintJob ¶
type PrintJob struct {
// contains filtered or unexported fields
}
PrintJob is a printer with its settings: chosen in the system dialog (Window.PrintDialog) or the file a job is written to (PrintToPDF). Print draws the pages.
func PrintToPDF ¶
func PrintToPDF(path string, o PrintOptions) (*PrintJob, error)
PrintToPDF makes a job that writes a PDF file instead of printing: macOS and Linux save the job as PDF, Windows prints to the "Microsoft Print to PDF" printer with the file name set, which needs that printer (a Windows feature that is on by default). The file is written by Print.
func (*PrintJob) PageRange ¶
PageRange is the range of pages chosen in the dialog: first is 1-based and last is 0 for the end of the document. A job from PrintToPDF prints everything.
func (*PrintJob) Print ¶
Print runs the job: it asks the printer for pages first..last of a document of pages pages (the dialog's range, clamped to the document) and calls draw for each, in order. The job ends when draw has returned for the last page, or is cancelled when draw panics. The printer is released by Print; a job prints once.
type PrintOptions ¶
type PrintOptions struct {
// Title is the name of the job in the printer queue; empty is "gowt".
Title string
// Margin is kept free on every side inside the area the printer can reach, in points.
Margin float64
}
PrintOptions are the settings of a print job that the system dialog does not ask for.
type PrintPage ¶
type PrintPage struct {
Number int // 1-based
Paper PrintArea // the sheet; X and Y are 0
Printable PrintArea // what the printer can reach, on the sheet
Area PrintArea // Printable less the margin, in the coordinates of the page
// contains filtered or unexported fields
}
PrintPage is one page being drawn. Draw through GC, or through a gfx page of the package gfx/printing, which takes Native. Coordinates are points from the top left corner of the area the printer can reach (Printable); the part inside the margin of PrintOptions is Area.
func (*PrintPage) GC ¶
GC returns a graphics context whose unit is the point and whose origin is the top left corner of the printable area. Use it instead of Native on a page, not both.
func (*PrintPage) Native ¶
func (p *PrintPage) Native() NativeContext
Native returns the native context of the page, for package gfx/printing. A page is drawn through GC or through Native, not both.
type ProgressView ¶
type ProgressView struct {
// contains filtered or unexported fields
}
ProgressView is a progress bar; Vertical() rotates it, Indeterminate() animates it without a value.
func (*ProgressView) Dispose ¶
func (w *ProgressView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*ProgressView) Enabled ¶
func (w *ProgressView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*ProgressView) Focus ¶
func (w *ProgressView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*ProgressView) OnDispose ¶
func (w *ProgressView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*ProgressView) SetBackground ¶
func (w *ProgressView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*ProgressView) SetEnabled ¶
func (w *ProgressView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*ProgressView) SetFont ¶
func (w *ProgressView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*ProgressView) SetForeground ¶
func (w *ProgressView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*ProgressView) SetHeight ¶
func (w *ProgressView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*ProgressView) SetMaxHeight ¶
func (w *ProgressView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*ProgressView) SetSize ¶
func (w *ProgressView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*ProgressView) SetTooltip ¶
func (w *ProgressView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*ProgressView) SetValue ¶
func (p *ProgressView) SetValue(v int)
SetValue sets the progress to v, within [0, max].
func (*ProgressView) SetVisible ¶
func (w *ProgressView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*ProgressView) Unwrap ¶
func (p *ProgressView) Unwrap() *swt.ProgressBar
Unwrap returns the underlying swt.ProgressBar for the full API.
func (*ProgressView) Value ¶
func (p *ProgressView) Value() int
Value returns the progress within [0, max].
type SashView ¶
type SashView struct {
// contains filtered or unexported fields
}
SashView is a bare draggable divider; most code wants Split instead. The sash does not move itself: OnMove must lay it out (Unwrap gives the layout data).
func (*SashView) Dispose ¶
func (w *SashView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*SashView) Enabled ¶
func (w *SashView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*SashView) Focus ¶
func (w *SashView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*SashView) OnDispose ¶
func (w *SashView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*SashView) OnMove ¶
OnMove runs f with the position the user dragged the sash to, in parent coordinates.
func (*SashView) SetBackground ¶
func (w *SashView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*SashView) SetEnabled ¶
func (w *SashView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*SashView) SetFont ¶
func (w *SashView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*SashView) SetForeground ¶
func (w *SashView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*SashView) SetHeight ¶
func (w *SashView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*SashView) SetMaxHeight ¶
func (w *SashView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*SashView) SetSize ¶
func (w *SashView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*SashView) SetTooltip ¶
func (w *SashView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*SashView) SetVisible ¶
func (w *SashView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
type ScaleView ¶
type ScaleView struct {
// contains filtered or unexported fields
}
ScaleView is a slider with tick marks; Vertical() rotates it.
func (*ScaleView) Dispose ¶
func (w *ScaleView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*ScaleView) Enabled ¶
func (w *ScaleView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*ScaleView) Focus ¶
func (w *ScaleView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*ScaleView) OnDispose ¶
func (w *ScaleView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*ScaleView) SetBackground ¶
func (w *ScaleView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*ScaleView) SetEnabled ¶
func (w *ScaleView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*ScaleView) SetFont ¶
func (w *ScaleView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*ScaleView) SetForeground ¶
func (w *ScaleView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*ScaleView) SetHeight ¶
func (w *ScaleView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*ScaleView) SetMaxHeight ¶
func (w *ScaleView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*ScaleView) SetSize ¶
func (w *ScaleView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*ScaleView) SetTooltip ¶
func (w *ScaleView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*ScaleView) SetVisible ¶
func (w *ScaleView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
type ScrollView ¶
type ScrollView struct {
// contains filtered or unexported fields
}
ScrollView shows content larger than itself with scroll bars.
func (*ScrollView) Add ¶
func (s *ScrollView) Add(children ...Option)
Add creates children at the end of the content, lays them out and fits the scrollable size as Fit does; the children already there keep their measured sizes.
func (*ScrollView) Content ¶
func (s *ScrollView) Content() *Panel
Content is the container that scrolls.
func (*ScrollView) Dispose ¶
func (w *ScrollView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*ScrollView) Enabled ¶
func (w *ScrollView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*ScrollView) Fit ¶
func (s *ScrollView) Fit()
Fit sets the scrollable size to the content's natural size; Scroll and Add call it, call it again after the content changes otherwise.
func (*ScrollView) Focus ¶
func (w *ScrollView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*ScrollView) OnDispose ¶
func (w *ScrollView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*ScrollView) OnScroll ¶
func (s *ScrollView) OnScroll(f func(x, y int))
OnScroll runs f with the new Origin after any scroll: the mouse wheel, a trackpad gesture and its momentum, the scroll bars, SetOrigin, a resize that moves the content. Scrolls that come faster than a frame are coalesced into one call; the last call reports where the scroll stopped.
func (*ScrollView) Origin ¶
func (s *ScrollView) Origin() (x, y int)
Origin returns the point of the content shown at the top left corner: 0, 0 before any scroll.
func (*ScrollView) SetBackground ¶
func (w *ScrollView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*ScrollView) SetEnabled ¶
func (w *ScrollView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*ScrollView) SetFont ¶
func (w *ScrollView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*ScrollView) SetForeground ¶
func (w *ScrollView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*ScrollView) SetHeight ¶
func (w *ScrollView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*ScrollView) SetMaxHeight ¶
func (w *ScrollView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*ScrollView) SetOrigin ¶
func (s *ScrollView) SetOrigin(x, y int)
SetOrigin scrolls so that the content's point x, y is at the top left corner, as far as the content reaches.
func (*ScrollView) SetSize ¶
func (w *ScrollView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*ScrollView) SetTooltip ¶
func (w *ScrollView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*ScrollView) SetVisible ¶
func (w *ScrollView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*ScrollView) Unwrap ¶
func (s *ScrollView) Unwrap() *swt.ScrolledComposite
Unwrap returns the underlying swt.ScrolledComposite for the full API.
type SectionView ¶
type SectionView struct {
// contains filtered or unexported fields
}
SectionView is a grouped "inset" section as in macOS System Settings: rows on a rounded card in the platform's grouped background colour, separated by lines. A heading is a Label above it.
func (*SectionView) AsComposite ¶
func (s *SectionView) AsComposite() *swt.Composite
AsComposite returns the underlying composite, as Panel does, for the look package.
func (*SectionView) Dispose ¶
func (w *SectionView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*SectionView) Enabled ¶
func (w *SectionView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*SectionView) Focus ¶
func (w *SectionView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*SectionView) OnDispose ¶
func (w *SectionView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*SectionView) SetBackground ¶
func (w *SectionView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*SectionView) SetEnabled ¶
func (w *SectionView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*SectionView) SetFont ¶
func (w *SectionView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*SectionView) SetForeground ¶
func (w *SectionView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*SectionView) SetHeight ¶
func (w *SectionView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*SectionView) SetMaxHeight ¶
func (w *SectionView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*SectionView) SetSize ¶
func (w *SectionView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*SectionView) SetTooltip ¶
func (w *SectionView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*SectionView) SetVisible ¶
func (w *SectionView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*SectionView) Unwrap ¶
func (s *SectionView) Unwrap() *swt.Composite
Unwrap returns the underlying composite.
type SliderView ¶
type SliderView struct {
// contains filtered or unexported fields
}
SliderView is a scroll-bar style control; Vertical() rotates it.
func (*SliderView) Dispose ¶
func (w *SliderView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*SliderView) Enabled ¶
func (w *SliderView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*SliderView) Focus ¶
func (w *SliderView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*SliderView) OnChange ¶
func (s *SliderView) OnChange(f func(value int))
OnChange runs f with the new value.
func (*SliderView) OnDispose ¶
func (w *SliderView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*SliderView) SetBackground ¶
func (w *SliderView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*SliderView) SetEnabled ¶
func (w *SliderView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*SliderView) SetFont ¶
func (w *SliderView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*SliderView) SetForeground ¶
func (w *SliderView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*SliderView) SetHeight ¶
func (w *SliderView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*SliderView) SetMaxHeight ¶
func (w *SliderView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*SliderView) SetSize ¶
func (w *SliderView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*SliderView) SetTooltip ¶
func (w *SliderView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*SliderView) SetVisible ¶
func (w *SliderView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*SliderView) Unwrap ¶
func (s *SliderView) Unwrap() *swt.Slider
Unwrap returns the underlying swt.Slider for the full API.
func (*SliderView) Value ¶
func (s *SliderView) Value() int
Value returns the position within [min, max].
type SortDir ¶
type SortDir int
SortDir is the sort indicator drawn in a column header. It only draws the arrow: sorting the rows is up to the app.
type SpacingScale ¶
type SpacingScale struct {
XS, SM, MD, LG, XL int
// PageMargin is the margin between a window or page edge and its content.
PageMargin int
// RowHeight is the height of a list, table or tree row, ControlHeight that of a button, text field
// or combo, SidebarRow that of a sidebar row; SidebarWidth and InspectorWidth are the usual widths
// of look.SetSidebar and look.SetInspector.
RowHeight, ControlHeight, SidebarRow int
SidebarWidth, InspectorWidth int
}
SpacingScale is the set of spacing tokens, in points like every other facade size. The platform scales points to pixels, so the values are whole pixels at 100..200% in steps of 25% as long as they are multiples of 4.
type SpinnerView ¶
type SpinnerView struct {
// contains filtered or unexported fields
}
SpinnerView is an integer edit field with arrows.
func (*SpinnerView) Dispose ¶
func (w *SpinnerView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*SpinnerView) Enabled ¶
func (w *SpinnerView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*SpinnerView) Focus ¶
func (w *SpinnerView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*SpinnerView) OnChange ¶
func (s *SpinnerView) OnChange(f func(value int))
OnChange runs f with the new value after the arrows or typing changed it.
func (*SpinnerView) OnDispose ¶
func (w *SpinnerView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*SpinnerView) SetBackground ¶
func (w *SpinnerView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*SpinnerView) SetEnabled ¶
func (w *SpinnerView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*SpinnerView) SetFont ¶
func (w *SpinnerView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*SpinnerView) SetForeground ¶
func (w *SpinnerView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*SpinnerView) SetHeight ¶
func (w *SpinnerView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*SpinnerView) SetMaxHeight ¶
func (w *SpinnerView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*SpinnerView) SetSize ¶
func (w *SpinnerView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*SpinnerView) SetTooltip ¶
func (w *SpinnerView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*SpinnerView) SetValue ¶
func (s *SpinnerView) SetValue(v int)
SetValue sets the number to v.
func (*SpinnerView) SetVisible ¶
func (w *SpinnerView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*SpinnerView) Unwrap ¶
func (s *SpinnerView) Unwrap() *swt.Spinner
Unwrap returns the underlying swt.Spinner for the full API.
func (*SpinnerView) Value ¶
func (s *SpinnerView) Value() int
Value returns the number within [min, max].
type SplitView ¶
type SplitView struct {
// contains filtered or unexported fields
}
SplitView divides its children with draggable sashes; the children are ordinary Panel children.
func (SplitView) Add ¶
func (p SplitView) Add(children ...Option)
Add creates children at the end of p, in order, and lays p out again when it is on screen, measuring only the new children. It is the way to fill a container after its creation, for content that changes; see Clear.
func (SplitView) AsComposite ¶
AsComposite returns the underlying composite; unlike Unwrap it has the same type on Panel, Window, Group, Split and CoolBar, so one function can take any of them.
func (SplitView) Clear ¶
func (p SplitView) Clear()
Clear disposes every child and lays p out again, ready for new content.
func (SplitView) Relayout ¶
func (p SplitView) Relayout()
Relayout lays the children out again and recomputes their sizes, as needed after a change made through Unwrap, such as swt.Label.SetText. The facade setters that change a size (SetText, SetImage, SetFont, SetTitle of a Group, SetItems of a Combo) lay out by themselves. p keeps its own size: to let it grow too, Relayout the Window.
func (*SplitView) SetWeights ¶
SetWeights sets the relative size of each child, one weight per child.
type StyledTextView ¶
type StyledTextView struct {
// contains filtered or unexported fields
}
StyledTextView is a multi-line editor with per-range styles. All offsets and lengths are in runes, i.e. indexes into []rune(Text()); the facade converts to the UTF-16 units SWT uses. Each conversion scans the text, O(n) per call: fine for documents up to some hundred kilobytes; for larger ones keep a line index and use Unwrap with SWT offsets.
Not wrapped (use Unwrap): bullets other than LineNumbers, line alignment and indent, glyph metrics, underline styles and colors, block selection, verify and extended-modify listeners (undo), bidi segments, custom content.
func (*StyledTextView) Append ¶
func (t *StyledTextView) Append(s string)
Append adds s at the end.
func (*StyledTextView) Caret ¶
func (t *StyledTextView) Caret() int
Caret returns the caret position.
func (*StyledTextView) ClearStyles ¶
func (t *StyledTextView) ClearStyles()
ClearStyles removes every style.
func (*StyledTextView) Copy ¶
func (t *StyledTextView) Copy()
Copy copies the selection to the system clipboard.
func (*StyledTextView) Cut ¶
func (t *StyledTextView) Cut()
Cut moves the selection to the system clipboard.
func (*StyledTextView) Dispose ¶
func (w *StyledTextView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*StyledTextView) Enabled ¶
func (w *StyledTextView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*StyledTextView) Focus ¶
func (w *StyledTextView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*StyledTextView) Insert ¶
func (t *StyledTextView) Insert(s string)
Insert adds s at the caret.
func (*StyledTextView) LineAt ¶
func (t *StyledTextView) LineAt(offset int) int
LineAt returns the line index that holds the rune offset.
func (*StyledTextView) LineStart ¶
func (t *StyledTextView) LineStart(line int) int
LineStart returns the rune offset of the first character of line.
func (*StyledTextView) Lines ¶
func (t *StyledTextView) Lines() int
Lines returns the number of lines.
func (*StyledTextView) OnCaret ¶
func (t *StyledTextView) OnCaret(f func(offset int))
OnCaret runs f with the caret position after it moved.
func (*StyledTextView) OnChange ¶
func (t *StyledTextView) OnChange(f func(text string))
OnChange runs f with the new content after every edit.
func (*StyledTextView) OnDispose ¶
func (w *StyledTextView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*StyledTextView) OnSelect ¶
func (t *StyledTextView) OnSelect(f func(start, length int))
OnSelect runs f with the selection after it changed.
func (*StyledTextView) OnStyle ¶
func (t *StyledTextView) OnStyle(f func(line string) []StyleSpan)
OnStyle runs f each time a line is drawn; the spans it returns style that line only. Start is counted in runes from the beginning of the line, so no whole-text conversion happens per repaint. f must not change the text.
func (*StyledTextView) Paste ¶
func (t *StyledTextView) Paste()
Paste inserts the system clipboard text at the caret.
func (*StyledTextView) Replace ¶
func (t *StyledTextView) Replace(start, length int, s string)
Replace replaces length runes from start with s.
func (*StyledTextView) Reveal ¶
func (t *StyledTextView) Reveal()
Reveal scrolls so that the selection is visible.
func (*StyledTextView) ScrollToEnd ¶
func (t *StyledTextView) ScrollToEnd()
ScrollToEnd moves the caret to the end and scrolls it into view.
func (*StyledTextView) SelectedText ¶
func (t *StyledTextView) SelectedText() string
SelectedText returns the selected text.
func (*StyledTextView) Selection ¶
func (t *StyledTextView) Selection() (start, length int)
Selection returns the selected range; length is 0 when only the caret is set.
func (*StyledTextView) SetBackground ¶
func (w *StyledTextView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*StyledTextView) SetCaret ¶
func (t *StyledTextView) SetCaret(offset int)
SetCaret moves the caret.
func (*StyledTextView) SetEditable ¶
func (t *StyledTextView) SetEditable(on bool)
SetEditable allows or forbids typing.
func (*StyledTextView) SetEnabled ¶
func (w *StyledTextView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*StyledTextView) SetFont ¶
func (w *StyledTextView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*StyledTextView) SetForeground ¶
func (w *StyledTextView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*StyledTextView) SetHeight ¶
func (w *StyledTextView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*StyledTextView) SetLineBackground ¶
func (t *StyledTextView) SetLineBackground(line, count int, c RGB)
SetLineBackground colors count lines from line.
func (*StyledTextView) SetLineNumbers ¶
func (t *StyledTextView) SetLineNumbers(on bool)
SetLineNumbers shows or hides the line number gutter, see LineNumbers.
func (*StyledTextView) SetMaxHeight ¶
func (w *StyledTextView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*StyledTextView) SetParagraphSpacing ¶
func (t *StyledTextView) SetParagraphSpacing(line, before int)
SetParagraphSpacing leaves before points of empty space above line (NSParagraphStyle paragraphSpacingBefore); 0 removes it. A SetLineBackground color stops at the gap, so the gap above the first line of a colored block shows the widget background. The space belongs to the line: it moves with it when text is inserted above, SetText and a replace of the whole text drop it, and it does nothing while an OnStyle listener is set.
func (*StyledTextView) SetSelection ¶
func (t *StyledTextView) SetSelection(start, length int)
SetSelection selects length runes from start.
func (*StyledTextView) SetSize ¶
func (w *StyledTextView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*StyledTextView) SetStyle ¶
func (t *StyledTextView) SetStyle(start, length int, s TextStyle)
SetStyle applies s to length runes from start, replacing the styles there.
func (*StyledTextView) SetTabs ¶
func (t *StyledTextView) SetTabs(n int)
SetTabs sets the tab width in spaces.
func (*StyledTextView) SetText ¶
func (t *StyledTextView) SetText(s string)
SetText replaces the whole content.
func (*StyledTextView) SetTooltip ¶
func (w *StyledTextView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*StyledTextView) SetTopLine ¶
func (t *StyledTextView) SetTopLine(line int)
SetTopLine scrolls so that line is the first visible one.
func (*StyledTextView) SetVisible ¶
func (w *StyledTextView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*StyledTextView) SetWrap ¶
func (t *StyledTextView) SetWrap(on bool)
SetWrap turns word wrapping on or off.
func (*StyledTextView) Styles ¶
func (t *StyledTextView) Styles() []StyleSpan
Styles returns the styled ranges in order. Font is not reported.
func (*StyledTextView) Text ¶
func (t *StyledTextView) Text() string
Text returns the whole content.
func (*StyledTextView) TrimHead ¶
func (t *StyledTextView) TrimHead(keep int)
TrimHead deletes the oldest lines so that at most keep lines remain; TrimHead(0) clears the text. It does not touch the rest of the text and works on a read-only view.
func (*StyledTextView) Unwrap ¶
func (t *StyledTextView) Unwrap() *swt.StyledText
Unwrap returns the underlying swt.StyledText for the full API (offsets there are UTF-16 units).
type SwitchView ¶
type SwitchView struct {
// contains filtered or unexported fields
}
SwitchView is an on/off toggle, see panel.SwitchView.
func (*SwitchView) Checked ¶
func (s *SwitchView) Checked() bool
Checked reports whether the switch is on.
func (*SwitchView) Dispose ¶
func (w *SwitchView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*SwitchView) Enabled ¶
func (w *SwitchView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*SwitchView) Focus ¶
func (w *SwitchView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*SwitchView) OnChange ¶
func (s *SwitchView) OnChange(f func(on bool))
OnChange runs f with the new state when the user toggles the switch.
func (*SwitchView) OnDispose ¶
func (w *SwitchView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*SwitchView) SetBackground ¶
func (w *SwitchView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*SwitchView) SetChecked ¶
func (s *SwitchView) SetChecked(v bool)
SetChecked sets the state without calling OnChange.
func (*SwitchView) SetEnabled ¶
func (w *SwitchView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*SwitchView) SetFont ¶
func (w *SwitchView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*SwitchView) SetForeground ¶
func (w *SwitchView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*SwitchView) SetHeight ¶
func (w *SwitchView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*SwitchView) SetMaxHeight ¶
func (w *SwitchView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*SwitchView) SetSize ¶
func (w *SwitchView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*SwitchView) SetText ¶
func (s *SwitchView) SetText(t string)
SetText replaces the label. Lays the parents out when the size changes.
func (*SwitchView) SetTooltip ¶
func (w *SwitchView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*SwitchView) SetVisible ¶
func (w *SwitchView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*SwitchView) Unwrap ¶
func (s *SwitchView) Unwrap() *swt.Button
Unwrap returns the underlying swt.Button for the full API.
type TableClick ¶
type TableClick struct {
Row, Col int // row index and column index of the cell under the pointer
Button int // SWT's numbering: 1 left, 2 middle, 3 right
Count int // 1 for a single press, 2 for the second press of a double click
X, Y int // pointer position in the table's coordinates
Mods // keys held down
}
TableClick is a mouse press on a Table. Row and Col are -1 when the point is not on a row.
type TableRow ¶
type TableRow struct {
// contains filtered or unexported fields
}
TableRow is a table row. Rows are re-wrapped on every lookup: keep per-row state in SetData.
func (*TableRow) SetChecked ¶
SetChecked sets the check box of a Check table.
func (*TableRow) SetImageAt ¶
SetImageAt sets the icon of column col; the row does not own img.
type TableView ¶
type TableView struct {
// contains filtered or unexported fields
}
TableView is a multi-column grid with a header; rows are added with Row. Check makes rows checkable.
func (*TableView) Batch ¶
func (t *TableView) Batch(f func())
Batch runs f with drawing of the table suspended, so that many row changes repaint once.
func (*TableView) CellAt ¶
CellAt returns the row and column under the point (x, y) in the table's coordinates, or -1, -1 when no row is there. Col is -1 for a point in a row band but left of the first column or right of the last one.
func (*TableView) Clear ¶
func (t *TableView) Clear()
Clear deletes all rows and with them the selection.
func (*TableView) Column ¶
Column appends a column; Right() or Center() set the alignment, Fit() keeps the width to the content. Options: Right, Center, Fit.
func (*TableView) Deselect ¶
func (t *TableView) Deselect()
Deselect clears the selection and calls no OnSelect, as SWT's deselectAll sends no Selection.
func (*TableView) Dispose ¶
func (w *TableView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*TableView) Enabled ¶
func (w *TableView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*TableView) FitColumns ¶
func (t *TableView) FitColumns()
FitColumns resizes every column to its header and widest cell once, whether or not it has Fit.
func (*TableView) Focus ¶
func (w *TableView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*TableView) OnActivate ¶
OnActivate runs f on double click or Enter.
func (*TableView) OnCellClick ¶
func (t *TableView) OnCellClick(f func(TableClick))
OnCellClick runs f on every mouse press, so a handler can ignore right clicks (Button != 1) and double clicks (Count > 1). The cell comes from the hit test, not from the selection, which may not have moved yet.
func (*TableView) OnDispose ¶
func (w *TableView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*TableView) SetBackground ¶
func (w *TableView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*TableView) SetEnabled ¶
func (w *TableView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*TableView) SetFont ¶
func (w *TableView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*TableView) SetForeground ¶
func (w *TableView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*TableView) SetHeight ¶
func (w *TableView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*TableView) SetMaxHeight ¶
func (w *TableView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*TableView) SetSize ¶
func (w *TableView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*TableView) SetSort ¶
SetSort draws the sort indicator dir in the header of col; col nil or SortNone clears it.
func (*TableView) SetTooltip ¶
func (w *TableView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*TableView) SetVisible ¶
func (w *TableView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*TableView) ShowHeader ¶
ShowHeader shows or hides the column headers.
func (*TableView) ShowRowLines ¶
ShowRowLines shows or hides thin lines between rows only. On macOS ShowLines also turns on vertical lines and alternating row colors, this does not; elsewhere it is ShowLines.
type TabsView ¶
type TabsView struct {
// contains filtered or unexported fields
}
TabsView is a native tab folder; each Tab returns the page container.
func (*TabsView) Dispose ¶
func (w *TabsView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*TabsView) Enabled ¶
func (w *TabsView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*TabsView) Focus ¶
func (w *TabsView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*TabsView) OnDispose ¶
func (w *TabsView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*TabsView) SetBackground ¶
func (w *TabsView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*TabsView) SetEnabled ¶
func (w *TabsView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*TabsView) SetFont ¶
func (w *TabsView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*TabsView) SetForeground ¶
func (w *TabsView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*TabsView) SetHeight ¶
func (w *TabsView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*TabsView) SetMaxHeight ¶
func (w *TabsView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*TabsView) SetSize ¶
func (w *TabsView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*TabsView) SetTooltip ¶
func (w *TabsView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*TabsView) SetVisible ¶
func (w *TabsView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
type TextStyle ¶
type TextStyle struct {
Foreground, Background *RGB
Bold, Italic bool
Underline, Strikeout bool
Font *Font // a typeface other than the widget's, resolved as SetFont does
}
TextStyle is the look of a range of a StyledText. Nil colors inherit the widget's.
type TextView ¶
type TextView struct {
// contains filtered or unexported fields
}
TextView is an edit field.
func (*TextView) ContentHeight ¶
ContentHeight returns the height in points the text needs when the field is width points wide: the visual lines after wrapping, with the vertical inset, one line at least. It is the number to pass to SetHeight for a field that follows its text; AutoGrow does that itself. On a single-line Text it returns the natural height.
func (*TextView) Dispose ¶
func (w *TextView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*TextView) Enabled ¶
func (w *TextView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*TextView) Focus ¶
func (w *TextView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*TextView) Lines ¶
Lines returns the number of lines; a trailing newline starts an empty last line.
func (*TextView) OnActivate ¶
func (t *TextView) OnActivate(f func())
OnActivate runs f when the user presses Enter in a single-line field.
func (*TextView) OnDispose ¶
func (w *TextView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*TextView) ScrollToEnd ¶
func (t *TextView) ScrollToEnd()
ScrollToEnd moves the caret to the end and scrolls it into view.
func (*TextView) SetAutoGrow ¶
SetAutoGrow makes a multi-line Text ask its layout for the height of its text, as ContentHeight reports it, but not less than minHeight and, unless maxHeight is 0, not more than maxHeight points; beyond that the text scrolls. Text shorter than minHeight is centred vertically, so a one-line field looks as the single line of a native field does. The height follows every edit and every change of the width. maxHeight below minHeight is taken as minHeight.
func (*TextView) SetBackground ¶
func (w *TextView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*TextView) SetEnabled ¶
func (w *TextView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*TextView) SetFont ¶
func (w *TextView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*TextView) SetForeground ¶
func (w *TextView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*TextView) SetHeight ¶
func (w *TextView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*TextView) SetInset ¶
SetInset puts x points between the text and the left and right edge of a multi-line Text and y points above and below it; the hint moves with the text. macOS has one inset for both sides (textContainerInset), so the facade does the same; the default is 0. Inset does it at creation.
func (*TextView) SetMaxHeight ¶
func (w *TextView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*TextView) SetSize ¶
func (w *TextView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*TextView) SetTooltip ¶
func (w *TextView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*TextView) SetVisible ¶
func (w *TextView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*TextView) Text ¶
Text returns the current content; line breaks are \n on every system (Windows stores \r\n).
func (*TextView) TrimHead ¶
TrimHead deletes the oldest lines so that at most keep lines remain; TrimHead(0) clears the text. It reads the content to find the cut, so call it when Lines exceeds a cap by a margin, not after every Append. It works on a read-only Text.
type ToolBarView ¶
type ToolBarView struct {
// contains filtered or unexported fields
}
ToolBarView is a row of tool buttons.
func (*ToolBarView) Dispose ¶
func (w *ToolBarView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*ToolBarView) Enabled ¶
func (w *ToolBarView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*ToolBarView) Focus ¶
func (w *ToolBarView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*ToolBarView) Item ¶
func (t *ToolBarView) Item(text string, onClick func(), opts ...Option) *ToolItem
Item appends a push button (Check, Radio or DropDown for other kinds). onClick may be nil. Options: Check, Radio, DropDown; for a tooltip or a disabled item use SetTooltip and SetEnabled.
func (*ToolBarView) OnDispose ¶
func (w *ToolBarView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*ToolBarView) SetBackground ¶
func (w *ToolBarView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*ToolBarView) SetEnabled ¶
func (w *ToolBarView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*ToolBarView) SetFont ¶
func (w *ToolBarView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*ToolBarView) SetForeground ¶
func (w *ToolBarView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*ToolBarView) SetHeight ¶
func (w *ToolBarView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*ToolBarView) SetMaxHeight ¶
func (w *ToolBarView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*ToolBarView) SetSize ¶
func (w *ToolBarView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*ToolBarView) SetTooltip ¶
func (w *ToolBarView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*ToolBarView) SetVisible ¶
func (w *ToolBarView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*ToolBarView) Unwrap ¶
func (t *ToolBarView) Unwrap() *swt.ToolBar
Unwrap returns the underlying swt.ToolBar for the full API.
type ToolItem ¶
type ToolItem struct {
// contains filtered or unexported fields
}
ToolItem is a tool bar button.
func (*ToolItem) OnClick ¶
func (i *ToolItem) OnClick(f func())
OnClick runs f when the item is pressed (or toggled).
func (*ToolItem) SetChecked ¶
SetChecked sets the state of a Check or Radio item.
func (*ToolItem) SetEnabled ¶
SetEnabled enables or greys out the item.
func (*ToolItem) SetImage ¶
SetImage sets the icon; the item does not own img. Lays the tool bar's parents out when its size changes.
func (*ToolItem) SetText ¶
SetText replaces the item text. Lays the tool bar's parents out when its size changes.
func (*ToolItem) SetTooltip ¶
SetTooltip sets the text shown on hover.
type TrayIcon ¶
type TrayIcon struct {
// contains filtered or unexported fields
}
TrayIcon is an icon in the system tray / status area.
func (*TrayIcon) OnClick ¶
func (t *TrayIcon) OnClick(f func())
OnClick runs f when the icon is clicked.
func (*TrayIcon) SetTooltip ¶
SetTooltip sets the text shown on hover.
type TreeClick ¶
type TreeClick struct {
Node *Node
Col int // column index of the cell under the pointer
Button int // SWT's numbering: 1 left, 2 middle, 3 right
Count int // 1 for a single press, 2 for the second press of a double click
X, Y int // pointer position in the tree's coordinates
Mods // keys held down
}
TreeClick is a mouse press on a Tree. Node is nil and Col is -1 when the point is not on a node.
type TreeView ¶
type TreeView struct {
// contains filtered or unexported fields
}
TreeView is a hierarchy of Nodes. Check makes nodes checkable, MultiSelect allows several selected.
func (*TreeView) Batch ¶
func (t *TreeView) Batch(f func())
Batch runs f with drawing of the tree suspended, so that many node changes repaint once.
func (*TreeView) CellAt ¶
CellAt returns the node and column under the point (x, y) in the tree's coordinates, or nil, -1 when no node is there. The expander arrow and the space right of the text map to the cell; col is -1 for a point in the row's band but right of the last column.
func (*TreeView) Column ¶
Column appends a column; Right() or Center() set the alignment. The first column holds the node text and the expand arrows. The first call shows the header. Options: Right, Center, Fit.
func (*TreeView) Deselect ¶
func (t *TreeView) Deselect()
Deselect clears the selection and calls no OnSelect, as SWT's deselectAll sends no Selection.
func (*TreeView) Dispose ¶
func (w *TreeView) Dispose()
Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.
func (*TreeView) Enabled ¶
func (w *TreeView) Enabled() bool
Enabled reports the state set by SetEnabled, not that of the parents.
func (*TreeView) FitColumns ¶
func (t *TreeView) FitColumns()
FitColumns resizes every column to its header and widest cell once, whether or not it has Fit.
func (*TreeView) Focus ¶
func (w *TreeView) Focus() bool
Focus gives the control the keyboard focus and reports whether it took it.
func (*TreeView) OnActivate ¶
OnActivate runs f on double click or Enter.
func (*TreeView) OnCellClick ¶
OnCellClick runs f on every mouse press, so a handler can ignore right clicks (Button != 1) and double clicks (Count > 1). The cell comes from the hit test, not from the selection, which may not have moved yet.
func (*TreeView) OnCollapse ¶
OnCollapse runs f with the node that was collapsed; see OnExpand.
func (*TreeView) OnDispose ¶
func (w *TreeView) OnDispose(f func())
OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.
func (*TreeView) Select ¶
Select selects n alone; nil clears the selection. It calls no OnSelect, as SWT's setSelection sends no Selection.
func (*TreeView) SetBackground ¶
func (w *TreeView) SetBackground(c Paint)
SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.
func (*TreeView) SetEnabled ¶
func (w *TreeView) SetEnabled(v bool)
SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.
func (*TreeView) SetFont ¶
func (w *TreeView) SetFont(f Font)
SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.
func (*TreeView) SetForeground ¶
func (w *TreeView) SetForeground(c Paint)
SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.
func (*TreeView) SetHeight ¶
func (w *TreeView) SetHeight(h int)
SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.
func (*TreeView) SetMaxHeight ¶
func (w *TreeView) SetMaxHeight(h int)
SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.
func (*TreeView) SetSize ¶
func (w *TreeView) SetSize(width, height int)
SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.
func (*TreeView) SetSort ¶
SetSort draws the sort indicator dir in the header of col; col nil or SortNone clears it.
func (*TreeView) SetTooltip ¶
func (w *TreeView) SetTooltip(s string)
SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.
func (*TreeView) SetVisible ¶
func (w *TreeView) SetVisible(v bool)
SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.
func (*TreeView) ShowHeader ¶
ShowHeader shows or hides the column headers.
func (*TreeView) ShowRowLines ¶
ShowRowLines shows or hides thin lines between rows only, see Table.ShowRowLines.
type TypeScale ¶
type TypeScale struct {
Caption, Body, BodyStrong, Subtitle, Title, LargeTitle Font
// Mono is the platform's monospace font at the body size.
Mono Font
}
TypeScale is the set of text styles, as Fonts in logical px for Typeface and SetFont.
var Type TypeScale
Type is the application-wide text scale: Typeface(gowt.Type.Title) gives a widget the title style, whose size and family are the OS's, see docs/cross-platform-look.md. Run fills it before setup; read it after SetDensity, a Typeface built earlier keeps the values of its time.
type Weight ¶
type Weight int
Weight is a CSS-style font weight, 100 to 900. The zero value means unset: Bold decides.
type Widget ¶
type Widget interface {
SetEnabled(v bool)
Enabled() bool
SetVisible(v bool)
Visible() bool
SetTooltip(s string)
SetFont(f Font)
SetForeground(c Paint)
SetBackground(c Paint)
Focus() bool
Dispose()
OnDispose(f func())
// contains filtered or unexported methods
}
Widget is any gowt control. Layouts and containers take it where they refer to a sibling or a child. Its methods are the ones every widget type has.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is a top-level window. Its children stack as in a VBox, with Padding(Spacing.PageMargin) unless Padding says otherwise.
func (Window) Add ¶
func (p Window) Add(children ...Option)
Add creates children at the end of p, in order, and lays p out again when it is on screen, measuring only the new children. It is the way to fill a container after its creation, for content that changes; see Clear.
func (Window) AsComposite ¶
AsComposite returns the underlying composite; unlike Unwrap it has the same type on Panel, Window, Group, Split and CoolBar, so one function can take any of them.
func (Window) Clear ¶
func (p Window) Clear()
Clear disposes every child and lays p out again, ready for new content.
func (*Window) Close ¶
func (w *Window) Close()
Close closes the window as the user would, running OnClose.
func (*Window) ColorDialog ¶
ColorDialog shows a color chooser starting at initial; ok is false if cancelled.
func (*Window) Confirm ¶
Confirm asks a Yes/No question and reports whether Yes was pressed.
Example ¶
A modal question over a window.
package main
import (
"github.com/haiodo/gowt"
)
func main() {
_ = gowt.Run(func(app *gowt.App) {
w := app.Window("Editor")
w.Add(gowt.Button("Quit", gowt.OnClick(func() {
if w.Confirm("Quit", "Discard unsaved changes?") {
w.Close()
}
})))
w.Show()
})
}
Output:
func (*Window) FileDialog ¶
func (w *Window) FileDialog(d FileDialog) []string
FileDialog shows d modal over w and returns the chosen paths, nil if cancelled. Multi only applies to open dialogs.
func (*Window) FontDialog ¶
FontDialog shows a font chooser starting at initial; ok is false if cancelled. The dialog knows only regular and bold: an initial Weight of Semibold or more starts bold. The result has Weight 0 if initial.Weight was 0, else Bold or Regular, so a Medium or Semibold round trip is not preserved.
func (*Window) MenuBar ¶
MenuBar creates the window's menu bar. On macOS it becomes the application menu bar.
func (*Window) MessageBox ¶
MessageBox shows m modal over w and returns the pressed button.
func (*Window) OnClose ¶
OnClose registers f; returning false keeps the window open. Several handlers are asked in order and the first false stops the rest. Closing the last window then asks App.OnQuit.
func (*Window) OnKey ¶
OnKey runs f when keys are pressed anywhere in the window: w.OnKey("Cmd+[", back). keys is written as for Shortcut. A focused text field (Text, StyledText, Spinner, an editable Combo) keeps the combinations it types or edits with, and f does not run for them there; see editsText. OnKey panics on a name it does not know.
func (*Window) Popover ¶
Popover creates a hidden popover for w; Show it with ShowAt or ShowAtPoint once its content is built. Children of a callback that needs the popover go in p.Add after this call. Options: Gap, Padding, children; the placement options do not apply. Padding defaults to Spacing.SM.
func (*Window) PrintDialog ¶
func (w *Window) PrintDialog(o PrintOptions) (job *PrintJob, ok bool)
PrintDialog shows the system print dialog over w and returns the job it describes; ok is false when the user cancelled. In a QA build the dialog is not shown: the scripted reply of kind "print" is the path of a PDF file to print into (see docs/qa.md).
func (Window) Relayout ¶
func (p Window) Relayout()
Relayout lays the children out again and recomputes their sizes, as needed after a change made through Unwrap, such as swt.Label.SetText. The facade setters that change a size (SetText, SetImage, SetFont, SetTitle of a Group, SetItems of a Combo) lay out by themselves. p keeps its own size: to let it grow too, Relayout the Window.
func (*Window) SetMinSize ¶
SetMinSize keeps the user from resizing the window below width x height points. A window laid out by look.SetSidebar or look.SetInspector takes the larger of this and the room its panes and content need.
func (*Window) SetTopInset ¶
SetTopInset adds points to the top margin of the window layout on top of its Padding. look.SetFullSizeContent uses it to keep the content below the title bar and the toolbar.
Source Files
¶
- avatar.go
- badge.go
- badge_linux.go
- bind.go
- boundary.go
- buttonkind.go
- canvaschild.go
- clipboard.go
- ctabs_look_other.go
- ctabs_render.go
- density.go
- density_sys.go
- dialogs.go
- dnd.go
- doc.go
- each.go
- fields.go
- fit_linux.go
- fitcolumns.go
- fluent_other.go
- gowt.go
- graphics.go
- hint.go
- hint_linux.go
- hint_other.go
- iconbutton_linux.go
- jobs.go
- layout.go
- linkcolor.go
- menu.go
- mono_linux.go
- on.go
- openfiles.go
- popover.go
- popover_linux.go
- popover_shell.go
- print.go
- print_linux.go
- qa_off.go
- quit_other.go
- rowlines_other.go
- scroll_other.go
- section.go
- section_other.go
- singleinstance_linux.go
- singleinstance_socket.go
- sizehint.go
- snap.go
- snap_other.go
- spacing.go
- style_linux.go
- textbg_linux.go
- textfit.go
- textfit_linux.go
- textscroll_linux.go
- theme.go
- theme_other.go
- tree.go
- widgets_common.go
- widgets_container.go
- widgets_list.go
- widgets_range.go
- widgets_text.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package browser is SWT's Browser widget (org.eclipse.swt.browser) for porting SWT code: the Browser class, its location, progress, title, status, window and authentication listeners and BrowserFunction.
|
Package browser is SWT's Browser widget (org.eclipse.swt.browser) for porting SWT code: the Browser class, its location, progress, title, status, window and authentication listeners and BrowserFunction. |
|
cmd
|
|
|
backdropdemo
command
Command backdropdemo switches the window material (none / translucent = Acrylic / glass = Mica) and the rounded corners.
|
Command backdropdemo switches the window material (none / translucent = Acrylic / glass = Mica) and the rounded corners. |
|
controlexample
command
Command controlexample runs SWT's ControlExample (examples/controlexample, translated by j2go) with the tabs translated so far.
|
Command controlexample runs SWT's ControlExample (examples/controlexample, translated by j2go) with the tabs translated so far. |
|
fieldcheck
command
Command fieldcheck runs gowt's checks on a real machine and writes one zip file with the environment, the results of every suite, the full logs and a few window snapshots.
|
Command fieldcheck runs gowt's checks on a real machine and writes one zip file with the environment, the results of every suite, the full logs and a few window snapshots. |
|
finderdemo
command
Command finderdemo shows the macOS 26 Finder and System Settings look: a floating Liquid Glass sidebar (look.SetSidebar), an edge-to-edge glass inspector on the right (look.SetInspector), a toolbar with an item over the sidebar, a back/forward capsule, a button, a search field and the inspector toggle (look.SetToolbar) and grouped sections (gowt.Section).
|
Command finderdemo shows the macOS 26 Finder and System Settings look: a floating Liquid Glass sidebar (look.SetSidebar), an edge-to-edge glass inspector on the right (look.SetInspector), a toolbar with an item over the sidebar, a back/forward capsule, a button, a search field and the inspector toggle (look.SetToolbar) and grouped sections (gowt.Section). |
|
form
command
Command form: a two-column Grid form (Name/Email + OK) with a File > Quit menu bar.
|
Command form: a two-column Grid form (Name/Email + OK) with a File > Quit menu bar. |
|
glassdemo
command
Command glassdemo shows the macOS 26 look options: window backdrop, glass panel, glass buttons, full-size content.
|
Command glassdemo shows the macOS 26 look options: window backdrop, glass panel, glass buttons, full-size content. |
|
gowtdemo
command
Command gowtdemo shows the gowt facade widgets, one tab per widget family.
|
Command gowtdemo shows the gowt facade widgets, one tab per widget family. |
|
hello
command
Command hello opens a Shell with one push button: the Display+Shell+Button path end to end.
|
Command hello opens a Shell with one push button: the Display+Shell+Button path end to end. |
|
hellogowt
command
Command hellogowt is the smallest gowt program: a window with a field, a button and a label.
|
Command hellogowt is the smallest gowt program: a window with a field, a button and a label. |
|
icondemo
command
Command icondemo shows every dictionary icon as a button and rebuilds them when the system theme changes.
|
Command icondemo shows every dictionary icon as a button and rebuilds them when the system theme changes. |
|
images
command
Command images loads 3 of the ControlExample test images through getResourceAsStream -> ImageData(InputStream) -> Image(Display, ImageData), and draws them on a Canvas with gc.DrawImage.
|
Command images loads 3 of the ControlExample test images through getResourceAsStream -> ImageData(InputStream) -> Image(Display, ImageData), and draws them on a Canvas with gc.DrawImage. |
|
jfacedemo
command
Command jfacedemo builds a form from JFace's fluent widget factories and layout factories only: labels, texts and a group, a table under a TableColumnLayout, and a row of buttons.
|
Command jfacedemo builds a form from JFace's fluent widget factories and layout factories only: labels, texts and a group, a table under a TableColumnLayout, and a row of buttons. |
|
minibrowser
command
Command minibrowser is a small tabbed browser: a SashForm with the list of open pages on the left and one WebView per page, stacked, on the right.
|
Command minibrowser is a small tabbed browser: a SashForm with the list of open pages on the left and one WebView per page, stacked, on the right. |
|
paint
command
Command paint draws on a Canvas from a paint callback: the drawRect: -> paint event -> GC path.
|
Command paint draws on a Canvas from a paint callback: the drawRect: -> paint event -> GC path. |
|
snapcheck
command
Command snapcheck compares the PNGs written by `controlexample -snap` with the committed references (tests/snapshots).
|
Command snapcheck compares the PNGs written by `controlexample -snap` with the committed references (tests/snapshots). |
|
stack
command
Command stack: a Split divides left (buttons) from right (Pages of Groups); clicking a button switches the visible panel.
|
Command stack: a Split divides left (buttons) from right (Pages of Groups); clicking a button switches the visible panel. |
|
swttest
command
Command swttest runs the translated SWT JUnit tests (tests/swttests) on the main thread with one Display, the way SWT's tests expect: a panic fails its test, not the run; a hung test ends the run with its name.
|
Command swttest runs the translated SWT JUnit tests (tests/swttests) on the main thread with one Display, the way SWT's tests expect: a panic fails its test, not the run; a hung test ends the run with its name. |
|
themecheck
command
Command themecheck shows the system theme and logs every change: switch light/dark in system settings while it runs and the label and stdout must follow (Linux: GOWT_THEMECHECK_SECS=n exits after n seconds).
|
Command themecheck shows the system theme and logs every change: switch light/dark in system settings while it runs and the label and stdout must follow (Linux: GOWT_THEMECHECK_SECS=n exits after n seconds). |
|
tree
command
Command tree shows a Tree (NSOutlineView) with three root items and their children.
|
Command tree shows a Tree (NSOutlineView) with three root items and their children. |
|
webviewdemo
command
Command webviewdemo shows a Tree beside a system web view: the pages come from an embed.FS over the app:// scheme, a button evaluates JS in the page, and page messages land in a Label.
|
Command webviewdemo shows a Tree beside a system web view: the pages come from an embed.FS over the app:// scheme, a button evaluates JS in the page, and page messages land in a Label. |
|
widgets2
command
Command widgets2 shows a Tabs holding a Combo pair, a Table, and a Scroll.
|
Command widgets2 shows a Tabs holding a Combo pair, a Table, and a Scroll. |
|
winprobe
command
|
|
|
examples
|
|
|
apps/chat
command
Command chat is a team chat window: a sidebar with sections and avatars, a message feed with reactions and links, a thread pane on the right and a glass composer capsule with attach and send.
|
Command chat is a team chat window: a sidebar with sections and avatars, a message feed with reactions and links, a thread pane on the right and a glass composer capsule with attach and send. |
|
apps/dashboard
command
Command dashboard is a metrics overview: summary cards, progress bars, a Canvas bar chart, a recent activity table and links.
|
Command dashboard is a metrics overview: summary cards, progress bars, a Canvas bar chart, a recent activity table and links. |
|
apps/editor
command
Command editor is a code editor: a file tree, closable tabs, a StyledText with highlighted code in the monospace font, line numbers and a status bar.
|
Command editor is a code editor: a file tree, closable tabs, a StyledText with highlighted code in the monospace font, line numbers and a status bar. |
|
apps/files
command
Command files is a file browser: a folder tree in the sidebar, a table with icons, sizes and dates, a path bar, sorting and a search field.
|
Command files is a file browser: a folder tree in the sidebar, a table with icons, sizes and dates, a path bar, sorting and a search field. |
|
apps/internal/kit
Package kit holds the small pieces the look-check apps share: fixed colours, round round avatars, pill badges and coloured dots.
|
Package kit holds the small pieces the look-check apps share: fixed colours, round round avatars, pill badges and coloured dots. |
|
apps/mail
command
Command mail is a three-pane mail client: mailboxes in a sidebar, a message list with unread dots and dates, a reader and a toolbar.
|
Command mail is a three-pane mail client: mailboxes in a sidebar, a message list with unread dots and dates, a reader and a toolbar. |
|
apps/monitor
command
Command monitor shows the load of the machine it runs on: CPU, per-core load, memory, network and the busiest processes.
|
Command monitor shows the load of the machine it runs on: CPU, per-core load, memory, network and the busiest processes. |
|
apps/monitor/sampler
Package sampler reads the load of the host it runs on: CPU per core, memory, network rates and the process list.
|
Package sampler reads the load of the host it runs on: CPU per core, memory, network rates and the process list. |
|
apps/settings
command
Command settings is a System Settings style window: category sidebar, grouped sections of form rows with Text, Combo, Switch, Check, Radio, Slider and Spinner, and primary and destructive buttons.
|
Command settings is a System Settings style window: category sidebar, grouped sections of form rows with Text, Combo, Switch, Check, Radio, Slider and Spinner, and primary and destructive buttons. |
|
apps/tracker
command
Command tracker is an issue tracker: a filter bar, tabs, a table of issues with status dots and an inspector panel with the selected issue.
|
Command tracker is an issue tracker: a filter bar, tabs, a table of issues with status dots and an inspector panel with the selected issue. |
|
boundary
command
Command boundary shows errors in place: a Boundary replaces the widgets inside it with a fallback when they fail to build or when their bindings panic after a state change.
|
Command boundary shows errors in place: a Boundary replaces the widgets inside it with a fallback when they fail to build or when their bindings panic after a state change. |
|
browser
command
Command browser uses SWT's Browser widget (package browser) inside a gowt window.
|
Command browser uses SWT's Browser widget (package browser) inside a gowt window. |
|
catalog
command
Command catalog shows one sample of every facade widget.
|
Command catalog shows one sample of every facade widget. |
|
clipboard
command
Command clipboard copies a field's text to the system clipboard and pastes it back.
|
Command clipboard copies a field's text to the system clipboard and pastes it back. |
|
controlexample
Hand-written glue for the translated ControlExample (tooling/j2go/manual.txt, README "Round 10 controlexample").
|
Hand-written glue for the translated ControlExample (tooling/j2go/manual.txt, README "Round 10 controlexample"). |
|
controlexample/res
Package res embeds the ControlExample resources.
|
Package res embeds the ControlExample resources. |
|
dialogs
command
Command dialogs shows a menu bar, a context menu, a tool bar and the modal dialogs.
|
Command dialogs shows a menu bar, a context menu, a tool bar and the modal dialogs. |
|
dnd
command
Command dnd drags a label's text onto a drop zone and accepts files dropped from a file manager.
|
Command dnd drags a label's text onto a drop zone and accepts files dropped from a file manager. |
|
events
command
Command events shows callbacks, the UI thread rule and background work reporting back.
|
Command events shows callbacks, the UI thread rule and background work reporting back. |
|
gfxcanvas
command
Command gfxcanvas puts a gfx scene in a window: two cards you can drag, pan with the trackpad or wheel, pinch to zoom.
|
Command gfxcanvas puts a gfx scene in a window: two cards you can drag, pan with the trackpad or wheel, pinch to zoom. |
|
gfxeditor
command
Command gfxeditor is the core of a mind-map editor on gfx: auto-layout of a topic tree, hit-testing, a selection outline and a remote cursor on the overlay, animations, dragging a topic and editing its title in place (double-click).
|
Command gfxeditor is the core of a mind-map editor on gfx: auto-layout of a topic tree, hit-testing, a selection outline and a remote cursor on the overlay, animations, dragging a topic and editing its title in place (double-click). |
|
gfxpng
command
Command gfxpng renders a scene to hello.png without a window, on macOS, Linux and Windows.
|
Command gfxpng renders a scene to hello.png without a window, on macOS, Linux and Windows. |
|
graphics
command
Command graphics draws on a Canvas and shows an Image built in memory.
|
Command graphics draws on a Canvas and shows an Image built in memory. |
|
hello
command
Command hello is the smallest gowt program: one window, a label and a button.
|
Command hello is the smallest gowt program: one window, a label and a button. |
|
icons
command
Command icons puts named system icons on buttons and tints them again when the theme changes.
|
Command icons puts named system icons on buttons and tints them again when the theme changes. |
|
jface
command
Command jface builds one window from gowt containers and JFace factories: the grid layout and the label, text field and button come from package jface, the status line is a gowt widget.
|
Command jface builds one window from gowt containers and JFace factories: the grid layout and the label, text field and button come from package jface, the status line is a gowt widget. |
|
layouts
command
Command layouts shows the layouts: VBox and HBox, Grid, Flow, Form and Pages.
|
Command layouts shows the layouts: VBox and HBox, Grid, Flow, Form and Pages. |
|
openfiles
command
Command openfiles lists the files the system asks it to open: Finder, Explorer or a file manager (double click, Open With), command-line arguments, and a second launch handed to the running one.
|
Command openfiles lists the files the system asks it to open: Finder, Explorer or a file manager (double click, Open With), command-line arguments, and a second launch handed to the running one. |
|
print
command
Command print prints a small gfx scene through the system print dialog and exports it as PDF.
|
Command print prints a small gfx scene through the system print dialog and exports it as PDF. |
|
qa
command
Command qa is a greeter written to be tested through the QA driver: see qa_test.go and README.md.
|
Command qa is a greeter written to be tested through the QA driver: see qa_test.go and README.md. |
|
quit
command
Command quit shows a document window that asks "Save changes?" on every way of quitting: its close button, Cmd+Q, the Dock, logout and shutdown.
|
Command quit shows a document window that asks "Save changes?" on every way of quitting: its close button, Cmd+Q, the Dock, logout and shutdown. |
|
rows
command
Command rows shows a table and a tree whose rows follow rx state: each tick changes a few elements, adds or drops one, and only those rows are touched; selection and expansion stay.
|
Command rows shows a table and a tree whose rows follow rx state: each tick changes a few elements, adds or drops one, and only those rows are touched; selection and expansion stay. |
|
sidebartable
command
Command sidebartable shows a List and a row-with-icon list side by side in a look.SetSidebar sidebar.
|
Command sidebartable shows a List and a row-with-icon list side by side in a look.SetSidebar sidebar. |
|
styledtext
command
Command styledtext highlights words in an editor.
|
Command styledtext highlights words in an editor. |
|
swtdirect
command
Command swtdirect drops from the facade to package swt for what the facade does not wrap: Unwrap gives the swt object of a widget, AsComposite the parent for a raw swt widget.
|
Command swtdirect drops from the facade to package swt for what the facade does not wrap: Unwrap gives the swt object of a widget, AsComposite the parent for a raw swt widget. |
|
theme
command
Command theme follows the system light/dark setting and tries the platform look options of package look.
|
Command theme follows the system light/dark setting and tries the platform look options of package look. |
|
webview
command
Command webview puts the system web view beside native widgets: a page served from Go over a custom scheme, a script run from a button, and messages from the page into a Label.
|
Command webview puts the system web view beside native widgets: a page served from Go over a custom scheme, a script run from a button, and messages from the page into a Label. |
|
widgets
command
Command widgets shows the common widgets: text fields, buttons, lists, a table, a tree and ranges.
|
Command widgets shows the common widgets: text fields, buttons, lists, a table, a tree and ranges. |
|
Package gfx is an experimental retained 2D canvas for gowt: a tree of nodes holding recorded Pictures, a compositor that shows it from cached tiles, and the geometry under both.
|
Package gfx is an experimental retained 2D canvas for gowt: a tree of nodes holding recorded Pictures, a compositor that shows it from cached tiles, and the geometry under both. |
|
cairo
Package cairo replays gfx Pictures with cairo and Pango into image surfaces on Linux, without a window, a display or GTK: only libcairo, libpango, libpangocairo, libgobject and fontconfig are loaded, with purego.
|
Package cairo replays gfx Pictures with cairo and Pango into image surfaces on Linux, without a window, a display or GTK: only libcairo, libpango, libpangocairo, libgobject and fontconfig are loaded, with purego. |
|
cg
Package cg replays gfx Pictures with CoreGraphics and CoreText into CGBitmapContext surfaces on macOS, without creating any window.
|
Package cg replays gfx Pictures with CoreGraphics and CoreText into CGBitmapContext surfaces on macOS, without creating any window. |
|
d2d
Package d2d replays gfx Pictures with Direct2D 1.1 and DirectWrite on Windows, with no window: the device is a D3D11 WARP device, so no GPU is needed and a service, CI or an SSH session in session 0 can render.
|
Package d2d replays gfx Pictures with Direct2D 1.1 and DirectWrite on Windows, with no window: the device is a D3D11 WARP device, so no GPU is needed and a service, CI or an SSH session in session 0 can render. |
|
internal/fonttest
Package fonttest holds the font checks every gfx backend must pass, so that cg, cairo and d2d are held to the same behavior.
|
Package fonttest holds the font checks every gfx backend must pass, so that cg, cairo and d2d are held to the same behavior. |
|
internal/pdftest
Package pdftest holds the PDF checks every gfx backend must pass, so that cg, cairo and the Windows writer are held to the same behavior.
|
Package pdftest holds the PDF checks every gfx backend must pass, so that cg, cairo and the Windows writer are held to the same behavior. |
|
layout
Package layout is a flexbox-like auto-layout for editors and design tools: rows and columns with gap, padding, alignment, justification, wrapping, min and max sizes, absolute children, and fixed, hug and fill sizes.
|
Package layout is a flexbox-like auto-layout for editors and design tools: rows and columns with gap, padding, alignment, justification, wrapping, min and max sizes, absolute children, and fixed, hug and fill sizes. |
|
offscreen
Package offscreen renders a gfx scene to an image without a window, a display or a build tag: it picks the headless gfx.Renderer of the running OS (CoreGraphics on macOS, cairo and Pango on Linux, Direct2D on Windows).
|
Package offscreen renders a gfx scene to an image without a window, a display or a build tag: it picks the headless gfx.Renderer of the running OS (CoreGraphics on macOS, cairo and Pango on Linux, Direct2D on Windows). |
|
pdf
Package pdf writes gfx pictures as PDF without any system library: paths, strokes, gradients, clips, images, group opacity and text.
|
Package pdf writes gfx pictures as PDF without any system library: paths, strokes, gradients, clips, images, group opacity and text. |
|
pen
Package pen loads pen.dev design files (.pen, JSON) into gfx scene subtrees.
|
Package pen loads pen.dev design files (.pen, JSON) into gfx scene subtrees. |
|
printing
Package printing draws gfx pictures and scenes onto the pages of a gowt.PrintJob.
|
Package printing draws gfx pictures and scenes onto the pages of a gowt.PrintJob. |
|
synth
Package synth builds a synthetic UI-mockup / diagram document for gfx benchmarks: rounded boxes with border, shadow and two text lines, joined by cubic connectors with arrowheads, every third one dashed.
|
Package synth builds a synthetic UI-mockup / diagram document for gfx benchmarks: rounded boxes with border, shadow and two text lines, joined by cubic connectors with arrowheads, every third one dashed. |
|
view
Package view puts a gfx scene into a gowt window as a widget.
|
Package view puts a gfx scene into a gowt window as a widget. |
|
Package icons gives a gowt app named system icons: SF Symbols on macOS, Segoe Fluent Icons on Windows, freedesktop symbolic icons on Linux, with an embedded Lucide set where the OS has none, so the same names work everywhere.
|
Package icons gives a gowt app named system icons: SF Symbols on macOS, Segoe Fluent Icons on Windows, freedesktop symbolic icons on Linux, with an embedded Lucide set where the OS has none, so the same names work everywhere. |
|
internal
|
|
|
cocoa
ObjC blocks over purego: a block literal is {isa, flags, reserved, invoke, descriptor}.
|
ObjC blocks over purego: a block literal is {isa, flags, reserved, invoke, descriptor}. |
|
dbus
Package dbus is a small session bus client written from the D-Bus specification: just enough to own a well-known name and to call or serve org.freedesktop.Application.Open and Activate.
|
Package dbus is a small session bus client written from the D-Bus specification: just enough to own a well-known name and to call or serve org.freedesktop.Application.Open and Activate. |
|
fluent
Package fluent gives native Win32 controls the Windows 11 (WinUI 3) look: text boxes, flat borders, subtle and standard buttons, a rounded input surface and the Explorer selection of tables.
|
Package fluent gives native Win32 controls the Windows 11 (WinUI 3) look: text boxes, flat borders, subtle and standard buttons, a rounded input surface and the Explorer selection of tables. |
|
gtk
Package gtk binds GTK 3, GLib, Pango and cairo through purego (no cgo): gen_*.go come from GIR via tooling/girgen, glue_*.go are hand-written from the public GTK/GLib documentation.
|
Package gtk binds GTK 3, GLib, Pango and cairo through purego (no cgo): gen_*.go come from GIR via tooling/girgen, glue_*.go are hand-written from the public GTK/GLib documentation. |
|
jrt
Package jrt hand-writes small Go stand-ins for the java.lang/java.util base types that some translated SWT classes extend (SWTException/SWTError extend RuntimeException/Error, TypedEvent extends EventObject) but that have no Java source for j2go to translate - see tooling/j2go/README.md "Manual superclass embedding".
|
Package jrt hand-writes small Go stand-ins for the java.lang/java.util base types that some translated SWT classes extend (SWTException/SWTError extend RuntimeException/Error, TypedEvent extends EventObject) but that have no Java source for j2go to translate - see tooling/j2go/README.md "Manual superclass embedding". |
|
junit
Package junit is the JUnit 5 surface the translated SWT tests (tests/swttests) use: the generated test registry and org.junit.jupiter.api.Assertions/Assumptions.
|
Package junit is the JUnit 5 surface the translated SWT tests (tests/swttests) use: the generated test registry and org.junit.jupiter.api.Assertions/Assumptions. |
|
pdfcheck
Package pdfcheck reads what a test needs to know about a PDF file written by any backend: the number of pages, their sizes, the fonts and the embedded images.
|
Package pdfcheck reads what a test needs to know about a PDF file written by any backend: the number of pages, their sizes, the fonts and the embedded images. |
|
qatree
Package qatree walks the controls of a running gowt app for the QA driver: a dump of the windows, selectors and semantic actions.
|
Package qatree walks the controls of a running gowt app for the QA driver: a dump of the windows, selectors and semantic actions. |
|
qaview
Package qaview is how a control that paints on its own clock (a gfx view) meets the QA driver and the capture commands without either importing the other: the driver waits for its frames and hands it scroll, pinch and pointer events.
|
Package qaview is how a control that paints on its own clock (a gfx view) meets the QA driver and the capture commands without either importing the other: the driver waits for its frames and hands it scroll, pinch and pointer events. |
|
shot
Package shot captures a Shell's window on linux for the snapshot commands (cmd/controlexample -snap, cmd/images).
|
Package shot captures a Shell's window on linux for the snapshot commands (cmd/controlexample -snap, cmd/images). |
|
snapcmp
Package snapcmp compares two screenshots with a per-pixel tolerance (stdlib only, no GUI).
|
Package snapcmp compares two screenshots with a per-pixel tolerance (stdlib only, no GUI). |
|
webkit
Package webkit binds WebKitGTK 4.1 (GTK 3) through purego, without cgo.
|
Package webkit binds WebKitGTK 4.1 (GTK 3) through purego, without cgo. |
|
win32
toC/fromC of the C bitfield structs Uniscribe and GetMenuBarInfo use: a Java boolean per bit, packed as the C compiler does (LSB first in the declared storage unit).
|
toC/fromC of the C bitfield structs Uniscribe and GetMenuBarInfo use: a Java boolean per bit, packed as the C compiler does (LSB first in the declared storage unit). |
|
Package jface holds the JFace layout and widget factories (GridLayoutFactory, GridDataFactory, ButtonFactory, TextFactory and the like) and the column layout data, translated to Go with the Java names on top of package swt.
|
Package jface holds the JFace layout and widget factories (GridLayoutFactory, GridDataFactory, ButtonFactory, TextFactory and the like) and the column layout data, translated to Go with the Java names on top of package swt. |
|
Package look sets the platform look of a gowt app: the window material, macOS 26 Liquid Glass, Windows 11 corners and dark content.
|
Package look sets the platform look of a gowt app: the window material, macOS 26 Liquid Glass, Windows 11 corners and dark content. |
|
Package qa is the QA hook of a gowt app.
|
Package qa is the QA hook of a gowt app. |
|
qatest
Package qatest drives a QA build of a gowt app (go build -tags gowtqa) from go test.
|
Package qatest drives a QA build of a gowt app (go build -tags gowtqa) from go test. |
|
Package rx is reactive state in the style of Svelte 5 runes.
|
Package rx is reactive state in the style of Svelte 5 runes. |
|
Package svg is gowt's optional SVG rasterizer (the counterpart of SWT's org.eclipse.swt.svg fragment): importing it for its side effect makes swt.Image load SVG at every zoom.
|
Package svg is gowt's optional SVG rasterizer (the counterpart of SWT's org.eclipse.swt.svg fragment): importing it for its side effect makes swt.Image load SVG at every zoom. |
|
Package swt is the Go translation of Eclipse SWT (the widgets, graphics, events, layouts, dialogs and drag and drop of org.eclipse.swt), with the Java names.
|
Package swt is the Go translation of Eclipse SWT (the widgets, graphics, events, layouts, dialogs and drag and drop of org.eclipse.swt), with the Java names. |
|
swtreflect
Package swtreflect registers the public methods of package swt's widgets for java.lang.reflect-style lookup (internal/jrt/reflect.go).
|
Package swtreflect registers the public methods of package swt's widgets for java.lang.reflect-style lookup (internal/jrt/reflect.go). |
|
tests
|
|
|
swttests
Package swttests is SWT's JUnit tests (org.eclipse.swt.tests.junit) translated by j2go; each test class registers itself with internal/junit, cmd/swttest runs them on the main thread.
|
Package swttests is SWT's JUnit tests (org.eclipse.swt.tests.junit) translated by j2go; each test class registers itself with internal/junit, cmd/swttest runs them on the main thread. |
|
tooling
|
|
|
apidump
command
Command apidump prints the exported API of package swt for one GOOS, one symbol per line, sorted: package-level funcs/vars/consts/types and the full method set (promoted included) of every exported type.
|
Command apidump prints the exported API of package swt for one GOOS, one symbol per line, sorted: package-level funcs/vars/consts/types and the full method set (promoted included) of every exported type. |
|
assoc
command
Command assoc writes the files that associate a document type with a program: a Windows .reg file, a Linux .desktop file, a D-Bus service file and a shared-mime-info XML.
|
Command assoc writes the files that associate a document type with a program: a Windows .reg file, a Linux .desktop file, a D-Bus service file and a shared-mime-info XML. |
|
doccounts
command
Command doccounts checks that the test-count tables in README.md and docs/platforms.md equal the counts in tests/expected*.txt (macOS, Windows under Wine and on the VM, Linux in Docker and on the desktop) and tests/expected_jface*.txt.
|
Command doccounts checks that the test-count tables in README.md and docs/platforms.md equal the counts in tests/expected*.txt (macOS, Windows under Wine and on the VM, Linux in Docker and on the desktop) and tests/expected_jface*.txt. |
|
fieldreport
command
Command fieldreport prints one table row per field-check zip (cmd/fieldcheck):
|
Command fieldreport prints one table row per field-check zip (cmd/fieldcheck): |
|
girgen
command
girgen emits internal/gtk (purego bindings) from GIR files for exactly the names the SWT widget code uses; the call-site names are the interface spec (see README, "GIR-driven gtk binding").
|
girgen emits internal/gtk (purego bindings) from GIR files for exactly the names the SWT widget code uses; the call-site names are the interface spec (see README, "GIR-driven gtk binding"). |
|
mksyso
command
Command mksyso writes a COFF object with Windows resources, for go build to link into an executable: no windres needed.
|
Command mksyso writes a COFF object with Windows resources, for go build to link into an executable: no windres needed. |
|
webkitgen
command
webkitgen emits internal/webkit/gen_funcs.go: purego prototypes for the C functions named in names.txt, with parameter and return types taken from the GIR files of WebKitGTK 4.1 and the libraries it sits on.
|
webkitgen emits internal/webkit/gen_funcs.go: purego prototypes for the C functions named in names.txt, with parameter and return types taken from the GIR files of WebKitGTK 4.1 and the libraries it sits on. |
|
Package webview embeds the system web view (WKWebView on macOS, WebView2 on Windows, WebKitGTK 4.1 on Linux) in an SWT Composite and bridges it to Go: custom URL schemes served from Go, page-to-Go messages, async script evaluation.
|
Package webview embeds the system web view (WKWebView on macOS, WebView2 on Windows, WebKitGTK 4.1 on Linux) in an SWT Composite and bridges it to Go: custom URL schemes served from Go, page-to-Go messages, async script evaluation. |
|
Package winmanifest embeds an application manifest into a Windows executable: comctl32 v6 (visual styles, SysLink) and per-monitor DPI awareness (v2, falling back to per-monitor and system-aware on older Windows).
|
Package winmanifest embeds an application manifest into a Windows executable: comctl32 v6 (visual styles, SysLink) and per-monitor DPI awareness (v2, falling back to per-monitor and system-aware on older Windows). |










