gowt

package module
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: EPL-2.0 Imports: 29 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ¶

gowt

Native GUI for Go, without cgo. Windows, tables, menus and dialogs are the operating system's own widgets: AppKit on macOS, Win32 on Windows, GTK 3 on Linux. The API is a small idiomatic Go layer (gowt) over Eclipse SWT, which is translated from Java to Go and bound to the OS libraries at run time.

monitor is a live system monitor: CPU, memory and network history charts drawn with gfx, native cards and a process table, all plain Go with no cgo. The loop above is the real app on macOS (click it for the full-quality video); the same source gives the three windows below.

monitor, macOS
macOS: AppKit monitor, Windows
Windows: Win32 monitor, Linux
Linux: GTK 3

One code, three native UIs. More widgets side by side: components; how the Windows and Linux shots are made: docs/screenshots.md.

Demo apps

Eight apps in examples/apps, macOS shown first; the same window on Windows and Linux is one click away, all three side by side on docs/apps.md.

chat, macOS
chat · Windows · Linuxdashboard, macOS
dashboard · Windows · Linuxeditor, macOS
editor · Windows · Linuxfiles, macOS
files · Windows · Linuxmail, macOS
mail · Windows · Linuxsettings, macOS
settings · Windows · Linuxtracker, macOS
tracker · Windows · Linuxmonitor, macOS
monitor · Windows · Linux

Install

Gopher catching a parcel on a parachute
go get github.com/haiodo/gowt@latest
go mod tidy

Run go mod tidy after writing code that imports gowt; until then go.mod lists it as // indirect. What to expect: the module is 5.2 MB; the first build with a cold cache took about 15 s (measured on a Mac for the hello program).

Go 1.27 or newer. No C compiler and no Java. Cross-compiling works from any host: GOOS=windows go build. Details, per-OS requirements and the errors a missing dependency gives: docs/install.md.


Hello

Gopher pressing a button that pops up a window
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)
	}
}

Run returns an error (no GTK, no display); examples/hello is the same program.


Documentation

Gopher reading on a pile of books

Start at docs/README.md. Each topic has a page and a runnable program:

Topic Page Example
Windows and layouts windows-layouts layouts
Widgets widgets widgets
Events and the UI thread events events
Dialogs and menus dialogs-menus dialogs
Graphics and images graphics graphics
Printing and PDF export printing print
Theme and platform look theme-look theme
One layout for three systems cross-platform-look -
Icons icons icons
Web view webview-browser webview
Testing with the QA driver qa qa

SWT port, for porting SWT and JFace code (apps and the examples above do not use it):

Topic Page Example
Using swt directly swt-direct swtdirect
JFace factories jface jface
SWT Browser webview-browser browser

What you get

  • Widgets: labels, buttons, text, combo, list, table, tree, tabs, pages, split, scroll, tool bar, menus, date picker, sliders, canvas, dialogs, tray icon.
  • Layouts: VBox, HBox, Grid, Flow, Fill, Form, Pages, with Gap and Padding.
  • The system web view next to native widgets: package webview, and SWT's Browser on top of it.
  • Platform look: Liquid Glass on macOS 26, Mica and Acrylic on Windows 11 22H2 and later (package look), light/dark following the system, system icons by name (package icons).
  • The full SWT API in package swt for what the facade does not wrap, and JFace layout and widget factories in jface.

Compared with Wails and Fyne

Gopher thinking at a crossroads signpost

Only what the pages linked in the table say, as fetched on 2026-10-10 (the wails.io and docs.fyne.io architecture pages returned 403/404 and are not used).

gowt Wails Fyne
UI is native OS widgets (SWT translated to Go) web frontend: "Use any frontend technology you are already familiar with to build your UI"; "Uses native rendering engines - no embedded browser!" (README) Go GUI toolkit; how it draws widgets was not checked
Build needs a C compiler no Linux: "standard gcc build tools plus libgtk3 and libwebkit"; macOS: Xcode command line tools (installation source) yes: "a C compiler" (README, Quick Start)
Web view next to native widgets yes: webview package not compared (not stated in the pages checked) not stated in the pages checked
Cross-compile GOOS=windows go build from any host (checked from a Mac for darwin, windows, linux builds of the examples) the build guide shows one CI job per OS (guide source); it does not say anything about cross-compiling fyne-cross, which needs Docker (fyne-cross README: "cross compile ... using docker images")

Not compared because it could not be confirmed from the documentation: how Fyne draws its widgets, Wails' cross-compile limits, binary sizes, performance. gowt is younger and covers fewer widgets than a mature toolkit; see the known gaps below.


Tests

Gopher in a lab coat checking test tubes

SWT's own JUnit tests, translated to Go and run per OS by make test-swt against tests/expected*.txt (a regression fails the gate):

OS pass fail skip
macOS 3818 4 (+3 flaky) 69
Windows (expected_windows.txt, recorded under Wine) 3728 70 (61 Browser tests, 9 others) (+7 flaky) 89
Windows 11 arm64 VM (expected_windows_vm.txt) 3799 0 (+6 flaky) 89
Linux (Docker, Xvfb) 3840 2 (+1 flaky) 58
Linux desktop (expected_linux_desktop.txt, Ubuntu 26.04 GNOME, Wayland) 3836 4 (+1 flaky) 60

3894 tests in all. The two rows from real machines are gate files recorded from two identical full runs: Windows 11 arm64 in a UTM virtual machine and Ubuntu 26.04.1 arm64 with GNOME on Wayland in a UTM virtual machine with a GPU.

JFace tests: 86 pass on macOS, 85 pass and 1 fail on Linux and Windows. Counts are the pass, fail, flaky and skip lines of the expected files; every non-pass line carries a reason. The facade itself has go test examples and an API stability gate (make api-check).


Platform requirements

OS Needed
macOS 13 or later
Windows 10 or later (the minimum is not verified); WebView2 Runtime for the webview package (preinstalled on Windows 11); visual styles and DPI awareness come with the gowt facade (it imports winmanifest); a program on swt alone imports _ "github.com/haiodo/gowt/winmanifest" itself
Linux glibc (musl distributions such as Alpine are not supported); GTK 3 and a Wayland or X11 display (on a Wayland session GTK uses native Wayland unless GDK_BACKEND=x11 is set); librsvg2-common on a minimal Debian or Ubuntu so that check marks draw; WebKitGTK 4.1 for webview

Known gaps

Gopher repairing a bridge with missing planks
  • Windows runs on a real Windows 11 arm64 (UTM virtual machine) and under Wine (CrossOver). Not checked: Mica, Acrylic and rounded corners by eye, a machine with two monitors (the VM has one display), the QA driver beyond the qa/qatest suite. Per-monitor DPI changes while running are not handled by the port itself; they use upstream SWT code and are untested.
  • CI (GitHub Actions) builds and vets for darwin, linux and windows on amd64 and arm64, and runs the GUI gates (swt, jface, unit and GUI tests) on Linux under Xvfb; Linux was also run on a real GNOME Wayland desktop. Hosted windows-latest and macos-latest runners build, vet and run the non-GUI tests; their GUI tests are a separate job that is allowed to fail, since a desktop session on those runners is unverified (the workflow has not been run yet). The swt and jface gates for macOS and Windows run locally and on the VM.
  • Linux: GTK 3 only.
  • Browser does not support the Authentication event; see docs/webview-browser.md for the rest.
  • Clipboard, drag and drop and StyledText are in the facade (App.Clipboard, DragFrom/DropOn, StyledText). Not verified: drag and drop with a real mouse on macOS (checked on Linux and Windows); cross-application clipboard transfer (the peer-process SWT tests are skipped); StyledText style rendering on macOS (upstream tests skipped). Accessible is a stub on all three OSes.
  • macOS Table and Tree use the cell-based AppKit views.

More: docs/platforms.md. How the repository and the translator work: docs/internals.md.

Contributing (build, tests, generated code, DCO sign-off): CONTRIBUTING.md. To help test on a real Windows, Linux or Mac: docs/field-check.md.

License: EPL-2.0, see LICENSE and NOTICE.

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 ¶

Examples ¶

Constants ¶

View Source
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 ¶

View Source
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)
)
View Source
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 ¶

func Golden(total int) (small, large int)

