energy/cef/types-display.go

186 lines
4.7 KiB
Go
Raw Normal View History

2023-02-20 14:42:17 +08:00
// ----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
2023-02-20 14:42:17 +08:00
// # Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
2023-02-20 14:42:17 +08:00
// ----------------------------------------
2022-12-29 18:42:16 +08:00
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-07-25 16:59:40 +08:00
"github.com/energye/golcl/lcl/api"
"github.com/energye/golcl/lcl/types"
2022-12-29 18:42:16 +08:00
"unsafe"
)
2023-07-25 16:59:40 +08:00
// DisplayRef -> ICefDisplay
var DisplayRef display
2023-07-25 18:06:54 +08:00
type display struct {
alls *ICefDisplayArray
}
2023-07-25 16:59:40 +08:00
func (m *display) Primary() *ICefDisplay {
var result uintptr
imports.Proc(def.CEFDisplayRef_Primary).Call(uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefDisplay{instance: getInstance(result)}
}
return nil
}
func (m *display) NearestPoint(point *TCefPoint, inputPixelCoords bool) *ICefDisplay {
var result uintptr
imports.Proc(def.CEFDisplayRef_NearestPoint).Call(uintptr(unsafe.Pointer(point)), api.PascalBool(inputPixelCoords), uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefDisplay{instance: getInstance(result)}
}
return nil
}
func (m *display) MatchingBounds(point *TCefRect, inputPixelCoords bool) *ICefDisplay {
var result uintptr
imports.Proc(def.CEFDisplayRef_MatchingBounds).Call(uintptr(unsafe.Pointer(point)), api.PascalBool(inputPixelCoords), uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefDisplay{instance: getInstance(result)}
}
return nil
}
func (m *display) GetCount() uint32 {
r1, _, _ := imports.Proc(def.CEFDisplayRef_GetCount).Call()
return uint32(r1)
}
func (m *display) GetAlls() *ICefDisplayArray {
2023-07-25 18:06:54 +08:00
if m.alls == nil {
var result uintptr
r1, _, _ := imports.Proc(def.CEFDisplayRef_GetAlls).Call(uintptr(unsafe.Pointer(&result)))
if r1 != 0 && result != 0 {
m.alls = &ICefDisplayArray{instance: getInstance(result), count: m.GetCount()}
}
2023-07-25 16:59:40 +08:00
}
2023-07-25 18:06:54 +08:00
return m.alls
2023-07-25 16:59:40 +08:00
}
func (m *display) ScreenPointToPixels(screenPoint *types.TPoint) (point types.TPoint) {
imports.Proc(def.CEFDisplayRef_ScreenPointToPixels).Call(uintptr(unsafe.Pointer(screenPoint)), uintptr(unsafe.Pointer(&point)))
return
}
func (m *display) ScreenPointFromPixels(pixelsPoint *types.TPoint) (point types.TPoint) {
imports.Proc(def.CEFDisplayRef_ScreenPointFromPixels).Call(uintptr(unsafe.Pointer(pixelsPoint)), uintptr(unsafe.Pointer(&point)))
return
}
func (m *display) ScreenRectToPixels(screenRect *types.TRect) (rect types.TRect) {
imports.Proc(def.CEFDisplayRef_ScreenRectToPixels).Call(uintptr(unsafe.Pointer(screenRect)), uintptr(unsafe.Pointer(&rect)))
return
}
func (m *display) ScreenRectFromPixels(pixelsRect *types.TRect) (rect types.TRect) {
imports.Proc(def.CEFDisplayRef_ScreenRectFromPixels).Call(uintptr(unsafe.Pointer(pixelsRect)), uintptr(unsafe.Pointer(&rect)))
return
}
2022-12-29 18:42:16 +08:00
func (m *ICefDisplay) ID() (result int64) {
2023-05-31 17:41:14 +08:00
if !m.IsValid() {
return 0
}
imports.Proc(def.CEFDisplay_ID).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2022-12-29 18:42:16 +08:00
return
}
2023-07-25 18:06:54 +08:00
func (m *ICefDisplay) DeviceScaleFactor() (result float32) {
2023-05-31 17:41:14 +08:00
if !m.IsValid() {
return 0
}
imports.Proc(def.CEFDisplay_DeviceScaleFactor).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2023-07-25 18:06:54 +08:00
return
2022-12-29 18:42:16 +08:00
}
func (m *ICefDisplay) Rotation() int32 {
2023-05-31 17:41:14 +08:00
if !m.IsValid() {
return 0
}
r1, _, _ := imports.Proc(def.CEFDisplay_Rotation).Call(m.Instance())
2022-12-29 18:42:16 +08:00
return int32(r1)
}
func (m *ICefDisplay) Bounds() (result TCefRect) {
2023-05-31 17:41:14 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CEFDisplay_Bounds).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2022-12-29 18:42:16 +08:00
return
}
func (m *ICefDisplay) WorkArea() (result TCefRect) {
2023-05-31 17:41:14 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CEFDisplay_WorkArea).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2022-12-29 18:42:16 +08:00
return
}
2023-03-13 18:12:55 +08:00
func (m *ICefDisplay) Instance() uintptr {
return uintptr(m.instance)
}
func (m *ICefDisplay) Free() {
if m.instance != nil {
m.base.Free(m.Instance())
m.instance = nil
}
}
2023-05-31 17:41:14 +08:00
func (m *ICefDisplay) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
return m.instance != nil
}
2023-07-25 16:59:40 +08:00
func (m *ICefDisplayArray) Instance() uintptr {
return uintptr(m.instance)
}
func (m *ICefDisplayArray) Free() {
if m.instance != nil {
m.instance = nil
}
}
func (m *ICefDisplayArray) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
return m.instance != nil
}
func (m *ICefDisplayArray) Get(index uint32) *ICefDisplay {
if !m.IsValid() {
return nil
}
if index < m.count {
var result uintptr
r1, _, _ := imports.Proc(def.CEFDisplayRef_Get).Call(m.Instance(), uintptr(index), uintptr(unsafe.Pointer(&result)))
if r1 != 0 && result != 0 {
return &ICefDisplay{instance: getInstance(result)}
}
}
return nil
}
func (m *ICefDisplayArray) Count() uint32 {
if !m.IsValid() {
return 0
}
return m.count
}