energy/cef/types-pdfprint-callback.go

71 lines
1.6 KiB
Go
Raw Normal View History

2023-03-01 23:02: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 (
"github.com/energye/energy/v2/cef/internal/def"
2023-05-31 18:00:34 +08:00
"github.com/energye/energy/v2/common/imports"
2023-03-01 23:02:14 +08:00
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/api"
"unsafe"
)
// PdfPrintCallbackRef -> ICefPdfPrintCallback
var PdfPrintCallbackRef pdfPrintCallback
type pdfPrintCallback uintptr
func (*pdfPrintCallback) New() *ICefPdfPrintCallback {
var result uintptr
imports.Proc(def.CefPdfPrintCallback_Create).Call(uintptr(unsafe.Pointer(&result)))
2023-03-01 23:02:14 +08:00
return &ICefPdfPrintCallback{instance: unsafe.Pointer(result)}
}
// Instance 实例
func (m *ICefPdfPrintCallback) Instance() uintptr {
if m == nil {
return 0
}
return uintptr(m.instance)
}
2023-03-13 18:12:55 +08:00
func (m *ICefPdfPrintCallback) Free() {
if m.instance != nil {
m.base.Free(m.Instance())
m.instance = nil
}
}
2023-05-31 17:41:14 +08:00
func (m *ICefPdfPrintCallback) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
return m.instance != nil
}
func (m *ICefPdfPrintCallback) OnPdfPrintFinished(fn OnPdfPrintFinished) {
imports.Proc(def.CefPdfPrintCallback_OnPdfPrintFinished).Call(m.Instance(), api.MakeEventDataPtr(fn))
2023-05-31 17:41:14 +08:00
}
type OnPdfPrintFinished func(path string, ok bool)
2023-03-01 23:02:14 +08:00
func init() {
lcl.RegisterExtEventCallback(func(fn interface{}, getVal func(idx int) uintptr) bool {
switch fn.(type) {
case OnPdfPrintFinished:
fn.(OnPdfPrintFinished)(api.GoStr(getVal(0)), api.GoBool(getVal(1)))
default:
return false
}
return true
})
}