window

package
v0.0.0-...-2f48622 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyAttached = errors.New("already attached")

wiErrAlreadyAttached is returned by Attach if the HWND or *WindowBase is already attached.

Functions

func Attach

func Attach(hwnd win32.HWND, window *WindowBase) error

func PreTranslateMessage

func PreTranslateMessage(msg *win32.MSG) bool

Types

type MouseClickOpt

type MouseClickOpt win32.WPARAM

func (MouseClickOpt) Control

func (mk MouseClickOpt) Control() bool

func (MouseClickOpt) LButton

func (mk MouseClickOpt) LButton() bool

func (MouseClickOpt) MButton

func (mk MouseClickOpt) MButton() bool

func (MouseClickOpt) RDown

func (mk MouseClickOpt) RDown() bool

func (MouseClickOpt) Shift

func (mk MouseClickOpt) Shift() bool

func (MouseClickOpt) XButton1

func (mk MouseClickOpt) XButton1() bool

func (MouseClickOpt) XButton2

func (mk MouseClickOpt) XButton2() bool

type MsgListenerKey

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

MsgListenerKey represents a message listener added by WindowBase.AddMsgListener.

func (MsgListenerKey) Remove

func (k MsgListenerKey) Remove()

Remove removes the listener.

type PopupMenuSpec

type PopupMenuSpec struct {
	Flags   win32.TRACK_POPUP_MENU_FLAG
	X, Y    win32.LONG // Screen coordinates.
	Exclude *win32.RECT
}

type Spec

type Spec struct {
	ClassName    string
	Text         string
	Style        win32.WINDOW_STYLE
	ExStyle      win32.WINDOW_EX_STYLE
	X            win32.INT
	Y            win32.INT
	Width        win32.INT
	Height       win32.INT
	InCurrentDPI bool // If true, X, Y, Width and Height are in current DPI, otherwise in USER_DEFAULT_SCREEN_DPI.
	WndParent    win32.HWND
	Menu         *menu.Menu
	Instance     win32.HINSTANCE // 0 for this module.
	OnCreate     func()
	OnClose      func()
}

type Window

type Window struct {
	WindowBase
	OnCreate func()
	OnClose  func()
}

func New

func New(spec *Spec) (*Window, error)

func (*Window) SetMenu

func (w *Window) SetMenu(menu *menu.Menu) error

type WindowBase

type WindowBase struct {
	OnLButtonUp   func(opt MouseClickOpt, x int, y int)
	OnLButtonDown func(opt MouseClickOpt, x int, y int)
	OnRButtonUp   func(opt MouseClickOpt, x int, y int)
	OnRButtonDown func(opt MouseClickOpt, x int, y int)
	// contains filtered or unexported fields
}

func Query

func Query(hwnd win32.HWND) *WindowBase

func (*WindowBase) AddMsgListener

func (w *WindowBase) AddMsgListener(message win32.UINT,
	listener func(hwnd win32.HWND, message win32.UINT, wParam win32.WPARAM, lParam win32.LPARAM)) MsgListenerKey

AddMsgListener adds a listener that is called when the message is received in the window procedure. To remove the listener, call Remove() of the returned MsgListenerKey.

func (*WindowBase) DPI

func (w *WindowBase) DPI() (win32.UINT, error)

func (*WindowBase) Destroy

func (w *WindowBase) Destroy() error

func (*WindowBase) GetClientRect

func (w *WindowBase) GetClientRect() (*win32.RECT, error)

func (*WindowBase) HWND

func (w *WindowBase) HWND() win32.HWND

func (*WindowBase) InvalidateRect

func (w *WindowBase) InvalidateRect(rect *win32.RECT, eraseBk bool) error

func (*WindowBase) SetPaintCallback

func (w *WindowBase) SetPaintCallback(f func(dc *paint.PaintDC, prev func(*paint.PaintDC)))

func (*WindowBase) SetText

func (w *WindowBase) SetText(text string) error

func (*WindowBase) SetValue

func (w *WindowBase) SetValue(key, value any)

Value sets the value associated with this window for key. Setting A nil value deletes the value associated with key if any. See Context.Value() in context package for the concept and usage of associated value.

func (*WindowBase) SetWndProc

func (w *WindowBase) SetWndProc(wndProc WndProc)

SetWndProc sets the window procedure of w. It panics if wndProc is nil.

func (*WindowBase) Show

func (w *WindowBase) Show(cmd win32.SHOW_WINDOW_CMD)

func (*WindowBase) Text

func (w *WindowBase) Text() (string, error)

func (*WindowBase) TrackPopupMenu

func (w *WindowBase) TrackPopupMenu(menu *menu.Menu, spec *PopupMenuSpec) error

TrackPopupMenu tracks a popup menu. If spec is nil, default flag, empty exclude RECT and GetCursorPos() are used.

func (*WindowBase) Value

func (w *WindowBase) Value(key any) any

Value returns the value associated with this window for key, or nil if no value is associated with key. See Context.Value() in context package for the concept and usage of associated value.

type WndProc

type WndProc func(hwnd win32.HWND, message win32.UINT, wParam win32.WPARAM, lParam win32.LPARAM, prevWndProc win32.WndProc) win32.LRESULT

Jump to

Keyboard shortcuts

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