wui

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 20 Imported by: 0

README

Windows GUI Library (wui)

A pure Go library to create native Windows GUIs. This project is a modified and enhanced version of the original gonutz/wui library.

See the online documentation for API details.

Credits

This project is based on the excellent work by gonutz who created the original wui library. We've extended it with additional features and improvements while maintaining compatibility with the original API.

Original library: github.com/gonutz/wui

Self-contained

The former third-party packages are now part of this module, so there are no external dependencies and no network access is needed to build:

  • github.com/2dprototype/wui/w32 (Win32 bindings, from gonutz/w32 v2, extended)
  • github.com/2dprototype/wui/check (test helper, from gonutz/check)

New Controls

  • GroupBox - captioned frame for visually grouping controls
  • TabControl - tab headers with SetOnChange; show/hide Panels per tab (use ContentBounds() to place them)
  • StatusBar - bottom status bar, optional multiple parts via SetParts / SetPartText
  • Window.AddTimer(ms, f) - periodic Timer running on the GUI thread (Start, Stop, SetInterval)
  • DatePicker - date / long date / time chooser with Value, SetValue, SetOnChange
  • ColorDialog - system color chooser (SetColor, Execute(parent), Color)
  • ClipboardText() / SetClipboardText(text) - read and write unicode text on the clipboard

Centering Windows

  • window.SetCenterOnShow(true) - centers on the screen when shown with Show, and over the parent window when shown with ShowModal
  • window.Center(), window.CenterOnScreen(), window.CenterOnParent() - center at any time

Examples

The examples folder has one small program for each new feature: group_box, tab_control, status_bar, timer, center_window, clipboard, color_dialog, date_picker, canvas_drawing, canvas_mouse, tree_view, context_menu, tooltip and toolbar. Run one with go run ./examples/timer.

Canvas Drawing (PaintBox)

New Canvas functions, all work inside PaintBox.SetOnPaint:

  • Strokes: SetStroke(wui.Stroke{Width, Style, Cap, Join}), SetLineWidth, SetLineStyle - width, dash styles (LineDash, LineDot, ...), round/square/flat caps, round/bevel/miter joins. They apply to every outline function (Line, DrawRect, DrawEllipse, Polyline, Arc, DrawPie, ...)
  • Shapes: DrawRoundRect, FillRoundRect, FillRoundRectOutline, FillRectOutline, FillEllipseOutline, DrawPolygon, FillPolygonOutline, Bezier, Curve (smooth curve through points), SetPixel, Pixel, DrawFocusRect
  • Helpers: RegularPolygonPoints (triangle, hexagon, ...), StarPoints, Clear
  • Fills: FillGradientH, FillGradientV, FillRectAlpha (transparent fill)
  • Images: DrawImageScaled (stretch), DrawImageAlpha (transparency)
  • Clipping: PushDrawEllipse, PushDrawRoundRect, PushDrawPolygon (undo with PopDrawRegion)
  • State: Save() / Restore() for stroke, font and clip region
  • Text: TextRectEllipsis (cuts long text with "...")
  • Mouse: PaintBox.SetOnMouseDown, SetOnMouseUp, SetOnDoubleClick (with MouseButton); dragging keeps reporting SetOnMouseMove outside the box

More Controls and Features

  • TreeView / TreeNode - hierarchical list (Add, Selected, SetOnSelect, SetOnDoubleClick, Expand, Collapse, ExpandAll, Remove, Tag)
  • PopupMenu - context menus; Window.SetContextMenu(menu) and control.SetContextMenu(menu) open on right click, or call menu.Show(window, x, y)
  • SetToolTip(text) - hover hint, available on every control
  • ToolBar - NewToolBar(parent, x, y, height) with AddButton and AddSeparator

New examples: canvas_drawing, canvas_mouse, tree_view, context_menu, tooltip, toolbar.

Window Effects, Tray, Colors and Drag and Drop

  • Drag and drop files: window.SetOnDropFiles(func(files []string, x, y int) {...}), and the same SetOnDropFiles on any control (the innermost control under the mouse gets the files)
  • Colored text: SetTextColor(color) / SetBackgroundColor(color) (and ResetTextColor, ResetBackgroundColor) on Label, CheckBox, RadioButton, GroupBox, EditLine, TextEdit, ComboBox and the fill of a Panel. Check boxes, radio buttons and group boxes drop visual styles when a text color is set because themed controls ignore it
  • System tray: NewTrayIcon() with SetToolTip, SetIcon, SetMenu(*PopupMenu), SetOnClick, SetOnDoubleClick, ShowBalloon(title, text, kind); attach it with window.SetTrayIcon(tray). window.SetMinimizeToTray(true), window.SetCloseToTray(true), HideToTray, RestoreFromTray, Quit. The icon comes back by itself when Explorer restarts
  • Transparent window: SetAlpha(0..255) for opacity, SetTransparentColor(color) / SetTransparent(true) for a color key (pixels in that color are see-through and click-through)
  • Headless window: SetHeadless(true) (no title bar and border) with SetDragByBackground(true) to move it, SetCornerRadius(px) for rounded corners
  • More window options: SetTopMost, SetShowInTaskbar, SetMinSize, SetMaxSize

New examples: drag_drop, tray, colored_text, overlay_window.

Minimal Example

This is all the code you need to create a window (which does not do much):

package main

import "github.com/2dprototype/wui"

func main() {
	wui.NewWindow().Show()
}

The Designer

A graphical designer tool is included for visually creating GUIs. It is located at github.com/2dprototype/wui/cmd/designer.

Features
  • Visual Layout: Drag and drop controls onto a window
  • Property Editor: Modify control properties in real-time
  • Live Preview: See your GUI as you build it
  • Code Generation: Export designs as Go source code
  • Project Management: Save and load designs as JSON project files
  • Font Customization: Configure fonts for individual controls
  • Event Handling: Define event handlers (OnPaint, etc.)
  • Multiple Controls: Button, Label, CheckBox, RadioButton, Slider, ProgressBar, EditLine, TextEdit, ComboBox, Panel, PaintBox, IntUpDown, FloatUpDown, GroupBox, TabControl, DatePicker, StatusBar
  • Full support for the new features: color pickers for text/background/key color, window options (transparency, headless via Has Border, corner radius, top most, taskbar, drag move, tray, drop files), OnClick and OnDropFiles event editors, copy / cut / paste / duplicate
  • Responsive: works on small screens. The toolbox and the property panel hide automatically when the window is narrow (F2 / F3 toggle them, F4 goes back to automatic), both scroll with the mouse wheel, the preview pans with the wheel (Shift for sideways) and project files can be dropped onto the designer to open them
Keyboard Shortcuts
Shortcut Action
Ctrl+N New Project
Ctrl+O Open Project (JSON)
Ctrl+S Save Project (JSON)
Ctrl+Shift+S Save Project As (JSON)
Ctrl+E Export as Go Code
Ctrl+J Export as JSON
F5 Run Preview
Del Delete Selected Control
Ctrl+D Duplicate selected control
Ctrl+C / Ctrl+X / Ctrl+V Copy / cut / paste control
F2 / F3 / F4 Toggle toolbox / toggle properties / automatic layout
F1 About
Ctrl+F1 Keyboard Shortcuts Reference
Project File Format

Projects are saved as JSON files with the following structure:

{
  "windows": [
    {
      "name": "window",
      "type": "Window",
      "props": [
        {"name": "Title", "value": "My Window"},
        {"name": "InnerWidth", "value": 400},
        {"name": "InnerHeight", "value": 300}
      ],
      "font": {
        "name": "Tahoma",
        "height": -11,
        "bold": false,
        "italic": false,
        "underlined": false,
        "striked_out": false
      },
      "children": [
        {
          "name": "button1",
          "type": "Button",
          "props": [
            {"name": "Text", "value": "Click Me"},
            {"name": "X", "value": 10},
            {"name": "Y", "value": 10},
            {"name": "Width", "value": 100},
            {"name": "Height", "value": 25}
          ]
        }
      ]
    }
  ],
  "events": [
    {
      "control_name": "paintBox1",
      "event_name": "OnPaint",
      "code": "func(canvas *wui.Canvas) {\n\tcanvas.FillRect(0, 0, 100, 100, wui.RGB(255, 0, 0))\n}"
    }
  ]
}

WML: XML Layouts (package wml)

github.com/2dprototype/wui/wml loads window layouts from XML files at run time, similar to QML or XAML. The layout contains data only; events refer to Go functions by name.

<wml version="1">
  <Window Name="main" Title="Login" InnerSize="400,300">
    <EditLine Name="user" Bounds="80,10,300,22"/>
    <Button Text="Login" Bounds="300,260,90,26" OnClick="doLogin"/>
  </Window>
</wml>
type form struct {
	Window *wui.Window   `wml:"main"`
	User   *wui.EditLine `wml:"user"`
}

doc, err := wml.ParseFile("login.xml") // validated, with line and column in errors
var f form
_, err = doc.Build(&f, wml.Handlers{"doLogin": func() { println(f.User.Text()) }})
f.Window.Show()

See wml/README.md for the format reference. go run ./cmd/wmlcheck file.xml validates a layout without opening a window, and examples/wml_login is a complete program.

Installation

go get github.com/2dprototype/wui

Requirements

  • Go 1.16 or later
  • Windows operating system (uses native Windows API)

Changes from Original

This version includes several enhancements over the original gonutz/wui:

  • JSON Project Files: Save and load complete GUI designs

License

This project maintains the same license as the original work. See the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

Acknowledgments

Special thanks to gonutz for creating the original wui library that made this project possible.

Documentation

Index

Constants

View Source
const (
	KeyLeftMouseButton   = w32.VK_LBUTTON
	KeyRightMouseButton  = w32.VK_RBUTTON
	KeyCancel            = w32.VK_CANCEL
	KeyMiddleMouseButton = w32.VK_MBUTTON
	KeyXMouseButton1     = w32.VK_XBUTTON1
	KeyXMouseButton2     = w32.VK_XBUTTON2
	KeyBack              = w32.VK_BACK
	KeyTab               = w32.VK_TAB
	KeyClear             = w32.VK_CLEAR
	KeyReturn            = w32.VK_RETURN
	KeyShift             = w32.VK_SHIFT
	KeyControl           = w32.VK_CONTROL
	KeyAlt               = w32.VK_MENU
	KeyPause             = w32.VK_PAUSE
	KeyCapital           = w32.VK_CAPITAL
	KeyKana              = w32.VK_KANA
	KeyHangul            = w32.VK_HANGUL
	KeyIMEOn             = w32.VK_IME_ON
	KeyJunja             = w32.VK_JUNJA
	KeyFinal             = w32.VK_FINAL
	KeyHanja             = w32.VK_HANJA
	KeyKanji             = w32.VK_KANJI
	KeyIMEOff            = w32.VK_IME_OFF
	KeyEscape            = w32.VK_ESCAPE
	KeyConvert           = w32.VK_CONVERT
	KeyNonConvert        = w32.VK_NONCONVERT
	KeyAccept            = w32.VK_ACCEPT
	KeyModeChange        = w32.VK_MODECHANGE
	KeySpace             = w32.VK_SPACE
	KeyPrior             = w32.VK_PRIOR
	KeyNext              = w32.VK_NEXT
	KeyEnd               = w32.VK_END
	KeyHome              = w32.VK_HOME
	KeyLeft              = w32.VK_LEFT
	KeyUp                = w32.VK_UP
	KeyRight             = w32.VK_RIGHT
	KeyDown              = w32.VK_DOWN
	KeySelect            = w32.VK_SELECT
	KeyPrint             = w32.VK_PRINT
	KeyExecute           = w32.VK_EXECUTE
	KeySnapshot          = w32.VK_SNAPSHOT
	KeyInsert            = w32.VK_INSERT
	KeyDelete            = w32.VK_DELETE
	KeyHelp              = w32.VK_HELP
	Key0                 = '0'
	Key1                 = '1'
	Key2                 = '2'
	Key3                 = '3'
	Key4                 = '4'
	Key5                 = '5'
	Key6                 = '6'
	Key7                 = '7'
	Key8                 = '8'
	Key9                 = '9'
	KeyA                 = 'A'
	KeyB                 = 'B'
	KeyC                 = 'C'
	KeyD                 = 'D'
	KeyE                 = 'E'
	KeyF                 = 'F'
	KeyG                 = 'G'
	KeyH                 = 'H'
	KeyI                 = 'I'
	KeyJ                 = 'J'
	KeyK                 = 'K'
	KeyL                 = 'L'
	KeyM                 = 'M'
	KeyN                 = 'N'
	KeyO                 = 'O'
	KeyP                 = 'P'
	KeyQ                 = 'Q'
	KeyR                 = 'R'
	KeyS                 = 'S'
	KeyT                 = 'T'
	KeyU                 = 'U'
	KeyV                 = 'V'
	KeyW                 = 'W'
	KeyX                 = 'X'
	KeyY                 = 'Y'
	KeyZ                 = 'Z'
	KeyLeftWindows       = w32.VK_LWIN
	KeyRightWindows      = w32.VK_RWIN
	KeyApps              = w32.VK_APPS
	KeySleep             = w32.VK_SLEEP
	KeyNum0              = w32.VK_NUMPAD0
	KeyNum1              = w32.VK_NUMPAD1
	KeyNum2              = w32.VK_NUMPAD2
	KeyNum3              = w32.VK_NUMPAD3
	KeyNum4              = w32.VK_NUMPAD4
	KeyNum5              = w32.VK_NUMPAD5
	KeyNum6              = w32.VK_NUMPAD6
	KeyNum7              = w32.VK_NUMPAD7
	KeyNum8              = w32.VK_NUMPAD8
	KeyNum9              = w32.VK_NUMPAD9
	KeyMultiply          = w32.VK_MULTIPLY
	KeyAdd               = w32.VK_ADD
	KeySeparator         = w32.VK_SEPARATOR
	KeySubtract          = w32.VK_SUBTRACT
	KeyDecimal           = w32.VK_DECIMAL
	KeyDivide            = w32.VK_DIVIDE
	KeyF1                = w32.VK_F1
	KeyF2                = w32.VK_F2
	KeyF3                = w32.VK_F3
	KeyF4                = w32.VK_F4
	KeyF5                = w32.VK_F5
	KeyF6                = w32.VK_F6
	KeyF7                = w32.VK_F7
	KeyF8                = w32.VK_F8
	KeyF9                = w32.VK_F9
	KeyF10               = w32.VK_F10
	KeyF11               = w32.VK_F11
	KeyF12               = w32.VK_F12
	KeyF13               = w32.VK_F13
	KeyF14               = w32.VK_F14
	KeyF15               = w32.VK_F15
	KeyF16               = w32.VK_F16
	KeyF17               = w32.VK_F17
	KeyF18               = w32.VK_F18
	KeyF19               = w32.VK_F19
	KeyF20               = w32.VK_F20
	KeyF21               = w32.VK_F21
	KeyF22               = w32.VK_F22
	KeyF23               = w32.VK_F23
	KeyF24               = w32.VK_F24
	KeyNumLock           = w32.VK_NUMLOCK
	KeyScroll            = w32.VK_SCROLL
	KeyOEMNecEqual       = w32.VK_OEM_NEC_EQUAL
	KeyOEMFjJisho        = w32.VK_OEM_FJ_JISHO
	KeyOEMFjMasshou      = w32.VK_OEM_FJ_MASSHOU
	KeyOEMFjTouroku      = w32.VK_OEM_FJ_TOUROKU
	KeyOEMFjLoya         = w32.VK_OEM_FJ_LOYA
	KeyOEMFjRoya         = w32.VK_OEM_FJ_ROYA
	KeyLeftShift         = w32.VK_LSHIFT
	KeyRightShift        = w32.VK_RSHIFT
	KeyLeftControl       = w32.VK_LCONTROL
	KeyRightControl      = w32.VK_RCONTROL
	KeyLeftAlt           = w32.VK_LMENU
	KeyRightAlt          = w32.VK_RMENU
	KeyBrowserBack       = w32.VK_BROWSER_BACK
	KeyBrowserForward    = w32.VK_BROWSER_FORWARD
	KeyBrowserRefresh    = w32.VK_BROWSER_REFRESH
	KeyBrowserStop       = w32.VK_BROWSER_STOP
	KeyBrowserSearch     = w32.VK_BROWSER_SEARCH
	KeyBrowserFavorites  = w32.VK_BROWSER_FAVORITES
	KeyBrowserHome       = w32.VK_BROWSER_HOME
	KeyVolumeMute        = w32.VK_VOLUME_MUTE
	KeyVolumeDown        = w32.VK_VOLUME_DOWN
	KeyVolumeUp          = w32.VK_VOLUME_UP
	KeyMediaNextTrack    = w32.VK_MEDIA_NEXT_TRACK
	KeyMediaPrevTrack    = w32.VK_MEDIA_PREV_TRACK
	KeyMediaStop         = w32.VK_MEDIA_STOP
	KeyMediaPlayPause    = w32.VK_MEDIA_PLAY_PAUSE
	KeyLaunchMail        = w32.VK_LAUNCH_MAIL
	KeyLaunchMediaSelect = w32.VK_LAUNCH_MEDIA_SELECT
	KeyLaunchApp1        = w32.VK_LAUNCH_APP1
	KeyLaunchApp2        = w32.VK_LAUNCH_APP2
	KeyOEM1              = w32.VK_OEM_1
	KeyOEMPlus           = w32.VK_OEM_PLUS
	KeyOEMComma          = w32.VK_OEM_COMMA
	KeyOEMMinus          = w32.VK_OEM_MINUS
	KeyOEMPeriod         = w32.VK_OEM_PERIOD
	KeyOEM2              = w32.VK_OEM_2
	KeyOEM3              = w32.VK_OEM_3
	KeyOEM4              = w32.VK_OEM_4
	KeyOEM5              = w32.VK_OEM_5
	KeyOEM6              = w32.VK_OEM_6
	KeyOEM7              = w32.VK_OEM_7
	KeyOEM8              = w32.VK_OEM_8
	KeyOEMAx             = w32.VK_OEM_AX
	KeyOEM102            = w32.VK_OEM_102
	KeyIcoHelp           = w32.VK_ICO_HELP
	KeyIco00             = w32.VK_ICO_00
	KeyProcesskey        = w32.VK_PROCESSKEY
	KeyIcoClear          = w32.VK_ICO_CLEAR
	KeyPacket            = w32.VK_PACKET
	KeyOEMReset          = w32.VK_OEM_RESET
	KeyOEMJump           = w32.VK_OEM_JUMP
	KeyOEMPA1            = w32.VK_OEM_PA1
	KeyOEMPA2            = w32.VK_OEM_PA2
	KeyOEMPA3            = w32.VK_OEM_PA3
	KeyOEMWSControl      = w32.VK_OEM_WSCTRL
	KeyOEMCuSel          = w32.VK_OEM_CUSEL
	KeyOEMAttention      = w32.VK_OEM_ATTN
	KeyOEMFinish         = w32.VK_OEM_FINISH
	KeyOEMCopy           = w32.VK_OEM_COPY
	KeyOEMAuto           = w32.VK_OEM_AUTO
	KeyOEMEnlw           = w32.VK_OEM_ENLW
	KeyOEMBacktab        = w32.VK_OEM_BACKTAB
	KeyAttention         = w32.VK_ATTN
	KeyCrSel             = w32.VK_CRSEL
	KeyExSel             = w32.VK_EXSEL
	KeyErEOF             = w32.VK_EREOF
	KeyPlay              = w32.VK_PLAY
	KeyZoom              = w32.VK_ZOOM
	KeyNoName            = w32.VK_NONAME
	KeyPa1               = w32.VK_PA1
	KeyOEMClear          = w32.VK_OEM_CLEAR
)

