mirror of
https://gitee.com/energye/energy.git
synced 2024-11-30 02:37:46 +08:00
A: TCEFButtonComponent Event Proc
This commit is contained in:
parent
70f2412105
commit
ccc2c2f6ea
@ -2384,4 +2384,14 @@ const (
|
||||
ViewComponent_SetOnLayoutChanged
|
||||
ViewComponent_SetOnFocus
|
||||
ViewComponent_SetOnBlur
|
||||
// TCEFButtonComponent
|
||||
ButtonComponent_Create
|
||||
ButtonComponent_SetInkDropEnabled
|
||||
ButtonComponent_SetTooltipText
|
||||
ButtonComponent_SetAccessibleName
|
||||
ButtonComponent_AsLabelButton
|
||||
ButtonComponent_GetState
|
||||
ButtonComponent_SetState
|
||||
ButtonComponent_SetOnButtonPressed
|
||||
ButtonComponent_SetOnButtonStateChanged
|
||||
) //end
|
||||
|
@ -2384,6 +2384,16 @@ func init() {
|
||||
dllimports.NewEnergyImport("ViewComponent_SetOnLayoutChanged", 0),
|
||||
dllimports.NewEnergyImport("ViewComponent_SetOnFocus", 0),
|
||||
dllimports.NewEnergyImport("ViewComponent_SetOnBlur", 0),
|
||||
// TCEFButtonComponent
|
||||
dllimports.NewEnergyImport("ButtonComponent_Create", 0),
|
||||
dllimports.NewEnergyImport("ButtonComponent_SetInkDropEnabled", 0),
|
||||
dllimports.NewEnergyImport("ButtonComponent_SetTooltipText", 0),
|
||||
dllimports.NewEnergyImport("ButtonComponent_SetAccessibleName", 0),
|
||||
dllimports.NewEnergyImport("ButtonComponent_AsLabelButton", 0),
|
||||
dllimports.NewEnergyImport("ButtonComponent_GetState", 0),
|
||||
dllimports.NewEnergyImport("ButtonComponent_SetState", 0),
|
||||
dllimports.NewEnergyImport("ButtonComponent_SetOnButtonPressed", 0),
|
||||
dllimports.NewEnergyImport("ButtonComponent_SetOnButtonStateChanged", 0),
|
||||
} //end
|
||||
imports.SetEnergyImportDefs(energyImportDefs)
|
||||
}
|
||||
|
118
cef/types-buttoncomponent.go
Normal file
118
cef/types-buttoncomponent.go
Normal file
@ -0,0 +1,118 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// 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"
|
||||
"github.com/energye/energy/v2/common/imports"
|
||||
"github.com/energye/energy/v2/consts"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/api"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// ButtonComponentRef -> TCEFButtonComponent
|
||||
var ButtonComponentRef buttonComponent
|
||||
|
||||
type buttonComponent uintptr
|
||||
|
||||
func (*buttonComponent) New(AOwner lcl.IComponent) *TCEFButtonComponent {
|
||||
var result uintptr
|
||||
imports.Proc(def.ButtonComponent_Create).Call(AOwner.Instance(), uintptr(unsafe.Pointer(&result)))
|
||||
if result != 0 {
|
||||
return &TCEFButtonComponent{&TCEFViewComponent{instance: getInstance(result)}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TCEFButtonComponent) SetInkDropEnabled(enabled bool) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
}
|
||||
imports.Proc(def.ButtonComponent_SetInkDropEnabled).Call(m.Instance(), api.PascalBool(enabled))
|
||||
}
|
||||
|
||||
func (m *TCEFButtonComponent) SetTooltipText(tooltipText string) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
}
|
||||
imports.Proc(def.ButtonComponent_SetTooltipText).Call(m.Instance(), api.PascalStr(tooltipText))
|
||||
}
|
||||
|
||||
func (m *TCEFButtonComponent) SetAccessibleName(name string) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
}
|
||||
imports.Proc(def.ButtonComponent_SetAccessibleName).Call(m.Instance(), api.PascalStr(name))
|
||||
}
|
||||
|
||||
func (m *TCEFButtonComponent) AsLabelButton() *ICefLabelButton {
|
||||
if !m.IsValid() {
|
||||
return nil
|
||||
}
|
||||
var result uintptr
|
||||
imports.Proc(def.ButtonComponent_AsLabelButton).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
||||
if result != 0 {
|
||||
return &ICefLabelButton{&ICefButton{&ICefView{instance: getInstance(result)}}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TCEFButtonComponent) GetState() consts.TCefButtonState {
|
||||
if !m.IsValid() {
|
||||
return 0
|
||||
}
|
||||
r1, _, _ := imports.Proc(def.ButtonComponent_GetState).Call(m.Instance())
|
||||
return consts.TCefButtonState(r1)
|
||||
}
|
||||
|
||||
func (m *TCEFButtonComponent) SetState(state consts.TCefButtonState) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
}
|
||||
imports.Proc(def.ButtonComponent_SetState).Call(m.Instance(), uintptr(state))
|
||||
}
|
||||
|
||||
func (m *TCEFButtonComponent) SetOnButtonPressed(fn onButtonPressed) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
}
|
||||
imports.Proc(def.ButtonComponent_SetOnButtonPressed).Call(m.Instance(), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
|
||||
func (m *TCEFButtonComponent) SetOnButtonStateChanged(fn onButtonStateChanged) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
}
|
||||
imports.Proc(def.ButtonComponent_SetOnButtonStateChanged).Call(m.Instance(), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
|
||||
type onButtonPressed func(sender lcl.IObject, button *ICefButton)
|
||||
type onButtonStateChanged func(sender lcl.IObject, button *ICefButton)
|
||||
|
||||
func init() {
|
||||
lcl.RegisterExtEventCallback(func(fn interface{}, getVal func(idx int) uintptr) bool {
|
||||
getPtr := func(i int) unsafe.Pointer {
|
||||
return unsafe.Pointer(getVal(i))
|
||||
}
|
||||
switch fn.(type) {
|
||||
case onButtonPressed:
|
||||
button := (*ICefButton)(getPtr(1))
|
||||
fn.(onButtonPressed)(lcl.AsObject(getPtr(0)), button)
|
||||
case onButtonStateChanged:
|
||||
button := (*ICefButton)(getPtr(1))
|
||||
fn.(onButtonStateChanged)(lcl.AsObject(getPtr(0)), button)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
11
cef/types.go
11
cef/types.go
@ -486,6 +486,12 @@ type ICefButton struct {
|
||||
*ICefView
|
||||
}
|
||||
|
||||
// ICefLabelButton
|
||||
// /include/capi/views/cef_label_button_capi.h (cef_label_button_t)
|
||||
type ICefLabelButton struct {
|
||||
*ICefButton
|
||||
}
|
||||
|
||||
// ICefPanel
|
||||
// /include/capi/views/cef_panel_capi.h (cef_panel_t)
|
||||
type ICefPanel struct {
|
||||
@ -523,6 +529,11 @@ type TCEFViewComponent struct {
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
||||
// TCEFButtonComponent
|
||||
type TCEFButtonComponent struct {
|
||||
*TCEFViewComponent
|
||||
}
|
||||
|
||||
// TCefX509CertificateArray
|
||||
// []ICefX509Certificate
|
||||
type TCefX509CertificateArray struct {
|
||||
|
@ -1474,3 +1474,13 @@ const (
|
||||
MENUITEMTYPE_SEPARATOR
|
||||
MENUITEMTYPE_SUBMENU
|
||||
)
|
||||
|
||||
// /include/internal/cef_types.h (cef_button_state_t)
|
||||
type TCefButtonState = types.Int32
|
||||
|
||||
const (
|
||||
CEF_BUTTON_STATE_NORMAL TCefButtonState = iota
|
||||
CEF_BUTTON_STATE_HOVERED
|
||||
CEF_BUTTON_STATE_PRESSED
|
||||
CEF_BUTTON_STATE_DISABLED
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user