Golden splits total into a smaller and a larger part in the golden ratio (about 38% and 62%); small+large == total.

func Run ¶

func Run(setup func(*App)) (err error)

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)
	}
}

func Scaled ¶

func Scaled(n int) int

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 ¶

func SingleInstance(id string) (bool, error)

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 and URL arguments (see OnOpenFiles and OnOpenURLs) 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 and URLs 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.

func Watch ¶

func Watch[T any](w Widget, r rx.Reader[T], apply func(T))

Watch calls apply with the value of r now and again whenever it changes, once per batch. Only r is tracked: signals that apply reads do not rerun it. The binding lives as long as w, or until the Effect or Scope it was made in is disposed. The Bind options cover the common properties.

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()
	})
}

type Align ¶

type Align int32

Align is a cell alignment inside a grid cell.

const (
	AlignStart Align = iota
	AlignCenter
	AlignEnd
	AlignFill
)

Cell alignments.

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).

const (
	AnswerOK Answer = iota
	AnswerCancel
	AnswerYes
	AnswerNo
	AnswerRetry
	AnswerAbort
	AnswerIgnore
)

Answers a message box returns.

type App ¶

type App struct {
	// contains filtered or unexported fields
}

App is the handle to the UI thread, valid inside Run.

func (*App) After ¶

func (a *App) After(d time.Duration, f func()) (cancel func())

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)
	})
}

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") })
		}()
	})
}

func (*App) AvatarImage ¶

func (a *App) AvatarImage(initials string, bg RGB, size int) *Image

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 ¶

func (a *App) CircleImage(img *Image, size int) *Image

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 ¶

func (a *App) Clipboard() *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)
	})
}

func (*App) Dark ¶

func (a *App) Dark() bool

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 ¶

func (a *App) Every(d time.Duration, f func()) (stop func())

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()
	})
}

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) ImageFrom ¶

func (a *App) ImageFrom(r io.Reader) (img *Image, err error)

ImageFrom decodes an image from r.

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 ¶

func (a *App) Jobs() []JobInfo

Jobs lists the running Jobs and Tracks, background ones included, oldest first. Safe from any goroutine.

func (*App) LoadImage ¶

func (a *App) LoadImage(path string) (img *Image, err error)

LoadImage reads an image file (PNG, JPEG, GIF, BMP, ICO, TIFF).

func (*App) OnAbout ¶

func (a *App) OnAbout(f func()) bool

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 ¶

func (a *App) OnError(f func(error))

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 ¶

func (a *App) OnJobs(f func([]JobInfo))

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 ¶

func (a *App) OnOpenFiles(f func(paths []string))

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: go to OnOpenURLs. 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) OnOpenURLs ¶

func (a *App) OnOpenURLs(f func(urls []string))

OnOpenURLs registers f, called on the UI thread with the URLs the system or another process asks the app to open, of any scheme but file: (those go to OnOpenFiles): a link to a scheme the app registers, such as myapp://, on macOS (CFBundleURLTypes in Info.plist, at launch and while running), command-line arguments of the form scheme:... on every OS (a .desktop file with Exec=app %U and MimeType=x-scheme-handler/myapp on Linux), and, with SingleInstance, the URLs of a second launch forwarded to the running app. URLs come as given, without duplicates within one call. URLs that arrive before the first handler (a launch by link) are kept and delivered to it once it is set. Several calls add several handlers. Users of Unwrap can still add an swt.OpenUrl listener on macOS. See docs/events.md.

func (*App) OnPreferences ¶

func (a *App) OnPreferences(f func()) bool

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 ¶

func (a *App) OnQuit(f func() bool)

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 ¶

func (a *App) OnThemeChange(f func(dark bool))

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 ¶

func (a *App) Pending() int

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 ¶

func (a *App) ScreenSize() (width, height int)

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 ¶

func (a *App) SetBadge(text string)

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 ¶

func (a *App) SetDensity(d Density)

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()
	})
}

func (*App) SetLinkColor ¶

func (a *App) SetLinkColor(c *Adaptive)

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 ¶

func (a *App) SystemFont() Font

SystemFont returns the family and size of the system UI font, which Font.Scale multiplies.

func (*App) Track ¶

func (a *App) Track(name string) (done func())

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 ¶

func (a *App) Tray(tooltip string, onClick func()) *TrayIcon

Tray adds a tray icon, or returns nil where the platform has no system tray. onClick may be nil.

func (*App) Unwrap ¶

func (a *App) Unwrap() *swt.Display

Unwrap returns the underlying display.

func (*App) Window ¶

func (a *App) Window(title string, opts ...Option) *Window

Window creates a hidden window with the children in opts; call Show once its content is built. Children whose callbacks use the window go in a w.Add after this call, when w is set. Options: Gap, Padding, children; the placement options do not apply.

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, radio or toggle button.

func (*ButtonView) Checked ¶

func (b *ButtonView) Checked() bool

Checked reports the state of a Check, Radio or Toggle 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, Radio or Toggle 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.

func (*ButtonView) Visible ¶

func (w *ButtonView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

type Buttons ¶

type Buttons int

Buttons selects the buttons of a message box.

const (
	ButtonsOK Buttons = iota
	ButtonsOKCancel
	ButtonsYesNo
	ButtonsYesNoCancel
	ButtonsRetryCancel
	ButtonsAbortRetryIgnore
)

Button sets of a message box.

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) Add ¶

func (t *CTabsView) Add(tabs ...Option)

Add appends Tab pages.

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) Index ¶

func (t *CTabsView) Index() int

Index is the selected tab, -1 if none.

func (*CTabsView) OnClose ¶

func (t *CTabsView) OnClose(f func(index int) bool)

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) OnSelect ¶

func (t *CTabsView) OnSelect(f func(index int))

OnSelect runs f with the selected tab index.

func (*CTabsView) Select ¶

func (t *CTabsView) Select(i int)

Select selects tab i.

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.

func (*CTabsView) Visible ¶

func (w *CTabsView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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.

func (*CanvasView) Visible ¶

func (w *CanvasView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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) Clear ¶

func (c *Clipboard) Clear()

Clear empties the clipboard.

func (*Clipboard) Files ¶

func (c *Clipboard) Files() []string

Files returns the paths of the files copied in a file manager, nil if there are none.

func (*Clipboard) HTML ¶

func (c *Clipboard) HTML() (string, bool)

HTML returns the HTML fragment on the clipboard.

func (*Clipboard) Image ¶

func (c *Clipboard) Image() (img *Image, ok bool)

Image returns a copy of the image on the clipboard, owned by the App like every Image.

func (*Clipboard) SetFiles ¶

func (c *Clipboard) SetFiles(paths []string) error

SetFiles replaces the clipboard content with a list of file paths.

func (*Clipboard) SetHTML ¶

func (c *Clipboard) SetHTML(html, plain string) (err error)

SetHTML replaces the clipboard content with html and, for applications that do not read HTML, plain.

func (*Clipboard) SetImage ¶

func (c *Clipboard) SetImage(img *Image) error

SetImage replaces the clipboard content with a copy of img.

func (*Clipboard) SetText ¶

func (c *Clipboard) SetText(s string) error

SetText replaces the clipboard content with s.

func (*Clipboard) Text ¶

func (c *Clipboard) Text() (string, bool)

Text returns the plain text on the clipboard.

func (*Clipboard) Unwrap ¶

func (c *Clipboard) Unwrap() *swt.Clipboard

Unwrap returns the underlying swt.Clipboard for the full API.

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) Pack ¶

func (c *Column) Pack()

Pack resizes the column to fit its content.

func (*Column) SetResizable ¶

func (c *Column) SetResizable(v bool)

SetResizable allows or forbids resizing the column by dragging the header edge.

func (*Column) SetTitle ¶

func (c *Column) SetTitle(s string)

SetTitle replaces the header text.

func (*Column) SetWidth ¶

func (c *Column) SetWidth(w int)

SetWidth sets the width in points.

func (*Column) Unwrap ¶

func (c *Column) Unwrap() *swt.Item

Unwrap returns the underlying item for the full API; its Impl() is the *swt.TableColumn or *swt.TreeColumn.

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) Index ¶

func (c *ComboView) Index() int

Index is the selected item, -1 if the text matches none.

func (*ComboView) Items ¶

func (c *ComboView) Items() []string

Items returns the list entries.

