gowt

package module
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: EPL-2.0 Imports: 22 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.

macOS Windows Linux
Table tab, macOS Table tab, Windows Table tab, Linux

The pictures above are the regression references of SWT's ControlExample (Table tab) taken by make snap-update on each OS (the Windows one under Wine, the Linux one in Docker with Xvfb). They show the translated SWT layer, not a program written with the gowt facade.

Install

go get github.com/haiodo/gowt@latest

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

Hello

package main

import "github.com/haiodo/gowt"

func main() {
	gowt.Run(func(app *gowt.App) {
		w := app.Window("Hello",
			gowt.Label("Hello, gowt"),
			gowt.Button("Quit", gowt.OnClick(app.Quit)))
		w.Show()
	})
}

Run returns an error; examples/hello is the same program with the check.

Documentation

Start at docs/index.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
Theme and platform look theme-look theme
Icons icons icons
Web view webview-browser webview

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

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

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 3492 30 (+2 flaky) 26
Windows (Wine, not real Windows) 3275 232 (209 Browser tests: no WebView2 Runtime in the CrossOver bottle; 23 others) 43
Linux (Docker, Xvfb) 3497 33 20

JFace tests: 86 pass on macOS and Windows, 85 on Linux. 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); import _ "github.com/haiodo/gowt/winmanifest" for visual styles and DPI awareness
Linux GTK 3 and an X11 or XWayland display; WebKitGTK 4.1 for webview

Known gaps

  • Windows was never run on real Windows, only under Wine (CrossOver). Mica, Acrylic and WebView2 are unverified; per-monitor DPI changes while running are not handled.
  • 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 any OS; 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.

License: EPL-2.0, see LICENSE and NOTICE.

Documentation

Overview

Package gowt is an idiomatic Go facade over the generated swt package: no Java-shaped overloads, listeners are plain funcs, errors come back from Run. Unwrap on any widget returns the underlying swt object for the full API.

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 Spacing = defaultSpacing()

Spacing is the application-wide scale: 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 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 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())

After runs f on the UI thread once, after d.

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) 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) 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 system is in dark mode (macOS appearance, Windows apps theme, Linux xdg-desktop-portal color-scheme). Run keeps the app following it; 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) LoadImage

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

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

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

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

ButtonView is a push, check or radio button.

func (*ButtonView) Checked

func (b *ButtonView) Checked() bool

Checked reports the state of a Check or Radio button.

func (*ButtonView) Dispose

func (w *ButtonView) Dispose()

Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.

func (*ButtonView) Enabled

func (w *ButtonView) Enabled() bool

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

func (*ButtonView) Focus

func (w *ButtonView) Focus() bool

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

func (*ButtonView) OnClick

func (b *ButtonView) OnClick(f func())

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

func (*ButtonView) OnDispose

func (w *ButtonView) OnDispose(f func())

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

func (*ButtonView) SetBackground

func (w *ButtonView) SetBackground(c Paint)

SetBackground sets the background colour of the control; an Adaptive one follows the system theme, nil restores the default. On a container (Window, VBox and the other boxes, Group, Pages, Section, Scroll, Split) the children without a background of their own, such as labels and nested boxes, show it too; text fields, lists, tables and buttons keep theirs. Background() does the same at creation.

func (*ButtonView) SetChecked

func (b *ButtonView) SetChecked(v bool)

SetChecked sets the state of a Check or Radio button.

func (*ButtonView) SetEnabled

func (w *ButtonView) SetEnabled(v bool)

SetEnabled enables or disables the control, a Window or container included (its children follow). A disabled control ignores input and is drawn dimmed; Disabled() does the same at creation.

func (*ButtonView) SetFont

func (w *ButtonView) SetFont(f Font)

SetFont gives the control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control); a zero Size with a Scale is the system font size times Scale. Controls given equal fonts share one native font, released after the last of them is disposed or given another font. Typeface() does the same at creation. Lays the parents out when the size changes.