These are the keyboard key constants.

Variables

View Source
var (
	// Scroll bar gray area.
	ColorScrollBar = sysColor(w32.COLOR_SCROLLBAR)

	// Desktop.
	ColorBackground = sysColor(w32.COLOR_BACKGROUND)

	// Desktop.
	ColorDesktop = sysColor(w32.COLOR_DESKTOP)

	// Active window title bar. The associated foreground color is
	// COLOR_CAPTIONTEXT. Specifies the left side color in the color gradient of
	// an active window's title bar if the gradient effect is enabled.
	ColorActiveCaption = sysColor(w32.COLOR_ACTIVECAPTION)

	// Inactive window caption. The associated foreground color is
	// COLOR_INACTIVECAPTIONTEXT. Specifies the left side color in the color
	// gradient of an inactive window's title bar if the gradient effect is
	// enabled.
	ColorInactiveCaption = sysColor(w32.COLOR_INACTIVECAPTION)

	// Menu background. The associated foreground color is COLOR_MENUTEXT.
	ColorMenu = sysColor(w32.COLOR_MENU)

	// Window background. The associated foreground colors are COLOR_WINDOWTEXT
	// and COLOR_HOTLITE.
	ColorWindow = sysColor(w32.COLOR_WINDOW)

	// Window frame.
	ColorWindowFrame = sysColor(w32.COLOR_WINDOWFRAME)

	// Text in menus. The associated background color is COLOR_MENU.
	ColorMenuText = sysColor(w32.COLOR_MENUTEXT)

	// Text in windows. The associated background color is COLOR_WINDOW.
	ColorWindowText = sysColor(w32.COLOR_WINDOWTEXT)

	// Text in caption, size box, and scroll bar arrow box. The associated
	// background color is COLOR_ACTIVECAPTION.
	ColorCaptionText = sysColor(w32.COLOR_CAPTIONTEXT)

	// Active window border.
	ColorActiveBorder = sysColor(w32.COLOR_ACTIVEBORDER)

	// Inactive window border.
	ColorInactiveBorder = sysColor(w32.COLOR_INACTIVEBORDER)

	// Background color of multiple document interface (MDI) applications.
	ColorAppWorkspace = sysColor(w32.COLOR_APPWORKSPACE)

	// Item(s) selected in a control. The associated foreground color is
	// COLOR_HIGHLIGHTTEXT.
	ColorHighlight = sysColor(w32.COLOR_HIGHLIGHT)

	// Text of item(s) selected in a control. The associated background color is
	// COLOR_HIGHLIGHT.
	ColorHighlightText = sysColor(w32.COLOR_HIGHLIGHTTEXT)

	// Face color for three-dimensional display elements and for dialog box
	// backgrounds.
	Color3DFace = sysColor(w32.COLOR_3DFACE)

	// Face color for three-dimensional display elements and for dialog box
	// backgrounds. The associated foreground color is COLOR_BTNTEXT.
	ColorButtonFace = sysColor(w32.COLOR_BTNFACE)

	// Shadow color for three-dimensional display elements (for edges facing
	// away from the light source).
	Color3DShadow = sysColor(w32.COLOR_3DSHADOW)

	// Shadow color for three-dimensional display elements (for edges facing
	// away from the light source).
	ColorButtonShadow = sysColor(w32.COLOR_BTNSHADOW)

	// Grayed (disabled) text. This color is set to 0 if the current display
	// driver does not support a solid gray color.
	ColorGrayText = sysColor(w32.COLOR_GRAYTEXT)

	// Text on push buttons. The associated background color is COLOR_BTNFACE.
	ColorButtonText = sysColor(w32.COLOR_BTNTEXT)

	// Color of text in an inactive caption. The associated background color is
	// COLOR_INACTIVECAPTION.
	ColorInactiveCaptionText = sysColor(w32.COLOR_INACTIVECAPTIONTEXT)

	// Highlight color for three-dimensional display elements (for edges facing
	// the light source.)
	Color3DHighlight = sysColor(w32.COLOR_3DHIGHLIGHT)

	// Highlight color for three-dimensional display elements (for edges facing
	// the light source.)
	ColorButtonHighlight = sysColor(w32.COLOR_BTNHIGHLIGHT)

	// Dark shadow for three-dimensional display elements.
	Color3DDarkShadow = sysColor(w32.COLOR_3DDKSHADOW)

	// Light color for three-dimensional display elements (for edges facing the
	// light source.)
	Color3DLight = sysColor(w32.COLOR_3DLIGHT)

	// Text color for tooltip controls. The associated background color is
	// COLOR_INFOBK.
	ColorInfoText = sysColor(w32.COLOR_INFOTEXT)

	// Background color for tooltip controls. The associated foreground color is
	// COLOR_INFOTEXT.
	ColorInfoBackground = sysColor(w32.COLOR_INFOBK)

	// Color for a hyperlink or hot-tracked item. The associated background
	// color is COLOR_WINDOW.
	ColorHotlight = sysColor(w32.COLOR_HOTLIGHT)

	// Right side color in the color gradient of an active window's title bar.
	// COLOR_ACTIVECAPTION specifies the left side color. Use
	// SPI_GETGRADIENTCAPTIONS with the SystemParametersInfo function to
	// determine whether the gradient effect is enabled.
	ColorGradientActiveCaption = sysColor(w32.COLOR_GRADIENTACTIVECAPTION)

	// Right side color in the color gradient of an inactive window's title bar.
	// COLOR_INACTIVECAPTION specifies the left side color.
	ColorGradientInactiveCaption = sysColor(w32.COLOR_GRADIENTINACTIVECAPTION)

	// The color used to highlight menu items when the menu appears as a flat
	// menu (see SystemParametersInfo). The highlighted menu item is outlined
	// with COLOR_HIGHLIGHT. Windows 2000: This value is not supported.
	ColorMenuHighlight = sysColor(w32.COLOR_MENUHILIGHT)

	// The background color for the menu bar when menus appear as flat menus
	// (see SystemParametersInfo). However, COLOR_MENU continues to specify the
	// background color of the menu popup. Windows 2000: This value is not
	// supported.
	ColorMenuBar = sysColor(w32.COLOR_MENUBAR)
)

These are predefined colors defined by the current Windows theme.

View Source
var (
	// CursorArrow is the standard, default arrow cursor.
	CursorArrow = loadCursor(w32.IDC_ARROW)

	// CursorIBeam is the text cursor, it looks like the letter I.
	CursorIBeam = loadCursor(w32.IDC_IBEAM)

	// CursorWait is the hour glass or rotating circle cursor that indicates
	// that an action will take some more time.
	CursorWait = loadCursor(w32.IDC_WAIT)

	// CursorCross looks like a black + (plus) symbol.
	CursorCross = loadCursor(w32.IDC_CROSS)

	// CursorUpArrow is a vertical arrow pointing upwards.
	CursorUpArrow = loadCursor(w32.IDC_UPARROW)

	// CursorSizeNWSE is a diagonal line from top-left to bottom-right with
	// arrows at both ends.
	CursorSizeNWSE = loadCursor(w32.IDC_SIZENWSE)

	// CursorSizeNESW is a diagonal line from top-right to bottom-left with
	// arrows at both ends.
	CursorSizeNESW = loadCursor(w32.IDC_SIZENESW)

	// CursorSizeWE is a horizontal line from left to right with arrows at both
	// ends.
	CursorSizeWE = loadCursor(w32.IDC_SIZEWE)

	// CursorSizeNS is a vertical line from top to bottom with arrows at both
	// ends.
	CursorSizeNS = loadCursor(w32.IDC_SIZENS)

	// CursorSizeAll is a white + (plus) symbol with arrows at all four ends.
	CursorSizeAll = loadCursor(w32.IDC_SIZEALL)

	// CursorNo indicates that an action is not possible. It is a crossed-out
	// red circle, like a stop sign.
	CursorNo = loadCursor(w32.IDC_NO)

	// CursorHand is a hand pointing its index finger upwards.
	CursorHand = loadCursor(w32.IDC_HAND)

	// CursorAppStarting is a combination of CursorArrow and CursorWait, it has
	// the arrow cursor but with an hour glass or rotating circle next to it.
	CursorAppStarting = loadCursor(w32.IDC_APPSTARTING)

	// CursorHelp is the default arrow cursor with a little question mark icon
	// next to it.
	CursorHelp = loadCursor(w32.IDC_HELP)
)
View Source
var (
	// IconApplication is the default application icon.
	IconApplication = loadIcon(w32.IDI_APPLICATION)
	// IconQuestion is a question mark icon.
	IconQuestion = loadIcon(w32.IDI_QUESTION)
	// versions (like Windows 2000) this was a Windows icon.
	IconWinLogo = loadIcon(w32.IDI_WINLOGO)
	// IconShield is the icon that comes up when Windows asks admin permission.
	// It looks like a knight's shield.
	IconShield = loadIcon(w32.IDI_SHIELD)
	// IconWarning is an exclamation mark icon.
	IconWarning = loadIcon(w32.IDI_WARNING)
	// IconError is a red cross icon.
	IconError = loadIcon(w32.IDI_ERROR)
	// IconInformation is a blue 'i' for information.
	IconInformation = loadIcon(w32.IDI_INFORMATION)
)
View Source
var DefaultTransparentColor = RGB(255, 0, 255)

DefaultTransparentColor is the key color used by SetTransparent when no color was chosen: magenta.

View Source
var NoExactFontMatch = errors.New("wui.NewFont: the desired font was not found in the system, a replacement is used")

Functions

func ClipboardText added in v0.0.2

func ClipboardText() (text string, ok bool)

ClipboardText returns the text on the system clipboard. ok is false if the clipboard does not contain text.

func Enabled

func Enabled(c EnabledControl) bool

Enabled return true if the given control and all of its parents are enabled. This is different from the control's Enabled() function which only returns the enabled state of the control itself. If it is contained in a disabled parent, c.Enabled() will return true while Enabled(c) will return false.

func MessageBox

func MessageBox(caption, text string)

func MessageBoxCustom

func MessageBoxCustom(caption, text string, flags uint) int

func MessageBoxError

func MessageBoxError(caption, text string)

func MessageBoxInfo

func MessageBoxInfo(caption, text string)

func MessageBoxOKCancel

func MessageBoxOKCancel(caption, text string) bool

func MessageBoxQuestion

func MessageBoxQuestion(caption, text string)

func MessageBoxWarning

func MessageBoxWarning(caption, text string)

func MessageBoxYesNo

func MessageBoxYesNo(caption, text string) bool

func SetClipboardText added in v0.0.2

func SetClipboardText(text string) bool

SetClipboardText replaces the clipboard contents with the given text.

func Visible

func Visible(c VisibleControl) bool

Visible return true if the given control and all of its parents are visible. This is different from the control's Visible() function which only returns the visibility of the control itself. If it is contained in an invisible parent, c.Visible() will return true while Visible(c) will return false.

Types

type Anchor

type Anchor int

Anchor defines how a child control is resized when its parent changes size. Children can be anchored to min (left or top), center and max (right or bottom) of their parents.

const (
	// AnchorMin makes a control stick to the left/top side of its parent. The
	// control's size is not changed.
	AnchorMin Anchor = iota

	// AnchorMax makes a control stick to the right/bottom side of its parent.
	// The control's size is not changed.
	AnchorMax

	// AnchorCenter keeps a control fixed at the horizontal/vertical center of
	// its parent, e.g. if it is placed 10 pixels left of the center, it will
	// stay 10 pixels left of its parent's center. Its size is not changed.
	AnchorCenter

	// AnchorMinAndMax makes a control's borders stick to its parent's borders.
	// The size changes propertionally to its parent's size, keeping the
	// original distances to its parents borders.
	AnchorMinAndMax

	// AnchorMinAndCenter makes the left/top side of a control stick to its
	// parent's left/top side while the right/bottom side sticks to the parent's
	// center.
	AnchorMinAndCenter

	// AnchorMaxAndCenter makes the right/bottom side of a control stick to its
	// parent's right/bottom side while the left/top side sticks to the parent's
	// center.
	AnchorMaxAndCenter
)

func (Anchor) String

func (a Anchor) String() string

type BalloonKind added in v0.0.3

type BalloonKind int

BalloonKind selects the icon shown in a tray balloon notification.

const (
	BalloonNone BalloonKind = iota
	BalloonInfo
	BalloonWarning
	BalloonError
)

type Button

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

func NewButton

func NewButton() *Button

func (*Button) Focus

func (c *Button) Focus()

func (*Button) Font

func (c *Button) Font() *Font

func (*Button) HasFocus

func (c *Button) HasFocus() bool

func (*Button) OnClick

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

func (*Button) OnTabFocus

func (b *Button) OnTabFocus() func()

func (*Button) SetFont

func (c *Button) SetFont(font *Font)

func (*Button) SetOnClick

func (b *Button) SetOnClick(f func())

func (*Button) SetOnTabFocus

func (b *Button) SetOnTabFocus(f func())

func (*Button) SetText

func (c *Button) SetText(text string)

func (*Button) Text

func (c *Button) Text() string

type Canvas

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

func (*Canvas) Arc

func (c *Canvas) Arc(x, y, width, height int, fromClockAngle, dAngle float64, color Color)

func (*Canvas) Bezier added in v0.0.2

func (c *Canvas) Bezier(p []Point, color Color)

Bezier draws connected cubic Bezier curves. The first point is the start point, every following group of three points is two control points and an end point, so len(p) must be 3n+1.

func (*Canvas) Clear added in v0.0.2

func (c *Canvas) Clear(color Color)

Clear fills the whole canvas with the given color.

func (*Canvas) ClearDrawRegions

func (c *Canvas) ClearDrawRegions()

func (*Canvas) Curve added in v0.0.2

func (c *Canvas) Curve(p []Point, color Color)

Curve draws a smooth curve through all given points (Catmull-Rom spline).

func (*Canvas) DrawEllipse

func (c *Canvas) DrawEllipse(x, y, width, height int, color Color)

func (*Canvas) DrawFocusRect added in v0.0.2

func (c *Canvas) DrawFocusRect(x, y, width, height int)

DrawFocusRect draws a dotted focus rectangle.

func (*Canvas) DrawImage

func (c *Canvas) DrawImage(img *Image, src Rectangle, destX, destY int)

func (*Canvas) DrawImageAlpha added in v0.0.2

func (c *Canvas) DrawImageAlpha(img *Image, src Rectangle, destX, destY int, alpha uint8)

DrawImageAlpha draws the src part of the image with an additional transparency, 0 is invisible and 255 is opaque.