func (*ComboView) OnChange ¶

func (c *ComboView) OnChange(f func(text string))

OnChange runs f with the new text after every edit.

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) OnSelect ¶

func (c *ComboView) OnSelect(f func(index int))

OnSelect runs f with the chosen item index.

func (*ComboView) Select ¶

func (c *ComboView) Select(i int)

Select selects item i.

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 ¶

func (c *ComboView) SetItems(s []string)

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) SetText ¶

func (c *ComboView) SetText(s string)

SetText replaces the edit field content.

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.

func (*ComboView) Text ¶

func (c *ComboView) Text() string

Text returns the edit field content, also when it matches no item.

func (*ComboView) Unwrap ¶

func (c *ComboView) Unwrap() *swt.Combo

Unwrap returns the underlying swt.Combo for the full API.

func (*ComboView) Visible ¶

func (w *ComboView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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 ¶

func (p CoolBarView) AsComposite() *swt.Composite

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.

func (*DateTimeView) Visible ¶

func (w *DateTimeView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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 ¶

func DensityFactor(f float64) Density

DensityFactor is DensitySame scaled by f: a body of 13*f px and f times the macOS Spacing.

func (Density) Legacy ¶

func (d Density) Legacy() bool

Legacy reports whether d is the zero value, the behaviour of the releases before Density.

type DisclosureView ¶

type DisclosureView struct {
	// contains filtered or unexported fields
}

DisclosureView is a collapsible section: a header row and a body that folds.

func (*DisclosureView) Add ¶

func (d *DisclosureView) Add(children ...Option)

Add appends children to the body.

func (*DisclosureView) AsComposite ¶

func (d *DisclosureView) AsComposite() *swt.Composite

AsComposite returns the body, as Panel does, for the look package.

func (*DisclosureView) Dispose ¶

func (w *DisclosureView) 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 (*DisclosureView) Enabled ¶

func (w *DisclosureView) Enabled() bool

Enabled reports the state set by SetEnabled, not that of the parents.

func (*DisclosureView) Expanded ¶

func (d *DisclosureView) Expanded() bool

Expanded reports whether the body shows.

func (*DisclosureView) Focus ¶

func (w *DisclosureView) Focus() bool

Focus gives the control the keyboard focus and reports whether it took it.

func (*DisclosureView) OnChange ¶

func (d *DisclosureView) OnChange(f func(expanded bool))

OnChange runs f with the new state after the user folded or unfolded the body.

func (*DisclosureView) OnDispose ¶

func (w *DisclosureView) OnDispose(f func())

OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.

func (*DisclosureView) SetBackground ¶

func (w *DisclosureView) 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 (*DisclosureView) SetEnabled ¶

func (w *DisclosureView) 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 (*DisclosureView) SetExpanded ¶

func (d *DisclosureView) SetExpanded(v bool)

SetExpanded shows or folds the body without running OnChange; the parents are laid out again on the next event-loop turn.

func (*DisclosureView) SetFont ¶

func (w *DisclosureView) 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 (*DisclosureView) SetForeground ¶

func (w *DisclosureView) 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 (*DisclosureView) SetHeight ¶

func (w *DisclosureView) 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 (*DisclosureView) SetMaxHeight ¶

func (w *DisclosureView) 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 (*DisclosureView) SetSize ¶

func (w *DisclosureView) 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 (*DisclosureView) SetTitle ¶

func (d *DisclosureView) SetTitle(s string)

SetTitle replaces the title of the header and the name of the chevron for VoiceOver, without folding or unfolding the body.

func (*DisclosureView) SetTooltip ¶

func (w *DisclosureView) SetTooltip(s string)

SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.

func (*DisclosureView) SetVisible ¶

func (w *DisclosureView) 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 (*DisclosureView) Unwrap ¶

func (d *DisclosureView) Unwrap() *swt.Composite

Unwrap returns the composite that holds the header and the body.

func (*DisclosureView) Visible ¶

func (w *DisclosureView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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()
	})
}

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 ¶

func Beside[T Widget](w *T, gap int) Edge

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.

func Percent ¶

func Percent(pct, offset int) Edge

Percent attaches the side to pct percent of the Form's width or height, plus offset points. Percent(0, 5) is 5 from the left/top, Percent(100, -5) is 5 from the right/bottom.

func Same ¶

func Same[T Widget](w *T, offset int) Edge

Same attaches the side to the same side of the sibling *w (left to left, top to top, ...), offset points away.

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 ¶

type Font struct {
	Name         string
	Size         int
	Px           float64
	Scale        float64
	Weight       Weight
	Bold, Italic bool
}

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 ¶

type FormCell struct {
	Left, Right, Top, Bottom Edge
	Width, Height            int
}

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) FillOval ¶

func (g *GC) FillOval(x, y, w, h int)

FillOval fills the oval inscribed in the rectangle (x, y, w, h).

func (*GC) FillRect ¶

func (g *GC) FillRect(x, y, w, h int)

FillRect fills the rectangle with top left (x, y).

func (*GC) Image ¶

func (g *GC) Image(img *Image, x, y int)

Image draws img with its top left at (x, y).

func (*GC) Line ¶

func (g *GC) Line(x1, y1, x2, y2 int)

Line draws a line from (x1, y1) to (x2, y2).

func (*GC) Oval ¶

func (g *GC) Oval(x, y, w, h int)

Oval outlines the oval inscribed in the rectangle (x, y, w, h).

func (*GC) Rect ¶

func (g *GC) Rect(x, y, w, h int)

Rect outlines the rectangle with top left (x, y).

func (*GC) SetColor ¶

func (g *GC) SetColor(c RGB)

SetColor sets the color of lines and text.

func (*GC) SetFill ¶

func (g *GC) SetFill(c RGB)

SetFill sets the color of filled shapes and the text background.

func (*GC) SetFont ¶

func (g *GC) SetFont(f Font)

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 ¶

func (g *GC) SetLineWidth(w int)

SetLineWidth sets the outline width in points.

func (*GC) Size ¶

func (g *GC) Size() (w, h int)

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 ¶

func (g *GC) Text(s string, x, y int)

Text draws s with its top left at (x, y) over the fill color; tabs and newlines are honored.

func (*GC) TextSize ¶

func (g *GC) TextSize(s string) (w, h int)

TextSize measures s as Text would draw it.

func (*GC) Unwrap ¶

func (g *GC) Unwrap() *swt.GC

Unwrap returns the underlying GC.

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 ¶

func (p GroupView) AsComposite() *swt.Composite

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.

func (*GroupView) SetTitle ¶

func (g *GroupView) SetTitle(s string)

SetTitle replaces the frame title. Lays the parents out when the size changes.

func (*GroupView) Unwrap ¶

func (g *GroupView) Unwrap() *swt.Group

Unwrap returns the underlying swt.Group for the full API.

type Icon ¶

type Icon int

Icon is the picture of a message box.

const (
	IconNone Icon = iota
	IconInfo
	IconWarning
	IconError
	IconQuestion
)

Message box icons.

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.

func (*Image) Size ¶

func (i *Image) Size() (w, h int)

Size returns the width and height in points.

func (*Image) Unwrap ¶

func (i *Image) Unwrap() *swt.Image

Unwrap returns the underlying image.

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.

func (*Job) Then ¶

func (j *Job) Then(f func(err error)) *Job

Then calls f on the UI thread with the error fn returned, once fn has returned. Called after that, it queues f at once. Several Then calls run in order. Returns j.

func (*Job) Wait ¶

func (j *Job) Wait() error

Wait blocks until fn has returned and the Then callbacks have run, and returns fn's error. If Run ends first it waits for fn only. From any goroutine except the UI thread, which could never run the callbacks: there it panics.

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) Step ¶

func (p *JobProgress) Step(n int)

Step adds n finished steps.

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 ¶

func (l *LabelView) SetImage(img *Image)

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 ¶

func (l *LabelView) SetText(s string)

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.

func (*LabelView) Unwrap ¶

func (l *LabelView) Unwrap() *swt.Label

Unwrap returns the underlying swt.Label for the full API.

func (*LabelView) Visible ¶

func (w *LabelView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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) OnClick ¶

func (l *LinkView) OnClick(f func(href string))

OnClick runs f with the clicked anchor's href.

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 ¶

