2023-02-19 23:21:47 +08:00
|
|
|
//----------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
//
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// CEF Browser View
|
2023-05-31 17:41:14 +08:00
|
|
|
|
2022-12-14 19:18:11 +08:00
|
|
|
package cef
|
|
|
|
|
2023-02-28 21:52:13 +08:00
|
|
|
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-02-28 21:52:13 +08:00
|
|
|
"github.com/energye/golcl/lcl/api"
|
|
|
|
"unsafe"
|
|
|
|
)
|
2022-12-14 19:18:11 +08:00
|
|
|
|
2023-07-02 22:06:51 +08:00
|
|
|
// BrowserViewRef -> ICefBrowserView
|
|
|
|
var BrowserViewRef browserView
|
|
|
|
|
|
|
|
type browserView uintptr
|
|
|
|
|
|
|
|
func (*browserView) New(client *ICefClient, url string, browserSettings *TCefBrowserSettings, extraInfo *ICefDictionaryValue, requestContext *ICefRequestContext, delegate *ICefBrowserViewDelegate) *ICefBrowserView {
|
|
|
|
var browserSettingsPtr = browserSettings.ToPtr()
|
|
|
|
var result uintptr
|
2023-07-03 12:09:25 +08:00
|
|
|
if extraInfo == nil {
|
|
|
|
extraInfo = DictionaryValueRef.New()
|
|
|
|
}
|
2023-07-02 22:06:51 +08:00
|
|
|
imports.Proc(def.CefBrowserViewRef_Create).Call(client.Instance(), api.PascalStr(url), uintptr(unsafe.Pointer(&browserSettingsPtr)), extraInfo.Instance(), requestContext.Instance(), delegate.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
if result != 0 {
|
|
|
|
return &ICefBrowserView{&ICefView{instance: unsafe.Pointer(result)}}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*browserView) GetForBrowser(browser *ICefBrowser) *ICefBrowserView {
|
|
|
|
var result uintptr
|
|
|
|
imports.Proc(def.CefBrowserViewRef_GetForBrowser).Call(browser.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
if result != 0 {
|
|
|
|
return &ICefBrowserView{&ICefView{instance: unsafe.Pointer(result)}}
|
2023-02-28 21:52:13 +08:00
|
|
|
}
|
2023-07-02 22:06:51 +08:00
|
|
|
return nil
|
2022-12-14 19:18:11 +08:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:52:13 +08:00
|
|
|
func (m *ICefBrowserView) Browser() *ICefBrowser {
|
|
|
|
var result uintptr
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefBrowserView_Browser).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
2023-02-28 21:52:13 +08:00
|
|
|
return &ICefBrowser{instance: unsafe.Pointer(result)}
|
2022-12-14 19:18:11 +08:00
|
|
|
}
|
2023-02-28 21:52:13 +08:00
|
|
|
|
|
|
|
func (m *ICefBrowserView) ChromeToolbar() *ICefView {
|
|
|
|
var result uintptr
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefBrowserView_ChromeToolbar).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
2023-02-28 21:52:13 +08:00
|
|
|
return &ICefView{instance: unsafe.Pointer(result)}
|
2022-12-14 19:18:11 +08:00
|
|
|
}
|
2023-02-28 21:52:13 +08:00
|
|
|
|
2022-12-14 19:18:11 +08:00
|
|
|
func (m *ICefBrowserView) SetPreferAccelerators(preferAccelerators bool) {
|
2023-06-11 00:10:55 +08:00
|
|
|
imports.Proc(def.CefBrowserView_SetPreferAccelerators).Call(m.Instance(), api.PascalBool(preferAccelerators))
|
2022-12-14 19:18:11 +08:00
|
|
|
}
|