func (*Canvas) DrawImageScaled added in v0.0.2

func (c *Canvas) DrawImageScaled(img *Image, src, dest Rectangle)

DrawImageScaled draws the src part of the image stretched into dest. A zero width or height in src means the full image, in dest it means the src size.

func (*Canvas) DrawPie

func (c *Canvas) DrawPie(x, y, width, height int, fromClockAngle, dAngle float64, color Color)

func (*Canvas) DrawPolygon added in v0.0.2

func (c *Canvas) DrawPolygon(p []Point, color Color)

DrawPolygon draws only the outline of a polygon.

func (*Canvas) DrawRect

func (c *Canvas) DrawRect(x, y, width, height int, color Color)

func (*Canvas) DrawRoundRect added in v0.0.2

func (c *Canvas) DrawRoundRect(x, y, width, height, radius int, color Color)

DrawRoundRect draws the outline of a rectangle with rounded corners.

func (*Canvas) FillEllipse

func (c *Canvas) FillEllipse(x, y, width, height int, color Color)

func (*Canvas) FillEllipseOutline added in v0.0.2

func (c *Canvas) FillEllipseOutline(x, y, width, height int, fill, outline Color)

FillEllipseOutline fills an ellipse and draws its outline in a different color.

func (*Canvas) FillGradientH added in v0.0.2

func (c *Canvas) FillGradientH(x, y, width, height int, left, right Color)

FillGradientH fills a rectangle with a horizontal gradient from left to right.

func (*Canvas) FillGradientV added in v0.0.2

func (c *Canvas) FillGradientV(x, y, width, height int, top, bottom Color)

FillGradientV fills a rectangle with a vertical gradient from top to bottom.

func (*Canvas) FillPie

func (c *Canvas) FillPie(x, y, width, height int, fromClockAngle, dAngle float64, color Color)

func (*Canvas) FillPolygonOutline added in v0.0.2

func (c *Canvas) FillPolygonOutline(p []Point, fill, outline Color)

FillPolygonOutline fills a polygon and draws its outline in a different color.

func (*Canvas) FillRect

func (c *Canvas) FillRect(x, y, width, height int, color Color)

func (*Canvas) FillRectAlpha added in v0.0.2

func (c *Canvas) FillRectAlpha(x, y, width, height int, color Color, alpha uint8)

FillRectAlpha fills a rectangle with a semi-transparent color. Alpha 0 is fully transparent, 255 is opaque.

func (*Canvas) FillRectOutline added in v0.0.2

func (c *Canvas) FillRectOutline(x, y, width, height int, fill, outline Color)

FillRectOutline fills a rectangle and draws its outline in a different color.

func (*Canvas) FillRoundRect added in v0.0.2

func (c *Canvas) FillRoundRect(x, y, width, height, radius int, color Color)

FillRoundRect fills a rectangle with rounded corners.

func (*Canvas) FillRoundRectOutline added in v0.0.2

func (c *Canvas) FillRoundRectOutline(x, y, width, height, radius int, fill, outline Color)

FillRoundRectOutline fills a rounded rectangle and draws its outline in a different color using the current stroke.

func (*Canvas) Handle

func (c *Canvas) Handle() uintptr

Handle returns the handle to the canvas' device context (HDC).

func (*Canvas) Height

func (c *Canvas) Height() int

func (*Canvas) Line

func (c *Canvas) Line(x1, y1, x2, y2 int, color Color)

func (*Canvas) Pixel added in v0.0.2

func (c *Canvas) Pixel(x, y int) Color

Pixel returns the color of a single pixel (0xFFFFFFFF outside the canvas).

func (*Canvas) Polygon

func (c *Canvas) Polygon(p []Point, color Color)

func (*Canvas) Polyline

func (c *Canvas) Polyline(p []Point, color Color)

func (*Canvas) PopDrawRegion

func (c *Canvas) PopDrawRegion()

func (*Canvas) PushDrawEllipse added in v0.0.2

func (c *Canvas) PushDrawEllipse(x, y, width, height int)

PushDrawEllipse restricts drawing to an ellipse. Undo with PopDrawRegion.

func (*Canvas) PushDrawPolygon added in v0.0.2

func (c *Canvas) PushDrawPolygon(p []Point)

PushDrawPolygon restricts drawing to a polygon. Undo with PopDrawRegion.

func (*Canvas) PushDrawRegion

func (c *Canvas) PushDrawRegion(x, y, width, height int)

func (*Canvas) PushDrawRoundRect added in v0.0.2

func (c *Canvas) PushDrawRoundRect(x, y, width, height, radius int)

PushDrawRoundRect restricts drawing to a rounded rectangle. Undo with PopDrawRegion.

func (*Canvas) Restore added in v0.0.2

func (c *Canvas) Restore()

Restore returns to the state of the last Save.

func (*Canvas) Save added in v0.0.2

func (c *Canvas) Save()

Save remembers the current stroke, font and clip region. Restore goes back to it. Calls can be nested.

func (*Canvas) SetFont

func (c *Canvas) SetFont(font *Font)

func (*Canvas) SetLineStyle added in v0.0.2

func (c *Canvas) SetLineStyle(s LineStyle)

SetLineStyle sets the dash pattern of outlines.

func (*Canvas) SetLineWidth added in v0.0.2

func (c *Canvas) SetLineWidth(width int)

SetLineWidth sets the outline width in pixels.

func (*Canvas) SetPixel added in v0.0.2

func (c *Canvas) SetPixel(x, y int, color Color)

SetPixel sets a single pixel.

func (*Canvas) SetStroke added in v0.0.2

func (c *Canvas) SetStroke(s Stroke)

SetStroke sets the pen used by all outline drawing functions (DrawRect, Line, DrawEllipse, Polyline, Arc, DrawPie, DrawPolygon, DrawRoundRect, Bezier, Curve and the *Outline functions).

func (*Canvas) Size

func (c *Canvas) Size() (width, height int)

func (*Canvas) Stroke added in v0.0.2

func (c *Canvas) Stroke() Stroke

Stroke returns the current stroke.

func (*Canvas) TextExtent

func (c *Canvas) TextExtent(s string) (width, height int)

func (*Canvas) TextOut

func (c *Canvas) TextOut(x, y int, s string, color Color)

func (*Canvas) TextRect

func (c *Canvas) TextRect(x, y, w, h int, s string, color Color)

func (*Canvas) TextRectEllipsis added in v0.0.2

func (c *Canvas) TextRectEllipsis(x, y, width, height int, s string, color Color)

TextRectEllipsis draws a single line of text, vertically centered in the rectangle, ending with "..." if it does not fit.

func (*Canvas) TextRectExtent

func (c *Canvas) TextRectExtent(s string, givenWidth int) (width, height int)

TextRectExtent returns the size of the text when drawn in a rectangle of the given width. The given width is necessary because text rects use word breaks and thus given a smaller width might produce a higher text height.

func (*Canvas) TextRectFormat

func (c *Canvas) TextRectFormat(x, y, w, h int, s string, format Format, color Color)

func (*Canvas) Width

func (c *Canvas) Width() int

type CheckBox

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

func NewCheckBox

func NewCheckBox() *CheckBox

func (*CheckBox) Checked

func (c *CheckBox) Checked() bool

func (*CheckBox) Focus

func (c *CheckBox) Focus()

func (*CheckBox) Font

func (c *CheckBox) Font() *Font

func (*CheckBox) HasFocus

func (c *CheckBox) HasFocus() bool

func (*CheckBox) OnTabFocus

func (c *CheckBox) OnTabFocus() func()

func (*CheckBox) SetChecked

func (c *CheckBox) SetChecked(checked bool)

func (*CheckBox) SetFont

func (c *CheckBox) SetFont(font *Font)

func (*CheckBox) SetOnChange

func (c *CheckBox) SetOnChange(f func(checked bool))

func (*CheckBox) SetOnTabFocus

func (c *CheckBox) SetOnTabFocus(f func())

func (*CheckBox) SetText

func (c *CheckBox) SetText(text string)

func (*CheckBox) SetTextColor added in v0.0.3

func (c *CheckBox) SetTextColor(col Color)

SetTextColor changes the text color. Visual styles are switched off for this check box because themed check boxes ignore the text color.

func (*CheckBox) Text

func (c *CheckBox) Text() string

type Color

type Color uint32

Color is a 24 bit color in BGR form. The alpha channel is always 0 and has no relevance.

func RGB

func RGB(r, g, b uint8) Color

RBG creates a new Color with the given intensities. r,g,b means red, green, blue. Value 0 is dark, 255 is full intensity.

func (Color) B

func (c Color) B() uint8

B returns the blue intensity in the Color, 0 means no blue, 255 means full blue.

func (Color) G

func (c Color) G() uint8

G returns the green intensity in the Color, 0 means no green, 255 means full green.

func (Color) R

func (c Color) R() uint8

R returns the red intensity in the Color, 0 means no red, 255 means full red.

type ColorDialog added in v0.0.2

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

ColorDialog is the system color chooser.

func NewColorDialog added in v0.0.2

func NewColorDialog() *ColorDialog

func (*ColorDialog) Color added in v0.0.2

func (d *ColorDialog) Color() Color

Color returns the color chosen in the last successful Execute.

func (*ColorDialog) Execute added in v0.0.2

func (d *ColorDialog) Execute(parent *Window) bool

Execute shows the dialog (parent may be nil) and returns true if the user confirmed a color, which is then available through Color.

func (*ColorDialog) SetColor added in v0.0.2

func (d *ColorDialog) SetColor(c Color)

SetColor sets the initially selected color.

type ComboBox

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

func NewComboBox

func NewComboBox() *ComboBox

func (*ComboBox) AddItem

func (e *ComboBox) AddItem(s string)

func (*ComboBox) Clear

func (e *ComboBox) Clear()

func (*ComboBox) Focus

func (c *ComboBox) Focus()

func (*ComboBox) Font

func (c *ComboBox) Font() *Font

func (*ComboBox) HasFocus

func (c *ComboBox) HasFocus() bool

func (*ComboBox) Items

func (e *ComboBox) Items() []string

func (*ComboBox) OnTabFocus

func (c *ComboBox) OnTabFocus() func()

func (*ComboBox) SelectedIndex

func (e *ComboBox) SelectedIndex() int

func (*ComboBox) SetFont

func (c *ComboBox) SetFont(font *Font)

func (*ComboBox) SetItems

func (e *ComboBox) SetItems(items []string)

func (*ComboBox) SetOnChange

func (e *ComboBox) SetOnChange(f func(newIndex int))

func (*ComboBox) SetOnTabFocus

func (c *ComboBox) SetOnTabFocus(f func())

func (*ComboBox) SetSelectedIndex

func (e *ComboBox) SetSelectedIndex(i int)

SetSelectedIndex sets the current index. Set -1 to remove any selection and make the combo box empty. If you pass a value < -1 it will be set to -1 instead. The index is not clamped to the number of items, you may set the index 10 where only 5 items are set. This lets you set the index and items at design time without one invalidating the other. At runtime though, SelectedIndex() will return -1 if you set an invalid index.

func (*ComboBox) SetText

func (c *ComboBox) SetText(text string)

func (*ComboBox) Text

func (c *ComboBox) Text() string

type Container

type Container interface {
	Add(Control)
	Remove(Control)
	Children() []Control
	Parent() Container
	Bounds() (x, y, width, height int)
	SetBounds(x, y, width, height int)
	InnerBounds() (x, y, width, height int)
	Font() *Font
	Visible() bool
	Enabled() bool
	// contains filtered or unexported methods
}

type Control

type Control interface {
	Bounds() (x, y, width, height int)
	SetBounds(x, y, width, height int)
	Anchors() (horizontal, vertical Anchor)
	SetHorizontalAnchor(a Anchor)
	SetVerticalAnchor(a Anchor)
	Parent() Container
	Handle() uintptr
	Visible() bool
	Enabled() bool
	// contains filtered or unexported methods
}

type Cursor

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

Cursor describes the mouse cursor image. You can use a pre-defined Cursor... variable (see below) or create a custom cursor with NewCursorFromImage.

func NewCursorFromImage

func NewCursorFromImage(img image.Image, x, y int) (*Cursor, error)

NewCursorFromImage creates a cursor with 4 possible colors: black, white, transparent and inverse screen color. Inverse screen color depends on what is under the cursor at any time. The cursor will be white minus the screen color to give maximum contrast for such pixels.

Fully opaque black and white pixels in the image are interpreted as black and white.

Fully transparent pixels in the image are interpreted as screen color.

All other pixels are interpreted as inverse screen color. This means even "almost" black/white/transparent, say with intensity 0xFFFE instead of 0xFFFF, will be interpreted as inverse screen color.

type DatePicker added in v0.0.2

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

DatePicker is a date (or time) chooser with a drop-down calendar.

func NewDatePicker added in v0.0.2

func NewDatePicker() *DatePicker

func (*DatePicker) Anchors added in v0.0.2

func (c *DatePicker) Anchors() (horizontal, vertical Anchor)

func (*DatePicker) BackgroundColor added in v0.0.3

func (c *DatePicker) BackgroundColor() Color

BackgroundColor returns the color set with SetBackgroundColor. If no color was set it returns the system button face color.

func (*DatePicker) Bounds added in v0.0.2

func (c *DatePicker) Bounds() (x, y, width, height int)

func (*DatePicker) ContextMenu added in v0.0.2

func (c *DatePicker) ContextMenu() *PopupMenu

func (*DatePicker) Enabled added in v0.0.2

func (c *DatePicker) Enabled() bool

func (*DatePicker) Handle added in v0.0.2

func (c *DatePicker) Handle() uintptr

func (*DatePicker) HasBackgroundColor added in v0.0.3

func (c *DatePicker) HasBackgroundColor() bool

HasBackgroundColor returns true if SetBackgroundColor was called.

func (*DatePicker) HasTextColor added in v0.0.3

func (c *DatePicker) HasTextColor() bool

HasTextColor returns true if SetTextColor was called.

func (*DatePicker) Height added in v0.0.2

func (c *DatePicker) Height() int

func (*DatePicker) HorizontalAnchor added in v0.0.2

func (c *DatePicker) HorizontalAnchor() Anchor

func (*DatePicker) Mode added in v0.0.2

func (d *DatePicker) Mode() DatePickerMode

func (*DatePicker) OnChange added in v0.0.2

func (d *DatePicker) OnChange() func(time.Time)

func (*DatePicker) OnDropFiles added in v0.0.3

func (c *DatePicker) OnDropFiles() DropFilesFunc

OnDropFiles returns the handler set with SetOnDropFiles.

func (*DatePicker) OnResize added in v0.0.2

func (c *DatePicker) OnResize() func()

func (*DatePicker) Parent added in v0.0.2

func (c *DatePicker) Parent() Container

func (*DatePicker) Position added in v0.0.2

func (c *DatePicker) Position() (x, y int)

func (*DatePicker) ResetBackgroundColor added in v0.0.3

func (c *DatePicker) ResetBackgroundColor()

ResetBackgroundColor goes back to the default background.

func (*DatePicker) ResetTextColor added in v0.0.3

func (c *DatePicker) ResetTextColor()

ResetTextColor goes back to the system text color.

func (*DatePicker) SetAnchors added in v0.0.2

func (c *DatePicker) SetAnchors(horizontal, vertical Anchor)

func (*DatePicker) SetBackgroundColor added in v0.0.3

func (c *DatePicker) SetBackgroundColor(col Color)

SetBackgroundColor changes the color behind the control's text (or the fill color of a Panel).

func (*DatePicker) SetBounds added in v0.0.2

func (c *DatePicker) SetBounds(x, y, width, height int)

func (*DatePicker) SetContextMenu added in v0.0.2

func (c *DatePicker) SetContextMenu(m *PopupMenu)

SetContextMenu sets the menu that opens when the user right-clicks the control. Not all native controls (e.g. edit boxes) forward right clicks.

func (*DatePicker) SetEnabled added in v0.0.2

func (c *DatePicker) SetEnabled(e bool)

func (*DatePicker) SetHeight added in v0.0.2

func (c *DatePicker) SetHeight(height int)

func (*DatePicker) SetHorizontalAnchor added in v0.0.2

func (c *DatePicker) SetHorizontalAnchor(a Anchor)

func (*DatePicker) SetMode added in v0.0.2

func (d *DatePicker) SetMode(m DatePickerMode)

SetMode must be called before the window is shown.

func (*DatePicker) SetOnChange added in v0.0.2

func (d *DatePicker) SetOnChange(f func(time.Time))

func (*DatePicker) SetOnDropFiles added in v0.0.3

func (c *DatePicker) SetOnDropFiles(f DropFilesFunc)

SetOnDropFiles makes the control a drop target for files dragged from the file explorer.

func (*DatePicker) SetOnResize added in v0.0.2

func (c *DatePicker) SetOnResize(f func())

func (*DatePicker) SetPosition added in v0.0.2

func (c *DatePicker) SetPosition(x, y int)

func (*DatePicker) SetSize added in v0.0.2

func (c *DatePicker) SetSize(width, height int)

func (*DatePicker) SetTextColor added in v0.0.3

