dialog

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const WM_CHOOSEFONT_GETLOGFONT = (win32.WM_USER + 1)

Variables

View Source
var ErrNotChild = errors.New("no a child")

Functions

func Modal(spec *Spec) (ret any, err error)

Modal shows a modal dialog box. The ret is the return value set by Dialog.End(), nil if Dialog.End() is not called.

Types

type ChooseFontSpec

type ChooseFontSpec struct {
	Owner   win32.HWND
	LogFont *font.LogFont // Initial value or nil.
	/* The following flags are automatically removed(added):
	CF_INITTOLOGFONTSTRUCT
	CF_APPLY
	CF_EFFECTS
	CF_ENABLEHOOK
	CF_ENABLETEMPLATE
	CF_ENABLETEMPLATEHANDLE
	CF_LIMITSIZE
	CF_USESTYLE
	*/
	Flags win32.CHOOSE_FONT_FLAG
	// If not nil, font effects(color, strikeout, underline) are enabled.
	// Strikeout and underline are specified in LogFont.
	Color          *win32.COLORREF
	PointSizeLimit *Limit                    // In point. Nil for none.
	OnApply        func(curFont *FontChosen) // If not nil, an Apply button is displayed, and OnApply is called if it is pressed.
}

type Dialog

type Dialog struct {
	window.Window
	OnCreate func(dlg *Dialog)
	OnOK     func(dlg *Dialog) bool
	OnCancel func(dlg *Dialog) bool
	// contains filtered or unexported fields
}

func (*Dialog) End

func (d *Dialog) End(result any) error

End ends the dialog and set the result value.

func (*Dialog) Reposition

func (d *Dialog) Reposition() error

Reposition repositions a top-level dialog box so that it fits within the desktop area.

func (*Dialog) SetCancel

func (d *Dialog) SetCancel(btn *button.Button) error

SetCancel sets the Cancel button of this dialog. Panic if btn is not a child of d.

func (*Dialog) SetDefault

func (d *Dialog) SetDefault(btn *button.Button) error

SetDefault sets the default button of this dialog. Panic if btn is not a child of d.

func (*Dialog) SetDlgProc

func (d *Dialog) SetDlgProc(dlgProc DlgProc)

func (*Dialog) SetOK

func (d *Dialog) SetOK(btn *button.Button) error

SetOK sets the OK button of this dialog. Panic if btn is not a child of d.

type DlgProc

type DlgProc func(hwnd win32.HWND, msg win32.UINT, wParam win32.WPARAM, lParam win32.LPARAM, prevDlgProc Proc) bool

type FontChosen

type FontChosen struct {
	Font      *font.LogFont
	Type      win32.CHOOSE_FONT_TYPE
	PointSize win32.INT
	Color     win32.COLORREF
}

func ChooseFont

func ChooseFont(spec *ChooseFontSpec) (*FontChosen, error)

ChooseFont displays a Font dialog. If the user cancels or closes the Font dialog box, it returns nil, nil. Nil spec means default setting.

type Limit

type Limit struct {
	Min, Max win32.INT
}

type Proc

type Proc func(hwnd win32.HWND, msg win32.UINT, wParam win32.WPARAM, lParam win32.LPARAM) bool

type Spec

type Spec struct {
	Text      string
	Style     win32.DWORD
	ExStyle   win32.DWORD
	X         int
	Y         int
	Width     int
	Height    int
	WndParent win32.HWND
	Menu      *menu.Menu
	Instance  win32.HINSTANCE // 0 for this module.
	OnCreate  func(dlg *Dialog)
	OnOK      func(dlg *Dialog) bool
	OnCancel  func(dlg *Dialog) bool
}

Jump to

Keyboard shortcuts

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