2023-07-03 12:09:25 +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
|
2023-07-04 22:35:28 +08:00
|
|
|
|
|
|
|
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/energy/v2/types"
|
2023-07-05 11:08:04 +08:00
|
|
|
"github.com/energye/golcl/lcl/api"
|
2023-07-04 22:35:28 +08:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2023-07-05 11:08:04 +08:00
|
|
|
// TextFieldRef -> ICefTextfield
|
2023-07-04 22:35:28 +08:00
|
|
|
var TextFieldRef textField
|
|
|
|
|
|
|
|
type textField uintptr
|
|
|
|
|
2023-07-05 12:47:22 +08:00
|
|
|
func (*textField) New(delegate *ICefTextFieldDelegate) *ICefTextfield {
|
2023-07-04 22:35:28 +08:00
|
|
|
var result uintptr
|
|
|
|
imports.Proc(def.TextfieldRef_CreateTextField).Call(delegate.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
if result != 0 {
|
|
|
|
return &ICefTextfield{&ICefView{
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetPasswordInput(passwordInput bool) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetPasswordInput).Call(m.Instance(), api.PascalBool(passwordInput))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) IsPasswordInput() bool {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
r1, _, _ := imports.Proc(def.Textfield_IsPasswordInput).Call(m.Instance())
|
|
|
|
return api.GoBool(r1)
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetReadOnly(readOnly bool) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetReadOnly).Call(m.Instance(), api.PascalBool(readOnly))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) IsReadOnly() bool {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
r1, _, _ := imports.Proc(def.Textfield_IsReadOnly).Call(m.Instance())
|
|
|
|
return api.GoBool(r1)
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) GetText() string {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
r1, _, _ := imports.Proc(def.Textfield_GetText).Call(m.Instance())
|
|
|
|
return api.GoStr(r1)
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetText(text string) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetText).Call(m.Instance(), api.PascalStr(text))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) AppendText(text string) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_AppendText).Call(m.Instance(), api.PascalStr(text))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) InsertOrReplaceText(text string) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_InsertOrReplaceText).Call(m.Instance(), api.PascalStr(text))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) HasSelection() bool {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
r1, _, _ := imports.Proc(def.Textfield_HasSelection).Call(m.Instance())
|
|
|
|
return api.GoBool(r1)
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) GetSelectedText() string {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
r1, _, _ := imports.Proc(def.Textfield_GetSelectedText).Call(m.Instance())
|
|
|
|
return api.GoStr(r1)
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SelectAll(reversed bool) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SelectAll).Call(m.Instance(), api.PascalBool(reversed))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) ClearSelection() {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_ClearSelection).Call(m.Instance())
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
2023-07-05 11:08:04 +08:00
|
|
|
func (m *ICefTextfield) GetSelectedRange() (result TCefRange) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_GetSelectedRange).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
return
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SelectRange(range_ TCefRange) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SelectRange).Call(m.Instance(), uintptr(unsafe.Pointer(&range_)))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
2023-07-05 11:08:04 +08:00
|
|
|
func (m *ICefTextfield) GetCursorPosition() uint32 {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
r1, _, _ := imports.Proc(def.Textfield_GetCursorPosition).Call(m.Instance())
|
|
|
|
return uint32(r1)
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetTextColor(color types.TCefColor) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetTextColor).Call(m.Instance(), uintptr(color))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
2023-07-05 11:08:04 +08:00
|
|
|
func (m *ICefTextfield) GetTextColor() (color types.TCefColor) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_GetTextColor).Call(m.Instance(), uintptr(unsafe.Pointer(&color)))
|
|
|
|
return
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetSelectionTextColor(color types.TCefColor) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetSelectionTextColor).Call(m.Instance(), uintptr(color))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
2023-07-05 11:08:04 +08:00
|
|
|
func (m *ICefTextfield) GetSelectionTextColor() (color types.TCefColor) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_GetSelectionTextColor).Call(m.Instance(), uintptr(unsafe.Pointer(&color)))
|
|
|
|
return
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetSelectionBackgroundColor(color types.TCefColor) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetSelectionBackgroundColor).Call(m.Instance(), uintptr(color))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
2023-07-05 11:08:04 +08:00
|
|
|
func (m *ICefTextfield) GetSelectionBackgroundColor() (color types.TCefColor) {
|
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_GetSelectionBackgroundColor).Call(m.Instance(), uintptr(unsafe.Pointer(&color)))
|
|
|
|
return
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetFontList(fontList string) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetFontList).Call(m.Instance(), api.PascalStr(fontList))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) ApplyTextColor(color types.TCefColor, range_ TCefRange) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_ApplyTextColor).Call(m.Instance(), uintptr(color), uintptr(unsafe.Pointer(&range_)))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) ApplyTextStyle(style consts.TCefTextStyle, add bool, range_ TCefRange) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_ApplyTextStyle).Call(m.Instance(), uintptr(style), api.PascalBool(add), uintptr(unsafe.Pointer(&range_)))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) IsCommandEnabled(commandId consts.TCefTextFieldCommands) bool {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
r1, _, _ := imports.Proc(def.Textfield_IsCommandEnabled).Call(m.Instance(), uintptr(commandId))
|
|
|
|
return api.GoBool(r1)
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) ExecuteCommand(commandId consts.TCefTextFieldCommands) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_ExecuteCommand).Call(m.Instance(), uintptr(commandId))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) ClearEditHistory() {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_ClearEditHistory).Call(m.Instance())
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetPlaceholderText(text string) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetPlaceholderText).Call(m.Instance(), api.PascalStr(text))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) GetPlaceholderText() string {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
r1, _, _ := imports.Proc(def.Textfield_GetPlaceholderText).Call(m.Instance())
|
|
|
|
return api.GoStr(r1)
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetPlaceholderTextColor(color types.TCefColor) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetPlaceholderTextColor).Call(m.Instance(), uintptr(color))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ICefTextfield) SetAccessibleName(name string) {
|
2023-07-05 11:08:04 +08:00
|
|
|
if !m.IsValid() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imports.Proc(def.Textfield_SetAccessibleName).Call(m.Instance(), api.PascalStr(name))
|
2023-07-04 22:35:28 +08:00
|
|
|
}
|