func (c *DatePicker) SetTextColor(col Color)

SetTextColor changes the color of the control's text.

func (*DatePicker) SetToolTip added in v0.0.2

func (c *DatePicker) SetToolTip(text string)

SetToolTip sets the hint text shown when the mouse rests over the control. An empty text removes the tool tip. It works for every control.

func (*DatePicker) SetValue added in v0.0.2

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

func (*DatePicker) SetVerticalAnchor added in v0.0.2

func (c *DatePicker) SetVerticalAnchor(a Anchor)

func (*DatePicker) SetVisible added in v0.0.2

func (c *DatePicker) SetVisible(v bool)

func (*DatePicker) SetWidth added in v0.0.2

func (c *DatePicker) SetWidth(width int)

func (*DatePicker) SetX added in v0.0.2

func (c *DatePicker) SetX(x int)

func (*DatePicker) SetY added in v0.0.2

func (c *DatePicker) SetY(y int)

func (*DatePicker) Size added in v0.0.2

func (c *DatePicker) Size() (width, height int)

func (*DatePicker) TextColor added in v0.0.3

func (c *DatePicker) TextColor() Color

TextColor returns the color set with SetTextColor. If no color was set it returns the system window text color.

func (*DatePicker) ToolTip added in v0.0.2

func (c *DatePicker) ToolTip() string

ToolTip returns the hint text of the control.

func (*DatePicker) Value added in v0.0.2

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

Value returns the selected date and time (in the local time zone).

func (*DatePicker) VerticalAnchor added in v0.0.2

func (c *DatePicker) VerticalAnchor() Anchor

func (*DatePicker) Visible added in v0.0.2

func (c *DatePicker) Visible() bool

func (*DatePicker) Width added in v0.0.2

func (c *DatePicker) Width() int

func (*DatePicker) X added in v0.0.2

func (c *DatePicker) X() int

func (*DatePicker) Y added in v0.0.2

func (c *DatePicker) Y() int

type DatePickerMode added in v0.0.2

type DatePickerMode int

DatePickerMode selects what a DatePicker shows.

const (
	DatePickerShortDate DatePickerMode = iota
	DatePickerLongDate
	DatePickerTime
)

func (DatePickerMode) String added in v0.0.3

func (m DatePickerMode) String() string

type DropFilesFunc added in v0.0.3

type DropFilesFunc func(files []string, x, y int)

DropFilesFunc is called when the user drops files from the file explorer onto a window or control. x and y are relative to the top left corner of the window's (or control's) client area.

type EditLine

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

func NewEditLine

func NewEditLine() *EditLine

func (*EditLine) CharacterLimit

func (e *EditLine) CharacterLimit() int

func (*EditLine) CursorPosition

func (c *EditLine) CursorPosition() (start, end int)

CursorPosition returns the current cursor position, respectively the current selection.

If no selection is active, the returned start and end values are the same. They then indicate the index of the UTF-8 character in this EditLine's Text() before which the caret is currently set.

If a selection is active, start is the index of the first selected UTF-8 character in Text() and end is the position one character after the end of the selection. The selected text is thus

c.Text()[start:end]

func (*EditLine) IsPassword

func (e *EditLine) IsPassword() bool

func (*EditLine) OnTabFocus

func (e *EditLine) OnTabFocus() func()

func (*EditLine) OnTextChange

func (e *EditLine) OnTextChange() func()

func (*EditLine) ReadOnly

func (e *EditLine) ReadOnly() bool

func (*EditLine) SelectAll

func (c *EditLine) SelectAll()

func (*EditLine) SetCharacterLimit

func (e *EditLine) SetCharacterLimit(count int)

func (*EditLine) SetCursorPosition

func (c *EditLine) SetCursorPosition(pos int)

func (*EditLine) SetIsPassword

func (e *EditLine) SetIsPassword(isPassword bool)

func (*EditLine) SetOnTabFocus

func (e *EditLine) SetOnTabFocus(f func())

func (*EditLine) SetOnTextChange

func (e *EditLine) SetOnTextChange(f func())

func (*EditLine) SetReadOnly

func (e *EditLine) SetReadOnly(readOnly bool)

func (*EditLine) SetSelection

func (c *EditLine) SetSelection(start, end int)

type EnabledControl

type EnabledControl interface {
	Enabled() bool
	Parent() Container
}

type FileOpenDialog

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

func NewFileOpenDialog

func NewFileOpenDialog() *FileOpenDialog

func (*FileOpenDialog) AddFilter

func (dlg *FileOpenDialog) AddFilter(text, ext1 string, exts ...string)

func (*FileOpenDialog) ExecuteMultiSelection

func (dlg *FileOpenDialog) ExecuteMultiSelection(parent *Window) (bool, []string)

func (*FileOpenDialog) ExecuteSingleSelection

func (dlg *FileOpenDialog) ExecuteSingleSelection(parent *Window) (bool, string)

func (*FileOpenDialog) SetFilterIndex

func (dlg *FileOpenDialog) SetFilterIndex(i int)

SetFilterIndex sets the active filter, 0-indexed.

func (*FileOpenDialog) SetInitialPath

func (dlg *FileOpenDialog) SetInitialPath(path string)

func (*FileOpenDialog) SetTitle

func (dlg *FileOpenDialog) SetTitle(title string)

type FileSaveDialog

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

func NewFileSaveDialog

func NewFileSaveDialog() *FileSaveDialog

func (*FileSaveDialog) AddFilter

func (dlg *FileSaveDialog) AddFilter(text, ext1 string, exts ...string)

func (*FileSaveDialog) Execute

func (dlg *FileSaveDialog) Execute(parent *Window) (bool, string)

func (*FileSaveDialog) SetAppendExt

func (dlg *FileSaveDialog) SetAppendExt(ext bool)

func (*FileSaveDialog) SetFilterIndex

func (dlg *FileSaveDialog) SetFilterIndex(i int)

SetFilterIndex sets the active filter, 0-indexed.

func (*FileSaveDialog) SetInitialPath

func (dlg *FileSaveDialog) SetInitialPath(path string)

func (*FileSaveDialog) SetTitle

func (dlg *FileSaveDialog) SetTitle(title string)

type FloatUpDown

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

func NewFloatUpDown

func NewFloatUpDown() *FloatUpDown

func (*FloatUpDown) CursorPosition

func (c *FloatUpDown) CursorPosition() (start, end int)

CursorPosition returns the current cursor position, respectively the current selection.

If no selection is active, the returned start and end values are the same. They then indicate the index of the UTF-8 character in this EditLine's Text() before which the caret is currently set.

If a selection is active, start is the index of the first selected UTF-8 character in Text() and end is the position one character after the end of the selection. The selected text is thus

c.Text()[start:end]

func (*FloatUpDown) Max

func (n *FloatUpDown) Max() float64

func (*FloatUpDown) Min

func (n *FloatUpDown) Min() float64

func (*FloatUpDown) MinMax

func (n *FloatUpDown) MinMax() (min, max float64)

func (*FloatUpDown) OnTabFocus

func (n *FloatUpDown) OnTabFocus() func()

func (*FloatUpDown) OnValueChange

func (n *FloatUpDown) OnValueChange() func(value float64)

func (*FloatUpDown) Precision

func (n *FloatUpDown) Precision() int

func (*FloatUpDown) SelectAll

func (c *FloatUpDown) SelectAll()

func (*FloatUpDown) SetBounds

func (n *FloatUpDown) SetBounds(x, y, width, height int)

func (*FloatUpDown) SetCursorPosition

func (c *FloatUpDown) SetCursorPosition(pos int)

func (*FloatUpDown) SetHeight

func (n *FloatUpDown) SetHeight(height int)

func (*FloatUpDown) SetMax

func (n *FloatUpDown) SetMax(max float64)

func (*FloatUpDown) SetMin

func (n *FloatUpDown) SetMin(min float64)

func (*FloatUpDown) SetMinMax

func (n *FloatUpDown) SetMinMax(min, max float64)

func (*FloatUpDown) SetOnTabFocus

func (n *FloatUpDown) SetOnTabFocus(f func())

func (*FloatUpDown) SetOnValueChange

func (n *FloatUpDown) SetOnValueChange(f func(value float64))

func (*FloatUpDown) SetPos

func (n *FloatUpDown) SetPos(x, y int)

func (*FloatUpDown) SetPrecision

func (n *FloatUpDown) SetPrecision(p int)

func (*FloatUpDown) SetSelection

func (c *FloatUpDown) SetSelection(start, end int)

func (*FloatUpDown) SetSize

func (n *FloatUpDown) SetSize(width, height int)

func (*FloatUpDown) SetValue

func (n *FloatUpDown) SetValue(f float64)

SetValue does not accept NaN (not a number). It does accept infinity, the user can type "+inf" or "-inf".

func (*FloatUpDown) SetWidth

func (n *FloatUpDown) SetWidth(width int)

func (*FloatUpDown) SetX

func (n *FloatUpDown) SetX(x int)

func (*FloatUpDown) SetY

func (n *FloatUpDown) SetY(y int)

func (*FloatUpDown) Value

func (n *FloatUpDown) Value() float64

type FolderSelectDialog

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

func NewFolderSelectDialog

func NewFolderSelectDialog() *FolderSelectDialog

func (*FolderSelectDialog) Execute

func (dlg *FolderSelectDialog) Execute(parent *Window) (bool, string)

func (*FolderSelectDialog) SetTitle

func (dlg *FolderSelectDialog) SetTitle(title string)

type Font

type Font struct {
	Desc FontDesc
	// contains filtered or unexported fields
}

func NewFont

func NewFont(desc FontDesc) (*Font, error)

NewFont returns a font according to the given description and an error. The error might be NoExactFontMatch in which case the returned Font is valid, but the system did not find an exact match. In case the creation fails, the returned Font is nil and the error gives the reason.

type FontDesc

type FontDesc struct {
	Name       string
	Height     int
	Bold       bool
	Italic     bool
	Underlined bool
	StrikedOut bool
}

type Format

type Format int
const (
	FormatTopLeft Format = iota
	FormatCenterLeft
	FormatBottomLeft
	FormatTopCenter
	FormatCenter
	FormatBottomCenter
	FormatTopRight
	FormatCenterRight
	FormatBottomRight
)

type GroupBox added in v0.0.2

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

func NewGroupBox added in v0.0.2

func NewGroupBox() *GroupBox

NewGroupBox creates a framed box with a caption. A GroupBox is a visual grouping only: place other controls on top of it (add the GroupBox to its parent first, then the controls that should appear inside it).

func (*GroupBox) Focus added in v0.0.2

func (c *GroupBox) Focus()

func (*GroupBox) Font added in v0.0.2

func (c *GroupBox) Font() *Font

func (*GroupBox) HasFocus added in v0.0.2

func (c *GroupBox) HasFocus() bool

func (*GroupBox) SetFont added in v0.0.2

func (c *GroupBox) SetFont(font *Font)

func (*GroupBox) SetText added in v0.0.2

func (c *GroupBox) SetText(text string)

func (*GroupBox) SetTextColor added in v0.0.3

func (g *GroupBox) SetTextColor(col Color)

SetTextColor changes the caption color. Visual styles are switched off for this group box because themed group boxes ignore the text color.

func (*GroupBox) Text added in v0.0.2

func (c *GroupBox) Text() string

type Icon

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

Icon holds a window icon. You can use a pre-defined Icon... variable (see below) or create a custom icon with NewIconFromImage, NewIconFromExeResource, NewIconFromFile or NewIconFromReader.

func NewIconFromExeResource

func NewIconFromExeResource(resourceID int) (*Icon, error)

NewIconFromExeResource loads an icon that was compiled into the executable. In Go you can create .syso files that contain resources. Each resource will get a unique ID. See for example the rsrc tool which can create .syso files: https://github.com/gonutz/rsrc

func NewIconFromFile

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

NewIconFromFile loads an icon from disk. The format must be .ico, not an image.

func NewIconFromImage

func NewIconFromImage(img image.Image) (*Icon, error)

IconInformation creates an icon from an image. The image should have a standard icon size, typically square and a power of 2, see https://docs.microsoft.com/en-us/windows/win32/uxguide/vis-icons

func NewIconFromReader

func NewIconFromReader(r io.Reader) (*Icon, error)

NewIconFromReader loads an icon from the given reader. The format must be .ico, not an image.

type Image

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

func NewImage

func NewImage(img image.Image) *Image

func NewImageFromHBITMAP

func NewImageFromHBITMAP(bitmap uintptr, width, height int) *Image

NewImageFromHBITMAP takes a handle to a bitmap (HBITMAP) and makes it an Image that you can use in Canvas.DrawImage.

func (*Image) Bounds

func (img *Image) Bounds() Rectangle

func (*Image) Height

func (img *Image) Height() int

func (*Image) Size

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

func (*Image) Width

func (img *Image) Width() int

type IntUpDown

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

func NewIntUpDown

func NewIntUpDown() *IntUpDown

func (*IntUpDown) CursorPosition

func (c *IntUpDown) CursorPosition() (start, end int)

CursorPosition returns the current cursor position, respectively the current selection.

If no selection is active, the returned start and end values are the same. They then indicate the index of the UTF-8 character in this EditLine's Text() before which the caret is currently set.

If a selection is active, start is the index of the first selected UTF-8 character in Text() and end is the position one character after the end of the selection. The selected text is thus

c.Text()[start:end]

func (*IntUpDown) Max

func (n *IntUpDown) Max() int

func (*IntUpDown) Min

func (n *IntUpDown) Min() int

func (*IntUpDown) MinMax

func (n *IntUpDown) MinMax() (min, max int)

func (*IntUpDown) OnTabFocus

func (n *IntUpDown) OnTabFocus() func()

func (*IntUpDown) OnValueChange

func (n *IntUpDown) OnValueChange() func(value int)

func (*IntUpDown) SelectAll

func (c *IntUpDown) SelectAll()

func (*IntUpDown) SetBounds

func (n *IntUpDown) SetBounds(x, y, width, height int)

func (*IntUpDown) SetCursorPosition

func (c *IntUpDown) SetCursorPosition(pos int)

func (*IntUpDown) SetHeight

func (n *IntUpDown) SetHeight(height int)

func (*IntUpDown) SetMax

func (n *IntUpDown) SetMax(max int)

func (*IntUpDown) SetMin

func (n *IntUpDown) SetMin(min int)

func (*IntUpDown) SetMinMax

func (n *IntUpDown) SetMinMax(min, max int)

func (*IntUpDown) SetOnTabFocus

func (n *IntUpDown) SetOnTabFocus(f func())

func (*IntUpDown) SetOnValueChange

func (n *IntUpDown) SetOnValueChange(f func(value int))

func (*IntUpDown) SetPos

func (n *IntUpDown) SetPos(x, y int)

func (*IntUpDown) SetSelection

func (c *IntUpDown) SetSelection(start, end int)

func (*IntUpDown) SetSize

func (n *IntUpDown) SetSize(width, height int)

func (*IntUpDown) SetValue

func (n *IntUpDown) SetValue(v int)

func (*IntUpDown) SetVisible

func (n *IntUpDown) SetVisible(v bool)

func (*IntUpDown) SetWidth

func (n *IntUpDown) SetWidth(width int)

func (*IntUpDown) SetX

func (n *IntUpDown) SetX(x int)

func (*IntUpDown) SetY

func (n *IntUpDown) SetY(y int)

func (*IntUpDown) Value

func (n *IntUpDown) Value() int

type Key

type Key int

Key represents a button on a keyboard. See the constants below.

type Label

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

func NewLabel

func NewLabel() *Label

func (*Label) Alignment

func (l *Label) Alignment() TextAlignment

func (*Label) Focus

func (c *Label) Focus()

func (*Label) Font

func (c *Label) Font() *Font

func (*Label) HasFocus

func (c *Label) HasFocus() bool

func (*Label) SetAlignment

func (l *Label) SetAlignment(a TextAlignment)

func (*Label) SetFont

func (c *Label) SetFont(font *Font)

func (*Label) SetText

func (c *Label) SetText(text string)

func (*Label) Text

func (c *Label) Text() string

type LineCap added in v0.0.2

type LineCap int

LineCap is the shape of the ends of wide lines.

const (
	CapRound LineCap = iota
	CapSquare
	CapFlat
)

type LineJoin added in v0.0.2

type LineJoin int

LineJoin is the shape of the corners of wide lines.

const (
	JoinRound LineJoin = iota
	JoinBevel
	JoinMiter
)

type LineStyle added in v0.0.2

type LineStyle int

LineStyle is the dash pattern of lines, see Canvas.SetStroke.

const (
	LineSolid LineStyle = iota
	LineDash
	LineDot
	LineDashDot
	LineDashDotDot
)
type Menu struct {
	// contains filtered or unexported fields
}

Menu is a named container for MenuItems. It is not executable, clicking a Menu will expand it and show its children. See NewMainMenu and NewMenu.

func NewMainMenu

func NewMainMenu() *Menu

NewMainMenu returns a new menu bar that can be added to a Window. You can add sub-menus to it with Menu.Add.

func NewMenu

func NewMenu(name string) *Menu

