gowt

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: EPL-2.0 Imports: 13 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")
		w.SetLayout(gowt.Row{Vertical: true, Margin: 12, Spacing: 8})
		w.Label("Hello, gowt")
		w.Button("Quit", 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 and Browser webview-browser webview, browser
Using swt directly swt-direct swtdirect

What you get

  • Widgets: labels, buttons, text, combo, list, table, tree, tabs, split, scroll, tool bar, menus, date picker, sliders, canvas, dialogs, tray icon.
  • Layouts: Grid, Row, Fill, Form, Stack.
  • 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

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled(w Widget) bool

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

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. SWT exceptions raised on the UI thread (panics carrying an error, e.g. *swt.SWTException) are returned; runtime errors and other panics propagate.

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

func main() {
	err := gowt.Run(func(app *gowt.App) {
		w := app.Window("Hello gowt")
		w.SetLayout(gowt.Grid{Columns: 2, Margin: 10, Spacing: 8})
		name := w.Text(gowt.Cell(gowt.GridCell{Align: gowt.AlignFill, GrowX: true, Width: 200}))
		greet := w.Label("", gowt.Cell(gowt.GridCell{SpanX: 2, Align: gowt.AlignFill, GrowX: true}))
		w.Button("Greet", func() { greet.SetText("Hello, " + name.Text() + "!") })
		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 SetEnabled

func SetEnabled(w Widget, v bool)

SetEnabled enables or disables any 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 SetFont

func SetFont(w Widget, f Font)

SetFont gives a control the font f. Empty Name and zero Size keep the control's current ones (the system font for a default control). The control owns the font and releases it when replaced by the next SetFont or when it is disposed.

func SetForeground

func SetForeground(w Widget, c RGB)

SetForeground sets the text color of a control.

func SetVisible

func SetVisible(w Widget, v bool)

SetVisible shows or hides a 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. A layout option applied to the control after SetVisible(false) (Cell, InRow) replaces its layout data and so undoes the exclusion.

func Visible

func Visible(w Widget) bool

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

Types

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.

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

func main() {
	_ = gowt.Run(func(app *gowt.App) {
		w := app.Window("Download")
		status := w.Label("working...")
		w.Show()
		go func() {
			time.Sleep(time.Second) // stands for slow work
			app.Async(func() { status.SetText("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) 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). The App owns it and disposes it when Run returns, like the other images it created.

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

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.

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; call Show once its content is built.

type Button

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

Button is a push, check or radio button.

func (*Button) Checked

func (b *Button) Checked() bool

Checked reports the state of a Check or Radio button.

func (*Button) OnClick

func (b *Button) OnClick(f func())

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

func (*Button) SetChecked

func (b *Button) SetChecked(v bool)

SetChecked sets the state of a Check or Radio button.

func (*Button) SetImage

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

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

func (*Button) SetText

func (b *Button) SetText(s string)

SetText replaces the button text.

func (*Button) Unwrap

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

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

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 CTabs

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

CTabs is the custom-drawn tab folder: closable tabs (Closable on the folder's Tab) and a flatter look.

func (*CTabs) Index

func (t *CTabs) Index() int

Index is the selected tab, -1 if none.

func (*CTabs) OnClose

func (t *CTabs) 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 (*CTabs) OnSelect

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

OnSelect runs f with the selected tab index.

func (*CTabs) Select

func (t *CTabs) Select(i int)

Select selects tab i.

func (*CTabs) Tab

func (t *CTabs) Tab(title string, opts ...Option) *Panel

Tab appends a tab and returns its page; Closable() adds a close button to the tab.

func (*CTabs) Unwrap

func (t *CTabs) Unwrap() *swt.CTabFolder

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

type Canvas

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

Canvas is a blank area drawn by the paint callback.

func (*Canvas) OnMouseDown

func (c *Canvas) OnMouseDown(f func(Mouse))

OnMouseDown runs f when a button is pressed.

func (*Canvas) OnMouseMove

func (c *Canvas) OnMouseMove(f func(Mouse))

OnMouseMove runs f when the pointer moves over the canvas.

func (*Canvas) OnMouseUp

func (c *Canvas) OnMouseUp(f func(Mouse))

OnMouseUp runs f when a button is released.

func (*Canvas) Redraw

func (c *Canvas) Redraw()

Redraw schedules a repaint, which calls the paint callback.

func (*Canvas) Size

func (c *Canvas) Size() (w, h int)

Size returns the drawable width and height.

func (*Canvas) Unwrap

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

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

type Clipboard

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

Clipboard is the system clipboard. App.Clipboard creates it; the App disposes it when Run returns, so there is nothing to dispose. UI thread only (from another goroutine use App.Sync).

Getters return ok=false when the clipboard holds no such format. Setters return an error when the system clipboard cannot be written, which is routine on Windows while another process has it open. Setting one format clears the others; use SetHTML for HTML with a plain-text fallback. Other formats (RTF, URL, custom) and the X11 selection clipboard are reachable through Unwrap.

func (*Clipboard) 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. The App owns it and disposes it when Run returns; Dispose may be called earlier.

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 table column.

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

func (*Column) Unwrap

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

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

type Combo

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

Combo is a drop-down (or Simple) list with an edit field; ReadOnly() makes it a pure chooser.

func (*Combo) Index

func (c *Combo) Index() int

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

func (*Combo) Items

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

Items returns the list entries.

func (*Combo) OnChange

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

OnChange runs f with the new text after every edit.

func (*Combo) OnSelect

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

OnSelect runs f with the chosen item index.

func (*Combo) Select

func (c *Combo) Select(i int)

Select selects item i.

func (*Combo) SetItems

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

SetItems replaces the list entries.

func (*Combo) SetText

func (c *Combo) SetText(s string)

SetText replaces the edit field content.

func (*Combo) Text

func (c *Combo) Text() string

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

func (*Combo) Unwrap

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

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

type CoolBar

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

CoolBar is a tool bar area whose bands the user can rearrange.

func (*CoolBar) Add

func (b *CoolBar) Add(w Widget)

Add makes w (a child of the cool bar) a draggable band of its natural size.

func (CoolBar) AsComposite

func (p CoolBar) 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 (CoolBar) Button

func (p CoolBar) Button(text string, onClick func(), opts ...Option) *Button

Button adds a push button (Check or Radio for other kinds). onClick may be nil.

func (CoolBar) CTabs

func (p CoolBar) CTabs(opts ...Option) *CTabs

CTabs adds a custom tab folder; Border() draws a frame.

func (CoolBar) Canvas

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

Canvas adds 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.

func (CoolBar) Combo

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

Combo adds a combo box with the given items.

func (CoolBar) CoolBar

func (p CoolBar) CoolBar(opts ...Option) *CoolBar

CoolBar adds a cool bar; create the band contents as its children, then Add them.

func (CoolBar) DateTime

func (p CoolBar) DateTime(opts ...Option) *DateTime

DateTime adds a date picker; DropDown() makes the date field a drop-down calendar.

func (CoolBar) Group

func (p CoolBar) Group(title string, opts ...Option) *Group

Group adds a titled container.

func (CoolBar) Label

func (p CoolBar) Label(text string, opts ...Option) *Label

Label adds a static text.

func (p CoolBar) Link(text string, onClick func(href string), opts ...Option) *Link

Link adds a link label; onClick gets the href of the clicked anchor (its text if there is no href). onClick may be nil.

func (CoolBar) List

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

List adds a list with the given items.

func (CoolBar) Panel

func (p CoolBar) Panel(opts ...Option) *Panel

Panel adds a nested container.

func (CoolBar) Progress

func (p CoolBar) Progress(max int, opts ...Option) *Progress

Progress adds a progress bar over [0, max].

func (CoolBar) Sash

func (p CoolBar) Sash(opts ...Option) *Sash

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

func (CoolBar) Scale

func (p CoolBar) Scale(min, max, value int, opts ...Option) *Scale

Scale adds a scale over [min, max] set to value.

func (CoolBar) Scroll

func (p CoolBar) Scroll(opts ...Option) *Scroll

Scroll adds a scrolled area; Border() draws a frame.

func (CoolBar) SetLayout

func (p CoolBar) SetLayout(l Layout) *Panel

SetLayout installs l and returns p.

func (CoolBar) ShowTop

func (p CoolBar) ShowTop(w Widget)

ShowTop makes w, a child of p, the visible one. p must have a Stack layout.

func (CoolBar) Slider

func (p CoolBar) Slider(min, max, value int, opts ...Option) *Slider

Slider adds a slider over [min, max] set to value.

func (CoolBar) Spinner

func (p CoolBar) Spinner(min, max, value int, opts ...Option) *Spinner

Spinner adds a spinner over [min, max] set to value.

func (CoolBar) Split

func (p CoolBar) Split(opts ...Option) *Split

Split adds a sash form: children side by side, or stacked with Vertical().

func (CoolBar) StyledText

func (p CoolBar) StyledText(opts ...Option) *StyledText

StyledText adds a multi-line styled editor; options: Scrollbars, Wrap, ReadOnly, Border.

func (CoolBar) Switch

func (p CoolBar) Switch(text string, onChange func(on bool), opts ...Option) *Switch

Switch adds an on/off toggle. It is a check box on every OS: SWT has no switch control, and NSSwitch on macOS or GtkSwitch on Linux would need a view that the toolkit does not create. onChange gets the new state and may be nil.

func (CoolBar) Table

func (p CoolBar) Table(opts ...Option) *Table

Table adds a table with a visible header and grid lines.

func (CoolBar) Tabs

func (p CoolBar) Tabs(opts ...Option) *Tabs

Tabs adds a tab folder; Bottom() moves the tabs below the pages.

func (CoolBar) Text

func (p CoolBar) Text(opts ...Option) *Text

Text adds an edit field.

func (CoolBar) ToolBar

func (p CoolBar) ToolBar(opts ...Option) *ToolBar

ToolBar adds a tool bar; Flat() and Wrap() change its look.

func (CoolBar) Tree

func (p CoolBar) Tree(opts ...Option) *Tree

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

func (*CoolBar) Unwrap

func (b *CoolBar) Unwrap() *swt.CoolBar

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

type DateTime

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

DateTime is a date field, a time field (AsTime) or a month calendar (AsCalendar).

func (*DateTime) OnChange

func (d *DateTime) OnChange(f func(t time.Time))

OnChange runs f with the new value.

func (*DateTime) SetValue

func (d *DateTime) SetValue(t time.Time)

SetValue shows t's time of day for AsTime, its date otherwise.

func (*DateTime) Unwrap

func (d *DateTime) Unwrap() *swt.DateTime

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

func (*DateTime) Value

func (d *DateTime) Value() time.Time

Value is the shown date, or the shown time of day on today's date for AsTime, in the local zone.

type 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) {
		w := app.Window("Drop")
		zone := w.Label("drop files here")
		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(w Widget, gap int) Edge

Beside attaches the side to the opposite side of w, gap points away: a left edge sits right of w.

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(w Widget, offset int) Edge

Same attaches the side to the same side of 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 Fill

type Fill struct{ Vertical bool }

Fill lays children out in one row or column of equal size.

type Font

type Font struct {
	Name         string
	Size         int
	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.

type Form

type Form struct{ Margin, Spacing int }

Form positions each child by attaching its edges (see Anchor), which lets children stretch or follow siblings.

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

func (g *GC) SetLineWidth(w int)

SetLineWidth sets the outline width in pixels.

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 Grid

type Grid struct {
	Columns    int
	EqualWidth bool
	Margin     int
	Spacing    int
}

Grid lays children out in Columns columns, left to right, top to bottom. Margin and Spacing are in points; zero means none (SWT's own defaults are 5 and 5).

Example

Grid places children in columns; GridCell tunes one child.

package main

import (
	"github.com/haiodo/gowt"
)

func main() {
	_ = gowt.Run(func(app *gowt.App) {
		w := app.Window("Form")
		w.SetLayout(gowt.Grid{Columns: 2, Margin: 10, Spacing: 6})
		w.Label("Name")
		w.Text(gowt.Cell(gowt.GridCell{Align: gowt.AlignFill, GrowX: true}))
		w.Label("Notes")
		w.Text(gowt.Multiline(), gowt.Cell(gowt.GridCell{Align: gowt.AlignFill, GrowX: true, GrowY: true, Height: 80}))
		w.Show()
	})
}

type GridCell

type GridCell struct {
	Align, VAlign Align
	GrowX, GrowY  bool
	SpanX, SpanY  int
	Width, Height int
}

GridCell places one child inside a Grid. Zero value: natural size, top left, one cell. Align zero is AlignStart.

type Group

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

Group is a container with a titled frame.

func (Group) AsComposite

func (p Group) 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 (Group) Button

func (p Group) Button(text string, onClick func(), opts ...Option) *Button

Button adds a push button (Check or Radio for other kinds). onClick may be nil.

func (Group) CTabs

func (p Group) CTabs(opts ...Option) *CTabs

CTabs adds a custom tab folder; Border() draws a frame.

func (Group) Canvas

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

Canvas adds 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.

func (Group) Combo

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

Combo adds a combo box with the given items.

func (Group) CoolBar

func (p Group) CoolBar(opts ...Option) *CoolBar

CoolBar adds a cool bar; create the band contents as its children, then Add them.

func (Group) DateTime

func (p Group) DateTime(opts ...Option) *DateTime

DateTime adds a date picker; DropDown() makes the date field a drop-down calendar.

func (Group) Group

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

Group adds a titled container.

func (Group) Label

func (p Group) Label(text string, opts ...Option) *Label

Label adds a static text.

func (p Group) Link(text string, onClick func(href string), opts ...Option) *Link

Link adds a link label; onClick gets the href of the clicked anchor (its text if there is no href). onClick may be nil.

func (Group) List

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

List adds a list with the given items.

func (Group) Panel

func (p Group) Panel(opts ...Option) *Panel

Panel adds a nested container.

func (Group) Progress

func (p Group) Progress(max int, opts ...Option) *Progress

Progress adds a progress bar over [0, max].

func (Group) Sash

func (p Group) Sash(opts ...Option) *Sash

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

func (Group) Scale

func (p Group) Scale(min, max, value int, opts ...Option) *Scale

Scale adds a scale over [min, max] set to value.

func (Group) Scroll

func (p Group) Scroll(opts ...Option) *Scroll

Scroll adds a scrolled area; Border() draws a frame.

func (Group) SetLayout

func (p Group) SetLayout(l Layout) *Panel

SetLayout installs l and returns p.

func (*Group) SetTitle

func (g *Group) SetTitle(s string)

SetTitle replaces the frame title.

func (Group) ShowTop

func (p Group) ShowTop(w Widget)

ShowTop makes w, a child of p, the visible one. p must have a Stack layout.

func (Group) Slider

func (p Group) Slider(min, max, value int, opts ...Option) *Slider

Slider adds a slider over [min, max] set to value.

func (Group) Spinner

func (p Group) Spinner(min, max, value int, opts ...Option) *Spinner

Spinner adds a spinner over [min, max] set to value.

func (Group) Split

func (p Group) Split(opts ...Option) *Split

Split adds a sash form: children side by side, or stacked with Vertical().

func (Group) StyledText

func (p Group) StyledText(opts ...Option) *StyledText

StyledText adds a multi-line styled editor; options: Scrollbars, Wrap, ReadOnly, Border.

func (Group) Switch

func (p Group) Switch(text string, onChange func(on bool), opts ...Option) *Switch

Switch adds an on/off toggle. It is a check box on every OS: SWT has no switch control, and NSSwitch on macOS or GtkSwitch on Linux would need a view that the toolkit does not create. onChange gets the new state and may be nil.

func (Group) Table

func (p Group) Table(opts ...Option) *Table

Table adds a table with a visible header and grid lines.

func (Group) Tabs

func (p Group) Tabs(opts ...Option) *Tabs

Tabs adds a tab folder; Bottom() moves the tabs below the pages.

func (Group) Text

func (p Group) Text(opts ...Option) *Text

Text adds an edit field.

func (Group) ToolBar

func (p Group) ToolBar(opts ...Option) *ToolBar

ToolBar adds a tool bar; Flat() and Wrap() change its look.

func (Group) Tree

func (p Group) Tree(opts ...Option) *Tree

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

func (*Group) Unwrap

func (g *Group) 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 caller owns it: Dispose when done. Widgets that show an image (SetImage) do not take ownership and do not copy it, so keep it alive while shown. Images still alive when Run returns are disposed with the App.

func (*Image) Dispose

func (i *Image) Dispose()

Dispose releases the image; 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 Label

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

Label is a static text.

func (*Label) SetImage

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

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

func (*Label) SetText

func (l *Label) SetText(s string)

SetText replaces the label text.

func (*Label) Unwrap

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

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

type Layout

type Layout interface {
	// contains filtered or unexported methods
}

Layout arranges the children of a Panel or Window.

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

Link is a label with clickable parts: text uses <a href="...">anchor</a>.

func (*Link) OnClick

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

OnClick runs f with the clicked anchor's href.

func (*Link) SetText

func (l *Link) SetText(s string)

SetText replaces the text; anchors use <a href="...">.

func (*Link) Unwrap

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

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

type List

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

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

func (*List) Add

func (l *List) Add(s string)

Add appends an entry.

func (*List) Clear

func (l *List) Clear()

Clear deletes all entries and with them the selection.

func (*List) Index

func (l *List) Index() int

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

func (*List) Items

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

Items returns the list entries.

func (*List) Len

func (l *List) Len() int

Len counts all entries, selected or not.

func (*List) OnActivate

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

OnActivate runs f on double click or Enter.

func (*List) OnSelect

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

OnSelect runs f with the first selected index.

func (*List) Remove

func (l *List) Remove(i int)

Remove deletes entry i.

func (*List) Selected

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

Selected returns all selected item indices.

func (*List) SetItem

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

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

func (*List) SetItems

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

SetItems replaces the list entries.

func (*List) SetSelection

func (l *List) SetSelection(i ...int)

SetSelection replaces the selection.

func (*List) Unwrap

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

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

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; text after "\t" is shown as the shortcut hint (it does not bind a key).

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.

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 struct {
	// contains filtered or unexported fields
}

Option adjusts a widget at construction: style bits are OR-ed before creation, apply runs after.

func Anchor

func Anchor(c FormCell) Option

Anchor sets the position of a child laid out by Form. Edges that refer to a sibling need that sibling to exist already.

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 Background

func Background(c RGB) Option

Background sets the background color of a widget.

func Border

func Border() Option

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

func Bottom

func Bottom() Option

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

func Cell

func Cell(c GridCell) Option

Cell sets the GridData of a widget laid out by Grid.

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 Closable

func Closable() Option

Closable adds a close button to a CTabs tab.

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

func Flat() Option

Flat gives a ToolBar the flat look.

func InRow

func InRow(c RowCell) Option

InRow sets the size of a child laid out by Row.

func Indeterminate

func Indeterminate() Option

Indeterminate animates a Progress without a value.

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 Password

func Password() Option

Password masks the characters typed into a Text.

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

Right right-aligns a table Column.

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 the clear button where the OS draws one).

func Simple

func Simple() Option

Simple makes a Combo show its list permanently.

func Smooth

func Smooth() Option

Smooth makes a Progress an unsegmented bar.

func Tooltip

func Tooltip(s string) Option

Tooltip sets the hover text.

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 lets a ToolBar wrap its items to further rows.

type Panel

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

Panel is a plain container; Window, Group, Split and CoolBar embed its methods.

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

func (p Panel) Button(text string, onClick func(), opts ...Option) *Button

Button adds a push button (Check or Radio for other kinds). onClick may be nil.

func (Panel) CTabs

func (p Panel) CTabs(opts ...Option) *CTabs

CTabs adds a custom tab folder; Border() draws a frame.

func (Panel) Canvas

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

Canvas adds 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.

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")
		w.Canvas(func(g *gowt.GC) {
			g.SetFill(gowt.RGB{R: 30, G: 120, B: 220})
			g.FillOval(10, 10, 100, 60)
		}, gowt.Cell(gowt.GridCell{Width: 200, Height: 100}))
		w.Show()
	})
}

func (Panel) Combo

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

Combo adds a combo box with the given items.

func (Panel) CoolBar

func (p Panel) CoolBar(opts ...Option) *CoolBar

CoolBar adds a cool bar; create the band contents as its children, then Add them.

func (Panel) DateTime

func (p Panel) DateTime(opts ...Option) *DateTime

DateTime adds a date picker; DropDown() makes the date field a drop-down calendar.

func (Panel) Group

func (p Panel) Group(title string, opts ...Option) *Group

Group adds a titled container.

func (Panel) Label

func (p Panel) Label(text string, opts ...Option) *Label

Label adds a static text.

func (p Panel) Link(text string, onClick func(href string), opts ...Option) *Link

Link adds a link label; onClick gets the href of the clicked anchor (its text if there is no href). onClick may be nil.

func (Panel) List

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

List adds a list with the given items.

func (Panel) Panel

func (p Panel) Panel(opts ...Option) *Panel

Panel adds a nested container.

func (Panel) Progress

func (p Panel) Progress(max int, opts ...Option) *Progress

Progress adds a progress bar over [0, max].

func (Panel) Sash

func (p Panel) Sash(opts ...Option) *Sash

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

func (Panel) Scale

func (p Panel) Scale(min, max, value int, opts ...Option) *Scale

Scale adds a scale over [min, max] set to value.

func (Panel) Scroll

func (p Panel) Scroll(opts ...Option) *Scroll

Scroll adds a scrolled area; Border() draws a frame.

func (Panel) SetLayout

func (p Panel) SetLayout(l Layout) *Panel

SetLayout installs l and returns p.

func (Panel) ShowTop

func (p Panel) ShowTop(w Widget)

ShowTop makes w, a child of p, the visible one. p must have a Stack layout.

func (Panel) Slider

func (p Panel) Slider(min, max, value int, opts ...Option) *Slider

Slider adds a slider over [min, max] set to value.

func (Panel) Spinner

func (p Panel) Spinner(min, max, value int, opts ...Option) *Spinner

Spinner adds a spinner over [min, max] set to value.

func (Panel) Split

func (p Panel) Split(opts ...Option) *Split

Split adds a sash form: children side by side, or stacked with Vertical().

func (Panel) StyledText

func (p Panel) StyledText(opts ...Option) *StyledText

StyledText adds a multi-line styled editor; options: Scrollbars, Wrap, ReadOnly, Border.

func (Panel) Switch

func (p Panel) Switch(text string, onChange func(on bool), opts ...Option) *Switch

Switch adds an on/off toggle. It is a check box on every OS: SWT has no switch control, and NSSwitch on macOS or GtkSwitch on Linux would need a view that the toolkit does not create. onChange gets the new state and may be nil.

func (Panel) Table

func (p Panel) Table(opts ...Option) *Table

Table adds a table with a visible header and grid lines.

func (Panel) Tabs

func (p Panel) Tabs(opts ...Option) *Tabs

Tabs adds a tab folder; Bottom() moves the tabs below the pages.

func (Panel) Text

func (p Panel) Text(opts ...Option) *Text

Text adds an edit field.

func (Panel) ToolBar

func (p Panel) ToolBar(opts ...Option) *ToolBar

ToolBar adds a tool bar; Flat() and Wrap() change its look.

func (Panel) Tree

func (p Panel) Tree(opts ...Option) *Tree

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

func (Panel) Unwrap

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

Unwrap returns the underlying composite.

type Progress

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

Progress is a progress bar; Vertical() rotates it, Indeterminate() animates it without a value.

func (*Progress) SetMax

func (p *Progress) SetMax(v int)

SetMax sets the upper bound.

func (*Progress) SetValue

func (p *Progress) SetValue(v int)

SetValue sets the progress to v, within [0, max].

func (*Progress) Unwrap

func (p *Progress) Unwrap() *swt.ProgressBar

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

func (*Progress) Value

func (p *Progress) Value() int

Value returns the progress within [0, max].

type RGB

type RGB struct{ R, G, B uint8 }

RGB is a color, 0-255 per channel.

type Row

type Row struct {
	Vertical, Wrap, Fill, Center bool
	Margin, Spacing              int
}

Row lays children out in a row (or column with Vertical) at their natural size, wrapping if Wrap is set. Fill stretches every child to the row's full height (width for Vertical), Center centers them.

type RowCell

type RowCell struct{ Width, Height int }

RowCell sets the size of one child of a Row; zero means natural size.

type Sash

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

Sash 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 (*Sash) OnMove

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

OnMove runs f with the position the user dragged the sash to, in parent coordinates.

func (*Sash) Unwrap

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

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

type Scale

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

Scale is a slider with tick marks; Vertical() rotates it.

func (*Scale) OnChange

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

OnChange runs f with the new value.

func (*Scale) SetValue

func (s *Scale) SetValue(v int)

SetValue moves the scale to v.

func (*Scale) Unwrap

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

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

func (*Scale) Value

func (s *Scale) Value() int

Value returns the position within [min, max].

type Scroll

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

Scroll shows content larger than itself with scroll bars. Build the content in Content, then call Fit.

func (*Scroll) Content

func (s *Scroll) Content() *Panel

Content is the container that scrolls.

func (*Scroll) Fit

func (s *Scroll) Fit()

Fit sets the scrollable size to the content's natural size; call it after the content is built.

func (*Scroll) Unwrap

func (s *Scroll) Unwrap() *swt.ScrolledComposite

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

type Slider

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

Slider is a scroll-bar style control; Vertical() rotates it.

func (*Slider) OnChange

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

OnChange runs f with the new value.

func (*Slider) SetValue

func (s *Slider) SetValue(v int)

SetValue moves the slider to v.

func (*Slider) Unwrap

func (s *Slider) Unwrap() *swt.Slider

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

func (*Slider) Value

func (s *Slider) Value() int

Value returns the position within [min, max].

type SortDir

type SortDir int

SortDir is the sort indicator drawn in a column header. It only draws the arrow: sorting the rows is up to the app.

const (
	SortNone SortDir = iota
	SortAscending
	SortDescending
)

The sort indicator values.

type Spinner

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

Spinner is an integer edit field with arrows.

func (*Spinner) OnChange

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

OnChange runs f with the new value after the arrows or typing changed it.

func (*Spinner) SetValue

func (s *Spinner) SetValue(v int)

SetValue sets the number to v.

func (*Spinner) Unwrap

func (s *Spinner) Unwrap() *swt.Spinner

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

func (*Spinner) Value

func (s *Spinner) Value() int

Value returns the number within [min, max].

type Split

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

Split divides its children with draggable sashes; the children are ordinary Panel children.

func (Split) AsComposite

func (p Split) 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 (Split) Button

func (p Split) Button(text string, onClick func(), opts ...Option) *Button

Button adds a push button (Check or Radio for other kinds). onClick may be nil.

func (Split) CTabs

func (p Split) CTabs(opts ...Option) *CTabs

CTabs adds a custom tab folder; Border() draws a frame.

func (Split) Canvas

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

Canvas adds 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.

func (Split) Combo

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

Combo adds a combo box with the given items.

func (Split) CoolBar

func (p Split) CoolBar(opts ...Option) *CoolBar

CoolBar adds a cool bar; create the band contents as its children, then Add them.

func (Split) DateTime

func (p Split) DateTime(opts ...Option) *DateTime

DateTime adds a date picker; DropDown() makes the date field a drop-down calendar.

func (Split) Group

func (p Split) Group(title string, opts ...Option) *Group

Group adds a titled container.

func (Split) Label

func (p Split) Label(text string, opts ...Option) *Label

Label adds a static text.

func (p Split) Link(text string, onClick func(href string), opts ...Option) *Link

Link adds a link label; onClick gets the href of the clicked anchor (its text if there is no href). onClick may be nil.

func (Split) List

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

List adds a list with the given items.

func (Split) Panel

func (p Split) Panel(opts ...Option) *Panel

Panel adds a nested container.

func (Split) Progress

func (p Split) Progress(max int, opts ...Option) *Progress

Progress adds a progress bar over [0, max].

func (Split) Sash

func (p Split) Sash(opts ...Option) *Sash

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

func (Split) Scale

func (p Split) Scale(min, max, value int, opts ...Option) *Scale

Scale adds a scale over [min, max] set to value.

func (Split) Scroll

func (p Split) Scroll(opts ...Option) *Scroll

Scroll adds a scrolled area; Border() draws a frame.

func (Split) SetLayout

func (p Split) SetLayout(l Layout) *Panel

SetLayout installs l and returns p.

func (*Split) SetWeights

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

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

func (Split) ShowTop

func (p Split) ShowTop(w Widget)

ShowTop makes w, a child of p, the visible one. p must have a Stack layout.

func (Split) Slider

func (p Split) Slider(min, max, value int, opts ...Option) *Slider

Slider adds a slider over [min, max] set to value.

func (Split) Spinner

func (p Split) Spinner(min, max, value int, opts ...Option) *Spinner

Spinner adds a spinner over [min, max] set to value.

func (Split) Split

func (p Split) Split(opts ...Option) *Split

Split adds a sash form: children side by side, or stacked with Vertical().

func (Split) StyledText

func (p Split) StyledText(opts ...Option) *StyledText

StyledText adds a multi-line styled editor; options: Scrollbars, Wrap, ReadOnly, Border.

func (Split) Switch

func (p Split) Switch(text string, onChange func(on bool), opts ...Option) *Switch

Switch adds an on/off toggle. It is a check box on every OS: SWT has no switch control, and NSSwitch on macOS or GtkSwitch on Linux would need a view that the toolkit does not create. onChange gets the new state and may be nil.

func (Split) Table

func (p Split) Table(opts ...Option) *Table

Table adds a table with a visible header and grid lines.

func (Split) Tabs

func (p Split) Tabs(opts ...Option) *Tabs

Tabs adds a tab folder; Bottom() moves the tabs below the pages.

func (Split) Text

func (p Split) Text(opts ...Option) *Text

Text adds an edit field.

func (Split) ToolBar

func (p Split) ToolBar(opts ...Option) *ToolBar

ToolBar adds a tool bar; Flat() and Wrap() change its look.

func (Split) Tree

func (p Split) Tree(opts ...Option) *Tree

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

func (*Split) Unwrap

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

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

type Stack

type Stack struct{ Margin int }

Stack shows one child at a time, all at the full size of the container; choose it with Panel.ShowTop.

type StyleSpan

type StyleSpan struct {
	Start, Length int
	Style         TextStyle
}

StyleSpan is a TextStyle applied to Length runes from Start.

type StyledText

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

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

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")
		ed := w.StyledText(gowt.Scrollbars())
		ed.SetText("bold word")
		ed.SetStyle(0, 4, gowt.TextStyle{Bold: true})
		w.Show()
	})
}

func (*StyledText) Append

func (t *StyledText) Append(s string)

Append adds s at the end.

func (*StyledText) Caret

func (t *StyledText) Caret() int

Caret returns the caret position.

func (*StyledText) ClearStyles

func (t *StyledText) ClearStyles()

ClearStyles removes every style.

func (*StyledText) Copy

func (t *StyledText) Copy()

Copy copies the selection to the system clipboard.

func (*StyledText) Cut

func (t *StyledText) Cut()

Cut moves the selection to the system clipboard.

func (*StyledText) Insert

func (t *StyledText) Insert(s string)

Insert adds s at the caret.

func (*StyledText) LineAt

func (t *StyledText) LineAt(offset int) int

LineAt returns the line index that holds the rune offset.

func (*StyledText) LineStart

func (t *StyledText) LineStart(line int) int

LineStart returns the rune offset of the first character of line.

func (*StyledText) Lines

func (t *StyledText) Lines() int

Lines returns the number of lines.

func (*StyledText) OnCaret

func (t *StyledText) OnCaret(f func(offset int))

OnCaret runs f with the caret position after it moved.

func (*StyledText) OnChange

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

OnChange runs f with the new content after every edit.

func (*StyledText) OnSelect

func (t *StyledText) OnSelect(f func(start, length int))

OnSelect runs f with the selection after it changed.

func (*StyledText) OnStyle

func (t *StyledText) 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 (*StyledText) Paste

func (t *StyledText) Paste()

Paste inserts the system clipboard text at the caret.

func (*StyledText) Replace

func (t *StyledText) Replace(start, length int, s string)

Replace replaces length runes from start with s.

func (*StyledText) Reveal

func (t *StyledText) Reveal()

Reveal scrolls so that the selection is visible.

func (*StyledText) ScrollToEnd

func (t *StyledText) ScrollToEnd()

ScrollToEnd moves the caret to the end and scrolls it into view.

func (*StyledText) SelectedText

func (t *StyledText) SelectedText() string

SelectedText returns the selected text.

func (*StyledText) Selection

func (t *StyledText) Selection() (start, length int)

Selection returns the selected range; length is 0 when only the caret is set.

func (*StyledText) SetCaret

func (t *StyledText) SetCaret(offset int)

SetCaret moves the caret.

func (*StyledText) SetEditable

func (t *StyledText) SetEditable(on bool)

SetEditable allows or forbids typing.

func (*StyledText) SetLineBackground

func (t *StyledText) SetLineBackground(line, count int, c RGB)

SetLineBackground colors count lines from line.

func (*StyledText) SetSelection

func (t *StyledText) SetSelection(start, length int)

SetSelection selects length runes from start.

func (*StyledText) SetStyle

func (t *StyledText) SetStyle(start, length int, s TextStyle)

SetStyle applies s to length runes from start, replacing the styles there.

func (*StyledText) SetTabs

func (t *StyledText) SetTabs(n int)

SetTabs sets the tab width in spaces.

func (*StyledText) SetText

func (t *StyledText) SetText(s string)

SetText replaces the whole content.

func (*StyledText) SetTopLine

func (t *StyledText) SetTopLine(line int)

SetTopLine scrolls so that line is the first visible one.

func (*StyledText) SetWrap

func (t *StyledText) SetWrap(on bool)

SetWrap turns word wrapping on or off.

func (*StyledText) Styles

func (t *StyledText) Styles() []StyleSpan

Styles returns the styled ranges in order. Font is not reported.

func (*StyledText) Text

func (t *StyledText) Text() string

Text returns the whole content.

func (*StyledText) TrimHead

func (t *StyledText) 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 (*StyledText) Unwrap

func (t *StyledText) Unwrap() *swt.StyledText

Unwrap returns the underlying swt.StyledText for the full API (offsets there are UTF-16 units).

type Switch

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

Switch is an on/off toggle, see panel.Switch.

func (*Switch) Checked

func (s *Switch) Checked() bool

Checked reports whether the switch is on.

func (*Switch) OnChange

func (s *Switch) OnChange(f func(on bool))

OnChange runs f with the new state when the user toggles the switch.

func (*Switch) SetChecked

func (s *Switch) SetChecked(v bool)

SetChecked sets the state without calling OnChange.

func (*Switch) SetText

func (s *Switch) SetText(t string)

SetText replaces the label.

func (*Switch) Unwrap

func (s *Switch) Unwrap() *swt.Button

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

type Table

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

Table is a multi-column grid with a header; rows are added with Row. Check makes rows checkable.

Example

Table rows hold one text per column; SetData keeps an application value with a row.

package main

import (
	"fmt"

	"github.com/haiodo/gowt"
)

func main() {
	_ = gowt.Run(func(app *gowt.App) {
		w := app.Window("Files")
		t := w.Table()
		t.Column("Name", 200)
		t.Column("Size", 80, gowt.Right())
		t.Row("a.txt", "12").SetData("id-1")
		t.OnSelect(func(i int) { fmt.Println(t.RowAt(i).Data()) })
		w.Show()
	})
}

func (*Table) CellAt

func (t *Table) 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 (*Table) Clear

func (t *Table) Clear()

Clear deletes all rows and with them the selection.

func (*Table) Column

func (t *Table) Column(title string, width int, opts ...Option) *Column

Column appends a column; Right() or Center() set the alignment.

func (*Table) Index

func (t *Table) Index() int

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

func (*Table) Len

func (t *Table) Len() int

Len counts rows, not columns.

func (*Table) OnActivate

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

OnActivate runs f on double click or Enter.

func (*Table) OnCellClick

func (t *Table) 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 (*Table) OnSelect

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

OnSelect runs f with the first selected row.

func (*Table) Remove

func (t *Table) Remove(i int)

Remove deletes row i.

func (*Table) Row

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

Row appends a row with one text per column.

func (*Table) RowAt

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

RowAt returns row i.

func (*Table) Selected

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

Selected returns all selected row indices.

func (*Table) SetSelection

func (t *Table) SetSelection(i ...int)

SetSelection replaces the selection.

func (*Table) SetSort

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

SetSort draws the sort indicator dir in the header of col; col nil or SortNone clears it.

func (*Table) ShowHeader

func (t *Table) ShowHeader(v bool)

ShowHeader shows or hides the column headers.

func (*Table) ShowLines

func (t *Table) ShowLines(v bool)

ShowLines shows or hides the grid lines.

func (*Table) ShowRowLines

func (t *Table) 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 (*Table) Unwrap

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

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

type TableClick

type TableClick struct {
	Row, Col int // row index and column index of the cell under the pointer
	Button   int // SWT's numbering: 1 left, 2 middle, 3 right
	Count    int // 1 for a single press, 2 for the second press of a double click
	X, Y     int // pointer position in the table's coordinates
	Mods         // keys held down
}

TableClick is a mouse press on a Table. Row and Col are -1 when the point is not on a row.

type TableRow

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

TableRow is a table row. Rows are re-wrapped on every lookup: keep per-row state in SetData.

func (*TableRow) 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) SetImage

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

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

func (*TableRow) SetText

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

SetText sets the text of column col.

func (*TableRow) Text

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

Text 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 Tabs

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

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

func (*Tabs) Index

func (t *Tabs) Index() int

Index is the selected tab, -1 if none.

func (*Tabs) OnSelect

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

OnSelect runs f with the selected tab index.

func (*Tabs) Select

func (t *Tabs) Select(i int)

Select selects tab i.

func (*Tabs) Tab

func (t *Tabs) Tab(title string, opts ...Option) *Panel

Tab appends a tab and returns its page.

func (*Tabs) Unwrap

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

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

type Text

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

Text is an edit field.

func (*Text) Append

func (t *Text) Append(s string)

Append adds s at the end without rewriting the content.

func (*Text) Lines

func (t *Text) Lines() int

Lines returns the number of lines; a trailing newline starts an empty last line.

func (*Text) OnActivate

func (t *Text) OnActivate(f func())

OnActivate runs f when the user presses Enter in a single-line field.

func (*Text) OnChange

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

OnChange runs f with the new content after every edit.

func (*Text) ScrollToEnd

func (t *Text) ScrollToEnd()

ScrollToEnd moves the caret to the end and scrolls it into view.

func (*Text) SetHint

func (t *Text) SetHint(s string)

SetHint sets the placeholder shown while the field is empty.

func (*Text) SetText

func (t *Text) SetText(s string)

SetText replaces the content.

func (*Text) Text

func (t *Text) Text() string

Text returns the current content.

func (*Text) TrimHead

func (t *Text) 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 (*Text) Unwrap

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

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

type TextStyle

type TextStyle struct {
	Foreground, Background *RGB
	Bold, Italic           bool
	Underline, Strikeout   bool
	Font                   *Font // a typeface other than the widget's; the widget owns the native font
}

TextStyle is the look of a range of a StyledText. Nil colors inherit the widget's.

type ToolBar

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

ToolBar is a row of tool buttons.

func (*ToolBar) Item

func (t *ToolBar) Item(text string, onClick func(), opts ...Option) *ToolItem

Item appends a push button (Check, Radio or DropDown for other kinds). onClick may be nil.

func (*ToolBar) Separator

func (t *ToolBar) Separator()

Separator appends a divider.

func (*ToolBar) Unwrap

func (t *ToolBar) Unwrap() *swt.ToolBar

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

type ToolItem

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

ToolItem is a tool bar button.

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

func (*ToolItem) SetText

func (i *ToolItem) SetText(s string)

SetText replaces the item text.

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 Tree

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

Tree is a hierarchy of Nodes. Check makes nodes checkable, MultiSelect allows several selected.

func (*Tree) CellAt

func (t *Tree) 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 (*Tree) Clear

func (t *Tree) Clear()

Clear deletes all nodes, children included.

func (*Tree) Column

func (t *Tree) Column(title string, width int, opts ...Option) *TreeColumn

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.

func (*Tree) Node

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

Node appends a root node.

func (*Tree) OnActivate

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

OnActivate runs f on double click or Enter.

func (*Tree) OnCellClick

func (t *Tree) 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 (*Tree) OnCollapse

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

OnCollapse runs f with the node that was collapsed; see OnExpand.

func (*Tree) OnExpand

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

OnExpand and OnCollapse run f with the node that changed. The event carries the item as a bare *swt.Widget that cannot be downcast, so the node is found by walking the tree.

func (*Tree) OnSelect

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

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

func (*Tree) Roots

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

Roots returns the top-level nodes.

func (*Tree) Select

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

Select selects n alone.

func (*Tree) Selected

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

Selected returns the selected nodes.

func (*Tree) SetSort

func (t *Tree) SetSort(col *TreeColumn, dir SortDir)

SetSort draws the sort indicator dir in the header of col; col nil or SortNone clears it.

func (*Tree) ShowHeader

func (t *Tree) ShowHeader(v bool)

ShowHeader shows or hides the column headers.

func (*Tree) ShowRowLines

func (t *Tree) ShowRowLines(v bool)

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

func (*Tree) Unwrap

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

Unwrap returns the underlying swt.Tree 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 TreeColumn

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

TreeColumn is a tree column.

func (*TreeColumn) OnClick

func (c *TreeColumn) OnClick(f func())

OnClick runs f when the header is clicked, e.g. to sort.

func (*TreeColumn) Pack

func (c *TreeColumn) Pack()

Pack resizes the column to fit its content.

func (*TreeColumn) SetResizable

func (c *TreeColumn) SetResizable(v bool)

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

func (*TreeColumn) SetTitle

func (c *TreeColumn) SetTitle(s string)

SetTitle replaces the header text.

func (*TreeColumn) SetWidth

func (c *TreeColumn) SetWidth(w int)

SetWidth sets the width in pixels.

func (*TreeColumn) Unwrap

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

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

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 {
	// contains filtered or unexported methods
}

Widget is any gowt control. Layouts and containers take it where they refer to a sibling or a child.

type Window

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

Window is a top-level window.

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

func (p Window) Button(text string, onClick func(), opts ...Option) *Button

Button adds a push button (Check or Radio for other kinds). onClick may be nil.

func (Window) CTabs

func (p Window) CTabs(opts ...Option) *CTabs

CTabs adds a custom tab folder; Border() draws a frame.

func (Window) Canvas

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

Canvas adds 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.

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

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

Combo adds a combo box with the given items.

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.Button("Quit", func() {
			if w.Confirm("Quit", "Discard unsaved changes?") {
				w.Close()
			}
		})
		w.Show()
	})
}

func (Window) CoolBar

func (p Window) CoolBar(opts ...Option) *CoolBar

CoolBar adds a cool bar; create the band contents as its children, then Add them.

func (Window) DateTime

func (p Window) DateTime(opts ...Option) *DateTime

DateTime adds a date picker; DropDown() makes the date field a drop-down calendar.

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

func (p Window) Group(title string, opts ...Option) *Group

Group adds a titled container.

func (Window) Label

func (p Window) Label(text string, opts ...Option) *Label

Label adds a static text.

func (p Window) Link(text string, onClick func(href string), opts ...Option) *Link

Link adds a link label; onClick gets the href of the clicked anchor (its text if there is no href). onClick may be nil.

func (Window) List

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

List adds a list with the given items.

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

func (p Window) Panel(opts ...Option) *Panel

Panel adds a nested container.

func (Window) Progress

func (p Window) Progress(max int, opts ...Option) *Progress

Progress adds a progress bar over [0, max].

func (Window) Sash

func (p Window) Sash(opts ...Option) *Sash

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

func (Window) Scale

func (p Window) Scale(min, max, value int, opts ...Option) *Scale

Scale adds a scale over [min, max] set to value.

func (Window) Scroll

func (p Window) Scroll(opts ...Option) *Scroll

Scroll adds a scrolled area; Border() draws a frame.

func (*Window) SetLayout

func (w *Window) SetLayout(l Layout) *Panel

SetLayout installs l and returns the window as a Panel; a top inset set earlier is kept.

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 (Grid, Row and Form; other layouts ignore it), on top of the layout's own Margin. 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) and opens it.

func (Window) ShowTop

func (p Window) ShowTop(w Widget)

ShowTop makes w, a child of p, the visible one. p must have a Stack layout.

func (Window) Slider

func (p Window) Slider(min, max, value int, opts ...Option) *Slider

Slider adds a slider over [min, max] set to value.

func (Window) Spinner

func (p Window) Spinner(min, max, value int, opts ...Option) *Spinner

Spinner adds a spinner over [min, max] set to value.

func (Window) Split

func (p Window) Split(opts ...Option) *Split

Split adds a sash form: children side by side, or stacked with Vertical().

func (Window) StyledText

func (p Window) StyledText(opts ...Option) *StyledText

StyledText adds a multi-line styled editor; options: Scrollbars, Wrap, ReadOnly, Border.

func (Window) Switch

func (p Window) Switch(text string, onChange func(on bool), opts ...Option) *Switch

Switch adds an on/off toggle. It is a check box on every OS: SWT has no switch control, and NSSwitch on macOS or GtkSwitch on Linux would need a view that the toolkit does not create. onChange gets the new state and may be nil.

func (Window) Table

func (p Window) Table(opts ...Option) *Table

Table adds a table with a visible header and grid lines.

func (Window) Tabs

func (p Window) Tabs(opts ...Option) *Tabs

Tabs adds a tab folder; Bottom() moves the tabs below the pages.

func (Window) Text

func (p Window) Text(opts ...Option) *Text

Text adds an edit field.

func (Window) ToolBar

func (p Window) ToolBar(opts ...Option) *ToolBar

ToolBar adds a tool bar; Flat() and Wrap() change its look.

func (Window) Tree

func (p Window) Tree(opts ...Option) *Tree

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

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.
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 (a Stack of Groups); clicking a button switches the visible panel.
Command stack: a Split divides left (buttons) from right (a Stack 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
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 five layouts: Grid, Row, Fill, Form and Stack.
Command layouts shows the five layouts: Grid, Row, Fill, Form and Stack.
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 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