energy/cef/cef-browser-window-lcl_other.go

105 lines
2.8 KiB
Go
Raw Normal View History

//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under GNU General Public License v3.0
//
//----------------------------------------
//go:build !windows
// +build !windows
package cef
import (
"github.com/energye/energy/common"
"github.com/energye/golcl/lcl/types"
)
2023-02-14 15:25:02 +08:00
// TODO no
type customWindowCaption struct {
2023-01-25 22:26:08 +08:00
bw *LCLBrowserWindow
regions *TCefDraggableRegions
}
func (m *customWindowCaption) free() {
//TODO no
}
2023-02-14 15:25:02 +08:00
// 显示标题栏
func (m *LCLBrowserWindow) ShowTitle() {
if m.TForm == nil {
return
}
2023-02-16 17:26:38 +08:00
m.WindowProperty().EnableHideCaption = false
m.SetBorderStyle(types.BsSizeable)
}
2023-02-14 15:25:02 +08:00
// 隐藏标题栏
func (m *LCLBrowserWindow) HideTitle() {
if m.TForm == nil {
return
}
2023-02-16 17:26:38 +08:00
m.WindowProperty().EnableHideCaption = true
m.SetBorderStyle(types.BsNone)
}
// 默认事件注册 windows 消息事件
func (m *LCLBrowserWindow) registerWindowsCompMsgEvent() {
}
func (m *LCLBrowserWindow) setDraggableRegions() {
}
2023-02-14 15:25:02 +08:00
// for other platform maximize and restore
func (m *LCLBrowserWindow) Maximize() {
if m.TForm == nil {
return
}
QueueAsyncCall(func(id int) {
var bs = m.BorderStyle()
var monitor = m.Monitor().WorkareaRect()
if m.windowProperty == nil {
m.windowProperty = &WindowProperty{}
}
2023-02-15 14:48:18 +08:00
//这个if判断应该不会执行了windows有自己的linux是VF的mac走else
if (bs == types.BsNone || bs == types.BsSingle) && !common.IsDarwin() { //不能调整窗口大,所以手动控制窗口状态
var ws = m.WindowState()
var redWindowState types.TWindowState
//默认状态0
2023-02-15 14:48:18 +08:00
if m.windowProperty.windowState == types.WsNormal && m.windowProperty.windowState == ws {
redWindowState = types.WsMaximized
} else {
2023-02-15 14:48:18 +08:00
if m.windowProperty.windowState == types.WsNormal {
redWindowState = types.WsMaximized
2023-02-15 14:48:18 +08:00
} else if m.windowProperty.windowState == types.WsMaximized {
redWindowState = types.WsNormal
}
}
2023-02-15 14:48:18 +08:00
m.windowProperty.windowState = redWindowState
if redWindowState == types.WsMaximized {
m.windowProperty.X = m.Left()
m.windowProperty.Y = m.Top()
m.windowProperty.Width = m.Width()
m.windowProperty.Height = m.Height()
m.SetBounds(monitor.Left, monitor.Top, monitor.Right-monitor.Left-1, monitor.Bottom-monitor.Top-1)
} else if redWindowState == types.WsNormal {
m.SetBounds(m.windowProperty.X, m.windowProperty.Y, m.windowProperty.Width, m.windowProperty.Height)
}
m.SetWindowState(redWindowState)
} else {
if m.WindowState() == types.WsMaximized {
m.SetWindowState(types.WsNormal)
2023-02-15 14:48:18 +08:00
if common.IsDarwin() { //要这样重复设置2次不然不启作用
m.SetWindowState(types.WsMaximized)
m.SetWindowState(types.WsNormal)
}
} else if m.WindowState() == types.WsNormal {
m.SetWindowState(types.WsMaximized)
}
2023-02-15 14:48:18 +08:00
m.windowProperty.windowState = m.WindowState()
}
})
}