NewMenu returns a new Menu with the given text. Add MenuItems to it using Menu.Add.

Place an ampersand in the name to underline the following character, e.g. "&File" to underline the "F". This will be the character used when the user uses the alt and arrow keys to navigate the menu.

func (m *Menu) Add(item MenuItem) *Menu

Add appends the given MenuItem to the Menu.

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

MenuItem is something that can go into a menu. Possible such things can be created via: NewMenu, NewMenuString, NewMenuSeparator.

func NewMenuSeparator

func NewMenuSeparator() MenuItem

NewMenuSeparator returns a horizontal line separating regions in a menu.

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

MenuString is an executable menu item, see NewMenuString.

func NewMenuString

func NewMenuString(text string) *MenuString

NewMenuString creates a new executable menu item with the given text.

Insert an ampersand to underline the following character, e.g. "New &File" to underline the "F". This will be the character used when the user uses the alt and arrow keys to navigate the menu.

If you want to display a shortcut text next to the menu, right aligned, insert a tab and then your text, e.g. "Open File\tCtrl+O" to have "Open File" on the left and "Ctrl+O" on the right.

func (m *MenuString) Checked() bool
func (m *MenuString) OnClick() func()
func (m *MenuString) SetChecked(c bool)
func (m *MenuString) SetOnClick(f func()) *MenuString
func (m *MenuString) SetText(s string)
func (m *MenuString) Text() string

type MessageCallback

type MessageCallback func(window uintptr, msg uint32, w, l uintptr) (handled bool, result uintptr)

MessageCallback is used as a hook into the main window procedure. It will run at its very start and may intercept all messages. If the callback returns true for handled, then the message is processed no further and the message loop returns the given result code. If the callback returns false for handled, then the message goes to this library's handler for it or to the default window procedure defined in the Windows API if it is not handled.

type MouseButton

type MouseButton int
const (
	MouseButtonLeft MouseButton = iota
	MouseButtonMiddle
	MouseButtonRight
)

func (MouseButton) String

func (b MouseButton) String() string

type PaintBox

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

func NewPaintBox

func NewPaintBox() *PaintBox

func (*PaintBox) Anchors

func (c *PaintBox) Anchors() (horizontal, vertical Anchor)

func (*PaintBox) BackgroundColor added in v0.0.3

func (c *PaintBox) BackgroundColor() Color

BackgroundColor returns the color set with SetBackgroundColor. If no color was set it returns the system button face color.

func (*PaintBox) Bounds

func (c *PaintBox) Bounds() (x, y, width, height int)

func (*PaintBox) ContextMenu added in v0.0.2

func (c *PaintBox) ContextMenu() *PopupMenu

func (*PaintBox) Enabled

func (c *PaintBox) Enabled() bool

func (*PaintBox) Handle

func (c *PaintBox) Handle() uintptr

func (*PaintBox) HasBackgroundColor added in v0.0.3

func (c *PaintBox) HasBackgroundColor() bool

HasBackgroundColor returns true if SetBackgroundColor was called.

func (*PaintBox) HasTextColor added in v0.0.3

func (c *PaintBox) HasTextColor() bool

HasTextColor returns true if SetTextColor was called.

func (*PaintBox) Height

func (c *PaintBox) Height() int

func (*PaintBox) HorizontalAnchor

func (c *PaintBox) HorizontalAnchor() Anchor

func (*PaintBox) OnDoubleClick added in v0.0.2

func (p *PaintBox) OnDoubleClick() func(x, y int, button MouseButton)

func (*PaintBox) OnDropFiles added in v0.0.3

func (c *PaintBox) OnDropFiles() DropFilesFunc

OnDropFiles returns the handler set with SetOnDropFiles.

func (*PaintBox) OnMouseDown added in v0.0.2

func (p *PaintBox) OnMouseDown() func(x, y int, button MouseButton)

func (*PaintBox) OnMouseMove

func (p *PaintBox) OnMouseMove() func(x, y int)

func (*PaintBox) OnMouseUp added in v0.0.2

func (p *PaintBox) OnMouseUp() func(x, y int, button MouseButton)

func (*PaintBox) OnPaint

func (p *PaintBox) OnPaint() func(*Canvas)

func (*PaintBox) OnResize

func (c *PaintBox) OnResize() func()

func (*PaintBox) Paint

func (p *PaintBox) Paint()

func (*PaintBox) Parent

func (c *PaintBox) Parent() Container

func (*PaintBox) Position

func (c *PaintBox) Position() (x, y int)

func (*PaintBox) ResetBackgroundColor added in v0.0.3

func (c *PaintBox) ResetBackgroundColor()

ResetBackgroundColor goes back to the default background.

func (*PaintBox) ResetTextColor added in v0.0.3

func (c *PaintBox) ResetTextColor()

ResetTextColor goes back to the system text color.

func (*PaintBox) SetAnchors

func (c *PaintBox) SetAnchors(horizontal, vertical Anchor)

func (*PaintBox) SetBackgroundColor added in v0.0.3

func (c *PaintBox) SetBackgroundColor(col Color)

SetBackgroundColor changes the color behind the control's text (or the fill color of a Panel).

func (*PaintBox) SetBounds

func (c *PaintBox) SetBounds(x, y, width, height int)

func (*PaintBox) SetContextMenu added in v0.0.2

func (c *PaintBox) SetContextMenu(m *PopupMenu)

SetContextMenu sets the menu that opens when the user right-clicks the control. Not all native controls (e.g. edit boxes) forward right clicks.

func (*PaintBox) SetEnabled

func (c *PaintBox) SetEnabled(e bool)

func (*PaintBox) SetHeight

func (c *PaintBox) SetHeight(height int)

func (*PaintBox) SetHorizontalAnchor

func (c *PaintBox) SetHorizontalAnchor(a Anchor)

func (*PaintBox) SetOnDoubleClick added in v0.0.2

func (p *PaintBox) SetOnDoubleClick(f func(x, y int, button MouseButton))

SetOnDoubleClick sets the function called on a double click. Without it a double click is reported as a second mouse down.

func (*PaintBox) SetOnDropFiles added in v0.0.3

func (c *PaintBox) SetOnDropFiles(f DropFilesFunc)

SetOnDropFiles makes the control a drop target for files dragged from the file explorer.

func (*PaintBox) SetOnMouseDown added in v0.0.2

func (p *PaintBox) SetOnMouseDown(f func(x, y int, button MouseButton))

SetOnMouseDown sets the function called when a mouse button is pressed in the PaintBox. While the button is held, mouse move events keep coming even when the mouse leaves the PaintBox, so dragging works.

func (*PaintBox) SetOnMouseMove

func (p *PaintBox) SetOnMouseMove(f func(x, y int))

func (*PaintBox) SetOnMouseUp added in v0.0.2

func (p *PaintBox) SetOnMouseUp(f func(x, y int, button MouseButton))

SetOnMouseUp sets the function called when a mouse button is released.

func (*PaintBox) SetOnPaint

func (p *PaintBox) SetOnPaint(f func(*Canvas))

func (*PaintBox) SetOnResize

func (c *PaintBox) SetOnResize(f func())

func (*PaintBox) SetPosition

func (c *PaintBox) SetPosition(x, y int)

func (*PaintBox) SetSize

func (c *PaintBox) SetSize(width, height int)

func (*PaintBox) SetTextColor added in v0.0.3

func (c *PaintBox) SetTextColor(col Color)

SetTextColor changes the color of the control's text.

func (*PaintBox) SetToolTip added in v0.0.2

func (c *PaintBox) SetToolTip(text string)

SetToolTip sets the hint text shown when the mouse rests over the control. An empty text removes the tool tip. It works for every control.

func (*PaintBox) SetVerticalAnchor

func (c *PaintBox) SetVerticalAnchor(a Anchor)

func (*PaintBox) SetVisible

func (c *PaintBox) SetVisible(v bool)

func (*PaintBox) SetWidth

func (c *PaintBox) SetWidth(width int)

func (*PaintBox) SetX

func (c *PaintBox) SetX(x int)

func (*PaintBox) SetY

func (c *PaintBox) SetY(y int)

func (*PaintBox) Size

func (c *PaintBox) Size() (width, height int)

func (*PaintBox) TextColor added in v0.0.3

func (c *PaintBox) TextColor() Color

TextColor returns the color set with SetTextColor. If no color was set it returns the system window text color.

func (*PaintBox) ToolTip added in v0.0.2

func (c *PaintBox) ToolTip() string

ToolTip returns the hint text of the control.

func (*PaintBox) VerticalAnchor

func (c *PaintBox) VerticalAnchor() Anchor

func (*PaintBox) Visible

func (c *PaintBox) Visible() bool

func (*PaintBox) Width

func (c *PaintBox) Width() int

func (*PaintBox) X

func (c *PaintBox) X() int

func (*PaintBox) Y

func (c *PaintBox) Y() int

type Panel

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

func NewPanel

func NewPanel() *Panel

func (*Panel) Add

func (p *Panel) Add(c Control)

func (*Panel) Anchors

func (c *Panel) Anchors() (horizontal, vertical Anchor)

func (*Panel) BackgroundColor added in v0.0.3

func (c *Panel) BackgroundColor() Color

BackgroundColor returns the color set with SetBackgroundColor. If no color was set it returns the system button face color.

func (*Panel) BorderStyle

func (p *Panel) BorderStyle() PanelBorderStyle

func (*Panel) Bounds

func (c *Panel) Bounds() (x, y, width, height int)

func (*Panel) Children

func (p *Panel) Children() []Control

func (*Panel) ContextMenu added in v0.0.2

func (c *Panel) ContextMenu() *PopupMenu

func (*Panel) Enabled

func (c *Panel) Enabled() bool

func (*Panel) Font

func (p *Panel) Font() *Font

func (*Panel) Handle

func (c *Panel) Handle() uintptr

func (*Panel) HasBackgroundColor added in v0.0.3

func (c *Panel) HasBackgroundColor() bool

HasBackgroundColor returns true if SetBackgroundColor was called.

func (*Panel) HasTextColor added in v0.0.3

func (c *Panel) HasTextColor() bool

HasTextColor returns true if SetTextColor was called.

func (*Panel) Height

func (c *Panel) Height() int

func (*Panel) HorizontalAnchor

func (c *Panel) HorizontalAnchor() Anchor

func (*Panel) InnerBounds

func (p *Panel) InnerBounds() (x, y, width, height int)

func (*Panel) InnerHeight

func (p *Panel) InnerHeight() int

func (*Panel) InnerPosition

func (p *Panel) InnerPosition() (x, y int)

func (*Panel) InnerSize

func (p *Panel) InnerSize() (width, height int)

func (*Panel) InnerWidth

func (p *Panel) InnerWidth() int

func (*Panel) InnerX

func (p *Panel) InnerX() int

func (*Panel) InnerY

func (p *Panel) InnerY() int

func (*Panel) OnDropFiles added in v0.0.3

func (c *Panel) OnDropFiles() DropFilesFunc

OnDropFiles returns the handler set with SetOnDropFiles.

func (*Panel) OnResize

func (c *Panel) OnResize() func()

func (*Panel) Parent

func (c *Panel) Parent() Container

func (*Panel) Position

func (c *Panel) Position() (x, y int)

func (*Panel) Remove

func (p *Panel) Remove(c Control)

func (*Panel) ResetBackgroundColor added in v0.0.3

func (c *Panel) ResetBackgroundColor()

ResetBackgroundColor goes back to the default background.

func (*Panel) ResetTextColor added in v0.0.3

func (c *Panel) ResetTextColor()

ResetTextColor goes back to the system text color.

func (*Panel) SetAnchors

func (c *Panel) SetAnchors(horizontal, vertical Anchor)

func (*Panel) SetBackgroundColor added in v0.0.3

func (c *Panel) SetBackgroundColor(col Color)

SetBackgroundColor changes the color behind the control's text (or the fill color of a Panel).

func (*Panel) SetBorderStyle

func (p *Panel) SetBorderStyle(s PanelBorderStyle)

func (*Panel) SetBounds

func (p *Panel) SetBounds(x, y, width, height int)

func (*Panel) SetContextMenu added in v0.0.2

func (c *Panel) SetContextMenu(m *PopupMenu)

SetContextMenu sets the menu that opens when the user right-clicks the control. Not all native controls (e.g. edit boxes) forward right clicks.

func (*Panel) SetEnabled

func (c *Panel) SetEnabled(e bool)

func (*Panel) SetFont

func (p *Panel) SetFont(f *Font)

func (*Panel) SetHeight

func (p *Panel) SetHeight(height int)

func (*Panel) SetHorizontalAnchor

func (c *Panel) SetHorizontalAnchor(a Anchor)

func (*Panel) SetInnerBounds

func (p *Panel) SetInnerBounds(x, y, width, height int)

func (*Panel) SetInnerHeight

func (p *Panel) SetInnerHeight(height int)

func (*Panel) SetInnerPosition

func (p *Panel) SetInnerPosition(x, y int)

func (*Panel) SetInnerSize

func (p *Panel) SetInnerSize(width, height int)

func (*Panel) SetInnerWidth

func (p *Panel) SetInnerWidth(width int)

func (*Panel) SetInnerX

func (p *Panel) SetInnerX(x int)

func (*Panel) SetInnerY

func (p *Panel) SetInnerY(y int)

func (*Panel) SetOnDropFiles added in v0.0.3

func (c *Panel) SetOnDropFiles(f DropFilesFunc)

SetOnDropFiles makes the control a drop target for files dragged from the file explorer.

func (*Panel) SetOnResize

func (c *Panel) SetOnResize(f func())

func (*Panel) SetPosition

func (p *Panel) SetPosition(x, y int)

func (*Panel) SetSize

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

func (*Panel) SetTextColor added in v0.0.3

func (c *Panel) SetTextColor(col Color)

SetTextColor changes the color of the control's text.

func (*Panel) SetToolTip added in v0.0.2

func (c *Panel) SetToolTip(text string)

SetToolTip sets the hint text shown when the mouse rests over the control. An empty text removes the tool tip. It works for every control.

func (*Panel) SetVerticalAnchor

func (c *Panel) SetVerticalAnchor(a Anchor)

func (*Panel) SetVisible

func (c *Panel) SetVisible(v bool)

func (*Panel) SetWidth

func (p *Panel) SetWidth(width int)

func (*Panel) SetX

func (p *Panel) SetX(x int)

func (*Panel) SetY

func (p *Panel) SetY(y int)

func (*Panel) Size

func (c *Panel) Size() (width, height int)

func (*Panel) TextColor added in v0.0.3

func (c *Panel) TextColor() Color

TextColor returns the color set with SetTextColor. If no color was set it returns the system window text color.

func (*Panel) ToolTip added in v0.0.2

func (c *Panel) ToolTip() string

ToolTip returns the hint text of the control.

func (*Panel) VerticalAnchor

func (c *Panel) VerticalAnchor() Anchor

func (*Panel) Visible

func (c *Panel) Visible() bool

func (*Panel) Width

func (c *Panel) Width() int

func (*Panel) X

func (c *Panel) X() int

func (*Panel) Y

func (c *Panel) Y() int

type PanelBorderStyle

type PanelBorderStyle int
const (
	PanelBorderNone PanelBorderStyle = iota
	PanelBorderSingleLine
	PanelBorderSunken
	PanelBorderSunkenThick
	PanelBorderRaised
)

func (PanelBorderStyle) String

func (s PanelBorderStyle) String() string

type Point

type Point struct {
	X, Y int32
}

func RegularPolygonPoints added in v0.0.2

func RegularPolygonPoints(cx, cy, radius float64, sides int, rotationDegrees float64) []Point

RegularPolygonPoints returns the corners of a regular polygon (3 sides is a triangle, 6 a hexagon, ...). With rotationDegrees 0 the first corner points up. Use the result with Polygon, DrawPolygon or FillPolygonOutline.

func StarPoints added in v0.0.2

func StarPoints(cx, cy, outerRadius, innerRadius float64, tips int, rotationDegrees float64) []Point

StarPoints returns the corners of a star with the given number of tips.

type PopupMenu added in v0.0.2

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

func NewPopupMenu added in v0.0.2

func NewPopupMenu() *PopupMenu

NewPopupMenu creates a context menu. Fill it with the same items as normal menus: NewMenuString, NewMenuSeparator and sub-menus created with NewMenu.

Show it with PopupMenu.Show or attach it to a window with Window.SetContextMenu or to any control with SetContextMenu, then it opens on right click.

func (*PopupMenu) Add added in v0.0.2

func (m *PopupMenu) Add(item MenuItem) *PopupMenu

Add appends an item to the menu.

func (*PopupMenu) Show added in v0.0.2

func (m *PopupMenu) Show(parent *Window, x, y int)

Show opens the menu at a position in the client coordinates of the window.

func (*PopupMenu) ShowAtCursor added in v0.0.2

func (m *PopupMenu) ShowAtCursor(parent *Window)

ShowAtCursor opens the menu at the current mouse position.

func (*PopupMenu) ShowAtScreen added in v0.0.2

func (m *PopupMenu) ShowAtScreen(parent *Window, screenX, screenY int)