func (l *LinkView) SetText(s string)

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.

func (*LinkView) Unwrap ¶

func (l *LinkView) Unwrap() *swt.Link

Unwrap returns the underlying swt.Link for the full API.

func (*LinkView) Visible ¶

func (w *LinkView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

type ListView ¶

type ListView struct {
	// contains filtered or unexported fields
}

ListView is a single or multi (MultiSelect) selection list of strings.

func (*ListView) Add ¶

func (l *ListView) Add(s string)

Add appends an entry.

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) Index ¶

func (l *ListView) Index() int

Index is the first selected item, -1 if none.

func (*ListView) Items ¶

func (l *ListView) Items() []string

Items returns the list entries.

func (*ListView) Len ¶

func (l *ListView) Len() int

Len counts all entries, selected or not.

func (*ListView) OnActivate ¶

func (l *ListView) OnActivate(f func(index int))

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) OnSelect ¶

func (l *ListView) OnSelect(f func(index int))

OnSelect runs f with the first selected index.

func (*ListView) Remove ¶

func (l *ListView) Remove(i int)

Remove deletes entry i.

func (*ListView) Select ¶

func (l *ListView) Select(i ...int)

Select replaces the selection with items i; no i clears it.

func (*ListView) Selected ¶

func (l *ListView) Selected() []int

Selected returns all selected item indices.

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) SetItem ¶

func (l *ListView) SetItem(i int, s string)

SetItem replaces the text of item i, keeping the selection.

func (*ListView) SetItems ¶

func (l *ListView) SetItems(s []string)

SetItems replaces the list entries.

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.

func (*ListView) Unwrap ¶

func (l *ListView) Unwrap() *swt.List

Unwrap returns the underlying swt.List for the full API.

func (*ListView) Visible ¶

func (w *ListView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

type Menu struct {
	// contains filtered or unexported fields
}

Menu is a menu bar, a popup menu or a submenu.

func PopupMenu ¶

func PopupMenu(w Widget) *Menu

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 (m *Menu) Item(text string, onClick func(), opts ...Option) *MenuItem

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 (m *Menu) OnShow(f func())

OnShow runs f just before the menu opens, to refresh enabled states.

func (m *Menu) Separator()

Separator appends a divider.

func (m *Menu) Show()

Show opens the popup menu at the pointer.

func (m *Menu) Submenu(text string) *Menu

Submenu appends an item that opens and returns a nested menu.

func (m *Menu) Unwrap() *swt.Menu

Unwrap returns the underlying swt.Menu for the full API.

type MenuItem struct {
	// contains filtered or unexported fields
}

MenuItem is a menu entry.

func (i *MenuItem) Checked() bool

Checked reports the state of a check or radio item.

func (i *MenuItem) OnClick(f func())

OnClick runs f when the item is chosen (or toggled).

func (i *MenuItem) SetChecked(v bool)

SetChecked sets the state of a check or radio item.

func (i *MenuItem) SetEnabled(v bool)

SetEnabled enables or greys out the item.

func (i *MenuItem) SetText(s string)

SetText replaces the item text; "&" marks the mnemonic. The key of a Shortcut stays shown unless s has a "\t" part of its own.

func (i *MenuItem) Unwrap() *swt.MenuItem

Unwrap returns the underlying swt.MenuItem for the full API.

type Message ¶

type Message struct {
	Title, Text string
	Icon        Icon
	Buttons     Buttons
}

Message describes a message box.

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) Checked ¶

func (n *Node) Checked() bool

Checked reports the check box of a Check tree.

func (*Node) Children ¶

func (n *Node) Children() []*Node

Children returns the direct child nodes.

func (*Node) Data ¶

func (n *Node) Data() any

Data returns the value stored by SetData.

func (*Node) Expanded ¶

func (n *Node) Expanded() bool

Expanded reports whether the children are shown.

func (*Node) Node ¶

func (n *Node) Node(text string) *Node

Node appends a child node.

func (*Node) Remove ¶

func (n *Node) Remove()

Remove deletes the node with its children.

func (*Node) SetChecked ¶

func (n *Node) SetChecked(v bool)

SetChecked sets the check box of a Check tree.

func (*Node) SetData ¶

func (n *Node) SetData(v any)

SetData stores an application value with the node.

func (*Node) SetExpanded ¶

func (n *Node) SetExpanded(v bool)

SetExpanded shows or hides the children.

func (*Node) SetImage ¶

func (n *Node) SetImage(img *Image)

SetImage sets the icon; the node does not own img.

func (*Node) SetImageAt ¶

func (n *Node) SetImageAt(col int, img *Image)

SetImageAt sets the icon of column col; the node does not own img.

func (*Node) SetText ¶

func (n *Node) SetText(s string)

SetText replaces the node text.

func (*Node) SetTextAt ¶

func (n *Node) SetTextAt(col int, s string)

SetTextAt sets the text of column col; SetText is column 0.

func (*Node) Text ¶

func (n *Node) Text() string

Text returns the node text (the first column).

func (*Node) TextAt ¶

func (n *Node) TextAt(col int) string

TextAt returns the text of column col.

func (*Node) Unwrap ¶

func (n *Node) Unwrap() *swt.TreeItem

Unwrap returns the underlying swt.TreeItem for the full API.

type NumberView ¶

type NumberView struct {
	// contains filtered or unexported fields
}

NumberView is a field that holds a number, see Number.

func (*NumberView) Dispose ¶

func (w *NumberView) 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 (*NumberView) Enabled ¶

func (w *NumberView) Enabled() bool

Enabled reports the state set by SetEnabled, not that of the parents.

func (*NumberView) Focus ¶

func (w *NumberView) Focus() bool

Focus gives the control the keyboard focus and reports whether it took it.

func (*NumberView) OnChange ¶

func (n *NumberView) OnChange(f func(value float64))

OnChange runs f with the new number after the user changed it: by typing, the arrow keys or a scrub.

func (*NumberView) OnDispose ¶

func (w *NumberView) OnDispose(f func())

OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.

func (*NumberView) SetBackground ¶

func (w *NumberView) 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 (*NumberView) SetEnabled ¶

func (w *NumberView) 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 (*NumberView) SetFont ¶

func (w *NumberView) 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 (*NumberView) SetForeground ¶

func (w *NumberView) 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 (*NumberView) SetHeight ¶

func (w *NumberView) 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 (*NumberView) SetMaxHeight ¶

func (w *NumberView) 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 (*NumberView) SetSize ¶

func (w *NumberView) 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 (*NumberView) SetTooltip ¶

func (w *NumberView) SetTooltip(s string)

SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.

func (*NumberView) SetValue ¶

func (n *NumberView) SetValue(v float64)

SetValue sets the number, clamped to [min, max] and rounded to the step, without running OnChange.

func (*NumberView) SetVisible ¶

func (w *NumberView) 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 (*NumberView) Unwrap ¶

func (n *NumberView) Unwrap() *swt.Text

Unwrap returns the underlying swt.Text, whose text is the shown number.

func (*NumberView) Value ¶

func (n *NumberView) Value() float64

Value returns the number within [min, max].

func (*NumberView) Visible ¶

func (w *NumberView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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 ¶

func AccessibleLabel(s string) Option

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 Anchor ¶

func Anchor(c FormCell) Option

Anchor sets the position of a child laid out by Form.

func AsCalendar ¶

func AsCalendar() Option

AsCalendar makes a DateTime a month calendar.

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 ¶

func AutoGrow(minHeight, maxHeight int) Option

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 ¶

func Background(c Paint) Option

Background sets the background colour of a widget, as SetBackground does.

func Bind ¶

func Bind[T string | bool | int | float64](s *rx.State[T]) Option

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 or Toggle button or whether a Disclosure is expanded (bool), the value of a Scale, Slider, Spinner or Progress (one way), the selected index of a Combo, List or Segmented (int), or the value of a Number (float64, or int rounded). A Text is rewritten only when s differs from it, so typing keeps the caret.

func BindEnabled ¶

func BindEnabled(r rx.Reader[bool]) Option

BindEnabled enables or disables the widget as r changes.

func BindText ¶

func BindText(r rx.Reader[string]) Option

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 ¶

func BindVisible(r rx.Reader[bool]) Option

BindVisible shows or hides the widget as r changes, with SetVisible's handling of the layouts.

func Border ¶

func Border() Option

Border draws a frame; Table and Tree have one by default.

func Borderless ¶

func Borderless() Option

Borderless draws a push or Toggle Button without its frame, for an icon in a section header (+, -, an eye): macOS no bezel, a toggle with its symbol in the accent colour while on; GTK "flat"; Windows the WinUI Subtle button.

func Bottom ¶

func Bottom() Option

Bottom puts the tabs of Tabs or CTabs below the pages.

func Boundary ¶

func Boundary(opts ...Option) Option

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 ¶

func Button(text string, opts ...Option) Option

Button creates a push button (Check, Radio or Toggle for other kinds); OnClick gives it an action. Options: Check, Radio, Toggle, Small, OnClick, OnChange and Checked (Check, Radio, Toggle), 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()
	})
}

