Documentation
¶
Overview ¶
Package guigo 轻量、基于系统 WebView 的 Go 语言图形界面库
Index ¶
- Variables
- func DefaultUserDataDir(appID string) (string, error)
- func OpenURL(rawURL string) error
- func PageContext(ctx context.Context) context.Context
- func RegisterFileAssociations(o AssociationOptions, scope AssociationScope) error
- func Run(ctx context.Context, options Options) error
- func SupportsWindowMaterial(material WindowMaterial) bool
- func SystemDark() bool
- func UnregisterFileAssociations(o AssociationOptions, scope AssociationScope) error
- type AssociationOptions
- type AssociationScope
- type AssociationStatus
- type BridgeError
- type DialogOptions
- type FileAssociation
- type FileFilter
- type HandlerFunc
- type Instance
- type InstanceOptions
- type Options
- type PrintCapabilities
- type PrintCollation
- type PrintColorMode
- type PrintDialogKind
- type PrintDuplex
- type PrintMargins
- type PrintOptions
- type PrintOrientation
- type PrintPaper
- type PrintResult
- type PrinterInfo
- type PrinterProfile
- type Rect
- type Resource
- type Result
- type TitleBarColors
- type TitleBarInfo
- type TitleBarMode
- type Tray
- type TrayItem
- type TrayOptions
- type Window
- func (w *Window) Activate() error
- func (w *Window) Close() error
- func (w *Window) Emit(name string, value any) error
- func (w *Window) Hide() error
- func (w *Window) ListPrinters(ctx context.Context) ([]PrinterInfo, error)
- func (w *Window) NewTray(ctx context.Context, options TrayOptions) (*Tray, error)
- func (w *Window) OpenDirectory(ctx context.Context, options DialogOptions) (string, error)
- func (w *Window) OpenFile(ctx context.Context, options DialogOptions) (string, error)
- func (w *Window) OpenFiles(ctx context.Context, options DialogOptions) ([]string, error)
- func (w *Window) Print(ctx context.Context, options PrintOptions) (PrintResult, error)
- func (w *Window) PrintCapabilities(ctx context.Context) (PrintCapabilities, error)
- func (w *Window) QueryPrinter(ctx context.Context, options PrintOptions) (PrinterProfile, error)
- func (w *Window) SaveFile(ctx context.Context, options DialogOptions) (string, error)
- func (w *Window) SetDragRegions(regions []Rect) error
- func (w *Window) SetSize(width, height int) error
- func (w *Window) SetTitle(title string) error
- func (w *Window) SetTitleBarColors(colors TitleBarColors) error
- func (w *Window) SetWindowMaterial(material WindowMaterial) error
- func (w *Window) ShowPrintDialog(ctx context.Context, kind PrintDialogKind) error
- func (w *Window) ShowPrinterProperties(ctx context.Context, printer string) error
- func (w *Window) TitleBarInfo() (TitleBarInfo, error)
- type WindowMaterial
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedPlatform 表示当前平台没有可用宿主实现 ErrUnsupportedPlatform = errors.New("unsupported platform") // ErrCanceled 表示用户取消操作 ErrCanceled = errors.New("canceled") // ErrClosed 表示窗口、托盘或实例已经关闭 ErrClosed = errors.New("closed") // ErrAlreadyRunning 表示当前进程已有活动窗口循环 ErrAlreadyRunning = errors.New("another Run is active") // ErrDialogBusy 表示当前窗口已有活动文件对话框 ErrDialogBusy = errors.New("another dialog is active") ErrRuntimeUnavailable = errors.New("native runtime unavailable") )
var ( // ErrPrintUnsupported 表示当前运行时没有请求的打印能力 ErrPrintUnsupported = errors.New("requested printing capability is unavailable") // ErrPrintBusy 表示当前视图仍在处理另一个直接打印作业 ErrPrintBusy = errors.New("another print operation is active") // ErrPrinterNotFound 表示指定的打印机或系统默认打印机不存在 ErrPrinterNotFound = errors.New("printer not found") )
var ErrAssociationElevationRequired = errors.New("administrator privileges required")
ErrAssociationElevationRequired 表示所有用户范围需要以管理员权限运行
ErrTrayUnavailable 表示当前桌面没有可用托盘宿主
Functions ¶
func DefaultUserDataDir ¶
DefaultUserDataDir 返回应用的默认浏览器数据目录,不创建或删除目录 目录位于os.UserCacheDir返回的位置下,使用guigo/应用标识作为子目录,Windows使用GUIGo目录名 入参: appID 稳定的应用标识 返回: string 绝对目录路径, error 参数或路径错误
func PageContext ¶
PageContext 从处理器调用上下文中提取所属页面的生命周期上下文 当页面发生导航或窗口关闭时,返回的上下文取消;非宿主上下文原样返回 入参: ctx 处理器收到的调用上下文 返回: context.Context 页面上下文
func RegisterFileAssociations ¶
func RegisterFileAssociations(o AssociationOptions, scope AssociationScope) error
RegisterFileAssociations 登记指定范围的打开方式,不修改默认应用或自动提权 入参: o 应用配置, scope 作用范围 返回: error 登记错误
func Run ¶
Run 运行窗口事件循环,关闭后返回,同一进程不支持同时运行多个实例 当前实现支持windows/amd64及linux/amd64、linux/arm64,其他平台返回ErrUnsupportedPlatform Windows使用调用线程,Linux使用进程内固定的GTK线程 浏览器数据在关闭、启动失败和版本升级时保留,删除由调用方负责 入参: ctx 运行上下文, options 宿主选项 返回: error 启动、运行或上下文错误
func SupportsWindowMaterial ¶
func SupportsWindowMaterial(material WindowMaterial) bool
SupportsWindowMaterial 查询当前平台是否提供指定窗口材质,空值视为WindowSolid 入参: material 窗口材质 返回: bool 是否支持
func SystemDark ¶
func SystemDark() bool
SystemDark 返回系统当前是否偏好深色外观,未适配平台或查询失败时返回false 返回: bool 是否偏好深色外观
func UnregisterFileAssociations ¶
func UnregisterFileAssociations(o AssociationOptions, scope AssociationScope) error
UnregisterFileAssociations 删除指定范围的专用键及公共键中的应用值,不自动提权 入参: o 应用配置, scope 作用范围 返回: error 撤销错误
Types ¶
type AssociationOptions ¶
type AssociationOptions struct {
AppID string
Name string
Description string
Executable string
Arguments []string
IconIndex int
Types []FileAssociation
}
AssociationOptions 定义应用专用文件关联资源,重登和撤销会清理旧登记残留 Executable为程序绝对路径,Arguments为文件路径前的固定参数,撤销会整树删除专用键
type AssociationScope ¶
type AssociationScope string
AssociationScope 指定独立管理的文件关联范围
const ( // AssociationUser 仅登记当前用户的文件关联 AssociationUser AssociationScope = "user" // AssociationMachine 登记所有用户可用的文件关联,需要管理员权限 AssociationMachine AssociationScope = "machine" )
type AssociationStatus ¶
type AssociationStatus struct {
Supported bool `json:"supported"`
Registered bool `json:"registered"`
Complete bool `json:"complete"`
Writable bool `json:"writable"`
}
AssociationStatus 描述指定范围内的登记状态,不代表用户已选择为默认应用 Supported表示平台支持,Registered表示存在登记,Complete表示与当前配置一致,Writable表示当前权限可写
func QueryFileAssociations ¶
func QueryFileAssociations(o AssociationOptions, scope AssociationScope) (AssociationStatus, error)
QueryFileAssociations 查询指定范围的登记状态,不修改注册表 入参: o 应用配置, scope 作用范围 返回: AssociationStatus 登记状态, error 查询错误
type BridgeError ¶
BridgeError 定义传递给JavaScript的结构化错误,Name为空时默认Error,Code为空时不传递
func (*BridgeError) Error ¶
func (e *BridgeError) Error() string
Error 返回错误说明,nil接收者安全返回空字符串 返回: string 错误信息
type DialogOptions ¶
type DialogOptions struct {
Title string
DefaultPath string
DefaultName string
Filters []FileFilter
}
DialogOptions 定义原生文件对话框标题、初始路径、默认文件名及文件类型过滤,OpenDirectory忽略DefaultName与Filters
type FileAssociation ¶
FileAssociation 定义应用支持的文件类型,ID在应用内唯一,Extensions为不重复的小写带点扩展名
type FileFilter ¶
FileFilter 定义文件类型显示名及分号分隔的通配符模式,如*.txt;*.md
type HandlerFunc ¶
HandlerFunc 异步处理页面通过window.guigo.call(name, args, {signal})发起的调用 支持Blob/ArrayBuffer/TypedArray二进制直传与BridgeError结构化错误,调用结束、取消或页面退出时取消上下文 返回带Discard的Result时,上下文保持到页面确认接收或调用取消 入参: ctx 调用上下文, args 已解码参数,二进制为[]byte 返回: any 可JSON编码的值或Result, error 错误信息
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance 持有当前用户及会话内的实例入口,关闭后允许后续进程接管
func OpenInstance ¶
func OpenInstance(ctx context.Context, options InstanceOptions, receive func(context.Context, []byte) error) (*Instance, error)
OpenInstance 创建单实例入口,已有同组实例时转交消息并返回nil 首个实例不调用receive处理自己的消息,调用方自行处理初始请求 receive串行执行,应快速接收或入队;返回nil表示已接受,不表示业务已完成 receive应响应上下文取消,不得同步调用当前实例的Close receive返回ErrClosed时,发送方等待入口释放后重新竞争 不同用户、登录会话及Windows提升权限分别隔离,不修改窗口应用标识 入参: ctx 生命周期上下文, options 实例配置, receive 接收回调 返回: *Instance 新实例入口或nil, error 创建或转交错误
type InstanceOptions ¶
type InstanceOptions struct {
Key string
Payload []byte
Window bool
Timeout time.Duration
MaxPayloadBytes int
}
InstanceOptions 定义单实例入口的标识、转交消息及匹配策略 Key为非空隔离键;Payload长度不得超过MaxPayloadBytes(默认1MiB,最大16MiB) Window在windows/amd64上按当前虚拟桌面最近激活的同组窗口优先转交,其他平台沿用会话单实例 Timeout非正值默认10秒
type Options ¶
type Options struct {
Instance *Instance
AppID string
Title string
TitleBar TitleBarMode
TitleBarColors TitleBarColors
WindowMaterial WindowMaterial
Icon []byte
IconPath string
Width int
Height int
MinWidth int
MinHeight int
MaxWidth int
MaxHeight int
FixedSize bool
Center bool
Maximized bool
UserDataDir string
LibraryPath string
EntryPath string
FS fs.FS
Handler http.Handler
ResourceHandler func(*http.Request) (*Resource, error)
Bindings map[string]HandlerFunc
OnReady func(*Window)
OnTitleBarChanged func(TitleBarInfo)
OnClosing func(context.Context) bool
OnClose func()
OnDrop func([]string)
OnError func(error)
}
Options 定义窗口、资源和生命周期配置,客户区尺寸单位为逻辑像素,路径前缀/__guigo/由宿主保留 Instance传入OpenInstance返回的窗口入口并由调用方关闭;AppID与UserDataDir至少设置其一 TitleBarColors非零时需启用TitleBarContent并提供全部四种颜色;WindowMaterial非纯色需系统支持,否则返回ErrUnsupportedPlatform Icon与IconPath互斥,均要求边长不超过2048像素且不超过16MiB的正方形PNG Width/Height零值默认1024x768,Min/Max零值不限,FixedSize生效时忽略Maximized Handler非空时忽略FS,ResourceHandler返回nil, nil时回退到Handler或FS OnReady在首次导航前于后台调用,OnTitleBarChanged在其后串行通知,OnClose在宿主完全退出后执行
type PrintCapabilities ¶
type PrintCapabilities struct {
SystemDialog bool `json:"systemDialog"`
BrowserDialog bool `json:"browserDialog"`
DialogCompletion bool `json:"dialogCompletion"`
Direct bool `json:"direct"`
PageRanges bool `json:"pageRanges"`
DeviceSettings bool `json:"deviceSettings"`
Backgrounds bool `json:"backgrounds"`
}
PrintCapabilities 描述运行时支持的打印机制,不代表打印机已连接或具备所有硬件功能 分别表示系统/浏览器对话框、对话框返回即消费完成、直接提交、页码范围、设备设置、背景及页眉页脚支持
type PrintCollation ¶
type PrintCollation string
PrintCollation 定义多份打印的逐份整理方式
const ( // PrintCollationCollated 按份逐套整理打印 PrintCollationCollated PrintCollation = "collated" // PrintCollationUncollated 按页分组不逐套整理打印 PrintCollationUncollated PrintCollation = "uncollated" )
type PrintColorMode ¶
type PrintColorMode string
PrintColorMode 定义打印色彩模式
const ( // PrintColorModeColor 使用彩色打印 PrintColorModeColor PrintColorMode = "color" // PrintColorModeGrayscale 使用灰度打印 PrintColorModeGrayscale PrintColorMode = "grayscale" )
type PrintDialogKind ¶
type PrintDialogKind string
PrintDialogKind 定义打印对话框类型
const ( // PrintDialogSystem 使用系统打印窗口 PrintDialogSystem PrintDialogKind = "system" // PrintDialogBrowser 使用WebView内置打印窗口 PrintDialogBrowser PrintDialogKind = "browser" )
type PrintDuplex ¶
type PrintDuplex string
PrintDuplex 定义单双面打印方式
const ( // PrintDuplexSimplex 使用单面打印 PrintDuplexSimplex PrintDuplex = "simplex" // PrintDuplexLongEdge 使用长边翻页双面打印 PrintDuplexLongEdge PrintDuplex = "longEdge" // PrintDuplexShortEdge 使用短边翻页双面打印 PrintDuplexShortEdge PrintDuplex = "shortEdge" )
type PrintMargins ¶
type PrintMargins struct {
Top float64 `json:"top"`
Right float64 `json:"right"`
Bottom float64 `json:"bottom"`
Left float64 `json:"left"`
}
PrintMargins 指定应用方向后物理纸面的四边毫米边距
type PrintOptions ¶
type PrintOptions struct {
Printer string `json:"printer,omitempty"`
Orientation PrintOrientation `json:"orientation,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
Margins *PrintMargins `json:"margins,omitempty"`
Scale float64 `json:"scale,omitempty"`
Copies int `json:"copies,omitempty"`
Collation PrintCollation `json:"collation,omitempty"`
Color PrintColorMode `json:"color,omitempty"`
Duplex PrintDuplex `json:"duplex,omitempty"`
PageRanges string `json:"pageRanges,omitempty"`
PagesPerSide int `json:"pagesPerSide,omitempty"`
Backgrounds *bool `json:"backgrounds,omitempty"`
}
PrintOptions 设置当前顶层文档的直接打印参数,尺寸及边距单位均为毫米 Width/Height为未旋转纸张尺寸且须同时设置;Scale范围0.1至2,Copies范围1至999,PagesPerSide支持1/2/4/6/9/16 PageRanges为一基闭区间如1-3,5;空值或nil字段采用系统默认设置,提交期间须保持文档内容不变
type PrintOrientation ¶
type PrintOrientation string
PrintOrientation 定义纸张打印方向
const ( // PrintOrientationPortrait 使用纵向打印 PrintOrientationPortrait PrintOrientation = "portrait" // PrintOrientationLandscape 使用横向打印 PrintOrientationLandscape PrintOrientation = "landscape" )
type PrintPaper ¶
type PrintPaper struct {
ID string `json:"id"`
Name string `json:"name"`
Width float64 `json:"width"`
Height float64 `json:"height"`
}
PrintPaper 保存设备支持的纸张标识、名称及未旋转方向毫米尺寸
type PrintResult ¶
type PrintResult struct {
Submitted bool `json:"submitted"`
}
PrintResult 表示作业提交结果,Submitted为真不确认实体打印机已出纸
type PrinterInfo ¶
PrinterInfo 标识系统打印队列名及是否为默认设备,不表示设备一定在线
type PrinterProfile ¶
type PrinterProfile struct {
Printer PrinterInfo `json:"printer"`
Options PrintOptions `json:"options"`
Papers []PrintPaper `json:"papers"`
Width float64 `json:"width"`
Height float64 `json:"height"`
PrintableArea Rect `json:"printableArea"`
Color bool `json:"color"`
Duplex bool `json:"duplex"`
MaxCopies int `json:"maxCopies"`
CustomPaper bool `json:"customPaper"`
Properties bool `json:"properties"`
Fingerprint string `json:"fingerprint"`
}
PrinterProfile 是一次设备设置查询的独立结果,不缓存为永久设备能力 Width/Height为应用方向后的物理纸面毫米尺寸,PrintableArea为硬件可打印毫米区域 Fingerprint标识当前设置与设备几何信息,供提交前复查
type Rect ¶
type Rect struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
Height float64 `json:"height"`
}
Rect 定义二维平面矩形区域,用于逻辑像素拖动区或毫米可打印区域,零宽高表示空矩形
type Resource ¶
type Resource struct {
StatusCode int
Header http.Header
Body io.ReadSeekCloser
}
Resource 提供已就绪的可寻址响应流,StatusCode零值默认200,为204或304时允许Body为nil,非空Body所有权交给宿主并由宿主关闭 ResourceHandler返回nil, nil时回退到Handler或FS,范围请求需由处理器提供对应状态与区间内容
type Result ¶
type Result struct {
Value any
Discard func()
}
Result 保存调用结果,Discard在结果未交付时异步释放资源,页面确认接收后不再调用
type TitleBarColors ¶
type TitleBarColors struct {
Background string `json:"background"`
Foreground string `json:"foreground"`
InactiveBackground string `json:"inactiveBackground"`
InactiveForeground string `json:"inactiveForeground"`
}
TitleBarColors 定义内容标题栏激活与失焦的前景色及背景色,颜色使用#RRGGBB格式
type TitleBarInfo ¶
type TitleBarInfo struct {
Height float64 `json:"height"`
Left float64 `json:"left"`
Right float64 `json:"right"`
Active bool `json:"active"`
Maximized bool `json:"maximized"`
Colors TitleBarColors `json:"colors"`
Material WindowMaterial `json:"material"`
}
TitleBarInfo 保存逻辑像素标题栏布局和窗口状态 Height在系统模式下为零,Left/Right为系统窗口按钮保留宽度,非纯色Material需页面使用透明背景
type TitleBarMode ¶
type TitleBarMode string
TitleBarMode 定义窗口标题栏的显示方式
const ( // TitleBarSystem 使用系统标题栏,为默认值 TitleBarSystem TitleBarMode = "system" // TitleBarContent 将内容延伸到标题栏,保留系统窗口按钮 TitleBarContent TitleBarMode = "content" )
type Tray ¶
type Tray struct {
// contains filtered or unexported fields
}
Tray 持有窗口所属的系统托盘,可由后台Goroutine操作,随窗口销毁而释放 托盘宿主丢失且无法恢复时窗口会重新显示,调用方可用Available查询当前状态
func (*Tray) SetOptions ¶
func (t *Tray) SetOptions(ctx context.Context, options TrayOptions) error
SetOptions 完整替换托盘配置,包括回调,零值含义与NewTray相同 更新时可关闭已展开的菜单,已开始执行的回调不受影响 入参: ctx 调用上下文, options 新托盘配置,图标及菜单数据在返回前复制 返回: error 配置或更新错误,已关闭时返回ErrClosed
type TrayItem ¶
type TrayItem struct {
ID string
Label string
Disabled bool
Hidden bool
Separator bool
Checked *bool
Radio bool
Children []TrayItem
}
TrayItem 定义托盘菜单项,支持子菜单、分隔线及由调用方维护的选中状态 ID在菜单树内唯一(分隔线可省略),Label按原文显示,Separator不可带文本、选中态或子菜单 Radio须配合Checked使用;含Children的父项仅用于展开子菜单,不触发OnSelect且不带选中态
type TrayOptions ¶
type TrayOptions struct {
Title string
Icon []byte
IconPath string
Items []TrayItem
MenuOnActivate bool
OnSelect func(string)
OnActivate func()
OnSecondaryActivate func()
}
TrayOptions 定义托盘图标、菜单和交互回调 Title为空沿用窗口标题;Icon与IconPath互斥且约束同Options.Icon,均为空沿用窗口或系统默认图标 MenuOnActivate使主激活优先打开菜单;OnSelect、OnActivate、OnSecondaryActivate均在后台并发回调
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window 持有窗口宿主,由OnReady提供,所有公开方法可由后台Goroutine调用
func (*Window) Emit ¶
Emit 向页面发送命名事件,前端通过window.guigo.on(name, listener)订阅,返回值表示已交给宿主而非已消费 首屏就绪前最多缓存1024条待发事件,超限返回错误 入参: name 非空事件名称, value 可JSON编码的数据 返回: error 错误信息
func (*Window) ListPrinters ¶
func (w *Window) ListPrinters(ctx context.Context) ([]PrinterInfo, error)
ListPrinters 查询当前系统队列,返回空列表时没有可用设备,调用方可提供文件输出 入参: ctx 查询上下文 返回: []PrinterInfo 系统打印队列, error 查询或取消错误
func (*Window) NewTray ¶
NewTray 为当前窗口创建独立托盘,可创建多个,随窗口销毁而释放 Windows使用系统通知区域,Linux需要支持StatusNotifierItem和DBusMenu的桌面宿主 无可用宿主时返回ErrTrayUnavailable,未适配的平台返回ErrUnsupportedPlatform 入参: ctx 调用上下文, options 托盘配置,图标及菜单数据在返回前复制 返回: *Tray 托盘句柄, error 创建错误
func (*Window) OpenDirectory ¶
OpenDirectory 选择已有目录 入参: ctx 调用上下文, options 对话框选项 返回: string 目录路径, error 错误信息,用户取消返回ErrCanceled,并发调用返回ErrDialogBusy
func (*Window) OpenFile ¶
OpenFile 选择单个已有文件 入参: ctx 调用上下文, options 对话框选项 返回: string 文件路径, error 错误信息,用户取消返回ErrCanceled,并发调用返回ErrDialogBusy
func (*Window) OpenFiles ¶
OpenFiles 选择多个已有文件 入参: ctx 调用上下文, options 对话框选项 返回: []string 文件路径, error 错误信息,用户取消返回ErrCanceled,并发调用返回ErrDialogBusy
func (*Window) Print ¶
func (w *Window) Print(ctx context.Context, options PrintOptions) (PrintResult, error)
Print 直接提交当前顶层文档,设备设置仍受打印机驱动能力约束 返回前内容须保持不变;取消上下文不保证撤回已经提交给系统的作业 入参: ctx 调用上下文, options 设备打印选项 返回: PrintResult 提交结果, error 配置、提交或取消错误
func (*Window) PrintCapabilities ¶
func (w *Window) PrintCapabilities(ctx context.Context) (PrintCapabilities, error)
PrintCapabilities 查询当前窗口的打印接口能力,可从后台Goroutine调用 入参: ctx 调用上下文 返回: PrintCapabilities 打印机制能力, error 查询或取消错误
func (*Window) QueryPrinter ¶
func (w *Window) QueryPrinter(ctx context.Context, options PrintOptions) (PrinterProfile, error)
QueryPrinter 根据纸张、方向、颜色及双面请求读取设备可打印区域,不提交作业 空Printer选择系统默认设备;不支持的请求返回错误,不静默替换纸张或双面方式 入参: ctx 查询上下文, options 待核对设备设置 返回: PrinterProfile 设备能力及当前纸面, error 配置、查询或取消错误
func (*Window) SaveFile ¶
SaveFile 选择保存路径并提示覆盖已有文件 入参: ctx 调用上下文, options 对话框选项 返回: string 保存路径, error 错误信息,用户取消返回ErrCanceled,并发调用返回ErrDialogBusy
func (*Window) SetDragRegions ¶
SetDragRegions 替换内容标题栏的原生拖动区域,空切片清除区域,系统模式返回错误 区域使用客户区逻辑像素,不随页面缩放变化,调用方负责排除交互控件并随布局更新 超出客户区的部分裁剪,系统按钮及调整大小的边缘优先,不改变页面内容或注入JS接口 入参: regions 拖动矩形集合,调用时复制,坐标和尺寸必须有限且尺寸非负 返回: error 设置错误
func (*Window) SetTitleBarColors ¶
func (w *Window) SetTitleBarColors(colors TitleBarColors) error
SetTitleBarColors 更新内容标题栏配色,零值恢复系统外观,系统标题栏模式返回错误 入参: colors 激活及失焦配色,非零值必须完整提供四种#RRGGBB颜色 返回: error 配色、模式或窗口错误
func (*Window) SetWindowMaterial ¶
func (w *Window) SetWindowMaterial(material WindowMaterial) error
SetWindowMaterial 更新窗口背景材质,空值视为WindowSolid,不支持的材质返回ErrUnsupportedPlatform 入参: material 窗口材质,纯色关闭系统背景材质 返回: error 材质或窗口错误
func (*Window) ShowPrintDialog ¶
func (w *Window) ShowPrintDialog(ctx context.Context, kind PrintDialogKind) error
ShowPrintDialog 为当前顶层文档打开打印对话框,空值默认采用PrintDialogSystem Windows返回表示对话框请求已交付,不能据此释放内容或认定打印成功 调用方可以监听页面afterprint,在对话框关闭后恢复界面;Linux取消返回ErrCanceled 入参: ctx 调用上下文, kind 打印窗口类型 返回: error 不支持、取消或窗口调用错误
func (*Window) ShowPrinterProperties ¶
ShowPrinterProperties 打开系统设备属性,不修改调用方内容或自行提交作业 用户可能在系统窗口修改设备默认值,返回后调用方应重新查询设备并更新预览 入参: ctx 调用上下文, printer 系统队列名称 返回: error 不支持、取消或窗口调用错误
func (*Window) TitleBarInfo ¶
func (w *Window) TitleBarInfo() (TitleBarInfo, error)
TitleBarInfo 返回当前标题栏布局和窗口状态 返回: TitleBarInfo 标题栏信息, error 查询错误
type WindowMaterial ¶
type WindowMaterial string
WindowMaterial 定义窗口的背景材质
const ( // WindowSolid 使用纯色窗口材质,为默认值 WindowSolid WindowMaterial = "solid" // WindowMicaAlt 使用云母Alt窗口材质 WindowMicaAlt WindowMaterial = "micaAlt" // WindowAcrylic 使用亚克力窗口材质 WindowAcrylic WindowMaterial = "acrylic" )
Source Files
¶
- guigo.go
- guigo_association.go
- guigo_association_other.go
- guigo_bridge.go
- guigo_call.go
- guigo_dialog_linux.go
- guigo_icon.go
- guigo_instance.go
- guigo_instance_desktop_other.go
- guigo_instance_linux.go
- guigo_linux.go
- guigo_print.go
- guigo_print_linux.go
- guigo_printer.go
- guigo_printer_linux.go
- guigo_resource.go
- guigo_resource_linux.go
- guigo_runtime_linux.go
- guigo_theme_linux.go
- guigo_tray.go
- guigo_tray_dbus_linux.go
- guigo_tray_linux.go
- guigo_tray_menu_linux.go