ShowAtScreen opens the menu at the given screen position and runs the OnClick function of the chosen item. It returns after the menu is closed.

type ProgressBar

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

func NewProgressBar

func NewProgressBar() *ProgressBar

func (*ProgressBar) Anchors

func (c *ProgressBar) Anchors() (horizontal, vertical Anchor)

func (*ProgressBar) BackgroundColor added in v0.0.3

func (c *ProgressBar) BackgroundColor() Color

BackgroundColor returns the color set with SetBackgroundColor. If no color was set it returns the system button face color.

func (*ProgressBar) Bounds

func (c *ProgressBar) Bounds() (x, y, width, height int)

func (*ProgressBar) ContextMenu added in v0.0.2

func (c *ProgressBar) ContextMenu() *PopupMenu

func (*ProgressBar) Enabled

func (c *ProgressBar) Enabled() bool

func (*ProgressBar) Handle

func (c *ProgressBar) Handle() uintptr

func (*ProgressBar) HasBackgroundColor added in v0.0.3

func (c *ProgressBar) HasBackgroundColor() bool

HasBackgroundColor returns true if SetBackgroundColor was called.

func (*ProgressBar) HasTextColor added in v0.0.3

func (c *ProgressBar) HasTextColor() bool

HasTextColor returns true if SetTextColor was called.

func (*ProgressBar) Height

func (c *ProgressBar) Height() int

func (*ProgressBar) HorizontalAnchor

func (c *ProgressBar) HorizontalAnchor() Anchor

func (*ProgressBar) MovesForever

func (p *ProgressBar) MovesForever() bool

func (*ProgressBar) OnDropFiles added in v0.0.3

func (c *ProgressBar) OnDropFiles() DropFilesFunc

OnDropFiles returns the handler set with SetOnDropFiles.

func (*ProgressBar) OnResize

func (c *ProgressBar) OnResize() func()

func (*ProgressBar) Parent

func (c *ProgressBar) Parent() Container

func (*ProgressBar) Position

func (c *ProgressBar) Position() (x, y int)

func (*ProgressBar) ResetBackgroundColor added in v0.0.3

func (c *ProgressBar) ResetBackgroundColor()

ResetBackgroundColor goes back to the default background.

func (*ProgressBar) ResetTextColor added in v0.0.3

func (c *ProgressBar) ResetTextColor()

ResetTextColor goes back to the system text color.

func (*ProgressBar) SetAnchors

func (c *ProgressBar) SetAnchors(horizontal, vertical Anchor)

func (*ProgressBar) SetBackgroundColor added in v0.0.3

func (c *ProgressBar) SetBackgroundColor(col Color)

SetBackgroundColor changes the color behind the control's text (or the fill color of a Panel).

func (*ProgressBar) SetBounds

func (c *ProgressBar) SetBounds(x, y, width, height int)

func (*ProgressBar) SetContextMenu added in v0.0.2

func (c *ProgressBar) SetContextMenu(m *PopupMenu)

SetContextMenu sets the menu that opens when the user right-clicks the control. Not all native controls (e.g. edit boxes) forward right clicks.

func (*ProgressBar) SetEnabled

func (c *ProgressBar) SetEnabled(e bool)

func (*ProgressBar) SetHeight

func (c *ProgressBar) SetHeight(height int)

func (*ProgressBar) SetHorizontalAnchor

func (c *ProgressBar) SetHorizontalAnchor(a Anchor)

func (*ProgressBar) SetMovesForever

func (p *ProgressBar) SetMovesForever(move bool)

func (*ProgressBar) SetOnDropFiles added in v0.0.3

func (c *ProgressBar) SetOnDropFiles(f DropFilesFunc)

SetOnDropFiles makes the control a drop target for files dragged from the file explorer.

func (*ProgressBar) SetOnResize

func (c *ProgressBar) SetOnResize(f func())

func (*ProgressBar) SetPosition

func (c *ProgressBar) SetPosition(x, y int)

func (*ProgressBar) SetSize

func (c *ProgressBar) SetSize(width, height int)

func (*ProgressBar) SetTextColor added in v0.0.3

func (c *ProgressBar) SetTextColor(col Color)

SetTextColor changes the color of the control's text.

func (*ProgressBar) SetToolTip added in v0.0.2

func (c *ProgressBar) SetToolTip(text string)

SetToolTip sets the hint text shown when the mouse rests over the control. An empty text removes the tool tip. It works for every control.

func (*ProgressBar) SetValue

func (p *ProgressBar) SetValue(v float64)

func (*ProgressBar) SetVertical

func (p *ProgressBar) SetVertical(v bool)

func (*ProgressBar) SetVerticalAnchor

func (c *ProgressBar) SetVerticalAnchor(a Anchor)

func (*ProgressBar) SetVisible

func (c *ProgressBar) SetVisible(v bool)

func (*ProgressBar) SetWidth

func (c *ProgressBar) SetWidth(width int)

func (*ProgressBar) SetX

func (c *ProgressBar) SetX(x int)

func (*ProgressBar) SetY

func (c *ProgressBar) SetY(y int)

func (*ProgressBar) Size

func (c *ProgressBar) Size() (width, height int)

func (*ProgressBar) TextColor added in v0.0.3

func (c *ProgressBar) TextColor() Color

TextColor returns the color set with SetTextColor. If no color was set it returns the system window text color.

func (*ProgressBar) ToolTip added in v0.0.2

func (c *ProgressBar) ToolTip() string

ToolTip returns the hint text of the control.

func (*ProgressBar) Value

func (p *ProgressBar) Value() float64

func (*ProgressBar) Vertical

func (p *ProgressBar) Vertical() bool

func (*ProgressBar) VerticalAnchor

func (c *ProgressBar) VerticalAnchor() Anchor

func (*ProgressBar) Visible

func (c *ProgressBar) Visible() bool

func (*ProgressBar) Width

func (c *ProgressBar) Width() int

func (*ProgressBar) X

func (c *ProgressBar) X() int

func (*ProgressBar) Y

func (c *ProgressBar) Y() int

type RadioButton

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

RadioButton is a control with a circle that is either filled to indicate checked state or unfilled to indicate unchecked state. It has a label next to the circle. Of multiple radio buttons in a container, only one can ever be checked at a time. Also all might be unchecked. Checking one radio button will automatically uncheck all others in the container.

func NewRadioButton

func NewRadioButton() *RadioButton

NewRadioButton returns a new, unchecked RadioButton.

func (*RadioButton) Checked

func (r *RadioButton) Checked() bool

Checked returns true if the radio button is checked and false if not.

func (*RadioButton) Focus

func (c *RadioButton) Focus()

func (*RadioButton) Font

func (c *RadioButton) Font() *Font

func (*RadioButton) HasFocus

func (c *RadioButton) HasFocus() bool

func (*RadioButton) OnCheck

func (r *RadioButton) OnCheck() func(checked bool)

OnCheck returns the callback set in SetOnCheck.

func (*RadioButton) OnTabFocus

func (r *RadioButton) OnTabFocus() func()

func (*RadioButton) SetChecked

func (r *RadioButton) SetChecked(checked bool)

SetChecked updates the state of the RadioButton. If checked is true and the button was not checked before, the OnCheck notification is called. Checking a radio button will uncheck all its siblings, i.e. all radio buttons that are in the same parent container.

func (*RadioButton) SetFont

func (c *RadioButton) SetFont(font *Font)

func (*RadioButton) SetOnCheck

func (r *RadioButton) SetOnCheck(f func(checked bool))

SetOnCheck sets a callback for when the RadioButton is checked. It is not called when the RadioButton is being unchecked.

func (*RadioButton) SetOnTabFocus

func (r *RadioButton) SetOnTabFocus(f func())

func (*RadioButton) SetText

func (c *RadioButton) SetText(text string)

func (*RadioButton) SetTextColor added in v0.0.3

func (r *RadioButton) SetTextColor(col Color)

SetTextColor changes the text color. Visual styles are switched off for this radio button because themed radio buttons ignore the text color.

func (*RadioButton) Text

func (c *RadioButton) Text() string

type Rectangle

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

func Rect

func Rect(x, y, width, height int) Rectangle

type Slider

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

func NewSlider

func NewSlider() *Slider

func (*Slider) Anchors

func (c *Slider) Anchors() (horizontal, vertical Anchor)

func (*Slider) ArrowIncrement

func (s *Slider) ArrowIncrement() int

func (*Slider) BackgroundColor added in v0.0.3

func (c *Slider) BackgroundColor() Color

BackgroundColor returns the color set with SetBackgroundColor. If no color was set it returns the system button face color.

func (*Slider) Bounds

func (c *Slider) Bounds() (x, y, width, height int)

func (*Slider) ContextMenu added in v0.0.2

func (c *Slider) ContextMenu() *PopupMenu

func (*Slider) CursorPosition

func (s *Slider) CursorPosition() int

CursorPosition returns the current position of the Slider.

func (*Slider) Enabled

func (c *Slider) Enabled() bool

func (*Slider) Handle

func (c *Slider) Handle() uintptr

func (*Slider) HasBackgroundColor added in v0.0.3

func (c *Slider) HasBackgroundColor() bool

HasBackgroundColor returns true if SetBackgroundColor was called.

func (*Slider) HasTextColor added in v0.0.3

func (c *Slider) HasTextColor() bool

HasTextColor returns true if SetTextColor was called.

func (*Slider) Height

func (c *Slider) Height() int

func (*Slider) HorizontalAnchor

func (c *Slider) HorizontalAnchor() Anchor

func (*Slider) Max

func (s *Slider) Max() int

func (*Slider) Min

func (s *Slider) Min() int

func (*Slider) MinMax

func (s *Slider) MinMax() (min, max int)

func (*Slider) MouseIncrement

func (s *Slider) MouseIncrement() int

func (*Slider) OnChange

func (s *Slider) OnChange() func(cursor int)

func (*Slider) OnDropFiles added in v0.0.3

func (c *Slider) OnDropFiles() DropFilesFunc

OnDropFiles returns the handler set with SetOnDropFiles.

func (*Slider) OnResize

func (c *Slider) OnResize() func()

func (*Slider) OnTabFocus

func (s *Slider) OnTabFocus() func()

func (*Slider) Orientation

func (s *Slider) Orientation() SliderOrientation

func (*Slider) Parent

func (c *Slider) Parent() Container

func (*Slider) Position

func (c *Slider) Position() (x, y int)

func (*Slider) ResetBackgroundColor added in v0.0.3

func (c *Slider) ResetBackgroundColor()

ResetBackgroundColor goes back to the default background.

func (*Slider) ResetTextColor added in v0.0.3

func (c *Slider) ResetTextColor()

ResetTextColor goes back to the system text color.

func (*Slider) SetAnchors

func (c *Slider) SetAnchors(horizontal, vertical Anchor)

func (*Slider) SetArrowIncrement

func (s *Slider) SetArrowIncrement(inc int)

SetArrowIncrement is for the arrow keys, left/down/right/up.

func (*Slider) SetBackgroundColor added in v0.0.3

func (c *Slider) SetBackgroundColor(col Color)

SetBackgroundColor changes the color behind the control's text (or the fill color of a Panel).

func (*Slider) SetBounds

func (c *Slider) SetBounds(x, y, width, height int)

func (*Slider) SetContextMenu added in v0.0.2

func (c *Slider) SetContextMenu(m *PopupMenu)

SetContextMenu sets the menu that opens when the user right-clicks the control. Not all native controls (e.g. edit boxes) forward right clicks.

func (*Slider) SetCursorPosition

func (s *Slider) SetCursorPosition(cursor int)

SetCursorPosition sets the position of the cursor. It clamps it to the Slider's min/max values.

func (*Slider) SetEnabled

func (c *Slider) SetEnabled(e bool)

func (*Slider) SetHeight

func (c *Slider) SetHeight(height int)

func (*Slider) SetHorizontalAnchor

func (c *Slider) SetHorizontalAnchor(a Anchor)

func (*Slider) SetMax

func (s *Slider) SetMax(max int)

func (*Slider) SetMin

func (s *Slider) SetMin(min int)

func (*Slider) SetMinMax

func (s *Slider) SetMinMax(min, max int)

SetMinMax sets the minimum and maximum values of the Slider. min must be smaller or equal to max. If the current cursor is outside these ranges, it is clamped.

func (*Slider) SetMouseIncrement

func (s *Slider) SetMouseIncrement(inc int)

SetMouseIncrement is for mouse clicks and the page up/down keys.

func (*Slider) SetOnChange

func (s *Slider) SetOnChange(f func(cursor int))

func (*Slider) SetOnDropFiles added in v0.0.3

func (c *Slider) SetOnDropFiles(f DropFilesFunc)

SetOnDropFiles makes the control a drop target for files dragged from the file explorer.

func (*Slider) SetOnResize

func (c *Slider) SetOnResize(f func())

func (*Slider) SetOnTabFocus

func (s *Slider) SetOnTabFocus(f func())

func (*Slider) SetOrientation

func (s *Slider) SetOrientation(o SliderOrientation)

SetOrientation only takes effect before the window is shown on screen. At run-time this cannot be changed.

func (*Slider) SetPosition

func (c *Slider) SetPosition(x, y int)

func (*Slider) SetSize

func (c *Slider) SetSize(width, height int)

func (*Slider) SetTextColor added in v0.0.3

func (c *Slider) SetTextColor(col Color)

SetTextColor changes the color of the control's text.

func (*Slider) SetTickFrequency

func (s *Slider) SetTickFrequency(n int)

