2023-01-07 21:29:08 +08:00
|
|
|
|
//----------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
|
//
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
|
//
|
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2023-01-07 21:29:08 +08:00
|
|
|
|
//
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
|
|
//go:build !windows
|
|
|
|
|
|
2023-02-20 00:20:01 +08:00
|
|
|
|
// LCL窗口组件定义和实现-非windows平台
|
2023-05-31 17:41:14 +08:00
|
|
|
|
|
2023-01-07 21:29:08 +08:00
|
|
|
|
package cef
|
|
|
|
|
|
2023-01-18 17:21:55 +08:00
|
|
|
|
import (
|
2023-05-31 18:00:34 +08:00
|
|
|
|
"github.com/energye/energy/v2/common"
|
2023-01-18 17:21:55 +08:00
|
|
|
|
"github.com/energye/golcl/lcl/types"
|
|
|
|
|
)
|
2023-01-07 21:35:32 +08:00
|
|
|
|
|
2023-02-14 15:25:02 +08:00
|
|
|
|
// TODO no
|
2023-01-20 10:17:45 +08:00
|
|
|
|
type customWindowCaption struct {
|
2023-01-25 22:26:08 +08:00
|
|
|
|
bw *LCLBrowserWindow
|
|
|
|
|
regions *TCefDraggableRegions
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *customWindowCaption) free() {
|
|
|
|
|
//TODO no
|
2023-01-20 10:17:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-14 15:25:02 +08:00
|
|
|
|
// 显示标题栏
|
2023-01-07 21:29:08 +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-01-07 21:29:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-14 15:25:02 +08:00
|
|
|
|
// 隐藏标题栏
|
2023-01-07 21:29:08 +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)
|
2023-01-07 21:29:08 +08:00
|
|
|
|
}
|
2023-01-18 08:37:08 +08:00
|
|
|
|
|
|
|
|
|
// 默认事件注册 windows 消息事件
|
|
|
|
|
func (m *LCLBrowserWindow) registerWindowsCompMsgEvent() {
|
|
|
|
|
|
|
|
|
|
}
|
2023-01-18 16:34:04 +08:00
|
|
|
|
|
|
|
|
|
func (m *LCLBrowserWindow) setDraggableRegions() {
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-14 15:25:02 +08:00
|
|
|
|
// for other platform maximize and restore
|
2023-01-18 16:34:04 +08:00
|
|
|
|
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() { //不能调整窗口大,所以手动控制窗口状态
|
2023-01-18 16:34:04 +08:00
|
|
|
|
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 {
|
2023-01-18 16:34:04 +08:00
|
|
|
|
redWindowState = types.WsMaximized
|
|
|
|
|
} else {
|
2023-02-15 14:48:18 +08:00
|
|
|
|
if m.windowProperty.windowState == types.WsNormal {
|
2023-01-18 16:34:04 +08:00
|
|
|
|
redWindowState = types.WsMaximized
|
2023-02-15 14:48:18 +08:00
|
|
|
|
} else if m.windowProperty.windowState == types.WsMaximized {
|
2023-01-18 16:34:04 +08:00
|
|
|
|
redWindowState = types.WsNormal
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-15 14:48:18 +08:00
|
|
|
|
m.windowProperty.windowState = redWindowState
|
2023-01-18 16:34:04 +08:00
|
|
|
|
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次不然不启作用
|
2023-01-18 16:34:04 +08:00
|
|
|
|
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()
|
2023-01-18 16:34:04 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|