2022-10-04 13:21:05 +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
|
2022-10-04 13:21:05 +08:00
|
|
|
//
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
package cef
|
|
|
|
|
|
|
|
import (
|
2023-06-11 00:10:55 +08:00
|
|
|
"github.com/energye/energy/v2/cef/internal/def"
|
2023-05-31 18:00:34 +08:00
|
|
|
"github.com/energye/energy/v2/common/imports"
|
|
|
|
"github.com/energye/energy/v2/consts"
|
2022-10-04 13:21:05 +08:00
|
|
|
"github.com/energye/golcl/lcl"
|
|
|
|
"github.com/energye/golcl/lcl/api"
|
|
|
|
"github.com/energye/golcl/lcl/types"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// TCEFWindowParent 组件
|
2022-10-04 13:21:05 +08:00
|
|
|
type TCEFWindowParent struct {
|
|
|
|
BaseWinControl
|
2023-05-31 17:41:14 +08:00
|
|
|
x, y, w, h int32
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// NewCEFWindowParent 创建一个新的WindowParent组件
|
2022-10-04 13:21:05 +08:00
|
|
|
func NewCEFWindowParent(owner lcl.IComponent) *TCEFWindowParent {
|
|
|
|
m := new(TCEFWindowParent)
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CEFWindow_Create).Call(lcl.CheckPtr(owner))
|
2022-12-05 10:44:24 +08:00
|
|
|
m.instance = unsafe.Pointer(r1)
|
2022-10-04 13:21:05 +08:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
func (m *TCEFWindowParent) Instance() uintptr {
|
|
|
|
return uintptr(m.instance)
|
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// Handle 组件句柄
|
2022-10-04 13:21:05 +08:00
|
|
|
func (m *TCEFWindowParent) Handle() types.HWND {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetHandle).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return types.HWND(ret)
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// UpdateSize 更新组件大小
|
2022-10-04 13:21:05 +08:00
|
|
|
func (m *TCEFWindowParent) UpdateSize() {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_UpdateSize).Call(m.Instance())
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// Type 组件类型, 这里返回 TCEFWindowParent 类型
|
2022-10-26 19:52:55 +08:00
|
|
|
func (m *TCEFWindowParent) Type() consts.TCefWindowHandleType {
|
|
|
|
return consts.Wht_WindowParent
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// SetChromium 设置 IChromium, 只 TCEFLinkedWindowParent 有效
|
2022-12-01 15:24:22 +08:00
|
|
|
func (m *TCEFWindowParent) SetChromium(chromium IChromium, tag int32) {
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// HandleAllocated 处理所有
|
2022-10-04 13:21:05 +08:00
|
|
|
func (m *TCEFWindowParent) HandleAllocated() bool {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_HandleAllocated).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return api.GoBool(ret)
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// CreateHandle 创建句柄
|
2022-10-04 13:21:05 +08:00
|
|
|
func (m *TCEFWindowParent) CreateHandle() {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_CreateHandle).Call(m.Instance())
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// DestroyChildWindow 销毁子窗口
|
2022-10-04 13:21:05 +08:00
|
|
|
func (m *TCEFWindowParent) DestroyChildWindow() bool {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_DestroyChildWindow).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return api.GoBool(ret)
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// SetOnEnter 进入事件
|
2022-10-04 13:21:05 +08:00
|
|
|
func (m *TCEFWindowParent) SetOnEnter(fn lcl.TNotifyEvent) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_OnEnter).Call(m.Instance(), api.MakeEventDataPtr(fn))
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// SetOnExit 退出事件
|
2022-10-04 13:21:05 +08:00
|
|
|
func (m *TCEFWindowParent) SetOnExit(fn lcl.TNotifyEvent) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_OnExit).Call(m.Instance(), api.MakeEventDataPtr(fn))
|
2022-10-04 13:21:05 +08:00
|
|
|
}
|
2022-10-30 00:35:04 +08:00
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// Free 释放
|
2022-10-30 00:35:04 +08:00
|
|
|
func (m *TCEFWindowParent) Free() {
|
2022-12-05 10:44:24 +08:00
|
|
|
if m.IsValid() {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_Free).Call(m.Instance())
|
2023-03-24 09:11:32 +08:00
|
|
|
m.instance = nil
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// Name 获取组件名称
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Name() string {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetName).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return api.GoStr(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// SetName 设置组件名称
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetName(value string) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetName).Call(m.Instance(), api.PascalStr(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// SetParent 设置控件父容器
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetParent(value lcl.IWinControl) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetParent).Call(m.Instance(), lcl.CheckPtr(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
// RevertCustomAnchors 恢复到自定义四角锚点定位
|
|
|
|
func (m *TCEFWindowParent) RevertCustomAnchors() {
|
|
|
|
m.SetAlign(types.AlCustom)
|
|
|
|
m.SetAnchors(types.NewSet())
|
|
|
|
}
|
|
|
|
|
|
|
|
// DefaultAnchors 恢复到默认四角锚点定位
|
|
|
|
func (m *TCEFWindowParent) DefaultAnchors() {
|
|
|
|
m.SetAlign(types.AlClient)
|
|
|
|
m.SetAnchors(types.NewSet(types.AkTop, types.AkLeft, types.AkRight, types.AkBottom))
|
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// Align 获取控件自动调整
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Align() types.TAlign {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetAlign).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return types.TAlign(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// SetAlign 设置控件自动调整
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetAlign(value types.TAlign) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetAlign).Call(m.Instance(), uintptr(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// Anchors 获取四个角位置的锚点
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Anchors() types.TAnchors {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetAnchors).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return types.TAnchors(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// SetAnchors 设置四个角位置的锚点
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetAnchors(value types.TAnchors) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetAnchors).Call(m.Instance(), uintptr(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// Visible 获取控件可视
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Visible() bool {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetVisible).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return api.GoBool(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
// SetVisible 设置控件可视
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetVisible(value bool) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetVisible).Call(m.Instance(), api.PascalBool(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// Enabled 获取是否启用
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Enabled() bool {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetEnabled).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return api.GoBool(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// SetEnabled 设置是否启用
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetEnabled(value bool) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetEnabled).Call(m.Instance(), api.PascalBool(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// Left 获取左边距
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Left() int32 {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetLeft).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return int32(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// SetLeft 设置左边距
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetLeft(value int32) {
|
2023-05-31 17:41:14 +08:00
|
|
|
m.x = value
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetLeft).Call(m.Instance(), uintptr(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// Top 获取上边距
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Top() int32 {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetTop).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return int32(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// SetTop 设置上边距
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetTop(value int32) {
|
2023-05-31 17:41:14 +08:00
|
|
|
m.y = value
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetTop).Call(m.Instance(), uintptr(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// Width 获取宽度
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Width() int32 {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetWidth).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return int32(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// SetWidth 设置宽度
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetWidth(value int32) {
|
2023-05-31 17:41:14 +08:00
|
|
|
m.w = value
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetWidth).Call(m.Instance(), uintptr(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// Height 获取高度
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) Height() int32 {
|
2023-06-11 00:10:55 +08:00
|
|
|
ret, _, _ := imports.Proc(def.CEFWindow_GetHeight).Call(m.Instance())
|
2022-12-05 10:44:24 +08:00
|
|
|
return int32(ret)
|
|
|
|
}
|
|
|
|
|
2023-02-13 21:25:35 +08:00
|
|
|
// SetHeight 设置高度
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetHeight(value int32) {
|
2023-05-31 17:41:14 +08:00
|
|
|
m.h = value
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetHeight).Call(m.Instance(), uintptr(value))
|
2022-12-05 10:44:24 +08:00
|
|
|
}
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
// BoundsRect 获取坐标位置和宽高
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) BoundsRect() (result types.TRect) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_GetBoundsRect).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
2022-12-05 10:44:24 +08:00
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
// SetBoundsRect 设置坐标位置和宽高
|
2022-12-05 10:44:24 +08:00
|
|
|
func (m *TCEFWindowParent) SetBoundsRect(value types.TRect) {
|
2023-05-31 17:41:14 +08:00
|
|
|
m.x = value.Left
|
|
|
|
m.y = value.Top
|
|
|
|
m.w = value.Width()
|
|
|
|
m.h = value.Height()
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CEFWindow_SetBoundsRect).Call(m.Instance(), uintptr(unsafe.Pointer(&value)))
|
2022-10-30 00:35:04 +08:00
|
|
|
}
|
2023-05-31 17:41:14 +08:00
|
|
|
|
2023-06-15 12:11:06 +08:00
|
|
|
func (m *TCEFWindowParent) SetTag(tag int) {
|
|
|
|
imports.Proc(def.CEFWindow_SetTag).Call(m.Instance(), uintptr(int32(tag)))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *TCEFWindowParent) Tag() int {
|
|
|
|
r1, _, _ := imports.Proc(def.CEFWindow_GetTag).Call(m.Instance())
|
|
|
|
return int(int32(r1))
|
|
|
|
}
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
func (m *TCEFWindowParent) point() (x, y int32) {
|
|
|
|
return m.x, m.y
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *TCEFWindowParent) size() (w, h int32) {
|
|
|
|
return m.w, m.h
|
|
|
|
}
|