SetTickFrequency sets the distance between two ticks to n (only every n'th tick is drawn). The first and last ticks are always drawn (except if you hide ticks altogether).

func (*Slider) SetTickPosition

func (s *Slider) SetTickPosition(p TickPosition)

SetTickPosition only takes effect before the window is shown on screen. At run-time this cannot be changed.

func (*Slider) SetTicksVisible

func (s *Slider) SetTicksVisible(show bool)

SetTicksVisible only takes effect before the window is shown on screen. At run-time this cannot be changed.

func (*Slider) SetToolTip added in v0.0.2

func (c *Slider) SetToolTip(text string)

SetToolTip sets the hint text shown when the mouse rests over the control. An empty text removes the tool tip. It works for every control.

func (*Slider) SetVerticalAnchor

func (c *Slider) SetVerticalAnchor(a Anchor)

func (*Slider) SetVisible

func (c *Slider) SetVisible(v bool)

func (*Slider) SetWidth

func (c *Slider) SetWidth(width int)

func (*Slider) SetX

func (c *Slider) SetX(x int)

func (*Slider) SetY

func (c *Slider) SetY(y int)

func (*Slider) Size

func (c *Slider) Size() (width, height int)

func (*Slider) TextColor added in v0.0.3

func (c *Slider) TextColor() Color

TextColor returns the color set with SetTextColor. If no color was set it returns the system window text color.

func (*Slider) TickFrequency

func (s *Slider) TickFrequency() int

func (*Slider) TickPosition

func (s *Slider) TickPosition() TickPosition

func (*Slider) TicksVisible

func (s *Slider) TicksVisible() bool

func (*Slider) ToolTip added in v0.0.2

func (c *Slider) ToolTip() string

ToolTip returns the hint text of the control.

func (*Slider) VerticalAnchor

func (c *Slider) VerticalAnchor() Anchor

func (*Slider) Visible

func (c *Slider) Visible() bool

func (*Slider) Width

func (c *Slider) Width() int

func (*Slider) X

func (c *Slider) X() int

func (*Slider) Y

func (c *Slider) Y() int

type SliderOrientation

type SliderOrientation int
const (
	HorizontalSlider SliderOrientation = iota
	VerticalSlider
)

func (SliderOrientation) String

func (o SliderOrientation) String() string

type StatusBar added in v0.0.2

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

func NewStatusBar added in v0.0.2

func NewStatusBar() *StatusBar

NewStatusBar creates a status bar. Place it at the bottom of a window and anchor it with SetAnchors(AnchorMinAndMax, AnchorMax). SetText sets the text of the first part.

func (*StatusBar) Focus added in v0.0.2

func (c *StatusBar) Focus()

func (*StatusBar) Font added in v0.0.2

func (c *StatusBar) Font() *Font

func (*StatusBar) HasFocus added in v0.0.2

func (c *StatusBar) HasFocus() bool

func (*StatusBar) SetFont added in v0.0.2

func (c *StatusBar) SetFont(font *Font)

func (*StatusBar) SetPartText added in v0.0.2

func (s *StatusBar) SetPartText(index int, text string)

SetPartText sets the text of the part with the given index.

func (*StatusBar) SetParts added in v0.0.2

func (s *StatusBar) SetParts(widths ...int)

SetParts splits the status bar into parts with the given widths in pixels. A width of -1 for the last part makes it fill the remaining space.

func (*StatusBar) SetText added in v0.0.2

func (c *StatusBar) SetText(text string)

func (*StatusBar) Text added in v0.0.2

func (c *StatusBar) Text() string

type StringList

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

func NewStringList

func NewStringList() *StringList

func (*StringList) AddItem

func (l *StringList) AddItem(s string)

func (*StringList) Clear

func (l *StringList) Clear()

func (*StringList) Focus

func (c *StringList) Focus()

func (*StringList) Font

func (c *StringList) Font() *Font

func (*StringList) HasFocus

func (c *StringList) HasFocus() bool

func (*StringList) Items

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

func (*StringList) OnChange

func (l *StringList) OnChange() func(newIndex int)

func (*StringList) SelectedIndex

func (l *StringList) SelectedIndex() int

func (*StringList) SetFont

func (c *StringList) SetFont(font *Font)

func (*StringList) SetItems

func (l *StringList) SetItems(items []string)

func (*StringList) SetOnChange

func (l *StringList) SetOnChange(f func(newIndex int))

func (*StringList) SetSelectedIndex

func (l *StringList) SetSelectedIndex(i int)

SetSelectedIndex sets the current index. Set -1 to remove any selection and make the list box empty. If you pass a value < -1 it will be set to -1 instead. The index is not clamped to the number of items, you may set the index 10 where only 5 items are set. This lets you set the index and items at design time without one invalidating the other. At runtime though, SelectedIndex() will return -1 if you set an invalid index.

func (*StringList) SetText

func (c *StringList) SetText(text string)

func (*StringList) Text

func (c *StringList) Text() string

type StringTable

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

func NewStringTable

func NewStringTable(header1 string, headers ...string) *StringTable

func (*StringTable) Clear

func (c *StringTable) Clear()

func (*StringTable) ColCount

func (c *StringTable) ColCount() int

func (*StringTable) DeleteRow

func (c *StringTable) DeleteRow(row int)

func (*StringTable) Focus

func (c *StringTable) Focus()

func (*StringTable) Font

func (c *StringTable) Font() *Font

func (*StringTable) HasFocus

func (c *StringTable) HasFocus() bool

func (*StringTable) OnSelectionChange

func (c *StringTable) OnSelectionChange() func()

func (*StringTable) OnTabFocus

func (s *StringTable) OnTabFocus() func()

func (*StringTable) RowCount

func (c *StringTable) RowCount() int

func (*StringTable) SelectedRow

func (c *StringTable) SelectedRow() int

func (*StringTable) SetCell

func (c *StringTable) SetCell(col, row int, s string)

func (*StringTable) SetFont

func (c *StringTable) SetFont(font *Font)

func (*StringTable) SetOnSelectionChange

func (c *StringTable) SetOnSelectionChange(f func())

func (*StringTable) SetOnTabFocus

func (s *StringTable) SetOnTabFocus(f func())

func (*StringTable) SetText

func (c *StringTable) SetText(text string)

func (*StringTable) Text

func (c *StringTable) Text() string

type Stroke added in v0.0.2

type Stroke struct {
	Width int
	Style LineStyle
	Cap   LineCap
	Join  LineJoin
}

Stroke describes how outlines are drawn. The zero value is a solid line of width 1. A Width of 0 or 1 draws the fast default pen.

type TabControl added in v0.0.2

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

func NewTabControl added in v0.0.2

func NewTabControl() *TabControl

NewTabControl creates a row of tabs. It only shows the tab headers; to switch content, use SetOnChange and show/hide Panels. Add the TabControl to its parent before the panels that are displayed in its content area.

func (*TabControl) AddTab added in v0.0.2

func (t *TabControl) AddTab(title string)

AddTab appends a tab with the given title.

func (*TabControl) ContentBounds added in v0.0.2

func (t *TabControl) ContentBounds() (x, y, width, height int)

ContentBounds returns the area below the tab headers in the coordinates of the TabControl's parent. Use it to place a Panel for the tab's content.

func (*TabControl) Focus added in v0.0.2

func (c *TabControl) Focus()

func (*TabControl) Font added in v0.0.2

func (c *TabControl) Font() *Font

func (*TabControl) HasFocus added in v0.0.2

func (c *TabControl) HasFocus() bool

func (*TabControl) OnChange added in v0.0.2

func (t *TabControl) OnChange() func(index int)

func (*TabControl) SelectedIndex added in v0.0.2

func (t *TabControl) SelectedIndex() int

SelectedIndex returns the index of the selected tab or -1 if there are none.

func (*TabControl) SetFont added in v0.0.2

func (c *TabControl) SetFont(font *Font)

func (*TabControl) SetOnChange added in v0.0.2

func (t *TabControl) SetOnChange(f func(index int))

SetOnChange sets the function called when the selected tab changes.

func (*TabControl) SetSelectedIndex added in v0.0.2

func (t *TabControl) SetSelectedIndex(i int)

SetSelectedIndex selects the tab at the given index and calls the change handler if the selection changed.

func (*TabControl) SetTabs added in v0.0.2

func (t *TabControl) SetTabs(titles []string)

SetTabs replaces all tabs.

func (*TabControl) SetText added in v0.0.2

func (c *TabControl) SetText(text string)

func (*TabControl) Tabs added in v0.0.2

func (t *TabControl) Tabs() []string

Tabs returns the titles of all tabs.

func (*TabControl) Text added in v0.0.2

func (c *TabControl) Text() string

type TextAlignment

type TextAlignment int
const (
	AlignLeft TextAlignment = iota
	AlignCenter
	AlignRight
)

func (TextAlignment) String

func (a TextAlignment) String() string

type TextEdit

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

func NewTextEdit

func NewTextEdit() *TextEdit

func (*TextEdit) CharacterLimit

func (e *TextEdit) CharacterLimit() int

func (*TextEdit) CursorPosition

func (c *TextEdit) CursorPosition() (start, end int)

CursorPosition returns the current cursor position, respectively the current selection.

If no selection is active, the returned start and end values are the same. They then indicate the index of the UTF-8 character in this EditLine's Text() before which the caret is currently set.

If a selection is active, start is the index of the first selected UTF-8 character in Text() and end is the position one character after the end of the selection. The selected text is thus

c.Text()[start:end]

func (*TextEdit) OnTabFocus

func (e *TextEdit) OnTabFocus() func()

func (*TextEdit) OnTextChange

func (e *TextEdit) OnTextChange() func()

func (*TextEdit) ReadOnly

func (e *TextEdit) ReadOnly() bool

func (*TextEdit) SelectAll

func (c *TextEdit) SelectAll()

func (*TextEdit) SetCharacterLimit

func (e *TextEdit) SetCharacterLimit(count int)

func (*TextEdit) SetCursorPosition

func (c *TextEdit) SetCursorPosition(pos int)

func (*TextEdit) SetOnTabFocus

func (e *TextEdit) SetOnTabFocus(f func())

func (*TextEdit) SetOnTextChange

func (e *TextEdit) SetOnTextChange(f func())

func (*TextEdit) SetReadOnly

func (e *TextEdit) SetReadOnly(readOnly bool)

func (*TextEdit) SetSelection

func (c *TextEdit) SetSelection(start, end int)

func (*TextEdit) SetWordWrap

func (e *TextEdit) SetWordWrap(wrap bool)

func (*TextEdit) SetWritesTabs

func (e *TextEdit) SetWritesTabs(tabs bool)

func (*TextEdit) WordWrap

func (e *TextEdit) WordWrap() bool

func (*TextEdit) WritesTabs

func (e *TextEdit) WritesTabs() bool

type TickPosition

type TickPosition int
const (
	TicksBottomOrRight TickPosition = iota
	TicksTopOrLeft
	TicksOnBothSides
)

func (TickPosition) String

func (p TickPosition) String() string

type Timer added in v0.0.2

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

Timer calls a function periodically on the GUI thread. Create one with Window.AddTimer. Timers can be created before the window is shown.

func (*Timer) Running added in v0.0.2

func (t *Timer) Running() bool

Running returns true if the timer is active.

func (*Timer) SetInterval added in v0.0.2

func (t *Timer) SetInterval(ms int)

SetInterval changes the interval in milliseconds.

func (*Timer) Start added in v0.0.2

func (t *Timer) Start()

Start starts (or restarts) the timer.

func (*Timer) Stop added in v0.0.2

func (t *Timer) Stop()

Stop stops the timer. It can be started again with Start.

type ToolBar added in v0.0.2

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

func NewToolBar added in v0.0.2

func NewToolBar(parent Container, x, y, height int) *ToolBar

NewToolBar creates a horizontal row of buttons inside a window or panel. It is a layout helper: every button is a normal Button placed next to the previous one.

tb := wui.NewToolBar(window, 0, 0, 28)
tb.AddButton("New", 60, func() { ... })
tb.AddSeparator()
tb.AddButton("Open", 60, func() { ... })

func (*ToolBar) AddButton added in v0.0.2

func (t *ToolBar) AddButton(text string, width int, onClick func()) *Button

AddButton appends a button with the given text and width.

func (*ToolBar) AddSeparator added in v0.0.2

func (t *ToolBar) AddSeparator()

AddSeparator leaves a gap between button groups.

func (*ToolBar) Buttons added in v0.0.2

func (t *ToolBar) Buttons() []*Button

Buttons returns all buttons added so far.

func (*ToolBar) SetGap added in v0.0.2

func (t *ToolBar) SetGap(gap int)

SetGap sets the space between buttons for the buttons added afterwards.

func (*ToolBar) Width added in v0.0.2

func (t *ToolBar) Width() int

Width returns the width used by the toolbar so far.

type TrayIcon added in v0.0.3

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

TrayIcon is an icon in the system tray (notification area). Create it with NewTrayIcon and attach it to a window with Window.SetTrayIcon. It is shown as soon as the window is shown.

tray := wui.NewTrayIcon()
tray.SetToolTip("My App")
menu := wui.NewPopupMenu()
menu.Add(quit)
tray.SetMenu(menu)
window.SetTrayIcon(tray)

func NewTrayIcon added in v0.0.3

func NewTrayIcon() *TrayIcon

NewTrayIcon creates a tray icon that uses the window's icon. By default a left click restores the window if it was hidden in the tray.

func (*TrayIcon) Icon added in v0.0.3

func (t *TrayIcon) Icon() *Icon

Icon returns the icon set with SetIcon.

func (*TrayIcon) Menu added in v0.0.3

func (t *TrayIcon) Menu() *PopupMenu

Menu returns the right click menu.

func (*TrayIcon) SetIcon added in v0.0.3

func (t *TrayIcon) SetIcon(icon *Icon)

SetIcon sets the tray icon image. By default the icon of the window is used.

func (*TrayIcon) SetMenu added in v0.0.3

func (t *TrayIcon) SetMenu(m *PopupMenu)

SetMenu sets the menu that opens on right click.

func (*TrayIcon) SetOnBalloonClick added in v0.0.3

func (t *TrayIcon) SetOnBalloonClick(f func())

SetOnBalloonClick sets the function that is called when the user clicks a balloon notification.

func (*TrayIcon) SetOnClick added in v0.0.3

func (t *TrayIcon) SetOnClick(f func())

SetOnClick sets the function that is called on a left click.

func (*TrayIcon) SetOnDoubleClick added in v0.0.3

func (t *TrayIcon) SetOnDoubleClick(f func())

SetOnDoubleClick sets the function that is called on a double click.

func (*TrayIcon) SetOnRightClick added in v0.0.3

func (t *TrayIcon) SetOnRightClick(f func())

SetOnRightClick sets the function that is called on a right click, before the menu opens.

func (*TrayIcon) SetRestoreOnClick added in v0.0.3

func (t *TrayIcon) SetRestoreOnClick(restore bool)

SetRestoreOnClick controls whether a left click on the icon brings back a window that was hidden with HideToTray, MinimizeToTray or CloseToTray. The default is true.

func (*TrayIcon) SetToolTip added in v0.0.3

func (t *TrayIcon) SetToolTip(text string)

SetToolTip sets the text that appears when hovering over the tray icon (at most 127 characters).

func (*TrayIcon) SetVisible added in v0.0.3

func (t *TrayIcon) SetVisible(v bool)

SetVisible shows or hides the icon in the tray.

func (*TrayIcon) ShowBalloon added in v0.0.3

func (t *TrayIcon) ShowBalloon(title, text string, kind BalloonKind)

ShowBalloon shows a balloon notification at the tray icon.

func (*TrayIcon) ToolTip added in v0.0.3

func (t *TrayIcon) ToolTip() string

ToolTip returns the hover text.

func (*TrayIcon) Visible added in v0.0.3

func (t *TrayIcon) Visible() bool

Visible returns true if the icon is meant to be shown.

type TreeNode added in v0.0.2

type TreeNode struct {
	// Tag can hold any value you want to associate with the node.
	Tag interface{}
	// contains filtered or unexported fields
}

TreeNode is one entry of a TreeView.

func (*TreeNode) Add added in v0.0.2

func (n *TreeNode) Add(text string) *TreeNode

Add appends a child node.

func (*TreeNode) Children added in v0.0.2

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

func (*TreeNode) Collapse added in v0.0.2

func (n *TreeNode) Collapse()

Collapse closes the node.

func (*TreeNode) Expand added in v0.0.2

func (n *TreeNode) Expand()

Expand opens the node.

func (*TreeNode) Parent added in v0.0.2

func (n *TreeNode) Parent() *TreeNode

func (*TreeNode) Remove added in v0.0.2

func (n *TreeNode) Remove()

Remove deletes the node and all its children from the tree.

func (*TreeNode) Select added in v0.0.2

func (n *TreeNode) Select()

Select makes this node the selected one.

func (*TreeNode) SetText added in v0.0.2

func (n *TreeNode) SetText(text string)

func (*TreeNode) Text added in v0.0.2

func (n *TreeNode) Text() string

type TreeView added in v0.0.2

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

func NewTreeView added in v0.0.2

func NewTreeView() *TreeView

NewTreeView creates a hierarchical list. Add top level entries with TreeView.Add and children with TreeNode.Add.

func (*TreeView) Add added in v0.0.2

func (t *TreeView) Add(text string) *TreeNode

Add appends a top level node.

func (*TreeView) Clear added in v0.0.2

func (t *TreeView) Clear()

Clear removes all nodes.

func (*TreeView) CollapseAll added in v0.0.2

func (t *TreeView) CollapseAll()

CollapseAll closes every node.

func (*TreeView) ExpandAll added in v0.0.2

func (t *TreeView) ExpandAll()

ExpandAll opens every node.

func (*TreeView) Focus added in v0.0.2

func (c *TreeView) Focus()

func (*TreeView) Font added in v0.0.2

func (c *TreeView) Font() *Font

func (*TreeView) HasFocus added in v0.0.2

func (c *TreeView) HasFocus() bool

func (*TreeView) OnDoubleClick added in v0.0.2

func (t *TreeView) OnDoubleClick() func(*TreeNode)

func (*TreeView) OnSelect added in v0.0.2

func (t *TreeView) OnSelect() func(*TreeNode)

func (*TreeView) Roots added in v0.0.2

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

Roots returns the top level nodes.

func (*TreeView) Selected added in v0.0.2

func (t *TreeView) Selected() *TreeNode

Selected returns the selected node or nil.

func (*TreeView) SetFont added in v0.0.2

func (c *TreeView) SetFont(font *Font)

func (*TreeView) SetOnDoubleClick added in v0.0.2

func (t *TreeView) SetOnDoubleClick(f func(*TreeNode))

SetOnDoubleClick sets the function called when a node is double clicked.

func (*TreeView) SetOnSelect added in v0.0.2

func (t *TreeView) SetOnSelect(f func(*TreeNode))

SetOnSelect sets the function called when the selected node changes.

func (*TreeView) SetText added in v0.0.2

func (c *TreeView) SetText(text string)

func (*TreeView) Text added in v0.0.2

func (c *TreeView) Text() string

type VisibleControl

type VisibleControl interface {
	Visible() bool
	Parent() Container
}

type Window

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

func NewWindow

func NewWindow() *Window

func (*Window) AcceptFiles added in v0.0.3

func (w *Window) AcceptFiles() bool

AcceptFiles returns true if the window accepts dropped files.

func (*Window) Add

func (w *Window) Add(c Control)

func (*Window) AddTimer added in v0.0.2

func (w *Window) AddTimer(intervalMs int, f func()) *Timer

AddTimer creates and starts a timer that calls f every intervalMs milliseconds while the window is open.

func (*Window) Alpha

func (w *Window) Alpha() uint8

func (*Window) BackgroundColor added in v0.0.3

func (w *Window) BackgroundColor() Color

BackgroundColor returns the window background color.

func (*Window) Bounds

func (w *Window) Bounds() (x, y, width, height int)

func (*Window) Center added in v0.0.2

func (w *Window) Center()

Center moves the window to the center of the screen or, for a modal window, to the center of its parent. It can be called before the window is shown (the window size must be set already) and while it is shown.

func (*Window) CenterOnParent added in v0.0.2

func (w *Window) CenterOnParent()

CenterOnParent moves a modal window to the center of its parent. If there is no parent, the window is centered on the screen.

func (*Window) CenterOnScreen added in v0.0.2

func (w *Window) CenterOnScreen()

CenterOnScreen moves the window to the center of the monitor it is on.

func (*Window) CenterOnShow added in v0.0.2

func (w *Window) CenterOnShow() bool

CenterOnShow returns whether the window centers itself when shown.

func (*Window) Children

func (w *Window) Children() []Control

func (*Window) ClassName

func (w *Window) ClassName() string

func (*Window) Close

func (w *Window) Close()

func (*Window) CloseToTray added in v0.0.3

func (w *Window) CloseToTray() bool

CloseToTray returns true if the close button hides the window in the tray.

func (*Window) ContextMenu added in v0.0.2

func (w *Window) ContextMenu() *PopupMenu

func (*Window) CornerRadius added in v0.0.3

func (w *Window) CornerRadius() int

CornerRadius returns the radius set with SetCornerRadius.

func (*Window) Cursor

func (w *Window) Cursor() *Cursor

func (*Window) Destroy

func (w *Window) Destroy()

func (*Window) DisableAltF4

func (w *Window) DisableAltF4()

func (*Window) DragByBackground added in v0.0.3

func (w *Window) DragByBackground() bool

DragByBackground returns true if the window can be moved by its background.

func (*Window) EnableAltF4

func (w *Window) EnableAltF4()

func (*Window) Enabled

func (w *Window) Enabled() bool

func (*Window) Font

func (w *Window) Font() *Font

func (*Window) GetBackground

func (w *Window) GetBackground() Color

func (*Window) Handle

func (w *Window) Handle() uintptr

func (*Window) HasBorder

func (w *Window) HasBorder() bool

func (*Window) HasCloseButton

func (w *Window) HasCloseButton() bool

func (*Window) HasMaxButton

func (w *Window) HasMaxButton() bool

func (*Window) HasMinButton

func (w *Window) HasMinButton() bool

func (*Window) Headless added in v0.0.3

func (w *Window) Headless() bool

Headless returns true if the window has no title bar and border.

func (*Window) Height

func (w *Window) Height() int

func (*Window) HideConsoleOnStart

func (w *Window) HideConsoleOnStart()

func (*Window) HideToTray added in v0.0.3

func (w *Window) HideToTray()

HideToTray hides the window completely, including its taskbar button. Bring it back with RestoreFromTray, a left click on the tray icon does that by default.

func (*Window) Icon

func (w *Window) Icon() *Icon

func (*Window) InnerBounds

func (w *Window) InnerBounds() (x, y, width, height int)

func (*Window) InnerHeight

func (w *Window) InnerHeight() int

func (*Window) InnerPosition

func (w *Window) InnerPosition() (x, y int)

func (*Window) InnerSize

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

func (*Window) InnerWidth

func (w *Window) InnerWidth() int

func (*Window) InnerX

func (w *Window) InnerX() int

func (*Window) InnerY

func (w *Window) InnerY() int

func (*Window) MaxSize added in v0.0.3

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

MaxSize returns the size set with SetMaxSize.

func (*Window) Menu

func (w *Window) Menu() *Menu

func (*Window) MinSize added in v0.0.3

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

MinSize returns the size set with SetMinSize.

func (*Window) MinimizeToTray added in v0.0.3

func (w *Window) MinimizeToTray() bool

MinimizeToTray returns true if minimizing hides the window in the tray.

func (*Window) Monitor

func (w *Window) Monitor() uintptr

Monitor returns the handle to the monitor (HMONITOR) that the window is over. Before the window is shown, Monitor returns 0.

func (*Window) OnCanClose

func (w *Window) OnCanClose() func() bool

func (*Window) OnChar

func (w *Window) OnChar() func(r rune)

func (*Window) OnClose

func (w *Window) OnClose() func()

func (*Window) OnDropFiles added in v0.0.3

func (w *Window) OnDropFiles() DropFilesFunc

OnDropFiles returns the handler set with SetOnDropFiles.

func (*Window) OnKeyDown

func (w *Window) OnKeyDown() func(key int)

func (*Window) OnKeyUp

func (w *Window) OnKeyUp() func(key int)

func (*Window) OnMessage

func (w *Window) OnMessage() MessageCallback

func (*Window) OnMouseDown

func (w *Window) OnMouseDown() func(button MouseButton, x, y int)

func (*Window) OnMouseMove

func (w *Window) OnMouseMove() func(x, y int)

func (*Window) OnMouseUp

func (w *Window) OnMouseUp() func(button MouseButton, x, y int)

func (*Window) OnMouseWheel

func (w *Window) OnMouseWheel() func(x, y int, delta float64)

func (*Window) OnResize

func (w *Window) OnResize() func()

func (*Window) OnShow

func (w *Window) OnShow() func()

func (*Window) Parent

func (w *Window) Parent() Container

func (*Window) Position

func (w *Window) Position() (x, y int)

func (*Window) Quit added in v0.0.3

func (w *Window) Quit()

Quit closes the window for real, even if CloseToTray is set.

func (*Window) Remove

func (w *Window) Remove(c Control)

func (*Window) Repaint

func (w *Window) Repaint()

func (*Window) Resizable

func (w *Window) Resizable() bool

func (*Window) RestoreFromTray added in v0.0.3

func (w *Window) RestoreFromTray()

RestoreFromTray shows a window that was hidden with HideToTray and brings it to the front.

func (*Window) Scroll

func (w *Window) Scroll(dx, dy int)

func (*Window) SetAcceptFiles added in v0.0.3

func (w *Window) SetAcceptFiles(accept bool)

SetAcceptFiles enables or disables drag and drop of files onto the window. It is implied by SetOnDropFiles.

func (*Window) SetAlpha

func (w *Window) SetAlpha(a uint8)

func (*Window) SetBackground

func (w *Window) SetBackground(c Color)

func (*Window) SetBackgroundColor added in v0.0.3

func (w *Window) SetBackgroundColor(c Color)

SetBackgroundColor changes the window background color, it is the same as SetBackground.

func (*Window) SetBounds

func (w *Window) SetBounds(x, y, width, height int)

func (*Window) SetCenterOnShow added in v0.0.2

func (w *Window) SetCenterOnShow(center bool)

SetCenterOnShow makes the window center itself when it is shown. A window shown with ShowModal is centered over its parent window, any other window is centered on the screen (work area of its monitor).

func (*Window) SetClassName

func (w *Window) SetClassName(name string)

SetClassName sets the identifier used for registering this window's class using RegisterClass or RegisterClassEx when first creating this window. This can only be done before the window is shown. For a running window this name will not be updated.

func (*Window) SetCloseToTray added in v0.0.3

func (w *Window) SetCloseToTray(on bool)

SetCloseToTray makes the close button hide the window in the tray instead of closing it. Window.Close (and Quit) still close it for real. It needs a tray icon.

func (*Window) SetContextMenu added in v0.0.2

func (w *Window) SetContextMenu(m *PopupMenu)

SetContextMenu sets the menu that opens when the user right-clicks the window's background. Controls can have their own menu with SetContextMenu.

func (*Window) SetCornerRadius added in v0.0.3

func (w *Window) SetCornerRadius(radius int)

SetCornerRadius gives the window rounded corners with the given radius in pixels. 0 means square corners. It is most useful for headless windows.

func (*Window) SetCursor

func (w *Window) SetCursor(c *Cursor)

func (*Window) SetDragByBackground added in v0.0.3

func (w *Window) SetDragByBackground(on bool)

SetDragByBackground lets the user move the window by dragging any free area of its background. This is useful for headless windows.

func (*Window) SetFont

func (w *Window) SetFont(f *Font)

func (*Window) SetHasBorder

func (w *Window) SetHasBorder(border bool)

func (*Window) SetHasCloseButton

func (w *Window) SetHasCloseButton(hasClose bool)

func (*Window) SetHasMaxButton

func (w *Window) SetHasMaxButton(hasMax bool)

func (*Window) SetHasMinButton

func (w *Window) SetHasMinButton(hasMin bool)

func (*Window) SetHeadless added in v0.0.3

func (w *Window) SetHeadless(headless bool)

SetHeadless removes the title bar and the border of the window (it becomes a borderless popup window). Use SetDragByBackground to still be able to move it and SetResizable to keep or remove the resize edges.

func (*Window) SetHeight

func (w *Window) SetHeight(height int)

func (*Window) SetIcon

func (w *Window) SetIcon(icon *Icon)

func (*Window) SetInnerBounds

func (w *Window) SetInnerBounds(x, y, width, height int)

func (*Window) SetInnerHeight

func (w *Window) SetInnerHeight(height int)

func (*Window) SetInnerPosition

func (w *Window) SetInnerPosition(x, y int)

func (*Window) SetInnerSize

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

func (*Window) SetInnerWidth

func (w *Window) SetInnerWidth(width int)

func (*Window) SetInnerX

func (w *Window) SetInnerX(x int)

func (*Window) SetInnerY

func (w *Window) SetInnerY(y int)

func (*Window) SetMaxSize added in v0.0.3

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

SetMaxSize sets the biggest outer size the user can resize the window to. 0 means no limit.

func (*Window) SetMenu

func (w *Window) SetMenu(m *Menu)

func (*Window) SetMinSize added in v0.0.3

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

SetMinSize sets the smallest outer size the user can resize the window to. 0 means no limit.

func (*Window) SetMinimizeToTray added in v0.0.3

func (w *Window) SetMinimizeToTray(on bool)

SetMinimizeToTray makes the window disappear into the tray (instead of the taskbar) when it is minimized. It needs a tray icon.

func (*Window) SetOnCanClose

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

SetOnCanClose is passed a function that is called when the window is about to be closed, e.g. when the user hits Alt+F4. If f returns true the window is closed, if f returns false, the window stays open.

func (*Window) SetOnChar

func (w *Window) SetOnChar(f func(r rune))

func (*Window) SetOnClose

func (w *Window) SetOnClose(f func())

func (*Window) SetOnDropFiles added in v0.0.3

func (w *Window) SetOnDropFiles(f DropFilesFunc)

SetOnDropFiles makes the window accept files dragged from the file explorer. The handler receives the dropped file paths. Dropping onto a control that has its own handler calls the control's handler instead.

func (*Window) SetOnKeyDown

func (w *Window) SetOnKeyDown(f func(key int))

func (*Window) SetOnKeyUp

func (w *Window) SetOnKeyUp(f func(key int))

func (*Window) SetOnMessage

func (w *Window) SetOnMessage(f MessageCallback)

func (*Window) SetOnMouseDown

func (w *Window) SetOnMouseDown(f func(button MouseButton, x, y int))

func (*Window) SetOnMouseMove

func (w *Window) SetOnMouseMove(f func(x, y int))

func (*Window) SetOnMouseUp

func (w *Window) SetOnMouseUp(f func(button MouseButton, x, y int))

func (*Window) SetOnMouseWheel

func (w *Window) SetOnMouseWheel(f func(x, y int, delta float64))

func (*Window) SetOnResize

func (w *Window) SetOnResize(f func())

func (*Window) SetOnShow

func (w *Window) SetOnShow(f func())

func (*Window) SetPosition

func (w *Window) SetPosition(x, y int)

func (*Window) SetResizable

func (w *Window) SetResizable(canResize bool)

func (*Window) SetShortcut

func (w *Window) SetShortcut(f func(), keys ...Key)

func (*Window) SetShowInTaskbar added in v0.0.3

func (w *Window) SetShowInTaskbar(show bool)

SetShowInTaskbar chooses whether the window has a button in the taskbar. A window without taskbar button is a tool window. The default is true.

func (*Window) SetSize

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

func (*Window) SetState

func (w *Window) SetState(s WindowState)

func (*Window) SetTitle

func (w *Window) SetTitle(title string)

func (*Window) SetTopMost added in v0.0.3

func (w *Window) SetTopMost(on bool)

SetTopMost keeps the window above all non-topmost windows.

func (*Window) SetTransparent added in v0.0.3

func (w *Window) SetTransparent(on bool)

SetTransparent turns on (or off) color key transparency: every pixel of the window that has exactly the TransparentColor is invisible and lets mouse clicks pass through. Set the window background and the backgrounds of panels to that color to get a window with a free-form shape. Combine it with SetHeadless(true) for a window without caption and border. See also SetAlpha for a semi-transparent window.

func (*Window) SetTransparentColor added in v0.0.3

func (w *Window) SetTransparentColor(c Color)

SetTransparentColor chooses the key color and turns color key transparency on, see SetTransparent.

func (*Window) SetTrayEnabled added in v0.0.3

func (w *Window) SetTrayEnabled(on bool)

SetTrayEnabled adds a default tray icon (using the window icon) or removes the tray icon. Use SetTrayIcon for more control.

func (*Window) SetTrayIcon added in v0.0.3

func (w *Window) SetTrayIcon(t *TrayIcon)

SetTrayIcon puts an icon for the window into the system tray. Pass nil to remove it.

func (*Window) SetTrayToolTip added in v0.0.3

func (w *Window) SetTrayToolTip(text string)

SetTrayToolTip sets the tray icon's hover text and creates the tray icon if the window does not have one yet.

func (*Window) SetWidth

func (w *Window) SetWidth(width int)

func (*Window) SetX

func (w *Window) SetX(x int)

func (*Window) SetY

func (w *Window) SetY(y int)

func (*Window) Show

func (w *Window) Show() error

func (*Window) ShowConsoleOnStart

func (w *Window) ShowConsoleOnStart()

func (*Window) ShowInTaskbar added in v0.0.3

func (w *Window) ShowInTaskbar() bool

ShowInTaskbar returns true if the window has a taskbar button.

func (*Window) ShowModal

func (w *Window) ShowModal() error

func (*Window) Size

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

func (*Window) State

func (w *Window) State() WindowState

func (*Window) Title

func (w *Window) Title() string

func (*Window) TopMost added in v0.0.3

func (w *Window) TopMost() bool

TopMost returns true if the window stays on top of other windows.

func (*Window) Transparent added in v0.0.3

func (w *Window) Transparent() bool

Transparent returns true if color key transparency is on.

func (*Window) TransparentColor added in v0.0.3

func (w *Window) TransparentColor() Color

TransparentColor returns the key color, magenta by default.

func (*Window) TrayEnabled added in v0.0.3

func (w *Window) TrayEnabled() bool

TrayEnabled returns true if the window has a tray icon.

func (*Window) TrayIcon added in v0.0.3

func (w *Window) TrayIcon() *TrayIcon

TrayIcon returns the tray icon of the window or nil.

func (*Window) TrayToolTip added in v0.0.3

func (w *Window) TrayToolTip() string

TrayToolTip returns the tray icon's hover text.

func (*Window) Visible

func (w *Window) Visible() bool

func (*Window) Width

func (w *Window) Width() int

func (*Window) X

func (w *Window) X() int

func (*Window) Y

func (w *Window) Y() int

type WindowState

type WindowState int
const (
	WindowNormal WindowState = iota
	WindowMaximized
	WindowMinimized
)

func (WindowState) String

func (s WindowState) String() string

Directories

Path Synopsis
Package check implements easy to use functions to write your tests in a concise way.
Package check implements easy to use functions to write your tests in a concise way.
cmd
designer command
wmlcheck command
Command wmlcheck validates WML layout files without opening a window.
Command wmlcheck validates WML layout files without opening a window.
examples
canvas_drawing command
Canvas drawing example: strokes, rounded rectangles, curves, gradients, transparency, polygons, stars and clipping.
Canvas drawing example: strokes, rounded rectangles, curves, gradients, transparency, polygons, stars and clipping.
canvas_mouse command
Canvas mouse example: draw freehand lines with the left mouse button, clear with the right button.
Canvas mouse example: draw freehand lines with the left mouse button, clear with the right button.
center_window command
Center example: the main window centers on the screen, the modal dialog centers over its parent.
Center example: the main window centers on the screen, the modal dialog centers over its parent.
clipboard command
Clipboard example: copy the edit text to the clipboard and paste it back.
Clipboard example: copy the edit text to the clipboard and paste it back.
color_dialog command
ColorDialog example: pick a color and show it in a paint box.
ColorDialog example: pick a color and show it in a paint box.
colored_text command
context_menu command
Context menu example: right-click the window or the button.
Context menu example: right-click the window or the button.
date_picker command
DatePicker example: a date picker and a time picker.
DatePicker example: a date picker and a time picker.
drag_drop command
group_box command
GroupBox example: a captioned frame around related controls.
GroupBox example: a captioned frame around related controls.
overlay_window command
status_bar command
StatusBar example: a multi-part status bar at the bottom of the window.
StatusBar example: a multi-part status bar at the bottom of the window.
tab_control command
TabControl example: one Panel per tab, switched in OnChange.
TabControl example: one Panel per tab, switched in OnChange.
timer command
Timer example: a clock updated every second plus a start/stop button.
Timer example: a clock updated every second plus a start/stop button.
toolbar command
ToolBar example: a row of buttons above a text box.
ToolBar example: a row of buttons above a text box.
tooltip command
ToolTip example: hover over the controls.
ToolTip example: hover over the controls.
tray command
tree_view command
TreeView example: a small hierarchy that shows the selected node.
TreeView example: a small hierarchy that shows the selected node.
wml_login command
WML example: the layout is described in XML (login.xml) and loaded at run time.
WML example: the layout is described in XML (login.xml) and loaded at run time.
Package wml loads window layouts from XML files at run time, similar to QML or XAML.
Package wml loads window layouts from XML files at run time, similar to QML or XAML.

Jump to

Keyboard shortcuts

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