func CTabs ¶

func CTabs(opts ...Option) Option

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 ¶

func Canvas(onPaint func(g *GC), opts ...Option) Option

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()
	})
}

func Cell ¶

func Cell(c GridCell) Option

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 Center ¶

func Center() Option

Center centers a table Column.

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 Checked ¶

func Checked(on bool) Option

Checked sets the state of a Switch or of a Check, Radio or Toggle button.

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 Closable ¶

func Closable() Option

Closable adds a close button to a CTabs tab.

func Collapsed ¶

func Collapsed() Option

Collapsed starts a Disclosure folded.

func Combo ¶

func Combo(items []string, opts ...Option) Option

Combo creates a combo box with the given items. Options: ReadOnly, Simple, Value, Selected, OnSelect, OnChange, Bind (string: text, int: index).

func CoolBar ¶

func CoolBar(opts ...Option) Option

CoolBar creates a cool bar: each child, usually a ToolBar, becomes a band of its natural size. Options: common only, children.

func Custom ¶

func Custom(f func(*swt.Control)) Option

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 ¶

func DateTime(opts ...Option) Option

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 Disabled ¶

func Disabled() Option

Disabled creates the widget disabled.

func Disclosure ¶

func Disclosure(title string, opts ...Option) Option

Disclosure creates a collapsible section of an inspector: a header of a disclosure chevron, the title and the Trailing widgets, over a body of the children stacked as in a VBox, which a click on the chevron or the title folds. It starts expanded unless Collapsed; Gap and Padding apply to the body. macOS: the chevron is an NSButton with the disclosure bezel; GTK a flat arrow button; Windows the WinUI expander chevron. Options: Collapsed, Trailing, OnChange (bool: expanded), Bind (bool), Gap, Padding, children.

func Divider ¶

func Divider() Option

Divider makes every sash of a Split draw a hairline down its middle in the system separator colour, the thin divider of an NSSplitView, on every system. The panes of a Split on one background, a tree above an outline in a sidebar, otherwise run together.

func DropDown() Option

DropDown makes a DateTime date field a drop-down calendar, or a ToolBar item a drop-down.

func Failed ¶

func Failed(f func(err error, reset func()) Option) Option

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 ¶

func Field(label string, control Option, opts ...Option) Option

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 FieldFill ¶

func FieldFill(c Paint) Option

FieldFill gives a single-line Text or Number a rounded fill instead of the native bezel: the text, caret, focus ring and Prefix stay native, and Radius rounds the fill. Pair it with Inset for the padding of the text.

func FieldStroke ¶

func FieldStroke(c Paint) Option

FieldStroke draws a border of paint around the FieldFill of a single-line field; RGB.Alpha sets a translucent border such as the 25% black of an inspector field.

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 ¶

func Fields(opts ...Option) Option

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 ¶

func Fill(opts ...Option) Option

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 Flat ¶

func Flat() Option

Flat gives a ToolBar the flat look.

func Flow ¶

func Flow(opts ...Option) Option

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 ¶

func Foreground(c Paint) Option

Foreground sets the text colour of a widget, as SetForeground does.

func Form ¶

func Form(opts ...Option) Option

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 ¶

func Gap(points int) Option

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 ¶

func Grid(columns int, opts ...Option) Option

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()
	})
}

func Group ¶

func Group(title string, opts ...Option) Option

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 ¶

func HBox(opts ...Option) Option

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()
	})
}

func Hint ¶

func Hint(s string) Option

Hint sets the placeholder a Text shows while it is empty.

func ID ¶

func ID(id string) Option

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 ¶

func Indent(x, y int) Option

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 ¶

func Init[T Widget](f func(T)) Option

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 ¶

func Inset(x, y int) Option

Inset puts x points between the text and the left and right edge of a Text and, for a multi-line one, y points above and below it. A single-line Text takes x only, with FieldFill.

func Items ¶

func Items(list rx.Reader[[]string]) Option

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 Label ¶

func Label(text string, opts ...Option) Option

Label creates a static text. Options: Wrap, Center, Right, Border, BindText.

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(text string, opts ...Option) Option

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 ¶

func List(items []string, opts ...Option) Option

List creates a list with the given items. Options: MultiSelect, NoBorder, Selected, OnSelect, OnActivate, Bind (int).

func MaxHeight ¶

func MaxHeight(h int) Option

MaxHeight keeps the natural height of a widget at most h points, as SetMaxHeight does.

func Momentary ¶

func Momentary() Option

Momentary makes the segments of a Segmented buttons that run OnSelect and do not stay selected, as the "+" and "-" under a list.

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 NoBackground ¶

func NoBackground() Option

NoBackground makes a StyledText paint no background of its own, so what is under it shows through: the material of a look.SetMaterial pane, a coloured Panel. Selected text and TextStyle backgrounds are still drawn. It is an alpha-0 background colour, which SWT draws as the background of the parent.

func NoBorder ¶

func NoBorder() Option

NoBorder removes the frame that List, Table and Tree have by default, and the one Border gives a Text or StyledText; it wins over Border in either order.

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 Number ¶

func Number(min, max float64, opts ...Option) Option

Number creates a field for a number within [min, max], at min until Value sets another. Step sets the increment, 1 by default; the value is rounded to it and shown with as many decimals as it has. A typed number takes effect on Return and when the field loses the focus (text that is no number is put back, Escape puts it back too); Up and Down add and subtract a step, ten with Shift; dragging the Prefix left or right changes the value by a step per point, ten with Shift, as in Figma. Each of these runs OnChange; SetValue and Value do not. The field has a frame unless NoBorder. Options: Prefix, PrefixImage, Suffix, Small, Step, NoBorder, Value, OnChange, Bind (float64 or int).

func OnActivate ¶

func OnActivate[F func() | func(int) | func(*Node)](f F) Option

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 ¶

func OnChange[F func(string) | func(bool) | func(int) | func(float64) | func(time.Time)](f F) Option

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, a Check or Toggle button or a Disclosure (func(bool)), the value of a Scale, Slider or Spinner (func(int)), the value of a Number (func(float64), or func(int) rounded), the value of a DateTime (func(time.Time)).

func OnClick ¶

func OnClick[F func() | func(string)](f F) Option

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 ¶

func OnFocus(f func(focused bool)) Option

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 ¶

func OnSelect[F func(int) | func(*Node)](f F) Option

OnSelect runs f when the selection changes: with the index of the selected item of a Combo, List, Table, Tabs or CTabs or of the segment of a Segmented (func(int)), with the selected node of a Tree (func(*Node)).

func Padding ¶

func Padding(points int) Option

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 ¶

func Pages(opts ...Option) Option

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()
	})
}

func Password ¶

func Password() Option

Password masks the characters typed into a Text.

func Place ¶

func Place(h, v Align) Option

Place aligns the child inside its cell: Place(AlignEnd, AlignCenter) puts it at the right, centred vertically.

func Prefix ¶

func Prefix(s string) Option

Prefix puts a label such as "X" or "Gap" inside the frame of a single-line Text or a Number, before the value, in the secondary text colour; on a Number dragging it changes the value (scrub).

func PrefixImage ¶

func PrefixImage(img *Image) Option

PrefixImage puts an icon at its own size there instead of a label. On macOS an icons.Get image without a Color takes the secondary text colour; elsewhere an image keeps its own.

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 ¶

func Progress(max int, opts ...Option) Option

Progress creates a progress bar over [0, max]. Options: Vertical, Smooth, Indeterminate, Value.

