2023-05-31 17:41:14 +08:00
|
|
|
//----------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
//
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
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"
|
2023-05-31 17:41:14 +08:00
|
|
|
"github.com/energye/golcl/lcl"
|
|
|
|
"github.com/energye/golcl/lcl/api"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Instance 实例
|
|
|
|
func (m *ICefDragData) Instance() uintptr {
|
|
|
|
if m == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return uintptr(m.instance)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) Free() {
|
|
|
|
if m.instance != nil {
|
|
|
|
m.base.Free(m.Instance())
|
|
|
|
m.instance = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) IsValid() bool {
|
|
|
|
if m == nil || m.instance == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return m.instance != nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) Clone() *ICefDragData {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
var result uintptr
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_Clone).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
2023-05-31 17:41:14 +08:00
|
|
|
if result != 0 {
|
|
|
|
return &ICefDragData{instance: getInstance(result)}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) IsReadOnly() bool {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_IsReadOnly).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoBool(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) IsLink() bool {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_IsLink).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoBool(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) IsFragment() bool {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_IsFragment).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoBool(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) IsFile() bool {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_IsFile).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoBool(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetLinkUrl() string {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetLinkUrl).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoStr(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetLinkTitle() string {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetLinkTitle).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoStr(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetLinkMetadata() string {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetLinkMetadata).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoStr(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetFragmentText() string {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetFragmentText).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoStr(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetFragmentHtml() string {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetFragmentHtml).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoStr(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetFragmentBaseUrl() string {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetFragmentBaseUrl).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoStr(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetFileName() string {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetFileName).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoStr(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetFileContents(writer *ICefStreamWriter) uint32 {
|
|
|
|
if !m.IsValid() || !writer.IsValid() {
|
|
|
|
return 0
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetFileContents).Call(m.Instance(), writer.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return uint32(r1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetFileNames() ([]string, int32) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return nil, 0
|
|
|
|
}
|
|
|
|
var result uintptr
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_GetFileNames).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
2023-05-31 17:41:14 +08:00
|
|
|
if result != 0 && r1 > 0 {
|
|
|
|
fileNamesList := lcl.AsStrings(result)
|
|
|
|
if fileNamesList.IsValid() {
|
|
|
|
count := int(fileNamesList.Count())
|
|
|
|
fileNames := make([]string, count, count)
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
fileNames[i] = fileNamesList.Strings(int32(i))
|
|
|
|
}
|
|
|
|
fileNamesList.Free()
|
|
|
|
return fileNames, int32(count)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil, 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) SetLinkUrl(url string) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_SetLinkUrl).Call(m.Instance(), api.PascalStr(url))
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) SetLinkTitle(title string) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_SetLinkTitle).Call(m.Instance(), api.PascalStr(title))
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) SetLinkMetadata(data string) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_SetLinkMetadata).Call(m.Instance(), api.PascalStr(data))
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) SetFragmentText(text string) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_SetFragmentText).Call(m.Instance(), api.PascalStr(text))
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) SetFragmentHtml(html string) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_SetFragmentHtml).Call(m.Instance(), api.PascalStr(html))
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) SetFragmentBaseUrl(baseUrl string) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_SetFragmentBaseUrl).Call(m.Instance(), api.PascalStr(baseUrl))
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) ResetFileContents() {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_ResetFileContents).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) AddFile(path, displayName string) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_AddFile).Call(m.Instance(), api.PascalStr(path), api.PascalStr(displayName))
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) ClearFilenames() {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_ClearFilenames).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetImage() *ICefImage {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
var result uintptr
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_GetImage).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
2023-05-31 17:41:14 +08:00
|
|
|
if result != 0 {
|
|
|
|
return &ICefImage{instance: getInstance(result)}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) GetImageHotspot() *TCefPoint {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
var result uintptr
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefDragData_GetImageHotspot).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
2023-05-31 17:41:14 +08:00
|
|
|
if result != 0 {
|
|
|
|
return (*TCefPoint)(unsafe.Pointer(result))
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefDragData) HasImage() bool {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
2023-06-11 00:10:55 +08:00
|
|
|
r1, _, _ := imports.Proc(def.CefDragData_HasImage).Call(m.Instance())
|
2023-05-31 17:41:14 +08:00
|
|
|
return api.GoBool(r1)
|
|
|
|
}
|