func (*ButtonView) SetForeground

func (w *ButtonView) SetForeground(c Paint)

SetForeground sets the text colour of the control; an Adaptive one and SecondaryText follow the system theme, nil restores the default. Foreground() does the same at creation.

func (*ButtonView) SetHeight

func (w *ButtonView) SetHeight(h int)

SetHeight changes the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural height and removes a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetFont. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form, like Size.

func (*ButtonView) SetImage

func (b *ButtonView) SetImage(img *Image)

SetImage sets the icon; the button does not own img. Lays the parents out when the size changes.

func (*ButtonView) SetMaxHeight

func (w *ButtonView) SetMaxHeight(h int)

SetMaxHeight keeps the natural height of the control, as it follows its content (the rows of a Tree or Table, the lines of a Label), at most h points, border included; at h it stops growing and scrolls when it can. 0 removes the limit. A Tree or Table follows its rows, nodes expanded and collapsed included; another widget is measured after SetText, SetFont and the other setters that lay out. SetHeight and SetSize replace the limit. It needs a parent laid out by a VBox, HBox, Grid, Flow or Form.

func (*ButtonView) SetSize

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

SetSize changes the width and the height the layout gives the control, in points, as Size did at creation; 0 goes back to the natural value. It replaces a MaxHeight. The parents are laid out on the next event-loop turn or at App.Flush, as after SetHeight.

func (*ButtonView) SetText

func (b *ButtonView) SetText(s string)

SetText replaces the button text. Lays the parents out when the size changes.

func (*ButtonView) SetTooltip

func (w *ButtonView) SetTooltip(s string)

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

func (*ButtonView) SetVisible

func (w *ButtonView) SetVisible(v bool)

SetVisible shows or hides the control. In a Grid or Row layout a hidden control also gives up its cell, and the parent is laid out again so the neighbours take the space; SetVisible(true) clears that exclusion. Other layouts keep the gap.

func (*ButtonView) Unwrap

func (b *ButtonView) Unwrap() *swt.Button

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

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

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

func BindEnabled

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 Button without its frame (macOS: no bezel, GTK: "flat"); Windows keeps it.

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 or Radio for other kinds); OnClick gives it an action. Options: Check, Radio, OnClick, OnChange and Checked (Check, Radio), Bind (bool), BindText.

Example

A check box and a push button pushed to the right end of their row.

package main

import (
	"fmt"

	"github.com/haiodo/gowt"
	"github.com/haiodo/gowt/rx"
)

func main() {
	_ = gowt.Run(func(app *gowt.App) {
		remember := rx.New(true)
		w := app.Window("Buttons",
			gowt.HBox(gowt.GrowX(),
				gowt.Button("Remember me", gowt.Check(), gowt.Bind(remember)),
				gowt.Spacer(),
				gowt.Button("Sign in", gowt.OnClick(func() { fmt.Println("remember:", remember.Get()) }))))
		w.Show()
	})
}

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 or Radio 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 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 Disabled

func Disabled() Option

Disabled creates the widget disabled.

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 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 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 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 multi-line Text and y points above and below it, as SetInset does.

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 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 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, wrapped, with a vertical scroll bar.

func NoBorder

func NoBorder() Option

NoBorder removes the frame that List, Table and Tree have by default.

func Nodes

func Nodes[T, K comparable](list rx.Reader[[]T], key func(T) K, children func(T) []T, fill func(n *Node, item T, created bool)) Option

Nodes shows one root node of a Tree per element of list and below each node one child per element of children(item), nil for a flat tree. It is Rows for a tree, level by level: siblings are matched by key, a surviving node keeps its expansion and selection, and a node whose key moved among its siblings is made again with its subtree and keeps the expansion and selection of every node in it. fill runs after the children of the node exist; created is true when the node is made, also again after a move, and false when its element changed: set the initial expansion when created.

func OnActivate

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

