mirror of
https://gitee.com/energye/energy.git
synced 2024-11-30 10:47:57 +08:00
A: MenuModel Proc
This commit is contained in:
parent
adeaffb2e9
commit
0ab3161260
@ -1011,6 +1011,7 @@ const (
|
||||
CEFFrame_Parent
|
||||
CEFFrameRef_UnWrap
|
||||
// ICefMenuModel
|
||||
CefMenuModelRef_New
|
||||
CEFMenuModel_AddSeparator
|
||||
CEFMenuModel_Clear
|
||||
CEFMenuModel_IsSubMenu
|
||||
@ -1034,6 +1035,12 @@ const (
|
||||
CEFMenuModel_SetEnabled
|
||||
CEFMenuModel_SetLabel
|
||||
CEFMenuModel_GetIndexOf
|
||||
CefMenuModel_GetType
|
||||
CefMenuModel_GetLabel
|
||||
CefMenuModel_GetGroupId
|
||||
CefMenuModel_SetGroupId
|
||||
CefMenuModel_GetSubMenu
|
||||
CefMenuModel_GetColor
|
||||
// Misc Functions
|
||||
Misc_WindowInfoAsChild
|
||||
Misc_WindowInfoAsPopUp
|
||||
|
@ -1011,29 +1011,36 @@ func init() {
|
||||
dllimports.NewEnergyImport("CEFFrame_Parent", 0),
|
||||
dllimports.NewEnergyImport("CEFFrameRef_UnWrap", 0),
|
||||
//ICefMenuModel
|
||||
dllimports.NewEnergyImport("cefMenuModel_AddSeparator", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_Clear", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_IsSubMenu", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_GetCount", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_AddItem", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_AddCheckItem", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_AddRadioItem", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_AddSubMenu", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_Remove", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_RemoveAt", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_SetChecked", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_IsChecked", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_SetColor", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_SetFontList", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_HasAccelerator", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_SetAccelerator", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_RemoveAccelerator", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_IsVisible", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_SetVisible", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_IsEnabled", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_SetEnabled", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_SetLabel", 0),
|
||||
dllimports.NewEnergyImport("cefMenuModel_GetIndexOf", 0),
|
||||
dllimports.NewEnergyImport("CefMenuModelRef_New", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_AddSeparator", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_Clear", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_IsSubMenu", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_GetCount", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_AddItem", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_AddCheckItem", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_AddRadioItem", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_AddSubMenu", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_Remove", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_RemoveAt", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_SetChecked", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_IsChecked", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_SetColor", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_SetFontList", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_HasAccelerator", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_SetAccelerator", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_RemoveAccelerator", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_IsVisible", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_SetVisible", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_IsEnabled", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_SetEnabled", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_SetLabel", 0),
|
||||
dllimports.NewEnergyImport("CEFMenuModel_GetIndexOf", 0),
|
||||
dllimports.NewEnergyImport("CefMenuModel_GetType", 0),
|
||||
dllimports.NewEnergyImport("CefMenuModel_GetLabel", 0),
|
||||
dllimports.NewEnergyImport("CefMenuModel_GetGroupId", 0),
|
||||
dllimports.NewEnergyImport("CefMenuModel_SetGroupId", 0),
|
||||
dllimports.NewEnergyImport("CefMenuModel_GetSubMenu", 0),
|
||||
dllimports.NewEnergyImport("CefMenuModel_GetColor", 0),
|
||||
// Misc CEFWindowInfo
|
||||
dllimports.NewEnergyImport("Misc_WindowInfoAsChild", 0),
|
||||
dllimports.NewEnergyImport("Misc_WindowInfoAsPopUp", 0),
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
. "github.com/energye/energy/v2/common"
|
||||
"github.com/energye/energy/v2/common/imports"
|
||||
. "github.com/energye/energy/v2/consts"
|
||||
"github.com/energye/energy/v2/types"
|
||||
"github.com/energye/golcl/lcl/api"
|
||||
"strings"
|
||||
"unsafe"
|
||||
@ -178,6 +179,42 @@ func (m *ICefMenuModel) AddMenuItem(item *MenuItem) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// MenuModelRef -> ICefMenuModel
|
||||
var MenuModelRef menuModel
|
||||
|
||||
type menuModel uintptr
|
||||
|
||||
func (*menuModel) New(delegate *ICefMenuModelDelegate) *ICefMenuModel {
|
||||
var result uintptr
|
||||
imports.Proc(def.CefMenuModelRef_New).Call(delegate.Instance(), uintptr(unsafe.Pointer(&result)))
|
||||
if result != 0 {
|
||||
return &ICefMenuModel{instance: unsafe.Pointer(result)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Instance 实例
|
||||
func (m *ICefMenuModel) Instance() uintptr {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
return uintptr(m.instance)
|
||||
}
|
||||
|
||||
func (m *ICefMenuModel) Free() {
|
||||
if m.instance != nil {
|
||||
m.base.Free(m.Instance())
|
||||
m.instance = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *ICefMenuModel) IsValid() bool {
|
||||
if m == nil || m.instance == nil {
|
||||
return false
|
||||
}
|
||||
return m.instance != nil
|
||||
}
|
||||
|
||||
// AddSeparator 添加一个分隔线
|
||||
func (m *ICefMenuModel) AddSeparator() bool {
|
||||
return cefMenuModel_AddSeparator(uintptr(m.instance))
|
||||
@ -291,15 +328,37 @@ func (m *ICefMenuModel) GetIndexOf(commandId MenuId) int32 {
|
||||
return cefMenuModel_GetIndexOf(uintptr(m.instance), commandId)
|
||||
}
|
||||
|
||||
func (m *ICefMenuModel) Instance() uintptr {
|
||||
return uintptr(m.instance)
|
||||
func (m *ICefMenuModel) GetType(commandId MenuId) TCefMenuItemType {
|
||||
r1, _, _ := imports.Proc(def.CefMenuModel_GetType).Call(m.Instance(), uintptr(commandId))
|
||||
return TCefMenuItemType(r1)
|
||||
}
|
||||
|
||||
func (m *ICefMenuModel) Free() {
|
||||
if m.instance != nil {
|
||||
m.base.Free(m.Instance())
|
||||
m.instance = nil
|
||||
func (m *ICefMenuModel) GetLabel(commandId MenuId) string {
|
||||
r1, _, _ := imports.Proc(def.CefMenuModel_GetLabel).Call(m.Instance(), uintptr(commandId))
|
||||
return api.GoStr(r1)
|
||||
}
|
||||
|
||||
func (m *ICefMenuModel) GetGroupId(commandId MenuId) int32 {
|
||||
r1, _, _ := imports.Proc(def.CefMenuModel_GetGroupId).Call(m.Instance(), uintptr(commandId))
|
||||
return int32(r1)
|
||||
}
|
||||
|
||||
func (m *ICefMenuModel) SetGroupId(commandId MenuId, groupId int32) bool {
|
||||
r1, _, _ := imports.Proc(def.CefMenuModel_SetGroupId).Call(m.Instance(), uintptr(commandId), uintptr(groupId))
|
||||
return api.GoBool(r1)
|
||||
}
|
||||
|
||||
func (m *ICefMenuModel) GetSubMenu(commandId MenuId) *ICefMenuModel {
|
||||
r1, _, _ := imports.Proc(def.CefMenuModel_GetSubMenu).Call(m.Instance(), uintptr(commandId))
|
||||
if r1 != 0 {
|
||||
return &ICefMenuModel{instance: unsafe.Pointer(r1)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ICefMenuModel) GetColor(commandId MenuId, colorType TCefMenuColorType) (color types.TCefColor, result bool) {
|
||||
r1, _, _ := imports.Proc(def.CefMenuModel_GetColor).Call(m.Instance(), uintptr(commandId), uintptr(colorType), uintptr(unsafe.Pointer(&color)))
|
||||
return color, api.GoBool(r1)
|
||||
}
|
||||
|
||||
// ------------------------------------ PROC
|
50
cef/types-menumodel-delegate.go
Normal file
50
cef/types-menumodel-delegate.go
Normal file
@ -0,0 +1,50 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under Apache License Version 2.0, January 2004
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
// CEF 右键菜单
|
||||
|
||||
package cef
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// MenuModelDelegateRef -> ICefMenuModelDelegate
|
||||
var MenuModelDelegateRef menuModelDelegate
|
||||
|
||||
type menuModelDelegate uintptr
|
||||
|
||||
func (*menuModelDelegate) New() *ICefMenuModelDelegate {
|
||||
var result uintptr
|
||||
//imports.Proc(def.MenuModelRef_New).Call(uintptr(unsafe.Pointer(&result)))
|
||||
return &ICefMenuModelDelegate{instance: unsafe.Pointer(result)}
|
||||
}
|
||||
|
||||
// Instance 实例
|
||||
func (m *ICefMenuModelDelegate) Instance() uintptr {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
return uintptr(m.instance)
|
||||
}
|
||||
|
||||
func (m *ICefMenuModelDelegate) Free() {
|
||||
if m.instance != nil {
|
||||
m.base.Free(m.Instance())
|
||||
m.instance = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *ICefMenuModelDelegate) IsValid() bool {
|
||||
if m == nil || m.instance == nil {
|
||||
return false
|
||||
}
|
||||
return m.instance != nil
|
||||
}
|
@ -445,6 +445,13 @@ type ICefMenuModel struct {
|
||||
CefMis *keyEventAccelerator
|
||||
}
|
||||
|
||||
// ICefMenuModelDelegate
|
||||
// /include/capi/cef_menu_model_delegate_capi.h (cef_menu_model_delegate_t)
|
||||
type ICefMenuModelDelegate struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
||||
// ICefStringMultiMap 实例
|
||||
type ICefStringMultiMap struct {
|
||||
instance unsafe.Pointer
|
||||
|
@ -1462,3 +1462,15 @@ const (
|
||||
FILE_DIALOG_OPEN_FOLDER = 0x00000002
|
||||
FILE_DIALOG_SAVE = 0x00000003
|
||||
)
|
||||
|
||||
// /include/internal/cef_types.h (cef_menu_item_type_t)
|
||||
type TCefMenuItemType = types.Int32
|
||||
|
||||
const (
|
||||
MENUITEMTYPE_NONE TCefMenuItemType = iota
|
||||
MENUITEMTYPE_COMMAND
|
||||
MENUITEMTYPE_CHECK
|
||||
MENUITEMTYPE_RADIO
|
||||
MENUITEMTYPE_SEPARATOR
|
||||
MENUITEMTYPE_SUBMENU
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user