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-07-13 10:56:49 +08:00
|
|
|
|
//TODO no impl
|
2023-01-18 08:37:08 +08:00
|
|
|
|
}
|
2023-01-18 16:34:04 +08:00
|
|
|
|
|
|
|
|
|
func (m *LCLBrowserWindow) setDraggableRegions() {
|
2023-07-13 10:56:49 +08:00
|
|
|
|
//TODO no impl
|
2023-01-18 16:34:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 16:40:37 +08:00
|
|
|
|
// FramelessForLine 窗口四边框是一条细线
|
|
|
|
|
func (m *LCLBrowserWindow) FramelessForLine() {
|
|
|
|
|
//TODO no impl
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-06 16:27:38 +08:00
|
|
|
|
// Restore 非Windows平台,窗口还原
|
|
|
|
|
func (m *LCLBrowserWindow) Restore() {
|
|
|
|
|
if m.TForm == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
m.RunOnMainThread(func() {
|
|
|
|
|
m.SetWindowState(types.WsNormal)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Minimize 非Windows平台,窗口最小化
|
|
|
|
|
func (m *LCLBrowserWindow) Minimize() {
|
|
|
|
|
if m.TForm == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
m.RunOnMainThread(func() {
|
|
|
|
|
m.SetWindowState(types.WsMinimized)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Maximize 非Windows平台,窗口最大化/还原
|
2023-01-18 16:34:04 +08:00
|
|
|
|
func (m *LCLBrowserWindow) Maximize() {
|
|
|
|
|
if m.TForm == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
QueueAsyncCall(func(id int) {
|
2023-07-23 17:42:29 +08:00
|
|
|
|
//var bs = m.BorderStyle()
|
|
|
|
|
//var monitor = m.Monitor().WorkareaRect()
|
2023-02-15 14:48:18 +08:00
|
|
|
|
//这个if判断应该不会执行了,windows有自己的,linux是VF的,mac走else
|
2023-07-23 17:42:29 +08:00
|
|
|
|
//if (bs == types.BsNone || bs == types.BsSingle) && !common.IsDarwin() { //不能调整窗口大,所以手动控制窗口状态
|
|
|
|
|
// var ws = m.WindowState()
|
|
|
|
|
// var redWindowState types.TWindowState
|
|
|
|
|
// //默认状态0
|
|
|
|
|
// if m.windowProperty.windowState == types.WsNormal && m.windowProperty.windowState == ws {
|
|
|
|
|
// redWindowState = types.WsMaximized
|
|
|
|
|
// } else {
|
|
|
|
|
// if m.windowProperty.windowState == types.WsNormal {
|
|
|
|
|
// redWindowState = types.WsMaximized
|
|
|
|
|
// } else if m.windowProperty.windowState == types.WsMaximized {
|
|
|
|
|
// redWindowState = types.WsNormal
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// 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)
|
|
|
|
|
if common.IsDarwin() { //要这样重复设置2次不然不启作用
|
2023-01-18 16:34:04 +08:00
|
|
|
|
m.SetWindowState(types.WsMaximized)
|
2023-07-23 17:42:29 +08:00
|
|
|
|
m.SetWindowState(types.WsNormal)
|
2023-01-18 16:34:04 +08:00
|
|
|
|
}
|
2023-07-23 17:42:29 +08:00
|
|
|
|
} else if m.WindowState() == types.WsNormal {
|
|
|
|
|
m.SetWindowState(types.WsMaximized)
|
2023-01-18 16:34:04 +08:00
|
|
|
|
}
|
2023-07-23 17:42:29 +08:00
|
|
|
|
//m.windowProperty.windowState = m.WindowState()
|
|
|
|
|
//}
|
2023-01-18 16:34:04 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
2023-07-14 18:50:14 +08:00
|
|
|
|
|
2023-08-16 20:46:00 +08:00
|
|
|
|
// SetFocus 设置窗口焦点
|
|
|
|
|
func (m *LCLBrowserWindow) SetFocus() {
|
|
|
|
|
if m.TForm != nil {
|
|
|
|
|
m.TForm.SetFocus()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 12:00:49 +08:00
|
|
|
|
func (m *LCLBrowserWindow) doDrag() {
|
|
|
|
|
// MacOS/Linux Drag Window
|
|
|
|
|
if m.drag != nil {
|
|
|
|
|
m.drag.drag()
|
|
|
|
|
}
|
2023-07-14 18:50:14 +08:00
|
|
|
|
}
|