func Radio ¶

func Radio() Option

Radio makes a Button a radio button.

func Radius ¶

func Radius(points int) Option

Radius is the corner radius in points of the fill FieldFill gives a field.

func ReadOnly ¶

func ReadOnly() Option

ReadOnly makes a Text or Combo non-editable.

func Ref ¶

func Ref[T Widget](p *T) Option

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 Right() Option

Right right-aligns a table Column.

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 ¶

func Sash(opts ...Option) Option

Sash creates a sash; Vertical() makes a vertical bar that moves left and right. Options: Vertical.

func Scale ¶

func Scale(min, max int, opts ...Option) Option

Scale creates a scale over [min, max] at min; Value sets another start. Options: Vertical, Value, OnChange, Bind (int).

func Scroll ¶

func Scroll(opts ...Option) Option

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() Option

Search makes a Text a search field with a magnifier icon and a clear button.

func Section ¶

func Section(opts ...Option) Option

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 Segmented ¶

func Segmented(segments []Segment, opts ...Option) Option

Segmented creates a segmented control: segments side by side of which one is selected, for a choice among a few (Fixed, Hug, Fill), or with Momentary a row of buttons. The segments share the width equally; GrowX stretches the control. macOS: NSSegmentedControl; GTK: toggle buttons joined like a "linked" box; Windows: toggle buttons painted as one WinUI segmented control. No segment is selected until Selected, Select or a click. Options: Momentary, Small, Selected, OnSelect, Bind (int).

func Selected ¶

func Selected(i int) Option

Selected selects item i of a Combo, List or Table, tab i of a Tabs or CTabs, or segment i of a Segmented.

func Separator ¶

func Separator(opts ...Option) Option

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 ¶

func Shortcut(keys string) Option

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()
	})
}

func Simple ¶

func Simple() Option

Simple makes a Combo show its list permanently.

func Size ¶

func Size(w, h int) Option

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 ¶

func Slider(min, max int, opts ...Option) Option

Slider creates a slider over [min, max] at min; Value sets another start. Options: Vertical, Value, OnChange, Bind (int).

func Small ¶

func Small() Option

Small gives a Segmented, a Button, a single-line Text or a Number the small control size, as in Xcode's inspector: macOS NSControlSizeSmall with its 11-point font; Windows and Linux the font smaller by the same ratio, and a field the compact height (24 dips on Windows, 24 px on Linux).

func Smooth ¶

func Smooth() Option

Smooth makes a Progress an unsegmented bar.

func Spacer ¶

func Spacer(opts ...Option) Option

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 Span ¶

func Span(cols int) Option

Span makes the child cover cols columns of the Grid.

func Spinner ¶

func Spinner(min, max int, opts ...Option) Option

Spinner creates a spinner over [min, max] at min; Value sets another start. Options: ReadOnly, Border, Value, OnChange, Bind (int).

func Split ¶

func Split(opts ...Option) Option

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, Divider, children.

func Step ¶

func Step(step float64) Option

Step sets the increment of a Number (1 by default): the value is rounded to it, Up and Down and a scrub of one point add it, and the field shows as many decimals as it has, at most 6.

func StyledText ¶

func StyledText(opts ...Option) Option

StyledText creates a multi-line styled editor. Options: Scrollbars, Wrap, ReadOnly, Border, NoBorder, NoBackground, 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()
	})
}

func Suffix ¶

func Suffix(s string) Option

Suffix puts a unit, such as "%" or "px", inside the frame of a single-line Text or a Number at its trailing end, in the secondary text colour.

func Switch ¶

func Switch(text string, opts ...Option) Option

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 ¶

func Tab(title string, opts ...Option) Option

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 ¶

func Table(opts ...Option) Option

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()
	})
}

func Tabs ¶

func Tabs(opts ...Option) Option

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 ¶

func Text(opts ...Option) Option

Text creates an edit field. Options: Multiline, Password, ReadOnly, Search, Border, NoBorder, Scrollbars, Hint, Prefix, PrefixImage, Suffix, Small, 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()
	})
}

func Toggle ¶

func Toggle() Option

Toggle makes a Button a toggle button, which stays pressed until it is clicked again (Wrap, Clip): Checked, Bind (bool) and OnChange (bool) read and set its state. macOS: a push-on-push-off NSButton, with Borderless a symbol in the accent colour while on; GTK: GtkToggleButton; Windows: the WinUI ToggleButton, with the accent fill while it is on.

func ToolBar ¶

func ToolBar(opts ...Option) Option

ToolBar creates a tool bar; Flat() and Wrap() change its look. Its items come from Item. Options: Flat, Wrap.

func Tooltip ¶

func Tooltip(s string) Option

Tooltip sets the hover text.

func Trailing ¶

func Trailing(children ...Option) Option

Trailing puts widgets at the right end of a Disclosure header, such as Borderless + and - buttons.

func Tree ¶

func Tree(opts ...Option) Option

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()
	})
}

func Typeface ¶

func Typeface(f Font) Option

Typeface gives a widget the font f, as SetFont does.

func VBox ¶

func VBox(opts ...Option) Option

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 ¶

func Value[T string | int | float64 | time.Time](v T) Option

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), of a Number (float64 or int), the date or time of a DateTime.

func Vertical ¶

func Vertical() Option

Vertical rotates a Scale, Slider or Progress, stacks a Split, and makes a Sash a vertical bar.

func Wrap ¶

func Wrap() Option

Wrap breaks long text of a Label or StyledText into lines, and lets a ToolBar wrap its items to further rows.

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) Add ¶

func (g *PagesView) Add(pages ...Option)

Add appends pages; a page added while none is shown is shown.

func (*PagesView) AsComposite ¶

func (g *PagesView) AsComposite() *swt.Composite

AsComposite returns the underlying composite, as Panel does, for the look package.

func (*PagesView) Current ¶

func (g *PagesView) Current() int

Current returns the index of the visible page, -1 if there is none.

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 ¶

func (g *PagesView) Show(i int)

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.

func (*PagesView) Unwrap ¶

func (g *PagesView) Unwrap() *swt.Composite

Unwrap returns the underlying composite; its layout is an swt.StackLayout.

func (*PagesView) Visible ¶

func (w *PagesView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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()
	})
}

func (Panel) AsComposite ¶

func (p Panel) AsComposite() *swt.Composite

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.

func (Panel) Unwrap ¶

func (p Panel) Unwrap() *swt.Composite

Unwrap returns the underlying composite.

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 ¶

func (p Popover) AsComposite() *swt.Composite

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 ¶

func (p *Popover) OnEscape(f func() bool)

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 ¶

func (p *Popover) SetSize(width, height int)

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.

func (*Popover) Shown ¶

func (p *Popover) Shown() bool

Shown reports whether the popover is on screen.

func (*Popover) Unwrap ¶

func (p *Popover) Unwrap() *swt.Shell

Unwrap returns the underlying shell. On macOS it is never shown and keeps its window; its body view is moved into the NSPopover while the popover is on screen.

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 ¶

func (j *PrintJob) PageRange() (first, last int)

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 ¶

func (j *PrintJob) Print(pages int, draw func(*PrintPage)) (err error)

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 ¶

func (p *PrintPage) GC() *swt.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) SetMax ¶

func (p *ProgressView) SetMax(v int)

SetMax sets the upper bound.

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].

func (*ProgressView) Visible ¶

func (w *ProgressView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

type RGB ¶

type RGB struct{ R, G, B uint8 }

RGB is a color, 0-255 per channel.

func (RGB) Alpha ¶

func (c RGB) Alpha(a uint8) RGBA

Alpha returns c with alpha a.

type RGBA ¶

type RGBA struct{ R, G, B, A uint8 }

RGBA is an RGB with alpha, 0 transparent and 255 opaque, for a border such as FieldStroke.

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 ¶

func (s *SashView) OnMove(f func(x, y int))

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.

func (*SashView) Unwrap ¶

func (s *SashView) Unwrap() *swt.Sash

Unwrap returns the underlying swt.Sash for the full API.

func (*SashView) Visible ¶

func (w *SashView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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) OnChange ¶

func (s *ScaleView) OnChange(f func(value int))

OnChange runs f with the new value.

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) SetValue ¶

func (s *ScaleView) SetValue(v int)

