energy/cef/cef-browser-window-views-framework.go

597 lines
21 KiB
Go
Raw Normal View History

//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
2023-02-20 00:20:01 +08:00
// VF窗口组件定义和实现
package cef
import (
"github.com/energye/energy/common"
"github.com/energye/energy/common/assetserve"
"github.com/energye/energy/consts"
"github.com/energye/golcl/energy/emfs"
"github.com/energye/golcl/energy/tools"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/api"
"github.com/energye/golcl/lcl/types"
)
// ViewsFrameworkBrowserWindow 基于CEF views framework 窗口组件
//
// 该窗口使用CEF内部实现在linux下107.xx以后版本默认使用GTK3但无法使用lcl组件集成到窗口中
//
// 当创建应用配置时 MultiThreadedMessageLoop 和 ExternalMessagePump 属性同时为false(linux系统默认强制false)时启用ViewsFramework窗口
type ViewsFrameworkBrowserWindow struct {
2023-01-28 11:46:09 +08:00
isClosing bool //
windowType consts.WINDOW_TYPE //0:browser 1:devTools 2:viewSource 默认:0
windowId int32 //
chromium IChromium //
component lcl.IComponent //
windowComponent *TCEFWindowComponent //
browserViewComponent *TCEFBrowserViewComponent //
windowProperty *WindowProperty //窗口属性
frames TCEFFrame //当前浏览器下的所有frame
auxTools *auxTools //辅助工具
tray ITray //托盘
2023-02-14 15:25:02 +08:00
doOnWindowCreated WindowComponentOnWindowCreated //窗口创建
2023-01-28 11:46:09 +08:00
doOnGetInitialBounds WindowComponentOnGetInitialBounds //窗口初始bounds
regions *TCefDraggableRegions //窗口内html拖拽区域
}
2023-02-20 00:20:01 +08:00
// NewViewsFrameworkBrowserWindow 创建 ViewsFrameworkBrowserWindow 窗口
func NewViewsFrameworkBrowserWindow(chromiumConfig *tCefChromiumConfig, windowProperty WindowProperty, owner ...lcl.IComponent) *ViewsFrameworkBrowserWindow {
if chromiumConfig == nil {
chromiumConfig = NewChromiumConfig()
chromiumConfig.SetEnableViewSource(false)
chromiumConfig.SetEnableDevTools(false)
chromiumConfig.SetEnableMenu(false)
chromiumConfig.SetEnableWindowPopup(false)
}
var component lcl.IComponent
if len(owner) > 0 {
component = lcl.NewComponent(owner[0])
} else {
component = lcl.NewComponent(nil)
}
m := &ViewsFrameworkBrowserWindow{
windowProperty: &windowProperty,
component: component,
chromium: NewChromium(component, chromiumConfig),
windowComponent: NewWindowComponent(component),
browserViewComponent: NewBrowserViewComponent(component),
}
2023-02-03 08:36:26 +08:00
m.SetWindowType(windowProperty.WindowType)
m.chromium.SetEnableMultiBrowserMode(true)
m.windowComponent.SetOnWindowCreated(func(sender lcl.IObject, window *ICefWindow) {
if m.chromium.CreateBrowserByBrowserViewComponent(windowProperty.Url, m.browserViewComponent) {
m.windowComponent.AddChildView(m.browserViewComponent)
if windowProperty.Title != "" {
m.windowComponent.SetTitle(windowProperty.Title)
}
if windowProperty.EnableCenterWindow {
m.windowComponent.CenterWindow(NewCefSize(windowProperty.Width, windowProperty.Height))
}
if windowProperty.IconFS != "" {
if emfs.IsExist(windowProperty.IconFS) {
_ = m.windowComponent.SetWindowAppIconFS(1, windowProperty.IconFS)
}
} else if windowProperty.Icon != "" {
if tools.IsExist(windowProperty.Icon) {
_ = m.windowComponent.SetWindowAppIcon(1, windowProperty.Icon)
}
}
m.browserViewComponent.RequestFocus()
m.windowComponent.Show()
if m.doOnWindowCreated != nil {
m.doOnWindowCreated(sender, window)
}
}
})
return m
}
// ViewsFrameworkBrowserWindow 主窗口初始化
func (m *browser) appContextInitialized(app *TCEFApplication) {
if !common.Args.IsMain() {
return
}
app.SetOnContextInitialized(func() {
2023-02-03 08:36:26 +08:00
m.Config.WindowProperty.WindowType = consts.WT_MAIN_BROWSER
vFrameBrowserWindow := NewViewsFrameworkBrowserWindow(m.Config.ChromiumConfig(), m.Config.WindowProperty)
vFrameBrowserWindow.Chromium().SetOnBeforeClose(func(sender lcl.IObject, browser *ICefBrowser) {
if vFrameBrowserWindow.tray != nil {
vFrameBrowserWindow.tray.close()
}
})
vFrameBrowserWindow.ResetWindowPropertyForEvent()
vFrameBrowserWindow.windowId = BrowserWindow.GetNextWindowNum()
vFrameBrowserWindow.putChromiumWindowInfo()
vFrameBrowserWindow.registerPopupEvent()
vFrameBrowserWindow.registerDefaultEvent()
vFrameBrowserWindow.windowComponent.SetOnCanClose(func(sender lcl.IObject, window *ICefWindow, aResult *bool) {
*aResult = true
app.QuitMessageLoop()
})
vFrameBrowserWindow.doOnWindowCreated = func(sender lcl.IObject, window *ICefWindow) {
if m.Config.browserWindowAfterOnEventCallback != nil {
m.Config.browserWindowAfterOnEventCallback(vFrameBrowserWindow)
}
}
BrowserWindow.mainVFBrowserWindow = vFrameBrowserWindow
if m.Config.browserWindowOnEventCallback != nil {
BrowserWindow.browserEvent.chromium = vFrameBrowserWindow.chromium
m.Config.browserWindowOnEventCallback(BrowserWindow.browserEvent, vFrameBrowserWindow)
}
vFrameBrowserWindow.windowComponent.CreateTopLevelWindow()
})
}
2023-02-20 00:20:01 +08:00
// registerPopupEvent 注册弹出子窗口事件
func (m *ViewsFrameworkBrowserWindow) registerPopupEvent() {
var bwEvent = BrowserWindow.browserEvent
m.chromium.SetOnBeforePopup(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, noJavascriptAccess *bool) bool {
if !api.GoBool(BrowserWindow.Config.chromiumConfig.enableWindowPopup) {
return true
}
2023-01-31 19:44:03 +08:00
wp := BrowserWindow.Config.WindowProperty
wp.Url = beforePopupInfo.TargetUrl
2023-02-03 08:36:26 +08:00
wp.WindowType = consts.WT_POPUP_SUB_BROWSER
2023-01-31 19:44:03 +08:00
var vfbw = NewViewsFrameworkBrowserWindow(BrowserWindow.Config.ChromiumConfig(), wp, BrowserWindow.MainWindow().AsViewsFrameworkBrowserWindow().Component())
var result = false
if bwEvent.onBeforePopup != nil {
result = bwEvent.onBeforePopup(sender, browser, frame, beforePopupInfo, vfbw, noJavascriptAccess)
}
if !result {
vfbw.ResetWindowPropertyForEvent()
vfbw.SetWindowType(consts.WT_POPUP_SUB_BROWSER)
vfbw.windowId = BrowserWindow.GetNextWindowNum()
vfbw.putChromiumWindowInfo()
vfbw.registerPopupEvent()
vfbw.registerDefaultEvent()
vfbw.windowComponent.CreateTopLevelWindow()
result = true
}
return result
})
}
2023-02-20 00:20:01 +08:00
// ResetWindowPropertyForEvent 重置窗口属性-通过事件函数
func (m *ViewsFrameworkBrowserWindow) ResetWindowPropertyForEvent() {
2023-01-28 11:46:09 +08:00
wp := m.WindowProperty()
m.windowComponent.SetOnGetInitialBounds(func(sender lcl.IObject, window *ICefWindow, aResult *TCefRect) {
if wp.EnableCenterWindow {
m.windowComponent.CenterWindow(NewCefSize(wp.Width, wp.Height))
aResult.Width = wp.Width
aResult.Height = wp.Height
} else {
aResult.X = wp.X
aResult.Y = wp.Y
aResult.Width = wp.Width
aResult.Height = wp.Height
}
if m.doOnGetInitialBounds != nil {
m.doOnGetInitialBounds(sender, window, aResult)
}
})
m.windowComponent.SetOnCanMinimize(func(sender lcl.IObject, window *ICefWindow, aResult *bool) {
2023-01-28 11:46:09 +08:00
*aResult = wp.EnableMinimize
})
m.windowComponent.SetOnCanResize(func(sender lcl.IObject, window *ICefWindow, aResult *bool) {
2023-01-28 11:46:09 +08:00
*aResult = wp.EnableResize
})
m.windowComponent.SetOnCanMaximize(func(sender lcl.IObject, window *ICefWindow, aResult *bool) {
2023-01-28 11:46:09 +08:00
*aResult = wp.EnableMaximize
})
m.windowComponent.SetOnCanClose(func(sender lcl.IObject, window *ICefWindow, aResult *bool) {
2023-01-28 11:46:09 +08:00
*aResult = wp.EnableClose
})
m.windowComponent.SetOnIsFrameless(func(sender lcl.IObject, window *ICefWindow, aResult *bool) {
*aResult = wp.EnableHideCaption
})
2023-01-28 11:46:09 +08:00
m.windowComponent.SetAlwaysOnTop(wp.AlwaysOnTop)
m.windowComponent.SetBounds(NewCefRect(wp.X, wp.Y, wp.Width, wp.Height))
}
2023-02-20 00:20:01 +08:00
// registerDefaultEvent 注册默认事件
func (m *ViewsFrameworkBrowserWindow) registerDefaultEvent() {
var bwEvent = BrowserWindow.browserEvent
//默认自定义快捷键
defaultAcceleratorCustom()
2023-02-26 21:17:28 +08:00
m.chromium.SetOnProcessMessageReceived(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, sourceProcess consts.CefProcessId, message *ICefProcessMessage) bool {
if bwEvent.onProcessMessageReceived != nil {
return bwEvent.onProcessMessageReceived(sender, browser, frame, sourceProcess, message)
}
return false
})
m.chromium.SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, callback *ICefCallback, result *consts.TCefReturnValue) {
if assetserve.AssetsServerHeaderKeyValue != "" {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
}
if bwEvent.onBeforeResourceLoad != nil {
bwEvent.onBeforeResourceLoad(sender, browser, frame, request, callback, result)
}
})
//事件可以覆盖
2023-02-28 09:55:20 +08:00
m.chromium.SetOnBeforeDownload(func(sender lcl.IObject, browser *ICefBrowser, beforeDownloadItem *ICefDownloadItem, suggestedName string, callback *ICefBeforeDownloadCallback) {
if bwEvent.onBeforeDownload != nil {
bwEvent.onBeforeDownload(sender, browser, beforeDownloadItem, suggestedName, callback)
} else {
callback.Cont(consts.ExePath+consts.Separator+suggestedName, true)
}
})
//事件可以覆盖
m.chromium.SetOnBeforeContextMenu(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, params *ICefContextMenuParams, model *ICefMenuModel) {
if bwEvent.onBeforeContextMenu != nil {
bwEvent.onBeforeContextMenu(sender, browser, frame, params, model)
} else {
chromiumOnBeforeContextMenu(sender, browser, frame, params, model)
}
})
//事件可以覆盖
m.chromium.SetOnContextMenuCommand(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, params *ICefContextMenuParams, commandId consts.MenuId, eventFlags uint32, result *bool) {
if bwEvent.onContextMenuCommand != nil {
bwEvent.onContextMenuCommand(sender, browser, frame, params, commandId, eventFlags, result)
} else {
chromiumOnContextMenuCommand(sender, browser, frame, params, commandId, eventFlags, result)
}
})
m.chromium.SetOnFrameCreated(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame) {
if bwEvent.onFrameCreated != nil {
bwEvent.onFrameCreated(sender, browser, frame)
}
})
m.chromium.SetOnFrameDetached(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame) {
chromiumOnFrameDetached(browser, frame)
if bwEvent.onFrameDetached != nil {
bwEvent.onFrameDetached(sender, browser, frame)
}
})
m.chromium.SetOnAfterCreated(func(sender lcl.IObject, browser *ICefBrowser) {
if chromiumOnAfterCreate(browser) {
return
}
if bwEvent.onAfterCreated != nil {
bwEvent.onAfterCreated(sender, browser)
}
})
//事件可以被覆盖
m.chromium.SetOnKeyEvent(func(sender lcl.IObject, browser *ICefBrowser, event *TCefKeyEvent, result *bool) {
if bwEvent.onKeyEvent != nil {
bwEvent.onKeyEvent(sender, browser, event, result)
} else {
if api.GoBool(BrowserWindow.Config.chromiumConfig.enableDevTools) {
if winInfo := BrowserWindow.GetWindowInfo(browser.Identifier()); winInfo != nil {
if winInfo.WindowType() == consts.WT_DEV_TOOLS || winInfo.WindowType() == consts.WT_VIEW_SOURCE {
return
}
}
if event.WindowsKeyCode == VkF12 && event.Kind == consts.KEYEVENT_RAW_KEYDOWN {
browser.ShowDevTools()
*result = true
} else if event.WindowsKeyCode == VkF12 && event.Kind == consts.KEYEVENT_KEYUP {
*result = true
}
}
if KeyAccelerator.accelerator(browser, event, result) {
return
}
}
})
m.chromium.SetOnBeforeBrowser(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame) bool {
chromiumOnBeforeBrowser(browser, frame)
if bwEvent.onBeforeBrowser != nil {
return bwEvent.onBeforeBrowser(sender, browser, frame)
}
return false
})
m.chromium.SetOnTitleChange(func(sender lcl.IObject, browser *ICefBrowser, title string) {
if bwEvent.onTitleChange != nil {
bwEvent.onTitleChange(sender, browser, title)
}
})
m.chromium.SetOnDragEnter(func(sender lcl.IObject, browser *ICefBrowser, dragData *ICefDragData, mask consts.TCefDragOperations, result *bool) {
*result = !m.WindowProperty().EnableDragFile
if bwEvent.onDragEnter != nil {
bwEvent.onDragEnter(sender, browser, dragData, mask, result)
}
})
m.chromium.SetOnLoadEnd(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, httpStatusCode int32) {
if bwEvent.onLoadEnd != nil {
bwEvent.onLoadEnd(sender, browser, frame, httpStatusCode)
}
})
if m.WindowProperty().EnableWebkitAppRegion {
m.chromium.SetOnDraggableRegionsChanged(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, regions *TCefDraggableRegions) {
if bwEvent.onDraggableRegionsChanged != nil {
bwEvent.onDraggableRegionsChanged(sender, browser, frame, regions)
}
m.regions = regions
m.windowComponent.SetDraggableRegions(regions.Regions())
})
}
}
2023-02-20 00:20:01 +08:00
// EnableAllDefaultEvent 启用所有默认事件行为
func (m *ViewsFrameworkBrowserWindow) EnableAllDefaultEvent() {
m.registerPopupEvent()
m.registerDefaultEvent()
}
2023-02-20 00:20:01 +08:00
// SetOnWindowCreated 窗口创建
func (m *ViewsFrameworkBrowserWindow) SetOnWindowCreated(onWindowCreated WindowComponentOnWindowCreated) {
m.doOnWindowCreated = onWindowCreated
}
2023-02-20 00:20:01 +08:00
// SetOnGetInitialBounds 窗口初始坐标和大小
2023-01-28 11:46:09 +08:00
func (m *ViewsFrameworkBrowserWindow) SetOnGetInitialBounds(onGetInitialBounds WindowComponentOnGetInitialBounds) {
m.doOnGetInitialBounds = onGetInitialBounds
}
2023-02-20 00:20:01 +08:00
// IsViewsFramework 返回是否VF窗口组件这里返回true
func (m *ViewsFrameworkBrowserWindow) IsViewsFramework() bool {
return true
}
2023-02-20 00:20:01 +08:00
// IsLCL 返回是否LCL窗口组件这里返回false
func (m *ViewsFrameworkBrowserWindow) IsLCL() bool {
return false
}
2023-02-20 00:20:01 +08:00
// WindowProperty 部分提供部分窗口属性设置
func (m *ViewsFrameworkBrowserWindow) WindowProperty() *WindowProperty {
return m.windowProperty
}
2023-02-20 00:20:01 +08:00
// putChromiumWindowInfo
func (m *ViewsFrameworkBrowserWindow) putChromiumWindowInfo() {
BrowserWindow.putWindowInfo(m.windowId, m)
}
2023-02-20 00:20:01 +08:00
// BrowserWindow 返回VF窗口组件实现
func (m *ViewsFrameworkBrowserWindow) BrowserWindow() *ViewsFrameworkBrowserWindow {
return m
}
2023-02-20 00:20:01 +08:00
// Handle 返回窗口句柄
func (m *ViewsFrameworkBrowserWindow) Handle() types.HWND {
return types.HWND(m.WindowComponent().WindowHandle().ToPtr())
}
2023-02-20 00:20:01 +08:00
// AsViewsFrameworkBrowserWindow 转换为VF窗口组件这里返回VF窗口组件
func (m *ViewsFrameworkBrowserWindow) AsViewsFrameworkBrowserWindow() IViewsFrameworkBrowserWindow {
return m
}
2023-02-20 00:20:01 +08:00
// AsLCLBrowserWindow 转换为LCL窗口组件这里返回nil
func (m *ViewsFrameworkBrowserWindow) AsLCLBrowserWindow() ILCLBrowserWindow {
return nil
}
2023-02-20 00:20:01 +08:00
// SetTitle 设置窗口标题
func (m *ViewsFrameworkBrowserWindow) SetTitle(title string) {
m.WindowProperty().Title = title
}
2023-02-20 00:20:01 +08:00
// SetWidth 设置窗口宽
func (m *ViewsFrameworkBrowserWindow) SetWidth(value int32) {
m.WindowProperty().Width = value
}
2023-02-20 00:20:01 +08:00
// SetHeight 设置窗口高
func (m *ViewsFrameworkBrowserWindow) SetHeight(value int32) {
m.WindowProperty().Height = value
}
2023-02-20 00:20:01 +08:00
// Point 返回窗口坐标
func (m *ViewsFrameworkBrowserWindow) Point() *TCefPoint {
result := m.WindowComponent().Position()
m.WindowProperty().X = result.X
m.WindowProperty().Y = result.Y
return result
}
2023-02-20 00:20:01 +08:00
// Size 返回窗口宽高
func (m *ViewsFrameworkBrowserWindow) Size() *TCefSize {
result := m.WindowComponent().Size()
m.WindowProperty().Width = result.Width
m.WindowProperty().Height = result.Height
return result
}
2023-02-20 00:20:01 +08:00
// Bounds 返回窗口坐标和宽高
func (m *ViewsFrameworkBrowserWindow) Bounds() *TCefRect {
result := m.WindowComponent().Bounds()
m.WindowProperty().X = result.X
m.WindowProperty().Y = result.Y
m.WindowProperty().Width = result.Width
m.WindowProperty().Height = result.Height
return result
}
2023-02-20 00:20:01 +08:00
// SetPoint 设置窗口坐标
func (m *ViewsFrameworkBrowserWindow) SetPoint(x, y int32) {
m.WindowProperty().X = x
m.WindowProperty().Y = y
}
2023-02-20 00:20:01 +08:00
// SetSize 设置窗口宽高
func (m *ViewsFrameworkBrowserWindow) SetSize(width, height int32) {
m.WindowProperty().Width = width
m.WindowProperty().Height = height
}
2023-02-20 00:20:01 +08:00
// SetBounds 设置窗口坐标和宽高
func (m *ViewsFrameworkBrowserWindow) SetBounds(x, y, width, height int32) {
m.WindowProperty().X = x
m.WindowProperty().Y = y
m.WindowProperty().Width = width
m.WindowProperty().Height = height
}
2023-02-20 00:20:01 +08:00
// getAuxTools 获取辅助工具-开发者工具
func (m *ViewsFrameworkBrowserWindow) getAuxTools() *auxTools {
return m.auxTools
}
2023-02-20 00:20:01 +08:00
// createAuxTools 创建辅助工具-开发者工具
func (m *ViewsFrameworkBrowserWindow) createAuxTools() {
if m.auxTools == nil {
m.auxTools = &auxTools{}
}
}
2023-02-20 00:20:01 +08:00
// Browser 返回browser
func (m *ViewsFrameworkBrowserWindow) Browser() *ICefBrowser {
2023-02-26 19:14:49 +08:00
return m.Chromium().Browser()
}
2023-02-20 00:20:01 +08:00
// Frames 获取Frames
func (m *ViewsFrameworkBrowserWindow) Frames() TCEFFrame {
return m.frames
}
2023-02-20 00:20:01 +08:00
// Chromium 返回 chromium
func (m *ViewsFrameworkBrowserWindow) Chromium() IChromium {
return m.chromium
}
2023-02-20 00:20:01 +08:00
// Id 获取窗口ID
func (m *ViewsFrameworkBrowserWindow) Id() int32 {
return m.windowId
}
2023-02-20 00:20:01 +08:00
// Show 显示窗口
func (m *ViewsFrameworkBrowserWindow) Show() {
m.WindowComponent().Show()
}
2023-02-20 00:20:01 +08:00
// Hide 隐藏窗口
func (m *ViewsFrameworkBrowserWindow) Hide() {
m.WindowComponent().Hide()
}
2023-02-20 00:20:01 +08:00
// Close 关闭窗口,一搬不使用
func (m *ViewsFrameworkBrowserWindow) Close() {
m.WindowComponent().Close()
}
2023-02-20 00:20:01 +08:00
// WindowState 返回窗口最小化、最大化、全屏状态
2023-02-14 15:25:02 +08:00
func (m *ViewsFrameworkBrowserWindow) WindowState() types.TWindowState {
if m.windowComponent.IsMinimized() {
return types.WsMinimized
} else if m.windowComponent.IsMaximized() {
return types.WsMaximized
} else if m.windowComponent.IsFullscreen() {
return types.WsFullScreen
}
return types.WsNormal
}
2023-02-20 00:20:01 +08:00
// Maximize 窗口最大化/还原
func (m *ViewsFrameworkBrowserWindow) Maximize() {
2023-02-15 14:48:18 +08:00
m.windowProperty.windowState = m.WindowState()
if m.windowProperty.windowState == types.WsNormal {
2023-02-14 15:25:02 +08:00
m.WindowComponent().Maximize()
} else {
m.Restore()
}
}
2023-02-20 00:20:01 +08:00
// Minimize 窗口最小化
func (m *ViewsFrameworkBrowserWindow) Minimize() {
m.WindowComponent().Minimize()
}
2023-02-20 00:20:01 +08:00
// Restore 窗口还原
func (m *ViewsFrameworkBrowserWindow) Restore() {
m.WindowComponent().Restore()
}
2023-02-20 00:20:01 +08:00
// CloseBrowserWindow 关闭浏览器窗口
func (m *ViewsFrameworkBrowserWindow) CloseBrowserWindow() {
m.isClosing = true
m.chromium.CloseBrowser(true)
}
2023-02-20 00:20:01 +08:00
// CreateTopLevelWindow 创建顶层窗口
func (m *ViewsFrameworkBrowserWindow) CreateTopLevelWindow() {
m.WindowComponent().CreateTopLevelWindow()
}
2023-02-20 00:20:01 +08:00
// CenterWindow 设置窗口居中,同时指定窗口大小
func (m *ViewsFrameworkBrowserWindow) CenterWindow(size *TCefSize) {
m.WindowComponent().CenterWindow(size)
}
2023-02-20 00:20:01 +08:00
// SetCenterWindow 设置窗口居中显示
func (m *ViewsFrameworkBrowserWindow) SetCenterWindow(value bool) {
m.WindowProperty().EnableCenterWindow = value
}
2023-02-20 00:20:01 +08:00
// IsClosing 返回窗口是否正在关闭/或已关闭 true正在或已关闭
func (m *ViewsFrameworkBrowserWindow) IsClosing() bool {
return m.isClosing
}
2023-02-20 00:20:01 +08:00
// WindowType 返回窗口类型
func (m *ViewsFrameworkBrowserWindow) WindowType() consts.WINDOW_TYPE {
return m.windowType
}
2023-02-20 00:20:01 +08:00
// SetWindowType 设置窗口类型
func (m *ViewsFrameworkBrowserWindow) SetWindowType(windowType consts.WINDOW_TYPE) {
m.windowType = windowType
}
2023-02-20 00:20:01 +08:00
// DisableMinimize 禁用最小化按钮
func (m *ViewsFrameworkBrowserWindow) DisableMinimize() {
m.WindowProperty().EnableMinimize = false
}
2023-02-20 00:20:01 +08:00
// DisableMaximize 禁用最大化按钮
func (m *ViewsFrameworkBrowserWindow) DisableMaximize() {
m.WindowProperty().EnableMaximize = false
}
2023-02-20 00:20:01 +08:00
// DisableResize 禁用调整窗口大小
func (m *ViewsFrameworkBrowserWindow) DisableResize() {
m.WindowProperty().EnableResize = false
}
2023-02-20 00:20:01 +08:00
// EnableMinimize 启用最小化按钮
func (m *ViewsFrameworkBrowserWindow) EnableMinimize() {
m.WindowProperty().EnableMinimize = true
}
2023-02-20 00:20:01 +08:00
// EnableMaximize 启用最大化按钮
func (m *ViewsFrameworkBrowserWindow) EnableMaximize() {
m.WindowProperty().EnableMaximize = true
}
2023-02-20 00:20:01 +08:00
// EnableResize 启用允许调整窗口大小
func (m *ViewsFrameworkBrowserWindow) EnableResize() {
m.WindowProperty().EnableResize = true
}
2023-02-20 00:20:01 +08:00
// Component 返回窗口父组件
func (m *ViewsFrameworkBrowserWindow) Component() lcl.IComponent {
return m.component
}
2023-02-20 00:20:01 +08:00
// WindowComponent 返回窗口组件
func (m *ViewsFrameworkBrowserWindow) WindowComponent() *TCEFWindowComponent {
return m.windowComponent
}
2023-02-20 00:20:01 +08:00
// BrowserViewComponent 返回浏览器显示组件
func (m *ViewsFrameworkBrowserWindow) BrowserViewComponent() *TCEFBrowserViewComponent {
return m.browserViewComponent
}