winc

package
v2.0.0-...-c9c2afe Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT, MIT Imports: 14 Imported by: 0

README

winc

** This is a fork of tadvi/winc for the sole purpose of integration with Wails. This repository comes with no support **

Common library for Go GUI apps on Windows. It is for Windows OS only. This makes library smaller than some other UI libraries for Go.

Design goals: minimalism and simplicity.

Dependencies

No other dependencies except Go standard library.

Building

If you want to package icon files and other resources into binary rsrc tool is recommended:

rsrc -manifest app.manifest -ico=app.ico,application_edit.ico,application_error.ico -o rsrc.syso

Here app.manifest is XML file in format:

<?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="App" type="win32"/>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
        </dependentAssembly>
    </dependency>
</assembly>

Most Windows applications do not display command prompt. Build your Go project with flag to indicate that it is Windows GUI binary:

go build -ldflags="-H windowsgui"

Samples

Best way to learn how to use the library is to look at the included examples projects.

Setup

  1. Make sure you have a working Go installation and build environment, see more for details on page below. http://golang.org/doc/install

  2. go get github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc

Icons

When rsrc is used to pack icons into binary it displays IDs of the packed icons.

rsrc -manifest app.manifest -ico=app.ico,lightning.ico,edit.ico,application_error.ico -o rsrc.syso
Manifest ID:  1
Icon  app.ico  ID:  10
Icon  lightning.ico  ID:  13
Icon  edit.ico  ID:  16
Icon  application_error.ico  ID:  19

Use IDs to reference packed icons.

const myIcon = 13

btn.SetResIcon(myIcon) // Set icon on the button.

Included source examples use basic building via release.bat files. Note that icon IDs are order dependent. So if you change they order in -ico flag then icon IDs will be different. If you want to keep order the same, just add new icons to the end of -ico comma separated list.

Layout Manager

SimpleDock is default layout manager.

Current design of docking and split views allows building simple apps but if you need to have multiple split views in few different directions you might need to create your own layout manager.

Important point is to have one control inside SimpleDock set to dock as Fill. Controls that are not set to any docking get placed using SetPos() function. So you can have Panel set to dock at the Top and then have another dock to arrange controls inside that Panel or have controls placed using SetPos() at fixed positions.

Example layout with two toolbars and status bar

This is basic layout. Instead of toolbars and status bar you can have Panel or any other control that can resize. Panel can have its own internal Dock that will arrange other controls inside of it.

Example layout with two toolbars and navigation on the left

This is layout with extra control(s) on the left. Left side is usually treeview or listview.

The rule is simple: you either dock controls using SimpleDock OR use SetPos() to set them at fixed positions. That's it.

At some point winc may get more sophisticated layout manager.

Dialog Screens

Dialog screens are not based on Windows resource files (.rc). They are just windows with controls placed at fixed coordinates. This works fine for dialog screens up to 10-14 controls.

Minimal Demo

package main

import (
	"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc"
)

func main() {
	mainWindow := winc.NewForm(nil)
	mainWindow.SetSize(400, 300)  // (width, height)
	mainWindow.SetText("Hello World Demo")

	edt := winc.NewEdit(mainWindow)
	edt.SetPos(10, 20)
	// Most Controls have default size unless SetSize is called.
	edt.SetText("edit text")

	btn := winc.NewPushButton(mainWindow)
	btn.SetText("Show or Hide")
	btn.SetPos(40, 50)	// (x, y)
	btn.SetSize(100, 40) // (width, height)
	btn.OnClick().Bind(func(e *winc.Event) {
		if edt.Visible() {
			edt.Hide()
		} else {
			edt.Show()
		}
	})

	mainWindow.Center()
	mainWindow.Show()
	mainWindow.OnClose().Bind(wndOnClose)

	winc.RunMainLoop() // Must call to start event loop.
}

func wndOnClose(arg *winc.Event) {
	winc.Exit()
}

Hello World

Result of running sample_minimal.

Create Your Own

It is good practice to create your own controls based on existing structures and event model. Library contains some of the controls built that way: IconButton (button.go), ErrorPanel (panel.go), MultiEdit (edit.go), etc. Please look at existing controls as examples before building your own.

When designing your own controls keep in mind that types have to be converted from Go into Win32 API and back. This is usually due to string UTF8 and UTF16 conversions. But there are other types of conversions too.

When developing your own controls you might also need to:

import "github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc/w32"

w32 has Win32 API low level constants and functions.

Look at sample_control for example of custom built window.

Companion Package

Go package for Windows Systray icon, menu and notifications

Credits

This library is built on

AllenDang/gform Windows GUI framework for Go

winc takes most design decisions from gform and adds many more controls and code samples to it.

Documentation

Index

Constants

View Source
const (
	FontBold      byte = 0x01
	FontItalic    byte = 0x02
	FontUnderline byte = 0x04
	FontStrikeOut byte = 0x08
)
View Source
const (
	DirNone direction = iota
	DirX
	DirY
	DirX2
	DirY2
)

Variables

View Source
var (
	// resource compilation tool assigns app.ico ID of 3
	// rsrc -manifest app.manifest -ico app.ico -o rsrc.syso
	AppIconID = 3
)
View Source
var DefaultBackgroundBrush = NewSystemColorBrush(w32.COLOR_BTNFACE)
View Source
var ImageBoxHiPen = NewPen(w32.PS_GEOMETRIC, 2, NewSolidColorBrush(RGB(220, 140, 140)))
View Source
var ImageBoxMarkBrush = NewSolidColorBrush(RGB(40, 40, 40))
View Source
var ImageBoxMarkPen = NewPen(w32.PS_GEOMETRIC, 2, ImageBoxMarkBrush)
View Source
var ImageBoxPen = NewPen(w32.PS_GEOMETRIC, 2, NewSolidColorBrush(RGB(140, 140, 220)))
View Source
var NoShortcut = Shortcut{}

Functions

func AltDown

func AltDown() bool

func AppDataPath

func AppDataPath() (string, error)

func CommonAppDataPath

func CommonAppDataPath() (string, error)

func ControlDown

func ControlDown() bool

func CreateWindow

func CreateWindow(className string, parent Controller, exStyle, style uint) w32.HWND

func DriveNames

func DriveNames() ([]string, error)

func EnsureAppDataPath

func EnsureAppDataPath(company, product string) (string, error)

EnsureAppDataPath uses AppDataPath to ensure storage for local settings and databases.

func Errorf

func Errorf(parent Controller, format string, data ...interface{})

Errorf is generic error message with OK button.

func Exit

func Exit()

func GetAppInstance

func GetAppInstance() w32.HINSTANCE

func LocalAppDataPath

func LocalAppDataPath() (string, error)

func MsgBox

func MsgBox(parent Controller, title, caption string, flags uint) int

func MsgBoxOk

func MsgBoxOk(parent Controller, title, caption string)

func MsgBoxOkCancel

func MsgBoxOkCancel(parent Controller, title, caption string) int

MsgBoxOkCancel basic pop up message. Returns 1 for OK and 2 for CANCEL.

func MsgBoxYesNo

func MsgBoxYesNo(parent Controller, title, caption string) int

func PostMessages

func PostMessages()

PostMessages processes recent messages. Sometimes helpful for instant window refresh.

func PreTranslateMessage

func PreTranslateMessage(msg *w32.MSG) bool

func Printf

func Printf(parent Controller, format string, data ...interface{})

Printf is generic info message with OK button.

func RegClassOnlyOnce

func RegClassOnlyOnce(className string)

func RegMsgHandler

func RegMsgHandler(controller Controller)

func RegisterClass

func RegisterClass(className string, wndproc uintptr)

func RegisterWindowMessage

func RegisterWindowMessage(name string) uint32

func RunMainLoop

func RunMainLoop() int

RunMainLoop processes messages in main application loop.

func ScaleWithDPI

func ScaleWithDPI(pixels int, dpi uint) int

ScaleWithDPI scales the pixels from the default DPI-Space (96) to the target DPI-Space.

func SetAppIcon

func SetAppIcon(appIconID int)

SetAppIconID sets recource icon ID for the apps windows.