SetValue moves the scale to v.

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.

func (*ScaleView) Unwrap ¶

func (s *ScaleView) Unwrap() *swt.Scale

Unwrap returns the underlying swt.Scale for the full API.

func (*ScaleView) Value ¶

func (s *ScaleView) Value() int

Value returns the position within [min, max].

func (*ScaleView) Visible ¶

func (w *ScaleView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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.

func (*ScrollView) Visible ¶

func (w *ScrollView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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) Add ¶

func (s *SectionView) Add(rows ...Option)

Add appends rows.

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.

func (*SectionView) Visible ¶

func (w *SectionView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

type Segment ¶

type Segment struct {
	Text    string
	Image   *Image
	Tooltip string
}

Segment is one segment of a Segmented: a short Text, an Image, or both, and the Tooltip shown over it. A segment without Text is named to screen readers by its Tooltip.

type SegmentedView ¶

type SegmentedView struct {
	// contains filtered or unexported fields
}

SegmentedView is a segmented control.

func (*SegmentedView) Dispose ¶

func (w *SegmentedView) 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 (*SegmentedView) Enabled ¶

func (w *SegmentedView) Enabled() bool

Enabled reports the state set by SetEnabled, not that of the parents.

func (*SegmentedView) Focus ¶

func (w *SegmentedView) Focus() bool

Focus gives the control the keyboard focus and reports whether it took it.

func (*SegmentedView) Index ¶

func (s *SegmentedView) Index() int

Index returns the selected segment, -1 when none is selected and always for a Momentary control.

func (*SegmentedView) OnDispose ¶

func (w *SegmentedView) OnDispose(f func())

OnDispose runs f when the control is disposed: by Dispose, with its parent, or when its window closes.

func (*SegmentedView) OnSelect ¶

func (s *SegmentedView) OnSelect(f func(index int))

OnSelect runs f with the segment the user selected; a click on the selected one runs nothing. With Momentary it runs with the segment pressed, every time.

func (*SegmentedView) Select ¶

func (s *SegmentedView) Select(i int)

Select selects segment i without running OnSelect; -1 clears the selection. An index out of range and a Momentary control are left as they are.

func (*SegmentedView) SetBackground ¶

func (w *SegmentedView) 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 (*SegmentedView) SetEnabled ¶

func (s *SegmentedView) SetEnabled(v bool)

SetEnabled enables or dims the control. Disabled() does the same at creation.

func (*SegmentedView) SetFont ¶

func (w *SegmentedView) 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 (*SegmentedView) SetForeground ¶

func (w *SegmentedView) 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 (*SegmentedView) SetHeight ¶

func (w *SegmentedView) 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 (*SegmentedView) SetMaxHeight ¶

func (w *SegmentedView) 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 (*SegmentedView) SetSize ¶

func (w *SegmentedView) 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 (*SegmentedView) SetTooltip ¶

func (w *SegmentedView) SetTooltip(s string)

SetTooltip sets the hover text; "" removes it. Tooltip() does the same at creation.

func (*SegmentedView) SetVisible ¶

func (w *SegmentedView) 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 (*SegmentedView) Unwrap ¶

func (s *SegmentedView) Unwrap() *swt.Composite

Unwrap returns the composite that holds the segments.

func (*SegmentedView) Visible ¶

func (w *SegmentedView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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) SetValue ¶

func (s *SliderView) SetValue(v int)

SetValue moves the slider to v.

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].

func (*SliderView) Visible ¶

func (w *SliderView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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.

const (
	SortNone SortDir = iota
	SortAscending
	SortDescending
)

The sort indicator values.

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].

func (*SpinnerView) Visible ¶

func (w *SpinnerView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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 ¶

func (p SplitView) AsComposite() *swt.Composite

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 ¶

func (s *SplitView) SetWeights(w ...int)

SetWeights sets the relative size of each child, one weight per child.

func (*SplitView) Unwrap ¶

func (s *SplitView) Unwrap() *swt.SashForm

Unwrap returns the underlying swt.SashForm for the full API.

type StyleSpan ¶

type StyleSpan struct {
	Start, Length int
	Style         TextStyle
}

StyleSpan is a TextStyle applied to Length runes from Start.

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).

func (*StyledTextView) Visible ¶

func (w *StyledTextView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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.

func (*SwitchView) Visible ¶

func (w *SwitchView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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) Checked ¶

func (r *TableRow) Checked() bool

Checked reports the check box of a Check table.

func (*TableRow) Data ¶

func (r *TableRow) Data() any

Data returns the value stored by SetData.

func (*TableRow) SetChecked ¶

func (r *TableRow) SetChecked(v bool)

SetChecked sets the check box of a Check table.

func (*TableRow) SetData ¶

func (r *TableRow) SetData(v any)

SetData stores an application value with the row.

func (*TableRow) SetImageAt ¶

func (r *TableRow) SetImageAt(col int, img *Image)

SetImageAt sets the icon of column col; the row does not own img.

func (*TableRow) SetTextAt ¶

func (r *TableRow) SetTextAt(col int, s string)

SetTextAt sets the text of column col.

func (*TableRow) TextAt ¶

func (r *TableRow) TextAt(col int) string

TextAt returns the text of column col.

func (*TableRow) Unwrap ¶

func (r *TableRow) Unwrap() *swt.TableItem

Unwrap returns the underlying swt.TableItem for the full API.

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 ¶

func (t *TableView) CellAt(x, y int) (row, col int)

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 ¶

func (t *TableView) Column(title string, width int, opts ...Option) *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) Index ¶

func (t *TableView) Index() int

Index is the first selected row, -1 if none.

func (*TableView) Len ¶

func (t *TableView) Len() int

Len counts rows, not columns.

func (*TableView) OnActivate ¶

func (t *TableView) OnActivate(f func(index int))

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) OnSelect ¶

func (t *TableView) OnSelect(f func(index int))

OnSelect runs f with the first selected row.

func (*TableView) Remove ¶

func (t *TableView) Remove(i int)

Remove deletes row i.

func (*TableView) Row ¶

func (t *TableView) Row(cells ...string) *TableRow

Row appends a row with one text per column.

func (*TableView) RowAt ¶

func (t *TableView) RowAt(i int) *TableRow

RowAt returns row i.

func (*TableView) Select ¶

func (t *TableView) Select(i ...int)

Select replaces the selection with rows i; no i clears it.

func (*TableView) Selected ¶

func (t *TableView) Selected() []int

Selected returns all selected row indices.

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 ¶

func (t *TableView) SetSort(col *Column, dir SortDir)

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 ¶

func (t *TableView) ShowHeader(v bool)

ShowHeader shows or hides the column headers.

func (*TableView) ShowLines ¶

func (t *TableView) ShowLines(v bool)

ShowLines shows or hides the grid lines.

func (*TableView) ShowRowLines ¶

func (t *TableView) ShowRowLines(v bool)

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.

func (*TableView) Unwrap ¶

func (t *TableView) Unwrap() *swt.Table

Unwrap returns the underlying swt.Table for the full API.

func (*TableView) Visible ¶

func (w *TableView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

type TabsView ¶

type TabsView struct {
	// contains filtered or unexported fields
}

TabsView is a native tab folder; each Tab returns the page container.

func (*TabsView) Add ¶

func (t *TabsView) Add(tabs ...Option)

Add appends Tab pages.

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) Index ¶

func (t *TabsView) Index() int

Index is the selected tab, -1 if none.

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) OnSelect ¶

func (t *TabsView) OnSelect(f func(index int))

OnSelect runs f with the selected tab index.

func (*TabsView) Select ¶

func (t *TabsView) Select(i int)

Select selects tab i.

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.

func (*TabsView) Unwrap ¶

func (t *TabsView) Unwrap() *swt.TabFolder

Unwrap returns the underlying swt.TabFolder for the full API.

func (*TabsView) Visible ¶

func (w *TabsView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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) Append ¶

func (t *TextView) Append(s string)

Append adds s at the end without rewriting the content.

func (*TextView) ContentHeight ¶

func (t *TextView) ContentHeight(width int) int

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 ¶

func (t *TextView) Lines() int

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) OnChange ¶

func (t *TextView) OnChange(f func(text string))

OnChange runs f with the new content after every edit.

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 ¶

func (t *TextView) SetAutoGrow(minHeight, maxHeight int)

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) SetHint ¶