func OnClick

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 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 (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 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 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 Selected

func Selected(i int) Option

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

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

func StyledText

func StyledText(opts ...Option) Option

StyledText creates a multi-line styled editor. Options: Scrollbars, Wrap, ReadOnly, Border, Value, OnChange.

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 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, Hint, Value, OnChange, OnActivate, Bind (string).

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

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

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, 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) 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) 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. Options: Right, Center.

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

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.

func (*TreeView) Deselect

func (t *TreeView) Deselect()

Deselect clears the selection and calls no OnSelect, as SWT's deselectAll sends no Selection.

func (*TreeView) Dispose

func (w *TreeView) Dispose()

Dispose removes the control and its children from the window and lays the parent out again, so the neighbours take the space. The widget must not be used afterwards; a second Dispose does nothing.

func (*TreeView) Enabled

func (w *TreeView) Enabled() bool

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

func (*TreeView) 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 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.

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) 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
The WebBrowser behind SWT's Browser: package webview is the engine, standing in for SWT's own WebKit/Edge/WebKitGTK classes (manual.txt, port.sh).
The WebBrowser behind SWT's Browser: package webview is the engine, standing in for SWT's own WebKit/Edge/WebKitGTK classes (manual.txt, port.sh).
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.
finderdemo command
Command finderdemo shows the macOS 26 Finder and System Settings look: a floating Liquid Glass sidebar (look.SetSidebar), an edge-to-edge glass inspector on the right (look.SetInspector), a toolbar with an item over the sidebar, a back/forward capsule, a button, a search field and the inspector toggle (look.SetToolbar) and grouped sections (gowt.Section).
Command finderdemo shows the macOS 26 Finder and System Settings look: a floating Liquid Glass sidebar (look.SetSidebar), an edge-to-edge glass inspector on the right (look.SetInspector), a toolbar with an item over the sidebar, a back/forward capsule, a button, a search field and the inspector toggle (look.SetToolbar) and grouped sections (gowt.Section).
form command
Command form: a two-column Grid form (Name/Email + OK) with a File > Quit menu bar.
Command form: a two-column Grid form (Name/Email + OK) with a File > Quit menu bar.
glassdemo command
Command glassdemo shows the macOS 26 look options: window backdrop, glass panel, glass buttons, full-size content.
Command glassdemo shows the macOS 26 look options: window backdrop, glass panel, glass buttons, full-size content.
gowtdemo command
Command gowtdemo shows the gowt facade widgets, one tab per widget family.
Command gowtdemo shows the gowt facade widgets, one tab per widget family.
hello command
Command hello opens a Shell with one push button: the Display+Shell+Button path end to end.
Command hello opens a Shell with one push button: the Display+Shell+Button path end to end.
hellogowt command
Command hellogowt is the smallest gowt program: a window with a field, a button and a label.
Command hellogowt is the smallest gowt program: a window with a field, a button and a label.
icondemo command
Command icondemo shows every dictionary icon as a button and rebuilds them when the system theme changes.
Command icondemo shows every dictionary icon as a button and rebuilds them when the system theme changes.
images command
Command images loads 3 of the ControlExample test images through getResourceAsStream -> ImageData(InputStream) -> Image(Display, ImageData), and draws them on a Canvas with gc.DrawImage.
Command images loads 3 of the ControlExample test images through getResourceAsStream -> ImageData(InputStream) -> Image(Display, ImageData), and draws them on a Canvas with gc.DrawImage.
jfacedemo command
Command jfacedemo builds a form from JFace's fluent widget factories and layout factories only: labels, texts and a group, a table under a TableColumnLayout, and a row of buttons.
Command jfacedemo builds a form from JFace's fluent widget factories and layout factories only: labels, texts and a group, a table under a TableColumnLayout, and a row of buttons.
minibrowser command
Command minibrowser is a small tabbed browser: a SashForm with the list of open pages on the left and one WebView per page, stacked, on the right.
Command minibrowser is a small tabbed browser: a SashForm with the list of open pages on the left and one WebView per page, stacked, on the right.
paint command
Command paint draws on a Canvas from a paint callback: the drawRect: -> paint event -> GC path.
Command paint draws on a Canvas from a paint callback: the drawRect: -> paint event -> GC path.
snapcheck command
Command snapcheck compares the PNGs written by `controlexample -snap` with the committed references (tests/snapshots).
Command snapcheck compares the PNGs written by `controlexample -snap` with the committed references (tests/snapshots).
stack command
Command stack: a Split divides left (buttons) from right (Pages of Groups); clicking a button switches the visible panel.
Command stack: a Split divides left (buttons) from right (Pages of Groups); clicking a button switches the visible panel.
swttest command
Command swttest runs the translated SWT JUnit tests (tests/swttests) on the main thread with one Display, the way SWT's tests expect: a panic fails its test, not the run; a hung test ends the run with its name.
Command swttest runs the translated SWT JUnit tests (tests/swttests) on the main thread with one Display, the way SWT's tests expect: a panic fails its test, not the run; a hung test ends the run with its name.
themecheck command
Command themecheck shows the system theme and logs every change: switch light/dark in system settings while it runs and the label and stdout must follow (Linux: GOWT_THEMECHECK_SECS=n exits after n seconds).
Command themecheck shows the system theme and logs every change: switch light/dark in system settings while it runs and the label and stdout must follow (Linux: GOWT_THEMECHECK_SECS=n exits after n seconds).
tree command
Command tree shows a Tree (NSOutlineView) with three root items and their children.
Command tree shows a Tree (NSOutlineView) with three root items and their children.
webviewdemo command
Command webviewdemo shows a Tree beside a system web view: the pages come from an embed.FS over the app:// scheme, a button evaluates JS in the page, and page messages land in a Label.
Command webviewdemo shows a Tree beside a system web view: the pages come from an embed.FS over the app:// scheme, a button evaluates JS in the page, and page messages land in a Label.
widgets2 command
Command widgets2 shows a Tabs holding a Combo pair, a Table, and a Scroll.
Command widgets2 shows a Tabs holding a Combo pair, a Table, and a Scroll.
winprobe command
examples
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.
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.
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.
internal
cocoa
ObjC blocks over purego: a block literal is {isa, flags, reserved, invoke, descriptor}.
ObjC blocks over purego: a block literal is {isa, flags, reserved, invoke, descriptor}.
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.
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 look sets the platform look of a gowt app: the window material, macOS 26 Liquid Glass, Windows 11 corners and dark content.
Package look sets the platform look of a gowt app: the window material, macOS 26 Liquid Glass, Windows 11 corners and dark content.
Package 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
The PNG/GIF/BMP/JPEG codec backend is not translated from SWT's org.eclipse.swt.internal.image (FileFormat + PNGFileFormat/GIFFileFormat/WinBMPFileFormat/OS2BMPFileFormat/LZW*/Png*/LEData*): it is a hand-written wrapper over Go's stdlib image codecs plus golang.org/x/image/bmp instead.
The PNG/GIF/BMP/JPEG codec backend is not translated from SWT's org.eclipse.swt.internal.image (FileFormat + PNGFileFormat/GIFFileFormat/WinBMPFileFormat/OS2BMPFileFormat/LZW*/Png*/LEData*): it is a hand-written wrapper over Go's stdlib image codecs plus golang.org/x/image/bmp instead.
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.
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 one RT_MANIFEST resource (ID 1), for go build to link into a Windows executable: mksyso -arch amd64|arm64 -manifest app.manifest -o out.syso.
Command mksyso writes a COFF object with one RT_MANIFEST resource (ID 1), for go build to link into a Windows executable: mksyso -arch amd64|arm64 -manifest app.manifest -o out.syso.
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, 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, 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