func SetExStyle

func SetExStyle(hwnd w32.HWND, b bool, style int)

func SetStyle

func SetStyle(hwnd w32.HWND, b bool, style int)

func ShiftDown

func ShiftDown() bool

func ShowBrowseFolderDlg

func ShowBrowseFolderDlg(parent Controller, title string) (folder string, accepted bool)

func ShowOpenFileDlg

func ShowOpenFileDlg(parent Controller, title, filter string, filterIndex uint, initialDir string) (filePath string, accepted bool)

func ShowSaveFileDlg

func ShowSaveFileDlg(parent Controller, title, filter string, filterIndex uint, initialDir string) (filePath string, accepted bool)

func UnRegMsgHandler

func UnRegMsgHandler(hwnd w32.HWND)

func Warningf

func Warningf(parent Controller, format string, data ...interface{}) int

Warningf is generic warning message with OK and Cancel buttons. Returns 1 for OK.

Types

type Bitmap

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

func NewBitmapFromFile

func NewBitmapFromFile(filepath string, background Color) (*Bitmap, error)

func NewBitmapFromResource

func NewBitmapFromResource(instance w32.HINSTANCE, resName *uint16, resType *uint16, background Color) (*Bitmap, error)

func (*Bitmap) Dispose

func (bm *Bitmap) Dispose()

func (*Bitmap) GetHBITMAP

func (bm *Bitmap) GetHBITMAP() w32.HBITMAP

func (*Bitmap) Height

func (bm *Bitmap) Height() int

func (*Bitmap) Size

func (bm *Bitmap) Size() (int, int)

func (*Bitmap) Width

func (bm *Bitmap) Width() int

type Brush

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

func NewHatchedColorBrush

func NewHatchedColorBrush(color Color) *Brush

func NewNullBrush

func NewNullBrush() *Brush

func NewSolidColorBrush

func NewSolidColorBrush(color Color) *Brush

func NewSystemColorBrush

func NewSystemColorBrush(colorIndex int) *Brush

func (*Brush) Dispose

func (br *Brush) Dispose()

func (*Brush) GetHBRUSH

func (br *Brush) GetHBRUSH() w32.HBRUSH

func (*Brush) GetLOGBRUSH

func (br *Brush) GetLOGBRUSH() *w32.LOGBRUSH

type Button

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

func (*Button) Checked

func (bt *Button) Checked() bool

func (*Button) OnClick

func (bt *Button) OnClick() *EventManager

func (*Button) SetChecked

func (bt *Button) SetChecked(checked bool)

func (*Button) SetIcon

func (bt *Button) SetIcon(ico *Icon)

SetIcon sets icon on the button. Recommended icons are 32x32 with 32bit color depth.

func (*Button) SetResIcon

func (bt *Button) SetResIcon(iconID uint16)

func (*Button) WndProc

func (bt *Button) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type Canvas

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

func NewCanvasFromHDC

func NewCanvasFromHDC(hdc w32.HDC) *Canvas

func NewCanvasFromHwnd

func NewCanvasFromHwnd(hwnd w32.HWND) *Canvas

func (*Canvas) Dispose

func (ca *Canvas) Dispose()

func (*Canvas) DrawBitmap

func (ca *Canvas) DrawBitmap(bmp *Bitmap, x, y int)

func (*Canvas) DrawEllipse

func (ca *Canvas) DrawEllipse(rect *Rect, pen *Pen)

func (*Canvas) DrawFillEllipse

func (ca *Canvas) DrawFillEllipse(rect *Rect, pen *Pen, brush *Brush)

DrawFillEllipse draw and fill ellipse with color.

func (*Canvas) DrawFillRect

func (ca *Canvas) DrawFillRect(rect *Rect, pen *Pen, brush *Brush)

DrawFillRect draw and fill rectangle with color.

func (*Canvas) DrawIcon

func (ca *Canvas) DrawIcon(ico *Icon, x, y int) bool

func (*Canvas) DrawLine

func (ca *Canvas) DrawLine(x, y, x2, y2 int, pen *Pen)

func (*Canvas) DrawRect

func (ca *Canvas) DrawRect(rect *Rect, pen *Pen)

func (*Canvas) DrawStretchedBitmap

func (ca *Canvas) DrawStretchedBitmap(bmp *Bitmap, rect *Rect)

func (*Canvas) DrawText

func (ca *Canvas) DrawText(text string, rect *Rect, format uint, font *Font, textColor Color)

Refer win32 DrawText document for uFormat.

func (*Canvas) FillRect

func (ca *Canvas) FillRect(rect *Rect, brush *Brush)

type CheckBox

type CheckBox struct {
	Button
}

func NewCheckBox

func NewCheckBox(parent Controller) *CheckBox

type Color

type Color uint32

func RGB

func RGB(r, g, b byte) Color

func (Color) B

func (c Color) B() byte

func (Color) G

func (c Color) G() byte

func (Color) R

func (c Color) R() byte

type ComboBox

type ComboBox struct {
	ControlBase
	// contains filtered or unexported fields
}

func NewComboBox

func NewComboBox(parent Controller) *ComboBox

func (*ComboBox) DeleteAllItems

func (cb *ComboBox) DeleteAllItems() bool

func (*ComboBox) DeleteItem

func (cb *ComboBox) DeleteItem(index int) bool

func (*ComboBox) InsertItem

func (cb *ComboBox) InsertItem(index int, str string) bool

func (*ComboBox) OnSelectedChange

func (cb *ComboBox) OnSelectedChange() *EventManager

func (*ComboBox) SelectedItem

func (cb *ComboBox) SelectedItem() int

func (*ComboBox) SetSelectedItem

func (cb *ComboBox) SetSelectedItem(value int) bool

func (*ComboBox) WndProc

func (cb *ComboBox) WndProc(msg uint32, wparam, lparam uintptr) uintptr

Message processer

type ControlBase

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

func (*ControlBase) Bounds

func (cba *ControlBase) Bounds() *Rect

func (*ControlBase) ClientHeight

func (cba *ControlBase) ClientHeight() int

func (*ControlBase) ClientRect

func (cba *ControlBase) ClientRect() *Rect

func (*ControlBase) ClientWidth

func (cba *ControlBase) ClientWidth() int

func (*ControlBase) Close

func (cba *ControlBase) Close()

func (*ControlBase) ContextMenu

func (cba *ControlBase) ContextMenu() *MenuItem

func (*ControlBase) EnableDragAcceptFiles

func (cba *ControlBase) EnableDragAcceptFiles(b bool)

func (*ControlBase) Enabled

func (cba *ControlBase) Enabled() bool

func (*ControlBase) Font

func (cba *ControlBase) Font() *Font

func (*ControlBase) GetWindowDPI

func (cba *ControlBase) GetWindowDPI() (w32.UINT, w32.UINT)

func (*ControlBase) Handle

func (cba *ControlBase) Handle() w32.HWND

func (*ControlBase) Height

func (cba *ControlBase) Height() int

func (*ControlBase) Hide

func (cba *ControlBase) Hide()

func (*ControlBase) InitControl

func (cba *ControlBase) InitControl(className string, parent Controller, exstyle, style uint)

initControl is called by controls: edit, button, treeview, listview, and so on.

func (*ControlBase) InitWindow

func (cba *ControlBase) InitWindow(className string, parent Controller, exstyle, style uint)

InitWindow is called by custom window based controls such as split, panel, etc.

func (*ControlBase) Invalidate

func (cba *ControlBase) Invalidate(erase bool)

func (*ControlBase) Invoke

func (cba *ControlBase) Invoke(f func())

func (*ControlBase) InvokeRequired

func (cba *ControlBase) InvokeRequired() bool

func (*ControlBase) OnClose

func (cba *ControlBase) OnClose() *EventManager

func (*ControlBase) OnCreate

func (cba *ControlBase) OnCreate() *EventManager

Events

func (*ControlBase) OnDropFiles

func (cba *ControlBase) OnDropFiles() *EventManager

func (*ControlBase) OnKeyUp

func (cba *ControlBase) OnKeyUp() *EventManager

func (*ControlBase) OnKillFocus

func (cba *ControlBase) OnKillFocus() *EventManager

func (*ControlBase) OnLBDbl

func (cba *ControlBase) OnLBDbl() *EventManager

func (*ControlBase) OnLBDown

func (cba *ControlBase) OnLBDown() *EventManager

func (*ControlBase) OnLBUp

func (cba *ControlBase) OnLBUp() *EventManager

func (*ControlBase) OnMBDown

func (cba *ControlBase) OnMBDown() *EventManager

func (*ControlBase) OnMBUp

func (cba *ControlBase) OnMBUp() *EventManager

func (*ControlBase) OnMouseHover

func (cba *ControlBase) OnMouseHover() *EventManager

func (*ControlBase) OnMouseLeave

func (cba *ControlBase) OnMouseLeave() *EventManager

func (*ControlBase) OnMouseMove

func (cba *ControlBase) OnMouseMove() *EventManager

func (*ControlBase) OnPaint

func (cba *ControlBase) OnPaint() *EventManager

func (*ControlBase) OnRBDbl

func (cba *ControlBase) OnRBDbl() *EventManager

func (*ControlBase) OnRBDown

func (cba *ControlBase) OnRBDown() *EventManager

func (*ControlBase) OnRBUp

func (cba *ControlBase) OnRBUp() *EventManager

func (*ControlBase) OnSetFocus

func (cba *ControlBase) OnSetFocus() *EventManager

func (*ControlBase) OnSize

func (cba *ControlBase) OnSize() *EventManager

func (*ControlBase) Parent

func (cba *ControlBase) Parent() Controller

func (*ControlBase) Pos

func (cba *ControlBase) Pos() (x, y int)

func (*ControlBase) PreTranslateMessage

func (cba *ControlBase) PreTranslateMessage(msg *w32.MSG) bool

func (*ControlBase) SetAlwaysOnTop

func (cba *ControlBase) SetAlwaysOnTop(b bool)

func (*ControlBase) SetAndClearStyleBits

func (cba *ControlBase) SetAndClearStyleBits(set, clear uint32) error

func (*ControlBase) SetContextMenu

func (cba *ControlBase) SetContextMenu(menu *MenuItem)

func (*ControlBase) SetEnabled

func (cba *ControlBase) SetEnabled(b bool)

func (*ControlBase) SetFocus

func (cba *ControlBase) SetFocus()

func (*ControlBase) SetFont

func (cba *ControlBase) SetFont(font *Font)

func (*ControlBase) SetHandle

func (cba *ControlBase) SetHandle(hwnd w32.HWND)

func (*ControlBase) SetIsForm

func (cba *ControlBase) SetIsForm(isform bool)

func (*ControlBase) SetMaxSize

func (cba *ControlBase) SetMaxSize(width, height int)

func (*ControlBase) SetMinSize

func (cba *ControlBase) SetMinSize(width, height int)

func (*ControlBase) SetParent

func (cba *ControlBase) SetParent(parent Controller)

func (*ControlBase) SetPos

func (cba *ControlBase) SetPos(x, y int)

func (*ControlBase) SetSize

func (cba *ControlBase) SetSize(width, height int)

func (*ControlBase) SetText

func (cba *ControlBase) SetText(caption string)

func (*ControlBase) SetTheme

func (cba *ControlBase) SetTheme(appName string) error

SetTheme for TreeView and ListView controls.

func (*ControlBase) SetTranslucentBackground

func (cba *ControlBase) SetTranslucentBackground()

func (*ControlBase) Show

func (cba *ControlBase) Show()

func (*ControlBase) Size

func (cba *ControlBase) Size() (width, height int)

func (*ControlBase) Text

func (cba *ControlBase) Text() string

func (*ControlBase) ToggleVisible

func (cba *ControlBase) ToggleVisible() bool

func (*ControlBase) Visible

func (cba *ControlBase) Visible() bool

func (*ControlBase) Width

func (cba *ControlBase) Width() int

type Controller

type Controller interface {
	Text() string

	Enabled() bool
	SetFocus()

	Handle() w32.HWND
	Invalidate(erase bool)
	Parent() Controller

	Pos() (x, y int)
	Size() (w, h int)
	Height() int
	Width() int
	Visible() bool
	Bounds() *Rect
	ClientRect() *Rect

	SetText(s string)
	SetEnabled(b bool)
	SetPos(x, y int)
	SetSize(w, h int)
	EnableDragAcceptFiles(b bool)
	Show()
	Hide()

	ContextMenu() *MenuItem
	SetContextMenu(menu *MenuItem)

	Font() *Font
	SetFont(font *Font)
	InvokeRequired() bool
	Invoke(func())
	PreTranslateMessage(msg *w32.MSG) bool
	WndProc(msg uint32, wparam, lparam uintptr) uintptr

	//General events
	OnCreate() *EventManager
	OnClose() *EventManager

	// Focus events
	OnKillFocus() *EventManager
	OnSetFocus() *EventManager

	//Drag and drop events
	OnDropFiles() *EventManager

	//Mouse events
	OnLBDown() *EventManager
	OnLBUp() *EventManager
	OnLBDbl() *EventManager
	OnMBDown() *EventManager
	OnMBUp() *EventManager
	OnRBDown() *EventManager
	OnRBUp() *EventManager
	OnRBDbl() *EventManager
	OnMouseMove() *EventManager

	// OnMouseLeave and OnMouseHover does not fire unless control called internalTrackMouseEvent.
	// Use MouseControl for a how to example.
	OnMouseHover() *EventManager
	OnMouseLeave() *EventManager

	//Keyboard events
	OnKeyUp() *EventManager

	//Paint events
	OnPaint() *EventManager
	OnSize() *EventManager
	// contains filtered or unexported methods
}

func GetMsgHandler

func GetMsgHandler(hwnd w32.HWND) Controller

type CtlState

type CtlState struct {
	X, Y, Width, Height int
}

DockState gets saved and loaded from json

type Dialog

type Dialog struct {
	Form
	// contains filtered or unexported fields
}

Dialog displayed as z-order top window until closed. It also disables parent window so it can not be clicked.

func NewDialog

func NewDialog(parent Controller) *Dialog

func (*Dialog) Close

func (dlg *Dialog) Close()

Close dialog when you done with it.

func (*Dialog) OnCancel

func (dlg *Dialog) OnCancel() *EventManager

func (*Dialog) OnLoad

func (dlg *Dialog) OnLoad() *EventManager

Events

func (*Dialog) OnOk

func (dlg *Dialog) OnOk() *EventManager

func (*Dialog) PreTranslateMessage

func (dlg *Dialog) PreTranslateMessage(msg *w32.MSG) bool

PreTranslateMessage handles dialog specific messages. IMPORTANT.

func (*Dialog) SetButtons

func (dlg *Dialog) SetButtons(btnOk *PushButton, btnCancel *PushButton)

SetButtons wires up dialog events to buttons. btnCancel can be nil.

func (*Dialog) SetModal

func (dlg *Dialog) SetModal(modal bool)

func (*Dialog) Show

func (dlg *Dialog) Show()

Show dialog performs special setup for dialog windows.

func (*Dialog) WndProc

func (dlg *Dialog) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type Direction

type Direction int

Various layout managers

const (
	Top Direction = iota
	Bottom
	Left
	Right
	Fill
)

type DockAllow

type DockAllow interface {
	Handle() w32.HWND
	ClientWidth() int
	ClientHeight() int
	SetLayout(mng LayoutManager)
}

DockAllow is window, panel or other component that satisfies interface.

type Dockable

type Dockable interface {
	Handle() w32.HWND

	Pos() (x, y int)
	Width() int
	Height() int
	Visible() bool

	SetPos(x, y int)
	SetSize(width, height int)

	OnMouseMove() *EventManager
	OnLBUp() *EventManager
}

Dockable component must satisfy interface to be docked.

type DropFilesEventData

type DropFilesEventData struct {
	X, Y  int
	Files []string
}

type Edit

type Edit struct {
	ControlBase
	// contains filtered or unexported fields
}

func NewEdit

func NewEdit(parent Controller) *Edit

func (*Edit) OnChange

func (ed *Edit) OnChange() *EventManager

Events.

func (*Edit) SetPassword

func (ed *Edit) SetPassword(isPassword bool)

Public methods

func (*Edit) SetReadOnly

func (ed *Edit) SetReadOnly(isReadOnly bool)

Public methods.

func (*Edit) WndProc

func (ed *Edit) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type ErrorPanel

type ErrorPanel struct {
	ControlBase
	// contains filtered or unexported fields
}

ErrorPanel shows errors or important messages. It is meant to stand out of other on screen controls.

func NewErrorPanel

func NewErrorPanel(parent Controller) *ErrorPanel

NewErrorPanel.

func (*ErrorPanel) Errorf

func (epa *ErrorPanel) Errorf(format string, v ...interface{})

func (*ErrorPanel) Printf

func (epa *ErrorPanel) Printf(format string, v ...interface{})

func (*ErrorPanel) SetMargin

func (epa *ErrorPanel) SetMargin(margin int)

func (*ErrorPanel) ShowAsError

func (epa *ErrorPanel) ShowAsError(show bool)

func (*ErrorPanel) WndProc

func (epa *ErrorPanel) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type Event

type Event struct {
	Sender Controller
	Data   interface{}
}

func NewEvent

func NewEvent(sender Controller, data interface{}) *Event

type EventHandler

type EventHandler func(arg *Event)

type EventManager

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

func (*EventManager) Bind

func (evm *EventManager) Bind(handler EventHandler)

func (*EventManager) Fire

func (evm *EventManager) Fire(arg *Event)

type Font

type Font struct {
	// contains filtered or unexported fields
}
var (
	GeneralWndprocCallBack = syscall.NewCallback(generalWndProc)
	DefaultFont            *Font
)

Public global variables.

func NewFont

func NewFont(family string, pointSize int, style byte) *Font

func (*Font) Bold

func (fnt *Font) Bold() bool

func (*Font) Dispose

func (fnt *Font) Dispose()

func (*Font) Family

func (fnt *Font) Family() string

func (*Font) GetHFONT

func (fnt *Font) GetHFONT() w32.HFONT

func (*Font) Italic

func (fnt *Font) Italic() bool

func (*Font) StrikeOut

func (fnt *Font) StrikeOut() bool

func (*Font) Style

func (fnt *Font) Style() byte

func (*Font) Underline

func (fnt *Font) Underline() bool

type Form

type Form struct {
	ControlBase
	// contains filtered or unexported fields
}

A Form is main window of the application.

func NewCustomForm

func NewCustomForm(parent Controller, exStyle int, dwStyle uint) *Form

func NewForm

func NewForm(parent Controller) *Form

func (*Form) Center

func (fm *Form) Center()

Public methods

func (*Form) DisableIcon

func (fm *Form) DisableIcon()

func (*Form) EnableDragMove

func (fm *Form) EnableDragMove(_ bool)

func (*Form) EnableMaxButton

func (fm *Form) EnableMaxButton(b bool)

func (*Form) EnableMinButton

func (fm *Form) EnableMinButton(b bool)

func (*Form) EnableSizable

func (fm *Form) EnableSizable(b bool)

func (*Form) EnableTopMost

func (fm *Form) EnableTopMost(b bool)

func (*Form) Fullscreen

func (fm *Form) Fullscreen()

func (*Form) IsFullScreen

func (fm *Form) IsFullScreen() bool

func (*Form) Maximise

func (fm *Form) Maximise()

func (*Form) Minimise

func (fm *Form) Minimise()

func (*Form) NewMenu

func (fm *Form) NewMenu() *Menu

func (*Form) Restore

func (fm *Form) Restore()

func (*Form) SetIcon

func (fm *Form) SetIcon(iconType int, icon *Icon)

IconType: 1 - ICON_BIG; 0 - ICON_SMALL

func (*Form) SetLayout

func (fm *Form) SetLayout(mng LayoutManager)

func (*Form) UnFullscreen

func (fm *Form) UnFullscreen()

func (*Form) UpdateLayout

func (fm *Form) UpdateLayout()

UpdateLayout refresh layout.

func (*Form) WndProc

func (fm *Form) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type GroupBox

type GroupBox struct {
	Button
}

func NewGroupBox

func NewGroupBox(parent Controller) *GroupBox

type HResizer

type HResizer struct {
	ControlBase
	// contains filtered or unexported fields
}

func NewHResizer

func NewHResizer(parent Controller) *HResizer

func (*HResizer) SetControl

func (sp *HResizer) SetControl(control1, control2 Dockable, dir Direction, minSize int)

func (*HResizer) WndProc

func (sp *HResizer) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type Icon

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

func ExtractIcon

func ExtractIcon(fileName string, index int) (*Icon, error)

func NewIconFromFile

func NewIconFromFile(path string) (*Icon, error)

func NewIconFromResource

func NewIconFromResource(instance w32.HINSTANCE, resId uint16) (*Icon, error)

func (*Icon) Destroy

func (ic *Icon) Destroy() bool

func (*Icon) Handle

func (ic *Icon) Handle() w32.HICON

type IconButton

type IconButton struct {
	Button
}

IconButton does not display text, requires SetResIcon call.

func NewIconButton

func NewIconButton(parent Controller) *IconButton

type ImageBox

type ImageBox struct {
	Name         string
	Type         int
	X, Y, X2, Y2 int
	// contains filtered or unexported fields
}

func (*ImageBox) Rect

func (b *ImageBox) Rect() *Rect

type ImageList

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

func NewImageList

func NewImageList(cx, cy int) *ImageList

func (*ImageList) AddIcon

func (im *ImageList) AddIcon(icon *Icon) int

func (*ImageList) AddResIcon

func (im *ImageList) AddResIcon(iconID uint16)

func (*ImageList) Destroy

func (im *ImageList) Destroy() bool

func (*ImageList) Handle

func (im *ImageList) Handle() w32.HIMAGELIST

func (*ImageList) ImageCount

func (im *ImageList) ImageCount() int

func (*ImageList) Remove

func (im *ImageList) Remove(i int) bool

func (*ImageList) RemoveAll

func (im *ImageList) RemoveAll() bool

func (*ImageList) SetImageCount

func (im *ImageList) SetImageCount(uNewCount uint) bool

type ImageView

type ImageView struct {
	ControlBase
	// contains filtered or unexported fields
}

func NewImageView

func NewImageView(parent Controller) *ImageView

func (*ImageView) DrawImage

func (iv *ImageView) DrawImage(bmp *Bitmap)

func (*ImageView) DrawImageFile

func (iv *ImageView) DrawImageFile(filepath string) error

func (*ImageView) WndProc

func (iv *ImageView) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type ImageViewBox

type ImageViewBox struct {
	ControlBase

	Boxes []*ImageBox // might be persisted to file
	// contains filtered or unexported fields
}

ImageViewBox is image view with boxes.

func NewImageViewBox

func NewImageViewBox(parent Controller) *ImageViewBox

func (*ImageViewBox) AddMode

func (iv *ImageViewBox) AddMode() bool

func (*ImageViewBox) DeleteSelected

func (iv *ImageViewBox) DeleteSelected()

func (*ImageViewBox) DrawImage

func (iv *ImageViewBox) DrawImage(bmp *Bitmap)

func (*ImageViewBox) DrawImageFile

func (iv *ImageViewBox) DrawImageFile(filepath string) (err error)

func (*ImageViewBox) HasSelected

func (iv *ImageViewBox) HasSelected() bool

func (*ImageViewBox) IsLoaded

func (iv *ImageViewBox) IsLoaded() bool

func (*ImageViewBox) IsModified

func (iv *ImageViewBox) IsModified() bool

func (*ImageViewBox) NameSelected

func (iv *ImageViewBox) NameSelected() string

func (*ImageViewBox) OnAdd

func (iv *ImageViewBox) OnAdd() *EventManager

func (*ImageViewBox) OnModify

func (iv *ImageViewBox) OnModify() *EventManager

func (*ImageViewBox) OnSelectedChange

func (iv *ImageViewBox) OnSelectedChange() *EventManager

func (*ImageViewBox) SetAddMode

func (iv *ImageViewBox) SetAddMode(add bool)

func (*ImageViewBox) SetModified

func (iv *ImageViewBox) SetModified(modified bool)

func (*ImageViewBox) SetNameSelected

func (iv *ImageViewBox) SetNameSelected(name string)

func (*ImageViewBox) SetTypeSelected

func (iv *ImageViewBox) SetTypeSelected(typ int)

func (*ImageViewBox) TypeSelected

func (iv *ImageViewBox) TypeSelected() int

func (*ImageViewBox) WndProc

func (iv *ImageViewBox) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type Key

type Key uint16
const (
	KeyLButton           Key = w32.VK_LBUTTON
	KeyRButton           Key = w32.VK_RBUTTON
	KeyCancel            Key = w32.VK_CANCEL
	KeyMButton           Key = w32.VK_MBUTTON
	KeyXButton1          Key = w32.VK_XBUTTON1
	KeyXButton2          Key = w32.VK_XBUTTON2
	KeyBack              Key = w32.VK_BACK
	KeyTab               Key = w32.VK_TAB
	KeyClear             Key = w32.VK_CLEAR
	KeyReturn            Key = w32.VK_RETURN
	KeyShift             Key = w32.VK_SHIFT
	KeyControl           Key = w32.VK_CONTROL
	KeyAlt               Key = w32.VK_MENU
	KeyMenu              Key = w32.VK_MENU
	KeyPause             Key = w32.VK_PAUSE
	KeyCapital           Key = w32.VK_CAPITAL
	KeyKana              Key = w32.VK_KANA
	KeyHangul            Key = w32.VK_HANGUL
	KeyJunja             Key = w32.VK_JUNJA
	KeyFinal             Key = w32.VK_FINAL
	KeyHanja             Key = w32.VK_HANJA
	KeyKanji             Key = w32.VK_KANJI
	KeyEscape            Key = w32.VK_ESCAPE
	KeyConvert           Key = w32.VK_CONVERT
	KeyNonconvert        Key = w32.VK_NONCONVERT
	KeyAccept            Key = w32.VK_ACCEPT
	KeyModeChange        Key = w32.VK_MODECHANGE
	KeySpace             Key = w32.VK_SPACE
	KeyPrior             Key = w32.VK_PRIOR
	KeyNext              Key = w32.VK_NEXT
	KeyEnd               Key = w32.VK_END
	KeyHome              Key = w32.VK_HOME
	KeyLeft              Key = w32.VK_LEFT
	KeyUp                Key = w32.VK_UP
	KeyRight             Key = w32.VK_RIGHT
	KeyDown              Key = w32.VK_DOWN
	KeySelect            Key = w32.VK_SELECT
	KeyPrint             Key = w32.VK_PRINT
	KeyExecute           Key = w32.VK_EXECUTE
	KeySnapshot          Key = w32.VK_SNAPSHOT
	KeyInsert            Key = w32.VK_INSERT
	KeyDelete            Key = w32.VK_DELETE
	KeyHelp              Key = w32.VK_HELP
	Key0                 Key = 0x30
	Key1                 Key = 0x31
	Key2                 Key = 0x32
	Key3                 Key = 0x33
	Key4                 Key = 0x34
	Key5                 Key = 0x35
	Key6                 Key = 0x36
	Key7                 Key = 0x37
	Key8                 Key = 0x38
	Key9                 Key = 0x39
	KeyA                 Key = 0x41
	KeyB                 Key = 0x42
	KeyC                 Key = 0x43
	KeyD                 Key = 0x44
	KeyE                 Key = 0x45
	KeyF                 Key = 0x46
	KeyG                 Key = 0x47
	KeyH                 Key = 0x48
	KeyI                 Key = 0x49
	KeyJ                 Key = 0x4A
	KeyK                 Key = 0x4B
	KeyL                 Key = 0x4C
	KeyM                 Key = 0x4D
	KeyN                 Key = 0x4E
	KeyO                 Key = 0x4F
	KeyP                 Key = 0x50
	KeyQ                 Key = 0x51
	KeyR                 Key = 0x52
	KeyS                 Key = 0x53
	KeyT                 Key = 0x54
	KeyU                 Key = 0x55
	KeyV                 Key = 0x56
	KeyW                 Key = 0x57
	KeyX                 Key = 0x58
	KeyY                 Key = 0x59
	KeyZ                 Key = 0x5A
	KeyLWIN              Key = w32.VK_LWIN
	KeyRWIN              Key = w32.VK_RWIN
	KeyApps              Key = w32.VK_APPS
	KeySleep             Key = w32.VK_SLEEP
	KeyNumpad0           Key = w32.VK_NUMPAD0
	KeyNumpad1           Key = w32.VK_NUMPAD1
	KeyNumpad2           Key = w32.VK_NUMPAD2
	KeyNumpad3           Key = w32.VK_NUMPAD3
	KeyNumpad4           Key = w32.VK_NUMPAD4
	KeyNumpad5           Key = w32.VK_NUMPAD5
	KeyNumpad6           Key = w32.VK_NUMPAD6
	KeyNumpad7           Key = w32.VK_NUMPAD7
	KeyNumpad8           Key = w32.VK_NUMPAD8
	KeyNumpad9           Key = w32.VK_NUMPAD9
	KeyMultiply          Key = w32.VK_MULTIPLY
	KeyAdd               Key = w32.VK_ADD
	KeySeparator         Key = w32.VK_SEPARATOR
	KeySubtract          Key = w32.VK_SUBTRACT
	KeyDecimal           Key = w32.VK_DECIMAL
	KeyDivide            Key = w32.VK_DIVIDE
	KeyF1                Key = w32.VK_F1
	KeyF2                Key = w32.VK_F2
	KeyF3                Key = w32.VK_F3
	KeyF4                Key = w32.VK_F4
	KeyF5                Key = w32.VK_F5
	KeyF6                Key = w32.VK_F6
	KeyF7                Key = w32.VK_F7
	KeyF8                Key = w32.VK_F8
	KeyF9                Key = w32.VK_F9
	KeyF10               Key = w32.VK_F10
	KeyF11               Key = w32.VK_F11
	KeyF12               Key = w32.VK_F12
	KeyF13               Key = w32.VK_F13
	KeyF14               Key = w32.VK_F14
	KeyF15               Key = w32.VK_F15
	KeyF16               Key = w32.VK_F16
	KeyF17               Key = w32.VK_F17
	KeyF18               Key = w32.VK_F18
	KeyF19               Key = w32.VK_F19
	KeyF20               Key = w32.VK_F20
	KeyF21               Key = w32.VK_F21
	KeyF22               Key = w32.VK_F22
	KeyF23               Key = w32.VK_F23
	KeyF24               Key = w32.VK_F24
	KeyNumlock           Key = w32.VK_NUMLOCK
	KeyScroll            Key = w32.VK_SCROLL
	KeyLShift            Key = w32.VK_LSHIFT
	KeyRShift            Key = w32.VK_RSHIFT
	KeyLControl          Key = w32.VK_LCONTROL
	KeyRControl          Key = w32.VK_RCONTROL
	KeyLAlt              Key = w32.VK_LMENU
	KeyLMenu             Key = w32.VK_LMENU
	KeyRAlt              Key = w32.VK_RMENU
	KeyRMenu             Key = w32.VK_RMENU
	KeyBrowserBack       Key = w32.VK_BROWSER_BACK
	KeyBrowserForward    Key = w32.VK_BROWSER_FORWARD
	KeyBrowserRefresh    Key = w32.VK_BROWSER_REFRESH
	KeyBrowserStop       Key = w32.VK_BROWSER_STOP
	KeyBrowserSearch     Key = w32.VK_BROWSER_SEARCH
	KeyBrowserFavorites  Key = w32.VK_BROWSER_FAVORITES
	KeyBrowserHome       Key = w32.VK_BROWSER_HOME
	KeyVolumeMute        Key = w32.VK_VOLUME_MUTE
	KeyVolumeDown        Key = w32.VK_VOLUME_DOWN
	KeyVolumeUp          Key = w32.VK_VOLUME_UP
	KeyMediaNextTrack    Key = w32.VK_MEDIA_NEXT_TRACK
	KeyMediaPrevTrack    Key = w32.VK_MEDIA_PREV_TRACK
	KeyMediaStop         Key = w32.VK_MEDIA_STOP
	KeyMediaPlayPause    Key = w32.VK_MEDIA_PLAY_PAUSE
	KeyLaunchMail        Key = w32.VK_LAUNCH_MAIL
	KeyLaunchMediaSelect Key = w32.VK_LAUNCH_MEDIA_SELECT
	KeyLaunchApp1        Key = w32.VK_LAUNCH_APP1
	KeyLaunchApp2        Key = w32.VK_LAUNCH_APP2
	KeyOEM1              Key = w32.VK_OEM_1
	KeyOEMPlus           Key = w32.VK_OEM_PLUS
	KeyOEMComma          Key = w32.VK_OEM_COMMA
	KeyOEMMinus          Key = w32.VK_OEM_MINUS
	KeyOEMPeriod         Key = w32.VK_OEM_PERIOD
	KeyOEM2              Key = w32.VK_OEM_2
	KeyOEM3              Key = w32.VK_OEM_3
	KeyOEM4              Key = w32.VK_OEM_4
	KeyOEM5              Key = w32.VK_OEM_5
	KeyOEM6              Key = w32.VK_OEM_6
	KeyOEM7              Key = w32.VK_OEM_7
	KeyOEM8              Key = w32.VK_OEM_8
	KeyOEM102            Key = w32.VK_OEM_102
	KeyProcessKey        Key = w32.VK_PROCESSKEY
	KeyPacket            Key = w32.VK_PACKET
	KeyAttn              Key = w32.VK_ATTN
	KeyCRSel             Key = w32.VK_CRSEL
	KeyEXSel             Key = w32.VK_EXSEL
	KeyErEOF             Key = w32.VK_EREOF
	KeyPlay              Key = w32.VK_PLAY
	KeyZoom              Key = w32.VK_ZOOM
	KeyNoName            Key = w32.VK_NONAME
	KeyPA1               Key = w32.VK_PA1
	KeyOEMClear          Key = w32.VK_OEM_CLEAR
)

func (Key) String

func (k Key) String() string

type KeyUpEventData

type KeyUpEventData struct {
	VKey, Code int
}

type Label

type Label struct {
	ControlBase
}

func NewLabel

func NewLabel(parent Controller) *Label

func (*Label) WndProc

func (lb *Label) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type LabelEditEventData

type LabelEditEventData struct {
	Item ListItem
	Text string
}

type LayoutControl

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

type LayoutControls

type LayoutControls []*LayoutControl

func (LayoutControls) Len

func (lc LayoutControls) Len() int

func (LayoutControls) Less

func (lc LayoutControls) Less(i, j int) bool

func (LayoutControls) Swap

func (lc LayoutControls) Swap(i, j int)

type LayoutManager

type LayoutManager interface {
	Update()
}

type LayoutState

type LayoutState struct {
	WindowState string
	Controls    []*CtlState
}

type ListItem

type ListItem interface {
	Text() []string  // Text returns the text of the multi-column item.
	ImageIndex() int // ImageIndex is used only if SetImageList is called on the listview
}

ListItem represents an item in a ListView widget.

type ListItemChecker

type ListItemChecker interface {
	Checked() bool
	SetChecked(checked bool)
}

ListItemChecker is used for checkbox support in ListView.

type ListItemSetter

type ListItemSetter interface {
	SetText(s string) // set first item in the array via LabelEdit event
}

ListItemSetter is used in OnEndLabelEdit event.

type ListView

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

func NewListView

func NewListView(parent Controller) *ListView

func (*ListView) AddColumn

func (lv *ListView) AddColumn(caption string, width int)

func (*ListView) AddItem

func (lv *ListView) AddItem(item ListItem)

func (*ListView) CheckBoxes

func (lv *ListView) CheckBoxes() bool

CheckBoxes returns if the *TableView has check boxes.

func (*ListView) DeleteAllItems

func (lv *ListView) DeleteAllItems() bool

func (*ListView) DeleteItem

func (lv *ListView) DeleteItem(item ListItem) error

func (*ListView) EnableDoubleBuffer

func (lv *ListView) EnableDoubleBuffer(enable bool)

func (*ListView) EnableEditLabels

func (lv *ListView) EnableEditLabels(enable bool)

func (*ListView) EnableFullRowSelect

func (lv *ListView) EnableFullRowSelect(enable bool)

func (*ListView) EnableHotTrack

func (lv *ListView) EnableHotTrack(enable bool)

func (*ListView) EnableSingleSelect

func (lv *ListView) EnableSingleSelect(enable bool)

func (*ListView) EnableSortAscending

func (lv *ListView) EnableSortAscending(enable bool)

func (*ListView) EnableSortHeader

func (lv *ListView) EnableSortHeader(enable bool)

func (*ListView) EnsureVisible

func (lv *ListView) EnsureVisible(item ListItem) bool

func (*ListView) InsertItem

func (lv *ListView) InsertItem(item ListItem, index int)

func (*ListView) ItemAt

func (lv *ListView) ItemAt(x, y int) ListItem

func (*ListView) ItemCount

func (lv *ListView) ItemCount() int

func (*ListView) Items

func (lv *ListView) Items() (list []ListItem)

func (*ListView) OnCheckChanged

func (lv *ListView) OnCheckChanged() *EventManager

func (*ListView) OnClick

func (lv *ListView) OnClick() *EventManager

func (*ListView) OnDoubleClick

func (lv *ListView) OnDoubleClick() *EventManager

func (*ListView) OnEndLabelEdit

func (lv *ListView) OnEndLabelEdit() *EventManager

Event publishers

func (*ListView) OnEndScroll

func (lv *ListView) OnEndScroll() *EventManager

func (*ListView) OnItemChanged

func (lv *ListView) OnItemChanged() *EventManager

func (*ListView) OnItemChanging

func (lv *ListView) OnItemChanging() *EventManager

func (*ListView) OnKeyDown

func (lv *ListView) OnKeyDown() *EventManager

func (*ListView) OnViewChange

func (lv *ListView) OnViewChange() *EventManager

func (*ListView) SelectedCount

func (lv *ListView) SelectedCount() uint

func (*ListView) SelectedIndex

func (lv *ListView) SelectedIndex() int

GetSelectedIndex first selected item index. Returns -1 if no item is selected.

func (*ListView) SelectedItem

func (lv *ListView) SelectedItem() ListItem

func (*ListView) SelectedItems

func (lv *ListView) SelectedItems() []ListItem

mask is used to set the LVITEM.Mask for ListView.GetItem which indicates which attributes you'd like to receive of LVITEM.

func (*ListView) SetCheckBoxes

func (lv *ListView) SetCheckBoxes(value bool)

SetCheckBoxes sets if the *TableView has check boxes.

func (*ListView) SetImageList

func (lv *ListView) SetImageList(imageList *ImageList)

func (*ListView) SetItemCount

func (lv *ListView) SetItemCount(count int) bool

func (*ListView) SetSelectedIndex

func (lv *ListView) SetSelectedIndex(i int)

Set i to -1 to select all items.

func (*ListView) SetSelectedItem

func (lv *ListView) SetSelectedItem(item ListItem) bool

func (*ListView) StretchLastColumn

func (lv *ListView) StretchLastColumn() error

StretchLastColumn makes the last column take up all remaining horizontal space of the *ListView. The effect of this is not persistent.

func (*ListView) UpdateItem

func (lv *ListView) UpdateItem(item ListItem) bool

func (*ListView) WndProc

func (lv *ListView) WndProc(msg uint32, wparam, lparam uintptr) uintptr

Message processer

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

Menu for main window and context menus on controls. Most methods used for both main window menu and context menu.

func (m *Menu) AddSubMenu(text string) *MenuItem

AddSubMenu returns item that is used as submenu to perform AddItem(s).

func (m *Menu) Dispose()
func (m *Menu) IsDisposed() bool
func (m *Menu) Show()

Show menu on the main window.

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

func NewContextMenu

func NewContextMenu() *MenuItem
func (mi *MenuItem) AddItem(text string, shortcut Shortcut) *MenuItem

AddItem adds plain menu item.

func (mi *MenuItem) AddItemCheckable(text string, shortcut Shortcut) *MenuItem

AddItemCheckable adds plain menu item that can have a checkmark.

func (mi *MenuItem) AddItemRadio(text string, shortcut Shortcut) *MenuItem

AddItemRadio adds plain menu item that can have a checkmark and is part of a radio group.

func (mi *MenuItem) AddItemWithBitmap(text string, shortcut Shortcut, image *Bitmap) *MenuItem

AddItemWithBitmap adds menu item with shortcut and bitmap.

func (mi *MenuItem) AddSeparator()
func (mi *MenuItem) AddSubMenu(text string) *MenuItem

AddSubMenu adds a submenu.

func (mi *MenuItem) Checkable() bool
func (mi *MenuItem) Checked() bool
func (mi *MenuItem) Enabled() bool
func (mi *MenuItem) Image() *Bitmap
func (mi *MenuItem) IsSeparator() bool
func (mi *MenuItem) OnClick() *EventManager
func (mi *MenuItem) SetCheckable(b bool)
func (mi *MenuItem) SetChecked(b bool)
func (mi *MenuItem) SetEnabled(b bool)
func (mi *MenuItem) SetImage(b *Bitmap)
func (mi *MenuItem) SetSeparator()
func (mi *MenuItem) SetText(s string)
func (mi *MenuItem) SetToolTip(s string)
func (mi *MenuItem) Text() string
func (mi *MenuItem) ToolTip() string

type Modifiers

type Modifiers byte
const (
	ModShift Modifiers = 1 << iota
	ModControl
	ModAlt
)

func ModifiersDown

func ModifiersDown() Modifiers

func (Modifiers) String

func (m Modifiers) String() string

type MouseControl

type MouseControl struct {
	ControlBase
	// contains filtered or unexported fields
}

MouseControl used for creating custom controls that need mouse hover or mouse leave events.

func (*MouseControl) Init

func (cc *MouseControl) Init(parent Controller, className string, exStyle, style uint)

func (*MouseControl) WndProc

func (cc *MouseControl) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type MouseEventData

type MouseEventData struct {
	X, Y   int
	Button int
	Wheel  int
}

type MultiEdit

type MultiEdit struct {
	ControlBase
	// contains filtered or unexported fields
}

MultiEdit is multiline text edit.

func NewMultiEdit

func NewMultiEdit(parent Controller) *MultiEdit

func (*MultiEdit) AddLine

func (med *MultiEdit) AddLine(text string)

func (*MultiEdit) OnChange

func (med *MultiEdit) OnChange() *EventManager

Events

func (*MultiEdit) SetReadOnly

func (med *MultiEdit) SetReadOnly(isReadOnly bool)

Public methods

func (*MultiEdit) WndProc

func (med *MultiEdit) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type MultiPanel

type MultiPanel struct {
	ControlBase
	// contains filtered or unexported fields
}

MultiPanel contains other panels and only makes one of them visible.

func NewMultiPanel

func NewMultiPanel(parent Controller) *MultiPanel

func (*MultiPanel) AddPanel

func (mpa *MultiPanel) AddPanel(panel *Panel)

AddPanel adds panels to the internal list, first panel is visible all others are hidden.

func (*MultiPanel) Count

func (mpa *MultiPanel) Count() int

func (*MultiPanel) Current

func (mpa *MultiPanel) Current() int

func (*MultiPanel) DeletePanel

func (mpa *MultiPanel) DeletePanel(index int)

DeletePanel removed panel.

func (*MultiPanel) ReplacePanel

func (mpa *MultiPanel) ReplacePanel(index int, panel *Panel)

ReplacePanel replaces panel, useful for refreshing controls on screen.

func (*MultiPanel) SetCurrent

func (mpa *MultiPanel) SetCurrent(index int)

func (*MultiPanel) WndProc

func (mpa *MultiPanel) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type PaintEventData

type PaintEventData struct {
	Canvas *Canvas
}

type Panel

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

func NewPanel

func NewPanel(parent Controller) *Panel

func (*Panel) SetLayout

func (pa *Panel) SetLayout(mng LayoutManager)

SetLayout panel implements DockAllow interface.

func (*Panel) WndProc

func (pa *Panel) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type Pen

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

func NewNullPen

func NewNullPen() *Pen

func NewPen

func NewPen(style uint, width uint, brush *Brush) *Pen

func (*Pen) Brush

func (pen *Pen) Brush() *Brush

func (*Pen) Dispose

func (pen *Pen) Dispose()

func (*Pen) GetHPEN

func (pen *Pen) GetHPEN() w32.HPEN

func (*Pen) Style

func (pen *Pen) Style() uint

type ProgressBar

type ProgressBar struct {
	ControlBase
}

func NewProgressBar

func NewProgressBar(parent Controller) *ProgressBar

func (*ProgressBar) Range

func (pr *ProgressBar) Range() (min, max uint)

func (*ProgressBar) SetRange

func (pr *ProgressBar) SetRange(min, max int)

func (*ProgressBar) SetValue

func (pr *ProgressBar) SetValue(v int)

func (*ProgressBar) Value

func (pr *ProgressBar) Value() int

func (*ProgressBar) WndProc

func (pr *ProgressBar) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type PushButton

type PushButton struct {
	Button
}

func NewPushButton

func NewPushButton(parent Controller) *PushButton

func (*PushButton) SetDefault

func (pb *PushButton) SetDefault()

SetDefault is used for dialogs to set default button.

type RadioButton

type RadioButton struct {
	Button
}

func NewRadioButton

func NewRadioButton(parent Controller) *RadioButton

type RadioGroup

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

type RawMsg

type RawMsg struct {
	Hwnd           w32.HWND
	Msg            uint32
	WParam, LParam uintptr
}

type Rect

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

func NewEmptyRect

func NewEmptyRect() *Rect

func NewRect

func NewRect(left, top, right, bottom int) *Rect

func ScreenToClientRect

func ScreenToClientRect(hwnd w32.HWND, rect *w32.RECT) *Rect

func (*Rect) Data

func (re *Rect) Data() (left, top, right, bottom int32)

func (*Rect) GetW32Rect

func (re *Rect) GetW32Rect() *w32.RECT

func (*Rect) Height

func (re *Rect) Height() int

func (*Rect) Inflate

func (re *Rect) Inflate(x, y int)

func (*Rect) Intersect

func (re *Rect) Intersect(src *Rect)

func (*Rect) IsEmpty

func (re *Rect) IsEmpty() bool

func (*Rect) IsEqual

func (re *Rect) IsEqual(rect *Rect) bool

func (*Rect) IsPointIn

func (re *Rect) IsPointIn(x, y int) bool

func (*Rect) Offset

func (re *Rect) Offset(x, y int)

func (*Rect) Set

func (re *Rect) Set(left, top, right, bottom int)

func (*Rect) Substract

func (re *Rect) Substract(src *Rect)

func (*Rect) Union

func (re *Rect) Union(src *Rect)

func (*Rect) Width

func (re *Rect) Width() int

type ScrollView

type ScrollView struct {
	ControlBase
	// contains filtered or unexported fields
}

func NewScrollView

func NewScrollView(parent Controller) *ScrollView

func (*ScrollView) SetChild

func (sv *ScrollView) SetChild(child Dockable)

func (*ScrollView) UpdateScrollBars

func (sv *ScrollView) UpdateScrollBars()

func (*ScrollView) WndProc

func (sv *ScrollView) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type Shortcut

type Shortcut struct {
	Modifiers Modifiers
	Key       Key
}

func (Shortcut) String

func (s Shortcut) String() string

type SimpleDock

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

func NewSimpleDock

func NewSimpleDock(parent DockAllow) *SimpleDock

func (*SimpleDock) Dock

func (sd *SimpleDock) Dock(child Dockable, dir Direction)

Layout management for the child controls.

func (*SimpleDock) LoadState

func (sd *SimpleDock) LoadState(r io.Reader) error

LoadState of the layout. Only works for Docks with parent set to main form.

func (*SimpleDock) LoadStateFile

func (sd *SimpleDock) LoadStateFile(file string) error

LoadStateFile loads state ignores error if file is not found.

func (*SimpleDock) SaveState

func (sd *SimpleDock) SaveState(w io.Writer) error

SaveState of the layout. Only works for Docks with parent set to main form.

func (*SimpleDock) SaveStateFile

func (sd *SimpleDock) SaveStateFile(file string) error

SaveStateFile convenience function.

func (*SimpleDock) Update

func (sd *SimpleDock) Update()

Update is called to resize child items based on layout directions.

type SizeEventData

type SizeEventData struct {
	Type uint
	X, Y int
}

type Slider

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

func NewSlider

func NewSlider(parent Controller) *Slider

func (*Slider) OnScroll

func (tb *Slider) OnScroll() *EventManager

func (*Slider) Range

func (tb *Slider) Range() (min, max int)

func (*Slider) SetPage

func (tb *Slider) SetPage(pagesize int)

func (*Slider) SetRange

func (tb *Slider) SetRange(min, max int)

func (*Slider) SetValue

func (tb *Slider) SetValue(v int)

func (*Slider) Value

func (tb *Slider) Value() int

func (*Slider) WndProc

func (tb *Slider) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type StringListItem

type StringListItem struct {
	ID    int
	Data  string
	Check bool
}

StringListItem is helper for basic string lists.

func (StringListItem) Checked

func (s StringListItem) Checked() bool

func (StringListItem) ImageIndex

func (s StringListItem) ImageIndex() int

func (StringListItem) SetChecked

func (s StringListItem) SetChecked(checked bool)

func (StringListItem) Text

func (s StringListItem) Text() []string

type StringTreeItem

type StringTreeItem struct {
	Data  string
	Image int
}

StringTreeItem is helper for basic string lists.

func (StringTreeItem) ImageIndex

func (s StringTreeItem) ImageIndex() int

func (StringTreeItem) Text

func (s StringTreeItem) Text() string

type TabView

type TabView struct {
	ControlBase
	// contains filtered or unexported fields
}

TabView creates MultiPanel internally and manages tabs as panels.

func NewTabView

func NewTabView(parent Controller) *TabView

func (*TabView) AddPanel

func (tv *TabView) AddPanel(text string) *Panel

func (*TabView) Current

func (tv *TabView) Current() int

func (*TabView) DeletePanel

func (tv *TabView) DeletePanel(index int)

func (*TabView) Panels

func (tv *TabView) Panels() *MultiPanel

func (*TabView) SetCurrent

func (tv *TabView) SetCurrent(index int)

func (*TabView) WndProc

func (tv *TabView) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type ToolButton

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

func (*ToolButton) Checkable

func (bt *ToolButton) Checkable() bool

func (*ToolButton) Checked

func (bt *ToolButton) Checked() bool

func (*ToolButton) Enabled

func (bt *ToolButton) Enabled() bool

func (*ToolButton) Image

func (bt *ToolButton) Image() int

func (*ToolButton) IsSeparator

func (bt *ToolButton) IsSeparator() bool

func (*ToolButton) OnClick

func (bt *ToolButton) OnClick() *EventManager

func (*ToolButton) SetCheckable

func (bt *ToolButton) SetCheckable(b bool)

func (*ToolButton) SetChecked

func (bt *ToolButton) SetChecked(b bool)

func (*ToolButton) SetEnabled

func (bt *ToolButton) SetEnabled(b bool)

func (*ToolButton) SetImage

func (bt *ToolButton) SetImage(i int)

func (*ToolButton) SetSeparator

func (bt *ToolButton) SetSeparator()

func (*ToolButton) SetText

func (bt *ToolButton) SetText(s string)

func (*ToolButton) Text

func (bt *ToolButton) Text() string

type ToolTip

type ToolTip struct {
	ControlBase
}

func NewToolTip

func NewToolTip(parent Controller) *ToolTip

func (*ToolTip) SetTip

func (tp *ToolTip) SetTip(tool Controller, tip string) bool

func (*ToolTip) WndProc

func (tp *ToolTip) WndProc(msg uint, wparam, lparam uintptr) uintptr

type Toolbar

type Toolbar struct {
	ControlBase
	// contains filtered or unexported fields
}

func NewHToolbar

func NewHToolbar(parent Controller) *Toolbar

NewHToolbar creates horizontal toolbar with text on same line as image.

func NewToolbar

func NewToolbar(parent Controller) *Toolbar

NewToolbar creates toolbar with text below the image.

func (*Toolbar) AddButton

func (tb *Toolbar) AddButton(text string, image int) *ToolButton

AddButton creates and adds button to the toolbar. Use returned toolbutton to setup OnClick event.

func (*Toolbar) AddSeparator

func (tb *Toolbar) AddSeparator()

func (*Toolbar) SetImageList

func (tb *Toolbar) SetImageList(imageList *ImageList)

func (*Toolbar) WndProc

func (tb *Toolbar) WndProc(msg uint32, wparam, lparam uintptr) uintptr

type TreeItem

type TreeItem interface {
	Text() string    // Text returns the text of the item.
	ImageIndex() int // ImageIndex is used only if SetImageList is called on the treeview
}

TreeItem represents an item in a TreeView widget.

type TreeView

type TreeView struct {
	ControlBase
	// contains filtered or unexported fields
}

func NewTreeView

func NewTreeView(parent Controller) *TreeView

func (*TreeView) Collapse

func (tv *TreeView) Collapse(item TreeItem) bool

func (*TreeView) DeleteAllItems

func (tv *TreeView) DeleteAllItems() bool

func (*TreeView) DeleteItem

func (tv *TreeView) DeleteItem(item TreeItem) bool

func (*TreeView) EnableDoubleBuffer

func (tv *TreeView) EnableDoubleBuffer(enable bool)

func (*TreeView) EnsureVisible

func (tv *TreeView) EnsureVisible(item TreeItem) bool

func (*TreeView) Expand

func (tv *TreeView) Expand(item TreeItem) bool

func (*TreeView) InsertItem

func (tv *TreeView) InsertItem(item, parent, insertAfter TreeItem) error

func (*TreeView) ItemAt

func (tv *TreeView) ItemAt(x, y int) TreeItem

func (*TreeView) Items

func (tv *TreeView) Items() (list []TreeItem)

func (*TreeView) OnCollapse

func (tv *TreeView) OnCollapse() *EventManager

func (*TreeView) OnExpand

func (tv *TreeView) OnExpand() *EventManager

func (*TreeView) OnSelectedChange

func (tv *TreeView) OnSelectedChange() *EventManager

func (*TreeView) OnViewChange

func (tv *TreeView) OnViewChange() *EventManager

func (*TreeView) SelectedItem

func (tv *TreeView) SelectedItem() TreeItem

SelectedItem is current selected item after OnSelectedChange event.

func (*TreeView) SetImageList

func (tv *TreeView) SetImageList(imageList *ImageList)

func (*TreeView) SetSelectedItem

func (tv *TreeView) SetSelectedItem(item TreeItem) bool

func (*TreeView) UpdateItem

func (tv *TreeView) UpdateItem(item TreeItem) bool

func (*TreeView) WndProc

func (tv *TreeView) WndProc(msg uint32, wparam, lparam uintptr) uintptr

Message processer

type VResizer

type VResizer struct {
	ControlBase
	// contains filtered or unexported fields
}

func NewVResizer

func NewVResizer(parent Controller) *VResizer

func (*VResizer) SetControl

func (sp *VResizer) SetControl(control1, control2 Dockable, dir Direction, minSize int)

func (*VResizer) WndProc

func (sp *VResizer) WndProc(msg uint32, wparam, lparam uintptr) uintptr

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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