func (t *TextView) SetHint(s string)

SetHint sets the placeholder shown while the field is empty.

func (*TextView) SetInset ¶

func (t *TextView) SetInset(x, y int)

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) SetText ¶

func (t *TextView) SetText(s string)

SetText replaces the content.

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 ¶

func (t *TextView) Text() string

Text returns the current content; line breaks are \n on every system (Windows stores \r\n).

func (*TextView) TrimHead ¶

func (t *TextView) TrimHead(keep int)

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.

func (*TextView) Unwrap ¶

func (t *TextView) Unwrap() *swt.Text

Unwrap returns the underlying swt.Text for the full API.

func (*TextView) Visible ¶

func (w *TextView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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) Separator ¶

func (t *ToolBarView) Separator()

Separator appends a divider.

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.

func (*ToolBarView) Visible ¶

func (w *ToolBarView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

type ToolItem ¶

type ToolItem struct {
	// contains filtered or unexported fields
}

ToolItem is a tool bar button.

func (*ToolItem) Checked ¶

func (i *ToolItem) Checked() bool

Checked reports the state of a Check or Radio item.

func (*ToolItem) OnClick ¶

func (i *ToolItem) OnClick(f func())

OnClick runs f when the item is pressed (or toggled).

func (*ToolItem) SetChecked ¶

func (i *ToolItem) SetChecked(v bool)

SetChecked sets the state of a Check or Radio item.

func (*ToolItem) SetEnabled ¶

func (i *ToolItem) SetEnabled(v bool)

SetEnabled enables or greys out the item.

func (*ToolItem) SetImage ¶

func (i *ToolItem) SetImage(img *Image)

SetImage sets the icon; the item does not own img. Lays the tool bar's parents out when its size changes.

func (*ToolItem) SetText ¶

func (i *ToolItem) SetText(s string)

SetText replaces the item text. Lays the tool bar's parents out when its size changes.

func (*ToolItem) SetTooltip ¶

func (i *ToolItem) SetTooltip(s string)

SetTooltip sets the text shown on hover.

func (*ToolItem) Unwrap ¶

func (i *ToolItem) Unwrap() *swt.ToolItem

Unwrap returns the underlying swt.ToolItem for the full API.

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) Remove ¶

func (t *TrayIcon) Remove()

Remove deletes the icon from the tray.

func (*TrayIcon) SetImage ¶

func (t *TrayIcon) SetImage(img *Image)

SetImage sets the icon; the tray does not own img.

func (*TrayIcon) SetTooltip ¶

func (t *TrayIcon) SetTooltip(s string)

SetTooltip sets the text shown on hover.

func (*TrayIcon) Unwrap ¶

func (t *TrayIcon) Unwrap() *swt.TrayItem

Unwrap returns the underlying swt.TrayItem for the full API.

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 ¶

func (t *TreeView) CellAt(x, y int) (*Node, int)

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) Clear ¶

func (t *TreeView) Clear()

Clear deletes all nodes, children included.

func (*TreeView) Column ¶

func (t *TreeView) Column(title string, width int, opts ...Option) *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) Edit ¶

func (t *TreeView) Edit(n *Node, onCommit func(string), onCancel func())

Edit opens a focused editor; callbacks own updating the node. Enter/focus loss commit, Esc cancels. Another edit cancels the active editor, but waits for an already scheduled completion.

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) Node ¶

func (t *TreeView) Node(text string) *Node

Node appends a root node.

func (*TreeView) OnActivate ¶

func (t *TreeView) OnActivate(f func(n *Node))

OnActivate runs f on double click or Enter.

func (*TreeView) OnCellClick ¶

func (t *TreeView) OnCellClick(f func(TreeClick))

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 ¶

func (t *TreeView) OnCollapse(f func(n *Node))

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) OnExpand ¶

func (t *TreeView) OnExpand(f func(n *Node))

OnExpand and OnCollapse run f with the node that changed.

func (*TreeView) OnSelect ¶

func (t *TreeView) OnSelect(f func(n *Node))

OnSelect runs f with the first selected node, nil if none.

func (*TreeView) Roots ¶

func (t *TreeView) Roots() []*Node

Roots returns the top-level nodes.

func (*TreeView) Select ¶

func (t *TreeView) Select(n *Node)

Select selects n alone; nil clears the selection. It calls no OnSelect, as SWT's setSelection sends no Selection.

func (*TreeView) Selected ¶

func (t *TreeView) Selected() []*Node

Selected returns the selected nodes.

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 ¶

func (t *TreeView) SetSort(col *Column, dir SortDir)

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 ¶

func (t *TreeView) ShowHeader(v bool)

ShowHeader shows or hides the column headers.

func (*TreeView) ShowRowLines ¶

func (t *TreeView) ShowRowLines(v bool)

ShowRowLines shows or hides thin lines between rows only, see Table.ShowRowLines.

func (*TreeView) Unwrap ¶

func (t *TreeView) Unwrap() *swt.Tree

Unwrap returns the underlying swt.Tree for the full API.

func (*TreeView) Visible ¶

func (w *TreeView) Visible() bool

Visible reports the state set by SetVisible, not that of the parents.

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.

const (
	Light    Weight = 300
	Regular  Weight = 400
	Medium   Weight = 500
	Semibold Weight = 600
	Bold     Weight = 700
)

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 ¶

func (p Window) AsComposite() *swt.Composite

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 ¶

func (w *Window) ColorDialog(initial RGB) (c RGB, ok bool)

ColorDialog shows a color chooser starting at initial; ok is false if cancelled.

func (*Window) Confirm ¶

func (w *Window) Confirm(title, text string) bool

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()
	})
}

func (*Window) DirDialog ¶

func (w *Window) DirDialog(title, dir string) (path string, ok bool)

DirDialog shows a folder chooser; ok is false if cancelled.

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 ¶

func (w *Window) FontDialog(initial Font) (f Font, ok bool)

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 ¶

func (w *Window) MenuBar() *Menu

MenuBar creates the window's menu bar. On macOS it becomes the application menu bar.

func (*Window) MessageBox ¶

func (w *Window) MessageBox(m Message) Answer

MessageBox shows m modal over w and returns the pressed button.

func (*Window) OnClose ¶

func (w *Window) OnClose(f func() bool)

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 ¶

func (w *Window) OnKey(keys string, f func())

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 ¶

func (w *Window) Popover(opts ...Option) *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 ¶

func (w *Window) SetMinSize(width, height int)

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) SetSize ¶

func (w *Window) SetSize(width, height int)

SetSize sets the window size in points.

func (*Window) SetTitle ¶

func (w *Window) SetTitle(s string)

SetTitle changes the window title.

func (*Window) SetTopInset ¶

func (w *Window) SetTopInset(points int)

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.

func (*Window) Show ¶

func (w *Window) Show()

Show packs the window to its content size (unless SetSize was called), opens it and, the first time, gives the keyboard focus to the widget created with Focused.

func (*Window) Unwrap ¶

func (w *Window) Unwrap() *swt.Shell

Unwrap returns the underlying shell.

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 over the inspector (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 over the inspector (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.
materialpanel command
Command materialpanel puts a code panel under a diagram canvas as the bottom panel of a sidebar window (look.SetBottomPanel): on macOS 26 its glass and the canvas colour run on under the floating sidebar, and its StyledText paints no background of its own.
Command materialpanel puts a code panel under a diagram canvas as the bottom panel of a sidebar window (look.SetBottomPanel): on macOS 26 its glass and the canvas colour run on under the floating sidebar, and its StyledText paints no background of its own.
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.
gfx
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/cache
Package cache holds the caches the gfx backends keep per Renderer, bounded so that a scene which keeps making new strings, shadows or Rasters does not grow them without end.
Package cache holds the caches the gfx backends keep per Renderer, bounded so that a scene which keeps making new strings, shadows or Rasters does not grow them without end.
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
Hand-written: a label, an icon and a unit inside the frame of a single-line text field, and the scrub handle over the label of a numeric field.
Hand-written: a label, an icon and a unit inside the frame of a single-line text field, and the scrub handle over the label of a numeric field.
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.
qa
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.
swt
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.
testexec command
testexec records test process termination for go test -exec.
testexec records test process termination for go test -exec.
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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL