walk

package module
Version: v0.0.0-...-395de3d Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: BSD-3-Clause Imports: 29 Imported by: 0

README

About Walk
==========

Walk is a "Windows Application Library Kit" for the Go Programming Language.

Its primarily useful for Desktop GUI development, but there is some more stuff.

Setup
=====

Make sure you have a working Go installation.
See [Getting Started](http://golang.org/doc/install.html)

##### Note
Walk currently requires Go 1.11.x or later.

##### To Install
Now run `go get github.com/lxn/walk`

Using Walk
==========

The preferred way to create GUIs with Walk is to use its declarative sub package,
as illustrated in this small example:

##### `test.go`

```go
package main

import (
	"github.com/lxn/walk"
	. "github.com/lxn/walk/declarative"
	"strings"
)

func main() {
	var inTE, outTE *walk.TextEdit

	MainWindow{
		Title:   "SCREAMO",
		MinSize: Size{600, 400},
		Layout:  VBox{},
		Children: []Widget{
			HSplitter{
				Children: []Widget{
					TextEdit{AssignTo: &inTE},
					TextEdit{AssignTo: &outTE, ReadOnly: true},
				},
			},
			PushButton{
				Text: "SCREAM",
				OnClicked: func() {
					outTE.SetText(strings.ToUpper(inTE.Text()))
				},
			},
		},
	}.Run()
}
```

##### Create Manifest `test.manifest`

```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
        </dependentAssembly>
    </dependency>
    <application xmlns="urn:schemas-microsoft-com:asm.v3">
        <windowsSettings>
            <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
            <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>
        </windowsSettings>
    </application>
</assembly>
```

Then either compile the manifest using the [rsrc tool](https://github.com/akavel/rsrc), like this:

	go get github.com/akavel/rsrc
	rsrc -manifest test.manifest -o rsrc.syso

or rename the `test.manifest` file to `test.exe.manifest` and distribute it with the application instead.

##### Build app

In the directory containing `test.go` run

	go build
	
To get rid of the cmd window, instead run

	go build -ldflags="-H windowsgui"

##### Run app
	
	test.exe
	
##### Sample Output (Windows 7)

![alt tag](http://i.imgur.com/lUrgE2Q.png)

##### More Examples
There are some [examples](examples) that should get you started.

Application Manifest Files
==========================
Walk requires Common Controls 6. This means that you must put an appropriate
application manifest file either next to your executable or embedded as a
resource.

You can copy one of the application manifest files that come with the examples.

To embed a manifest file as a resource, you can use the [rsrc tool](https://github.com/akavel/rsrc).

IMPORTANT: If you don't embed a manifest as a resource, then you should not launch
your executable before the manifest file is in place.
If you do anyway, the program will not run properly. And worse, Windows will not
recognize a manifest file, you later drop next to the executable. To fix this,
rebuild your executable and only launch it with a manifest file in place.

CGo Optimizations
=================

The usual default message loop includes calls to win32 API functions, which incurs a decent amount
of runtime overhead coming from Go. As an alternative to this, you may compile Walk using an
optional C implementation of the main message loop, by passing the `walk_use_cgo` build tag:

   go build -tags walk_use_cgo

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	NoOrientation Orientation = 0
	Horizontal                = 1 << 0
	Vertical                  = 1 << 1
)
View Source
const (
	DlgCmdNone     = 0
	DlgCmdOK       = win.IDOK
	DlgCmdCancel   = win.IDCANCEL
	DlgCmdAbort    = win.IDABORT
	DlgCmdRetry    = win.IDRETRY
	DlgCmdIgnore   = win.IDIGNORE
	DlgCmdYes      = win.IDYES
	DlgCmdNo       = win.IDNO
	DlgCmdClose    = win.IDCLOSE
	DlgCmdHelp     = win.IDHELP
	DlgCmdTryAgain = win.IDTRYAGAIN
	DlgCmdContinue = win.IDCONTINUE
	DlgCmdTimeout  = win.IDTIMEOUT
)
View Source
const (
	EllipsisNone EllipsisMode = 0
	EllipsisEnd               = EllipsisMode(win.SS_ENDELLIPSIS)
	EllipsisPath              = EllipsisMode(win.SS_PATHELLIPSIS)
)

Variables

View Source
var (
	ErrPropertyReadOnly       = errors.New("read-only property")
	ErrPropertyNotValidatable = errors.New("property not validatable")
)
View Source
var (
	ErrInvalidType = errors.New("invalid type")
)

Functions

func AltDown

func AltDown() bool

func AppDataPath

func AppDataPath() (string, error)

func AppendToWalkInit

func AppendToWalkInit(fn func())

func CommonAppDataPath

func CommonAppDataPath() (string, error)

func ControlDown

func ControlDown() bool

func DriveNames

func DriveNames() ([]string, error)

func FormatFloat

func FormatFloat(f float64, prec int) string

func FormatFloatGrouped

func FormatFloatGrouped(f float64, prec int) string

func InitWidget

func InitWidget(widget Widget, parent Window, className string, style, exStyle uint32) error

InitWidget initializes a Widget.

func InitWindow

func InitWindow(window, parent Window, className string, style, exStyle uint32) error

InitWindow initializes a window.

Widgets should be initialized using InitWidget instead.

func InitWrapperWindow

func InitWrapperWindow(window Window) error

InitWrapperWindow initializes a window that wraps (embeds) another window.

Calling this method is necessary, if you want to be able to override the WndProc method of the embedded window. The embedded window should only be used as inseparable part of the wrapper window to avoid undefined behavior.

func IntFrom96DPI

func IntFrom96DPI(value, dpi int) int

IntFrom96DPI converts from 1/96" units to native pixels.

func IntTo96DPI

func IntTo96DPI(value, dpi int) int

IntTo96DPI converts from native pixels to 1/96" units.

func LocalAppDataPath

func LocalAppDataPath() (string, error)

func LogErrors

func LogErrors() bool

func MouseWheelEventDelta

func MouseWheelEventDelta(button MouseButton) int

func MouseWheelEventKeyState

func MouseWheelEventKeyState(button MouseButton) int

func MsgBox

func MsgBox(owner Form, title, message string, style MsgBoxStyle) int

func MustRegisterWindowClass

func MustRegisterWindowClass(className string)

MustRegisterWindowClass registers the specified window class.

MustRegisterWindowClass must be called once for every window type that is not based on any system provided control, before calling InitChildWidget or InitWidget. Calling MustRegisterWindowClass twice with the same className results in a panic.

func MustRegisterWindowClassWithStyle

func MustRegisterWindowClassWithStyle(className string, style uint32)

func MustRegisterWindowClassWithWndProcPtr

func MustRegisterWindowClassWithWndProcPtr(className string, wndProcPtr uintptr)

func MustRegisterWindowClassWithWndProcPtrAndStyle

func MustRegisterWindowClassWithWndProcPtrAndStyle(className string, wndProcPtr uintptr, style uint32)

func PanicOnError

func PanicOnError() bool

func ParseFloat

func ParseFloat(s string) (float64, error)

func PersonalPath

func PersonalPath() (string, error)

func RegistryKeyString

func RegistryKeyString(rootKey *RegistryKey, subKeyPath, valueName string) (value string, err error)

func RegistryKeyUint32

func RegistryKeyUint32(rootKey *RegistryKey, subKeyPath, valueName string) (value uint32, err error)

func SetLogErrors

func SetLogErrors(v bool)

func SetPanicOnError

func SetPanicOnError(v bool)

func SetTranslationFunc

func SetTranslationFunc(f TranslationFunction)

func SetWindowFont

func SetWindowFont(hwnd win.HWND, font *Font)

func ShiftDown

func ShiftDown() bool

func SystemPath

func SystemPath() (string, error)

Types

type AccRole

type AccRole int32

AccRole enum defines the role of the window/control in UI.

const (
	AccRoleTitlebar           AccRole = win.ROLE_SYSTEM_TITLEBAR
	AccRoleMenubar            AccRole = win.ROLE_SYSTEM_MENUBAR
	AccRoleScrollbar          AccRole = win.ROLE_SYSTEM_SCROLLBAR
	AccRoleGrip               AccRole = win.ROLE_SYSTEM_GRIP
	AccRoleSound              AccRole = win.ROLE_SYSTEM_SOUND
	AccRoleCursor             AccRole = win.ROLE_SYSTEM_CURSOR
	AccRoleCaret              AccRole = win.ROLE_SYSTEM_CARET
	AccRoleAlert              AccRole = win.ROLE_SYSTEM_ALERT
	AccRoleWindow             AccRole = win.ROLE_SYSTEM_WINDOW
	AccRoleClient             AccRole = win.ROLE_SYSTEM_CLIENT
	AccRoleMenuPopup          AccRole = win.ROLE_SYSTEM_MENUPOPUP
	AccRoleMenuItem           AccRole = win.ROLE_SYSTEM_MENUITEM
	AccRoleTooltip            AccRole = win.ROLE_SYSTEM_TOOLTIP
	AccRoleApplication        AccRole = win.ROLE_SYSTEM_APPLICATION
	AccRoleDocument           AccRole = win.ROLE_SYSTEM_DOCUMENT
	AccRolePane               AccRole = win.ROLE_SYSTEM_PANE
	AccRoleChart              AccRole = win.ROLE_SYSTEM_CHART
	AccRoleDialog             AccRole = win.ROLE_SYSTEM_DIALOG
	AccRoleBorder             AccRole = win.ROLE_SYSTEM_BORDER
	AccRoleGrouping           AccRole = win.ROLE_SYSTEM_GROUPING
	AccRoleSeparator          AccRole = win.ROLE_SYSTEM_SEPARATOR
	AccRoleToolbar            AccRole = win.ROLE_SYSTEM_TOOLBAR
	AccRoleStatusbar          AccRole = win.ROLE_SYSTEM_STATUSBAR
	AccRoleTable              AccRole = win.ROLE_SYSTEM_TABLE
	AccRoleColumnHeader       AccRole = win.ROLE_SYSTEM_COLUMNHEADER
	AccRoleRowHeader          AccRole = win.ROLE_SYSTEM_ROWHEADER
	AccRoleColumn             AccRole = win.ROLE_SYSTEM_COLUMN
	AccRoleRow                AccRole = win.ROLE_SYSTEM_ROW
	AccRoleCell               AccRole = win.ROLE_SYSTEM_CELL
	AccRoleLink               AccRole = win.ROLE_SYSTEM_LINK
	AccRoleHelpBalloon        AccRole = win.ROLE_SYSTEM_HELPBALLOON
	AccRoleCharacter          AccRole = win.ROLE_SYSTEM_CHARACTER
	AccRoleList               AccRole = win.ROLE_SYSTEM_LIST
	AccRoleListItem           AccRole = win.ROLE_SYSTEM_LISTITEM
	AccRoleOutline            AccRole = win.ROLE_SYSTEM_OUTLINE
	AccRoleOutlineItem        AccRole = win.ROLE_SYSTEM_OUTLINEITEM
	AccRolePagetab            AccRole = win.ROLE_SYSTEM_PAGETAB
	AccRolePropertyPage       AccRole = win.ROLE_SYSTEM_PROPERTYPAGE
	AccRoleIndicator          AccRole = win.ROLE_SYSTEM_INDICATOR
	AccRoleGraphic            AccRole = win.ROLE_SYSTEM_GRAPHIC
	AccRoleStatictext         AccRole = win.ROLE_SYSTEM_STATICTEXT
	AccRoleText               AccRole = win.ROLE_SYSTEM_TEXT
	AccRolePushbutton         AccRole = win.ROLE_SYSTEM_PUSHBUTTON
	AccRoleCheckbutton        AccRole = win.ROLE_SYSTEM_CHECKBUTTON
	AccRoleRadiobutton        AccRole = win.ROLE_SYSTEM_RADIOBUTTON
	AccRoleCombobox           AccRole = win.ROLE_SYSTEM_COMBOBOX
	AccRoleDroplist           AccRole = win.ROLE_SYSTEM_DROPLIST
	AccRoleProgressbar        AccRole = win.ROLE_SYSTEM_PROGRESSBAR
	AccRoleDial               AccRole = win.ROLE_SYSTEM_DIAL
	AccRoleHotkeyfield        AccRole = win.ROLE_SYSTEM_HOTKEYFIELD
	AccRoleSlider             AccRole = win.ROLE_SYSTEM_SLIDER
	AccRoleSpinbutton         AccRole = win.ROLE_SYSTEM_SPINBUTTON
	AccRoleDiagram            AccRole = win.ROLE_SYSTEM_DIAGRAM
	AccRoleAnimation          AccRole = win.ROLE_SYSTEM_ANIMATION
	AccRoleEquation           AccRole = win.ROLE_SYSTEM_EQUATION
	AccRoleButtonDropdown     AccRole = win.ROLE_SYSTEM_BUTTONDROPDOWN
	AccRoleButtonMenu         AccRole = win.ROLE_SYSTEM_BUTTONMENU
	AccRoleButtonDropdownGrid AccRole = win.ROLE_SYSTEM_BUTTONDROPDOWNGRID
	AccRoleWhitespace         AccRole = win.ROLE_SYSTEM_WHITESPACE
	AccRolePageTabList        AccRole = win.ROLE_SYSTEM_PAGETABLIST
	AccRoleClock              AccRole = win.ROLE_SYSTEM_CLOCK
	AccRoleSplitButton        AccRole = win.ROLE_SYSTEM_SPLITBUTTON
	AccRoleIPAddress          AccRole = win.ROLE_SYSTEM_IPADDRESS
	AccRoleOutlineButton      AccRole = win.ROLE_SYSTEM_OUTLINEBUTTON
)

Window/control system roles

type AccState

type AccState int32

AccState enum defines the state of the window/control

const (
	AccStateNormal          AccState = win.STATE_SYSTEM_NORMAL
	AccStateUnavailable     AccState = win.STATE_SYSTEM_UNAVAILABLE
	AccStateSelected        AccState = win.STATE_SYSTEM_SELECTED
	AccStateFocused         AccState = win.STATE_SYSTEM_FOCUSED
	AccStatePressed         AccState = win.STATE_SYSTEM_PRESSED
	AccStateChecked         AccState = win.STATE_SYSTEM_CHECKED
	AccStateMixed           AccState = win.STATE_SYSTEM_MIXED
	AccStateIndeterminate   AccState = win.STATE_SYSTEM_INDETERMINATE
	AccStateReadonly        AccState = win.STATE_SYSTEM_READONLY
	AccStateHotTracked      AccState = win.STATE_SYSTEM_HOTTRACKED
	AccStateDefault         AccState = win.STATE_SYSTEM_DEFAULT
	AccStateExpanded        AccState = win.STATE_SYSTEM_EXPANDED
	AccStateCollapsed       AccState = win.STATE_SYSTEM_COLLAPSED
	AccStateBusy            AccState = win.STATE_SYSTEM_BUSY
	AccStateFloating        AccState = win.STATE_SYSTEM_FLOATING
	AccStateMarqueed        AccState = win.STATE_SYSTEM_MARQUEED
	AccStateAnimated        AccState = win.STATE_SYSTEM_ANIMATED
	AccStateInvisible       AccState = win.STATE_SYSTEM_INVISIBLE
	AccStateOffscreen       AccState = win.STATE_SYSTEM_OFFSCREEN
	AccStateSizeable        AccState = win.STATE_SYSTEM_SIZEABLE
	AccStateMoveable        AccState = win.STATE_SYSTEM_MOVEABLE
	AccStateSelfVoicing     AccState = win.STATE_SYSTEM_SELFVOICING
	AccStateFocusable       AccState = win.STATE_SYSTEM_FOCUSABLE
	AccStateSelectable      AccState = win.STATE_SYSTEM_SELECTABLE
	AccStateLinked          AccState = win.STATE_SYSTEM_LINKED
	AccStateTraversed       AccState = win.STATE_SYSTEM_TRAVERSED
	AccStateMultiselectable AccState = win.STATE_SYSTEM_MULTISELECTABLE
	AccStateExtselectable   AccState = win.STATE_SYSTEM_EXTSELECTABLE
	AccStateAlertLow        AccState = win.STATE_SYSTEM_ALERT_LOW
	AccStateAlertMedium     AccState = win.STATE_SYSTEM_ALERT_MEDIUM
	AccStateAlertHigh       AccState = win.STATE_SYSTEM_ALERT_HIGH
	AccStateProtected       AccState = win.STATE_SYSTEM_PROTECTED
	AccStateHasPopup        AccState = win.STATE_SYSTEM_HASPOPUP
	AccStateValid           AccState = win.STATE_SYSTEM_VALID
)

Window/control states

type Accessibility

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

Accessibility provides basic Dynamic Annotation of windows and controls.

func (*Accessibility) SetAccelerator

func (a *Accessibility) SetAccelerator(acc string) error

SetAccelerator sets window accelerator name using Dynamic Annotation.

func (*Accessibility) SetDefaultAction

func (a *Accessibility) SetDefaultAction(defAction string) error

SetDefaultAction sets window default action using Dynamic Annotation.

func (*Accessibility) SetDescription

func (a *Accessibility) SetDescription(acc string) error

SetDescription sets window description using Dynamic Annotation.

func (*Accessibility) SetHelp

func (a *Accessibility) SetHelp(help string) error

SetHelp sets window help using Dynamic Annotation.

func (*Accessibility) SetName

func (a *Accessibility) SetName(name string) error

SetName sets window name using Dynamic Annotation.

func (*Accessibility) SetRole

func (a *Accessibility) SetRole(role AccRole) error

SetRole sets window role using Dynamic Annotation. The role must be set when the window is created and is not to be modified later.

func (*Accessibility) SetRoleMap

func (a *Accessibility) SetRoleMap(roleMap string) error

SetRoleMap sets window role map using Dynamic Annotation. The role map must be set when the window is created and is not to be modified later.

func (*Accessibility) SetState

func (a *Accessibility) SetState(state AccState) error

SetState sets window state using Dynamic Annotation.

func (*Accessibility) SetStateMap

func (a *Accessibility) SetStateMap(stateMap string) error

SetStateMap sets window state map using Dynamic Annotation. The state map must be set when the window is created and is not to be modified later.

func (*Accessibility) SetValueMap

func (a *Accessibility) SetValueMap(valueMap string) error

SetValueMap sets window value map using Dynamic Annotation. The value map must be set when the window is created and is not to be modified later.

type Action

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

func NewAction

func NewAction() *Action

func NewMenuAction

func NewMenuAction(menu *Menu) *Action

func NewSeparatorAction

func NewSeparatorAction() *Action

func (*Action) Checkable

func (a *Action) Checkable() bool

func (*Action) Checked

func (a *Action) Checked() bool

func (*Action) CheckedCondition

func (a *Action) CheckedCondition() Condition

func (*Action) Default

func (a *Action) Default() bool

func (*Action) DefaultCondition

func (a *Action) DefaultCondition() Condition

func (*Action) Enabled

func (a *Action) Enabled() bool

func (*Action) EnabledCondition

func (a *Action) EnabledCondition() Condition

func (*Action) Exclusive

func (a *Action) Exclusive() bool

func (*Action) Image

func (a *Action) Image() Image

func (*Action) IsSeparator

func (a *Action) IsSeparator() bool

func (*Action) Menu

func (a *Action) Menu() *Menu

func (*Action) SetCheckable

func (a *Action) SetCheckable(value bool) (err error)

func (*Action) SetChecked

func (a *Action) SetChecked(value bool) (err error)

func (*Action) SetCheckedCondition

func (a *Action) SetCheckedCondition(c Condition)

func (*Action) SetDefault

func (a *Action) SetDefault(value bool) (err error)

func (*Action) SetDefaultCondition

func (a *Action) SetDefaultCondition(c Condition)

func (*Action) SetEnabled

func (a *Action) SetEnabled(value bool) (err error)

func (*Action) SetEnabledCondition

func (a *Action) SetEnabledCondition(c Condition)

func (*Action) SetExclusive

func (a *Action) SetExclusive(value bool) (err error)

func (*Action) SetImage

func (a *Action) SetImage(value Image) (err error)

func (*Action) SetShortcut

func (a *Action) SetShortcut(shortcut Shortcut) (err error)

func (*Action) SetText

func (a *Action) SetText(value string) (err error)

func (*Action) SetToolTip

func (a *Action) SetToolTip(value string) (err error)

func (*Action) SetVisible

func (a *Action) SetVisible(value bool) (err error)

func (*Action) SetVisibleCondition

func (a *Action) SetVisibleCondition(c Condition)

func (*Action) Shortcut

func (a *Action) Shortcut() Shortcut

func (*Action) Text

func (a *Action) Text() string

func (*Action) ToolTip

func (a *Action) ToolTip() string

func (*Action) Triggered

func (a *Action) Triggered() *Event

func (*Action) Visible

func (a *Action) Visible() bool

func (*Action) VisibleCondition

func (a *Action) VisibleCondition() Condition

type ActionList

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

func (*ActionList) Add

func (l *ActionList) Add(action *Action) error

func (*ActionList) AddMenu

func (l *ActionList) AddMenu(menu *Menu) (*Action, error)

func (*ActionList) At

func (l *ActionList) At(index int) *Action

func (*ActionList) Clear

func (l *ActionList) Clear() error

func (*ActionList) Contains

func (l *ActionList) Contains(action *Action) bool

func (*ActionList) Index

func (l *ActionList) Index(action *Action) int

func (*ActionList) Insert

func (l *ActionList) Insert(index int, action *Action) error

func (*ActionList) InsertMenu

func (l *ActionList) InsertMenu(index int, menu *Menu) (*Action, error)

func (*ActionList) Len

func (l *ActionList) Len() int

func (*ActionList) Remove

func (l *ActionList) Remove(action *Action) error

func (*ActionList) RemoveAt

func (l *ActionList) RemoveAt(index int) error

type Alignment1D

type Alignment1D uint
const (
	AlignDefault Alignment1D = iota
	AlignNear
	AlignCenter
	AlignFar
)

type Alignment2D

type Alignment2D uint
const (
	AlignHVDefault Alignment2D = iota
	AlignHNearVNear
	AlignHCenterVNear
	AlignHFarVNear
	AlignHNearVCenter
	AlignHCenterVCenter
	AlignHFarVCenter
	AlignHNearVFar
	AlignHCenterVFar
	AlignHFarVFar
)

type Application

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

func App

func App() *Application

func (*Application) ActiveForm

func (app *Application) ActiveForm() Form

ActiveForm returns the currently active form for the caller's thread. It returns nil if no form is active or the caller's thread does not have any windows associated with it. It should be called from within synchronized functions.

func (*Application) Exit

func (app *Application) Exit(exitCode int)

func (*Application) ExitCode

func (app *Application) ExitCode() int

func (*Application) OrganizationName

func (app *Application) OrganizationName() string

func (*Application) Panicking

func (app *Application) Panicking() *ErrorEvent

func (*Application) ProductName

func (app *Application) ProductName() string

func (*Application) SetOrganizationName

func (app *Application) SetOrganizationName(value string)

func (*Application) SetProductName

func (app *Application) SetProductName(value string)

func (*Application) SetSettings

func (app *Application) SetSettings(value Settings)

func (*Application) Settings

func (app *Application) Settings() Settings

type ApplyDPIer

type ApplyDPIer interface {
	ApplyDPI(dpi int)
}

type ApplyFonter

type ApplyFonter interface {
	ApplyFont(font *Font)
}

type ApplySysColorser

type ApplySysColorser interface {
	ApplySysColors()
}

type BindingValueProvider

type BindingValueProvider interface {
	BindingValue(index int) interface{}
}

BindingValueProvider is the interface that a model must implement to support data binding with widgets like ComboBox.

type Bitmap

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

func BitmapFrom

func BitmapFrom(src interface{}, dpi int) (*Bitmap, error)

func NewBitmap deprecated

This function has been deprecated.
func NewBitmap(size Size) (*Bitmap, error)

NewBitmap creates an opaque bitmap with given size in 1/96" units at screen DPI.

Deprecated: Newer applications should use NewBitmapForDPI.

func NewBitmapForDPI

func NewBitmapForDPI(size Size, dpi int) (*Bitmap, error)

NewBitmapForDPI creates an opaque bitmap with given size in native pixels and DPI.

func NewBitmapFromFile deprecated

This function has been deprecated.
func NewBitmapFromFile(filePath string) (*Bitmap, error)

NewBitmapFromFile creates new bitmap from a bitmap file at 96dpi.

Deprecated: Newer applications should use NewBitmapFromFileForDPI.

func NewBitmapFromFileForDPI

func NewBitmapFromFileForDPI(filePath string, dpi int) (*Bitmap, error)

NewBitmapFromFileForDPI creates new bitmap from a bitmap file at given DPI.

func NewBitmapFromIcon deprecated

This function has been deprecated.
func NewBitmapFromIcon(icon *Icon, size Size) (*Bitmap, error)

NewBitmapFromIcon creates a new bitmap with given size in native pixels and 96dpi and paints the icon on it.

Deprecated: Newer applications should use NewBitmapFromIconForDPI.

func NewBitmapFromIconForDPI

func NewBitmapFromIconForDPI(icon *Icon, size Size, dpi int) (*Bitmap, error)

NewBitmapFromIconForDPI creates a new bitmap with given size in native pixels and DPI and paints the icon on it.

func NewBitmapFromImage deprecated

This function has been deprecated.
func NewBitmapFromImage(im image.Image) (*Bitmap, error)

NewBitmapFromImage creates a Bitmap from image.Image at 96dpi.

Deprecated: Newer applications should use NewBitmapFromImageForDPI.

func NewBitmapFromImageForDPI

func NewBitmapFromImageForDPI(im image.Image, dpi int) (*Bitmap, error)

NewBitmapFromImageForDPI creates a Bitmap from image.Image at given DPI.

func NewBitmapFromImageWithSize

func NewBitmapFromImageWithSize(image Image, size Size) (*Bitmap, error)

NewBitmapFromImageWithSize creates a bitmap with given size in native units and paints the image on it streched.

func NewBitmapFromResource deprecated

This function has been deprecated.
func NewBitmapFromResource(name string) (*Bitmap, error)

NewBitmapFromResource creates a Bitmap at 96dpi from resource by name.

Deprecated: Newer applications should use NewBitmapFromResourceForDPI.

func NewBitmapFromResourceForDPI

func NewBitmapFromResourceForDPI(name string, dpi int) (*Bitmap, error)

NewBitmapFromResourceForDPI creates a Bitmap at given DPI from resource by name.

func NewBitmapFromResourceId deprecated

This function has been deprecated.
func NewBitmapFromResourceId(id int) (*Bitmap, error)

NewBitmapFromResourceId creates a Bitmap at 96dpi from resource by ID.

Deprecated: Newer applications should use NewBitmapFromResourceIdForDPI.

func NewBitmapFromResourceIdForDPI

func NewBitmapFromResourceIdForDPI(id int, dpi int) (*Bitmap, error)

NewBitmapFromResourceIdForDPI creates a Bitmap at given DPI from resource by ID.

func NewBitmapFromWindow

func NewBitmapFromWindow(window Window) (*Bitmap, error)

func NewBitmapWithTransparentPixels deprecated

This function has been deprecated.
func NewBitmapWithTransparentPixels(size Size) (*Bitmap, error)

NewBitmapWithTransparentPixels creates a transparent bitmap with given size in 1/96" units at screen DPI.

Deprecated: Newer applications should use NewBitmapWithTransparentPixelsForDPI.

func NewBitmapWithTransparentPixelsForDPI

func NewBitmapWithTransparentPixelsForDPI(size Size, dpi int) (*Bitmap, error)

NewBitmapWithTransparentPixelsForDPI creates a transparent bitmap with given size in native pixels and DPI.

func (*Bitmap) Dispose

func (bmp *Bitmap) Dispose()

func (*Bitmap) Size

func (bmp *Bitmap) Size() Size

Size returns bitmap size in 1/96" units.

func (*Bitmap) ToImage

func (bmp *Bitmap) ToImage() (*image.RGBA, error)

type BitmapBrush

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

func NewBitmapBrush

func NewBitmapBrush(bitmap *Bitmap) (*BitmapBrush, error)

func (*BitmapBrush) Bitmap

func (b *BitmapBrush) Bitmap() *Bitmap

func (*BitmapBrush) Dispose

func (bb *BitmapBrush) Dispose()

type BorderGlowEffect

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

func NewBorderGlowEffect

func NewBorderGlowEffect(color Color) (*BorderGlowEffect, error)

func (*BorderGlowEffect) Dispose

func (wgeb *BorderGlowEffect) Dispose()

func (*BorderGlowEffect) Draw

func (bge *BorderGlowEffect) Draw(widget Widget, canvas *Canvas) error

type BoxLayout

type BoxLayout struct {
	LayoutBase
	// contains filtered or unexported fields
}

func NewHBoxLayout

func NewHBoxLayout() *BoxLayout

func NewVBoxLayout

func NewVBoxLayout() *BoxLayout

func (*BoxLayout) CreateLayoutItem

func (l *BoxLayout) CreateLayoutItem(ctx *LayoutContext) ContainerLayoutItem

func (*BoxLayout) Orientation

func (l *BoxLayout) Orientation() Orientation

func (*BoxLayout) SetOrientation

func (l *BoxLayout) SetOrientation(value Orientation) error

func (*BoxLayout) SetStretchFactor

func (l *BoxLayout) SetStretchFactor(widget Widget, factor int) error

func (*BoxLayout) StretchFactor

func (l *BoxLayout) StretchFactor(widget Widget) int

type Brush

type Brush interface {
	Dispose()
	// contains filtered or unexported methods
}

func NullBrush

func NullBrush() Brush

type Button

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

func (*Button) ApplyDPI

func (b *Button) ApplyDPI(dpi int)

func (*Button) Checked

func (b *Button) Checked() bool

func (*Button) CheckedChanged

func (b *Button) CheckedChanged() *Event

func (*Button) Clicked

func (b *Button) Clicked() *Event

func (*Button) CreateLayoutItem

func (b *Button) CreateLayoutItem(ctx *LayoutContext) LayoutItem

func (*Button) Image

func (b *Button) Image() Image

func (*Button) ImageChanged

func (b *Button) ImageChanged() *Event

func (*Button) Persistent

func (b *Button) Persistent() bool

func (*Button) RestoreState

func (b *Button) RestoreState() error

func (*Button) SaveState

func (b *Button) SaveState() error

func (*Button) SetChecked

func (b *Button) SetChecked(checked bool)

func (*Button) SetImage

func (b *Button) SetImage(image Image) error

func (*Button) SetPersistent

func (b *Button) SetPersistent(value bool)

func (*Button) SetText

func (b *Button) SetText(value string) error

func (*Button) Text

func (b *Button) Text() string

func (*Button) WndProc

func (b *Button) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr

type CancelEvent

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

func (*CancelEvent) Attach

func (e *CancelEvent) Attach(handler CancelEventHandler) int

func (*CancelEvent) Detach

func (e *CancelEvent) Detach(handle int)

func (*CancelEvent) Once

func (e *CancelEvent) Once(handler CancelEventHandler)

type CancelEventHandler

type CancelEventHandler func(canceled *bool)

type CancelEventPublisher

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

func (*CancelEventPublisher) Event

func (p *CancelEventPublisher) Event() *CancelEvent

func (*CancelEventPublisher) Publish

func (p *CancelEventPublisher) Publish(canceled *bool)

type Canvas

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

func NewCanvasFromImage

func NewCanvasFromImage(image Image) (*Canvas, error)

func (*Canvas) Bounds

func (c *Canvas) Bounds() Rectangle

func (*Canvas) BoundsPixels

func (c *Canvas) BoundsPixels() Rectangle

func (*Canvas) DPI

func (c *Canvas) DPI() int

func (*Canvas) Dispose

func (c *Canvas) Dispose()

func (*Canvas) DrawBitmapPart

func (c *Canvas) DrawBitmapPart(bmp *Bitmap, dst, src Rectangle) error

DrawBitmapPart draws bitmap at given location in native pixels.

func (*Canvas) DrawBitmapPartWithOpacity deprecated

This method has been deprecated.
func (c *Canvas) DrawBitmapPartWithOpacity(bmp *Bitmap, dst, src Rectangle, opacity byte) error

DrawBitmapPartWithOpacity draws bitmap at given location in 1/96" units.

Deprecated: Newer applications should use DrawBitmapPartWithOpacityPixels.

func (*Canvas) DrawBitmapPartWithOpacityPixels

func (c *Canvas) DrawBitmapPartWithOpacityPixels(bmp *Bitmap, dst, src Rectangle, opacity byte) error

DrawBitmapPartWithOpacityPixels draws bitmap at given location in native pixels.

func (*Canvas) DrawBitmapWithOpacity deprecated

This method has been deprecated.
func (c *Canvas) DrawBitmapWithOpacity(bmp *Bitmap, bounds Rectangle, opacity byte) error

DrawBitmapWithOpacity draws bitmap with opacity at given location in 1/96" units stretched.

Deprecated: Newer applications should use DrawBitmapWithOpacityPixels.

func (*Canvas) DrawBitmapWithOpacityPixels

func (c *Canvas) DrawBitmapWithOpacityPixels(bmp *Bitmap, bounds Rectangle, opacity byte) error

DrawBitmapWithOpacityPixels draws bitmap with opacity at given location in native pixels stretched.

func (*Canvas) DrawEllipse deprecated

This method has been deprecated.
func (c *Canvas) DrawEllipse(pen Pen, bounds Rectangle) error

DrawEllipse draws an ellipse in 1/96" units.

Deprecated: Newer applications should use DrawEllipsePixels.

func (*Canvas) DrawEllipsePixels

func (c *Canvas) DrawEllipsePixels(pen Pen, bounds Rectangle) error

DrawEllipsePixels draws an ellipse in native pixels.

func (*Canvas) DrawImage deprecated

This method has been deprecated.
func (c *Canvas) DrawImage(image Image, location Point) error

DrawImage draws image at given location (upper left) in 1/96" units unstretched.

Deprecated: Newer applications should use DrawImagePixels.

func (*Canvas) DrawImagePixels

func (c *Canvas) DrawImagePixels(image Image, location Point) error

DrawImagePixels draws image at given location (upper left) in native pixels unstretched.

func (*Canvas) DrawImageStretched deprecated

This method has been deprecated.
func (c *Canvas) DrawImageStretched(image Image, bounds Rectangle) error

DrawImageStretched draws image at given location in 1/96" units stretched.

Deprecated: Newer applications should use DrawImageStretchedPixels.

func (*Canvas) DrawImageStretchedPixels

func (c *Canvas) DrawImageStretchedPixels(image Image, bounds Rectangle) error

DrawImageStretchedPixels draws image at given location in native pixels stretched.

func (*Canvas) DrawLine deprecated

This method has been deprecated.
func (c *Canvas) DrawLine(pen Pen, from, to Point) error

DrawLine draws a line between two points in 1/96" units.

Deprecated: Newer applications should use DrawLinePixels.

func (*Canvas) DrawLinePixels

func (c *Canvas) DrawLinePixels(pen Pen, from, to Point) error

DrawLinePixels draws a line between two points in native pixels.

func (*Canvas) DrawPolyline deprecated

This method has been deprecated.
func (c *Canvas) DrawPolyline(pen Pen, points []Point) error

DrawLine draws a line between given points in 1/96" units.

Deprecated: Newer applications should use DrawLinePixels.

func (*Canvas) DrawPolylinePixels

func (c *Canvas) DrawPolylinePixels(pen Pen, points []Point) error

DrawPolylinePixels draws a line between given points in native pixels.

func (*Canvas) DrawRectangle deprecated

This method has been deprecated.
func (c *Canvas) DrawRectangle(pen Pen, bounds Rectangle) error

DrawRectangle draws a rectangle in 1/96" units.

Deprecated: Newer applications should use DrawRectanglePixels.

func (*Canvas) DrawRectanglePixels

func (c *Canvas) DrawRectanglePixels(pen Pen, bounds Rectangle) error

DrawRectanglePixels draws a rectangle in native pixels.

func (*Canvas) DrawRoundedRectangle deprecated

This method has been deprecated.
func (c *Canvas) DrawRoundedRectangle(pen Pen, bounds Rectangle, ellipseSize Size) error

DrawRoundedRectangle draws a rounded rectangle in 1/96" units. sizeCorrection parameter is in native pixels.

Deprecated: Newer applications should use DrawRoundedRectanglePixels.

func (*Canvas) DrawRoundedRectanglePixels

func (c *Canvas) DrawRoundedRectanglePixels(pen Pen, bounds Rectangle, ellipseSize Size) error

DrawRoundedRectanglePixels draws a rounded rectangle in native pixels.

func (*Canvas) DrawText deprecated

This method has been deprecated.
func (c *Canvas) DrawText(text string, font *Font, color Color, bounds Rectangle, format DrawTextFormat) error

DrawText draws text at given location in 1/96" units.

Deprecated: Newer applications should use DrawTextPixels.

func (*Canvas) DrawTextPixels

func (c *Canvas) DrawTextPixels(text string, font *Font, color Color, bounds Rectangle, format DrawTextFormat) error

DrawTextPixels draws text at given location in native pixels.

func (*Canvas) FillEllipse deprecated

This method has been deprecated.
func (c *Canvas) FillEllipse(brush Brush, bounds Rectangle) error

FillEllipse draws a filled ellipse in 1/96" units.

Deprecated: Newer applications should use FillEllipsePixels.

func (*Canvas) FillEllipsePixels

func (c *Canvas) FillEllipsePixels(brush Brush, bounds Rectangle) error

FillEllipsePixels draws a filled in native pixels.

func (*Canvas) FillRectangle deprecated

This method has been deprecated.
func (c *Canvas) FillRectangle(brush Brush, bounds Rectangle) error

FillRectangle draws a filled rectangle in 1/96" units.

Deprecated: Newer applications should use FillRectanglePixels.

func (*Canvas) FillRectanglePixels

func (c *Canvas) FillRectanglePixels(brush Brush, bounds Rectangle) error

FillRectanglePixels draws a filled rectangle in native pixels.

func (*Canvas) FillRoundedRectangle deprecated

This method has been deprecated.
func (c *Canvas) FillRoundedRectangle(brush Brush, bounds Rectangle, ellipseSize Size) error

FillRoundedRectangle draws a filled rounded rectangle in 1/96" units. sizeCorrection parameter is in native pixels.

Deprecated: Newer applications should use FillRoundedRectanglePixels.

func (*Canvas) FillRoundedRectanglePixels

func (c *Canvas) FillRoundedRectanglePixels(brush Brush, bounds Rectangle, ellipseSize Size) error

FillRoundedRectanglePixels draws a filled rounded rectangle in native pixels.

func (*Canvas) GradientFillRectangle deprecated

This method has been deprecated.
func (c *Canvas) GradientFillRectangle(color1, color2 Color, orientation Orientation, bounds Rectangle) error

GradientFillRectangle draws a gradient filled rectangle in 1/96" units.

Deprecated: Newer applications should use GradientFillRectanglePixels.

func (*Canvas) GradientFillRectanglePixels

func (c *Canvas) GradientFillRectanglePixels(color1, color2 Color, orientation Orientation, bounds Rectangle) error

GradientFillRectanglePixels draws a gradient filled rectangle in native pixels.

func (*Canvas) HDC

func (c *Canvas) HDC() win.HDC

func (*Canvas) MeasureAndModifyTextPixels

func (c *Canvas) MeasureAndModifyTextPixels(text string, font *Font, bounds Rectangle, format DrawTextFormat) (boundsMeasured Rectangle, textDisplayed string, err error)

MeasureAndModifyTextPixels measures text size and also supports modification of the text which occurs if it does not fit into the specified bounds.

Input and output bounds are in native pixels.

func (*Canvas) MeasureText deprecated

This method has been deprecated.
func (c *Canvas) MeasureText(text string, font *Font, bounds Rectangle, format DrawTextFormat) (boundsMeasured Rectangle, runesFitted int, err error)

MeasureText measures text size. Input and output bounds are in 1/96" units.

Deprecated: Newer applications should use MeasureTextPixels.

func (*Canvas) MeasureTextPixels

func (c *Canvas) MeasureTextPixels(text string, font *Font, bounds Rectangle, format DrawTextFormat) (boundsMeasured Rectangle, runesFitted int, err error)

MeasureTextPixels measures text size. Input and output bounds are in native pixels.

type CaseMode

type CaseMode uint32
const (
	CaseModeMixed CaseMode = iota
	CaseModeUpper
	CaseModeLower
)

type CellStyle

type CellStyle struct {
	BackgroundColor Color
	TextColor       Color
	Font            *Font

	// Image is the image to display in the cell.
	//
	// Supported types are *walk.Bitmap, *walk.Icon and string. A string will be
	// interpreted as a file path and the icon associated with the file will be
	// used. It is not supported to use strings together with the other options
	// in the same model instance.
	Image interface{}
	// contains filtered or unexported fields
}

CellStyle carries information about the display style of a cell in a tabular widget like TableView.

func (*CellStyle) Bounds

func (cs *CellStyle) Bounds() Rectangle

func (*CellStyle) BoundsPixels

func (cs *CellStyle) BoundsPixels() Rectangle

func (*CellStyle) Canvas

func (cs *CellStyle) Canvas() *Canvas

func (*CellStyle) Col

func (cs *CellStyle) Col() int

func (*CellStyle) Row

func (cs *CellStyle) Row() int

type CellStyler

type CellStyler interface {
	// StyleCell is called for each cell to pick up cell style information.
	StyleCell(style *CellStyle)
}

CellStyler is the interface that must be implemented to provide a tabular widget like TableView with cell display style information.

type CheckBox

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

func NewCheckBox

func NewCheckBox(parent Container) (*CheckBox, error)

func (*CheckBox) CheckState

func (cb *CheckBox) CheckState() CheckState

func (*CheckBox) CheckStateChanged

func (cb *CheckBox) CheckStateChanged() *Event

func (*CheckBox) RestoreState

func (cb *CheckBox) RestoreState() error

func (*CheckBox) SaveState

func (cb *CheckBox) SaveState() error

func (*CheckBox) SetCheckState

func (cb *CheckBox) SetCheckState(state CheckState)

func (*CheckBox) SetTextOnLeftSide

func (cb *CheckBox) SetTextOnLeftSide(textLeft bool) error

func (*CheckBox) SetTristate

func (cb *CheckBox) SetTristate(tristate bool) error

func (*CheckBox) TextOnLeftSide

func (cb *CheckBox) TextOnLeftSide() bool

func (*CheckBox) Tristate

func (cb *CheckBox) Tristate() bool

func (*CheckBox) WndProc

func (cb *CheckBox) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr

type CheckState

type CheckState int
const (
	CheckUnchecked     CheckState = win.BST_UNCHECKED
	CheckChecked       CheckState = win.BST_CHECKED
	CheckIndeterminate CheckState = win.BST_INDETERMINATE
)

type ClipboardService

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

ClipboardService provides access to the system clipboard.

func Clipboard

func Clipboard() *ClipboardService

Clipboard returns an object that provides access to the system clipboard.

func (*ClipboardService) Clear

func (c *ClipboardService) Clear() error

Clear clears the contents of the clipboard.

func (*ClipboardService) ContainsText

func (c *ClipboardService) ContainsText() (available bool, err error)

ContainsText returns whether the clipboard currently contains text data.

func (*ClipboardService) ContentsChanged

func (c *ClipboardService) ContentsChanged() *Event

ContentsChanged returns an Event that you can attach to for handling clipboard content changes.

func (*ClipboardService) SetText

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

SetText sets the current text data of the clipboard.

func (*ClipboardService) Text

func (c *ClipboardService) Text() (text string, err error)

Text returns the current text data of the clipboard.

type CloseEvent

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

func (*CloseEvent) Attach

func (e *CloseEvent) Attach(handler CloseEventHandler) int

func (*CloseEvent) Detach