提交 06102f9a 编写于 作者: R Richard Wilkes

Add capi/views header conversions as well

上级 327456c6
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// void gocef_box_layout_set_flex_for_view(cef_box_layout_t * self, cef_view_t * view, int flex, void (CEF_CALLBACK *callback__)(cef_box_layout_t *, cef_view_t *, int)) { return callback__(self, view, flex); }
// void gocef_box_layout_clear_flex_for_view(cef_box_layout_t * self, cef_view_t * view, void (CEF_CALLBACK *callback__)(cef_box_layout_t *, cef_view_t *)) { return callback__(self, view); }
"C"
)
// BoxLayout (cef_box_layout_t from include/capi/views/cef_box_layout_capi.h)
// A Layout manager that arranges child views vertically or horizontally in a
// side-by-side fashion with spacing around and between the child views. The
// child views are always sized according to their preferred size. If the host's
// bounds provide insufficient space, child views will be clamped. Excess space
// will not be distributed. Methods must be called on the browser process UI
// thread unless otherwise indicated.
type BoxLayout C.cef_box_layout_t
func (d *BoxLayout) toNative() *C.cef_box_layout_t {
return (*C.cef_box_layout_t)(d)
}
// Base (base)
// Base structure.
func (d *BoxLayout) Base() *Layout {
return (*Layout)(&d.base)
}
// SetFlexForView (set_flex_for_view)
// Set the flex weight for the given |view|. Using the preferred size as the
// basis, free space along the main axis is distributed to views in the ratio
// of their flex weights. Similarly, if the views will overflow the parent,
// space is subtracted in these ratios. A flex of 0 means this view is not
// resized. Flex values must not be negative.
func (d *BoxLayout) SetFlexForView(view *View, flex int32) {
C.gocef_box_layout_set_flex_for_view(d.toNative(), view.toNative(), C.int(flex), d.set_flex_for_view)
}
// ClearFlexForView (clear_flex_for_view)
// Clears the flex for the given |view|, causing it to use the default flex
// specified via cef_box_layout_tSettings.default_flex.
func (d *BoxLayout) ClearFlexForView(view *View) {
C.gocef_box_layout_clear_flex_for_view(d.toNative(), view.toNative(), d.clear_flex_for_view)
}
// Code generated - DO NOT EDIT.
#include "BrowserViewDelegate_gen.h"
#include "_cgo_export.h"
void gocef_set_browser_view_delegate_proxy(cef_browser_view_delegate_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->on_browser_created = (void *)&gocef_browser_view_delegate_on_browser_created;
self->on_browser_destroyed = (void *)&gocef_browser_view_delegate_on_browser_destroyed;
self->get_delegate_for_popup_browser_view = (void *)&gocef_browser_view_delegate_get_delegate_for_popup_browser_view;
self->on_popup_browser_view_created = (void *)&gocef_browser_view_delegate_on_popup_browser_view_created;
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "BrowserViewDelegate_gen.h"
"C"
"unsafe"
"github.com/richardwilkes/toolbox/errs"
"github.com/richardwilkes/toolbox/log/jot"
)
// BrowserViewDelegateProxy defines methods required for using BrowserViewDelegate.
type BrowserViewDelegateProxy interface {
OnBrowserCreated(self *BrowserViewDelegate, browser_view *BrowserView, browser *Browser)
OnBrowserDestroyed(self *BrowserViewDelegate, browser_view *BrowserView, browser *Browser)
GetDelegateForPopupBrowserView(self *BrowserViewDelegate, browser_view *BrowserView, settings *BrowserSettings, client *Client, is_devtools int32) *BrowserViewDelegate
OnPopupBrowserViewCreated(self *BrowserViewDelegate, browser_view, popup_browser_view *BrowserView, is_devtools int32) int32
}
// BrowserViewDelegate (cef_browser_view_delegate_t from include/capi/views/cef_browser_view_delegate_capi.h)
// Implement this structure to handle BrowserView events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
type BrowserViewDelegate C.cef_browser_view_delegate_t
// NewBrowserViewDelegate creates a new BrowserViewDelegate with the specified proxy. Passing
// in nil will result in default handling, if applicable.
func NewBrowserViewDelegate(proxy BrowserViewDelegateProxy) *BrowserViewDelegate {
result := (*BrowserViewDelegate)(unsafe.Pointer(newRefCntObj(C.sizeof_struct__cef_browser_view_delegate_t, proxy)))
if proxy != nil {
C.gocef_set_browser_view_delegate_proxy(result.toNative())
}
return result
}
func (d *BrowserViewDelegate) toNative() *C.cef_browser_view_delegate_t {
return (*C.cef_browser_view_delegate_t)(d)
}
func lookupBrowserViewDelegateProxy(obj *BaseRefCounted) BrowserViewDelegateProxy {
proxy, exists := lookupProxy(obj)
if !exists {
jot.Fatal(1, errs.New("Proxy not found for ID"))
}
actual, ok := proxy.(BrowserViewDelegateProxy)
if !ok {
jot.Fatal(1, errs.New("Proxy was not of type BrowserViewDelegateProxy"))
}
return actual
}
// Base (base)
// Base structure.
func (d *BrowserViewDelegate) Base() *ViewDelegate {
return (*ViewDelegate)(&d.base)
}
// OnBrowserCreated (on_browser_created)
// Called when |browser| associated with |browser_view| is created. This
// function will be called after cef_life_span_handler_t::on_after_created()
// is called for |browser| and before on_popup_browser_view_created() is
// called for |browser|'s parent delegate if |browser| is a popup.
func (d *BrowserViewDelegate) OnBrowserCreated(browser_view *BrowserView, browser *Browser) {
lookupBrowserViewDelegateProxy(d.Base().Base()).OnBrowserCreated(d, browser_view, browser)
}
//export gocef_browser_view_delegate_on_browser_created
func gocef_browser_view_delegate_on_browser_created(self *C.cef_browser_view_delegate_t, browser_view *C.cef_browser_view_t, browser *C.cef_browser_t) {
me__ := (*BrowserViewDelegate)(self)
proxy__ := lookupBrowserViewDelegateProxy(me__.Base().Base())
proxy__.OnBrowserCreated(me__, (*BrowserView)(browser_view), (*Browser)(browser))
}
// OnBrowserDestroyed (on_browser_destroyed)
// Called when |browser| associated with |browser_view| is destroyed. Release
// all references to |browser| and do not attempt to execute any functions on
// |browser| after this callback returns. This function will be called before
// cef_life_span_handler_t::on_before_close() is called for |browser|.
func (d *BrowserViewDelegate) OnBrowserDestroyed(browser_view *BrowserView, browser *Browser) {
lookupBrowserViewDelegateProxy(d.Base().Base()).OnBrowserDestroyed(d, browser_view, browser)
}
//export gocef_browser_view_delegate_on_browser_destroyed
func gocef_browser_view_delegate_on_browser_destroyed(self *C.cef_browser_view_delegate_t, browser_view *C.cef_browser_view_t, browser *C.cef_browser_t) {
me__ := (*BrowserViewDelegate)(self)
proxy__ := lookupBrowserViewDelegateProxy(me__.Base().Base())
proxy__.OnBrowserDestroyed(me__, (*BrowserView)(browser_view), (*Browser)(browser))
}
// GetDelegateForPopupBrowserView (get_delegate_for_popup_browser_view)
// Called before a new popup BrowserView is created. The popup originated from
// |browser_view|. |settings| and |client| are the values returned from
// cef_life_span_handler_t::on_before_popup(). |is_devtools| will be true (1)
// if the popup will be a DevTools browser. Return the delegate that will be
// used for the new popup BrowserView.
func (d *BrowserViewDelegate) GetDelegateForPopupBrowserView(browser_view *BrowserView, settings *BrowserSettings, client *Client, is_devtools int32) *BrowserViewDelegate {
return lookupBrowserViewDelegateProxy(d.Base().Base()).GetDelegateForPopupBrowserView(d, browser_view, settings, client, is_devtools)
}
//export gocef_browser_view_delegate_get_delegate_for_popup_browser_view
func gocef_browser_view_delegate_get_delegate_for_popup_browser_view(self *C.cef_browser_view_delegate_t, browser_view *C.cef_browser_view_t, settings *C.cef_browser_settings_t, client *C.cef_client_t, is_devtools C.int) *C.cef_browser_view_delegate_t {
me__ := (*BrowserViewDelegate)(self)
proxy__ := lookupBrowserViewDelegateProxy(me__.Base().Base())
settings_ := settings.toGo()
return (proxy__.GetDelegateForPopupBrowserView(me__, (*BrowserView)(browser_view), settings_, (*Client)(client), int32(is_devtools))).toNative()
}
// OnPopupBrowserViewCreated (on_popup_browser_view_created)
// Called after |popup_browser_view| is created. This function will be called
// after cef_life_span_handler_t::on_after_created() and on_browser_created()
// are called for the new popup browser. The popup originated from
// |browser_view|. |is_devtools| will be true (1) if the popup is a DevTools
// browser. Optionally add |popup_browser_view| to the views hierarchy
// yourself and return true (1). Otherwise return false (0) and a default
// cef_window_t will be created for the popup.
func (d *BrowserViewDelegate) OnPopupBrowserViewCreated(browser_view, popup_browser_view *BrowserView, is_devtools int32) int32 {
return lookupBrowserViewDelegateProxy(d.Base().Base()).OnPopupBrowserViewCreated(d, browser_view, popup_browser_view, is_devtools)
}
//export gocef_browser_view_delegate_on_popup_browser_view_created
func gocef_browser_view_delegate_on_popup_browser_view_created(self *C.cef_browser_view_delegate_t, browser_view *C.cef_browser_view_t, popup_browser_view *C.cef_browser_view_t, is_devtools C.int) C.int {
me__ := (*BrowserViewDelegate)(self)
proxy__ := lookupBrowserViewDelegateProxy(me__.Base().Base())
return C.int(proxy__.OnPopupBrowserViewCreated(me__, (*BrowserView)(browser_view), (*BrowserView)(popup_browser_view), int32(is_devtools)))
}
// Code generated - DO NOT EDIT.
#ifndef GOCEF_BrowserViewDelegate_H_
#define GOCEF_BrowserViewDelegate_H_
#pragma once
#include "capi_gen.h"
void gocef_set_browser_view_delegate_proxy(cef_browser_view_delegate_t *self);
#endif // GOCEF_BrowserViewDelegate_H_
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// cef_browser_t * gocef_browser_view_get_browser(cef_browser_view_t * self, cef_browser_t * (CEF_CALLBACK *callback__)(cef_browser_view_t *)) { return callback__(self); }
// void gocef_browser_view_set_prefer_accelerators(cef_browser_view_t * self, int prefer_accelerators, void (CEF_CALLBACK *callback__)(cef_browser_view_t *, int)) { return callback__(self, prefer_accelerators); }
"C"
)
// BrowserView (cef_browser_view_t from include/capi/views/cef_browser_view_capi.h)
// A View hosting a cef_browser_t instance. Methods must be called on the
// browser process UI thread unless otherwise indicated.
type BrowserView C.cef_browser_view_t
func (d *BrowserView) toNative() *C.cef_browser_view_t {
return (*C.cef_browser_view_t)(d)
}
// Base (base)
// Base structure.
func (d *BrowserView) Base() *View {
return (*View)(&d.base)
}
// GetBrowser (get_browser)
// Returns the cef_browser_t hosted by this BrowserView. Will return NULL if
// the browser has not yet been created or has already been destroyed.
func (d *BrowserView) GetBrowser() *Browser {
return (*Browser)(C.gocef_browser_view_get_browser(d.toNative(), d.get_browser))
}
// SetPreferAccelerators (set_prefer_accelerators)
// Sets whether accelerators registered with cef_window_t::SetAccelerator are
// triggered before or after the event is sent to the cef_browser_t. If
// |prefer_accelerators| is true (1) then the matching accelerator will be
// triggered immediately and the event will not be sent to the cef_browser_t.
// If |prefer_accelerators| is false (0) then the matching accelerator will
// only be triggered if the event is not handled by web content or by
// cef_keyboard_handler_t. The default value is false (0).
func (d *BrowserView) SetPreferAccelerators(prefer_accelerators int32) {
C.gocef_browser_view_set_prefer_accelerators(d.toNative(), C.int(prefer_accelerators), d.set_prefer_accelerators)
}
// Code generated - DO NOT EDIT.
#include "ButtonDelegate_gen.h"
#include "_cgo_export.h"
void gocef_set_button_delegate_proxy(cef_button_delegate_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->on_button_pressed = (void *)&gocef_button_delegate_on_button_pressed;
self->on_button_state_changed = (void *)&gocef_button_delegate_on_button_state_changed;
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "ButtonDelegate_gen.h"
"C"
"unsafe"
"github.com/richardwilkes/toolbox/errs"
"github.com/richardwilkes/toolbox/log/jot"
)
// ButtonDelegateProxy defines methods required for using ButtonDelegate.
type ButtonDelegateProxy interface {
OnButtonPressed(self *ButtonDelegate, button *Button)
OnButtonStateChanged(self *ButtonDelegate, button *Button)
}
// ButtonDelegate (cef_button_delegate_t from include/capi/views/cef_button_delegate_capi.h)
// Implement this structure to handle Button events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
type ButtonDelegate C.cef_button_delegate_t
// NewButtonDelegate creates a new ButtonDelegate with the specified proxy. Passing
// in nil will result in default handling, if applicable.
func NewButtonDelegate(proxy ButtonDelegateProxy) *ButtonDelegate {
result := (*ButtonDelegate)(unsafe.Pointer(newRefCntObj(C.sizeof_struct__cef_button_delegate_t, proxy)))
if proxy != nil {
C.gocef_set_button_delegate_proxy(result.toNative())
}
return result
}
func (d *ButtonDelegate) toNative() *C.cef_button_delegate_t {
return (*C.cef_button_delegate_t)(d)
}
func lookupButtonDelegateProxy(obj *BaseRefCounted) ButtonDelegateProxy {
proxy, exists := lookupProxy(obj)
if !exists {
jot.Fatal(1, errs.New("Proxy not found for ID"))
}
actual, ok := proxy.(ButtonDelegateProxy)
if !ok {
jot.Fatal(1, errs.New("Proxy was not of type ButtonDelegateProxy"))
}
return actual
}
// Base (base)
// Base structure.
func (d *ButtonDelegate) Base() *ViewDelegate {
return (*ViewDelegate)(&d.base)
}
// OnButtonPressed (on_button_pressed)
// Called when |button| is pressed.
func (d *ButtonDelegate) OnButtonPressed(button *Button) {
lookupButtonDelegateProxy(d.Base().Base()).OnButtonPressed(d, button)
}
//export gocef_button_delegate_on_button_pressed
func gocef_button_delegate_on_button_pressed(self *C.cef_button_delegate_t, button *C.cef_button_t) {
me__ := (*ButtonDelegate)(self)
proxy__ := lookupButtonDelegateProxy(me__.Base().Base())
proxy__.OnButtonPressed(me__, (*Button)(button))
}
// OnButtonStateChanged (on_button_state_changed)
// Called when the state of |button| changes.
func (d *ButtonDelegate) OnButtonStateChanged(button *Button) {
lookupButtonDelegateProxy(d.Base().Base()).OnButtonStateChanged(d, button)
}
//export gocef_button_delegate_on_button_state_changed
func gocef_button_delegate_on_button_state_changed(self *C.cef_button_delegate_t, button *C.cef_button_t) {
me__ := (*ButtonDelegate)(self)
proxy__ := lookupButtonDelegateProxy(me__.Base().Base())
proxy__.OnButtonStateChanged(me__, (*Button)(button))
}
// Code generated - DO NOT EDIT.
#ifndef GOCEF_ButtonDelegate_H_
#define GOCEF_ButtonDelegate_H_
#pragma once
#include "capi_gen.h"
void gocef_set_button_delegate_proxy(cef_button_delegate_t *self);
#endif // GOCEF_ButtonDelegate_H_
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// cef_label_button_t * gocef_button_as_label_button(cef_button_t * self, cef_label_button_t * (CEF_CALLBACK *callback__)(cef_button_t *)) { return callback__(self); }
// void gocef_button_set_state(cef_button_t * self, cef_button_state_t state, void (CEF_CALLBACK *callback__)(cef_button_t *, cef_button_state_t)) { return callback__(self, state); }
// cef_button_state_t gocef_button_get_state(cef_button_t * self, cef_button_state_t (CEF_CALLBACK *callback__)(cef_button_t *)) { return callback__(self); }
// void gocef_button_set_ink_drop_enabled(cef_button_t * self, int enabled, void (CEF_CALLBACK *callback__)(cef_button_t *, int)) { return callback__(self, enabled); }
// void gocef_button_set_tooltip_text(cef_button_t * self, cef_string_t * tooltip_text, void (CEF_CALLBACK *callback__)(cef_button_t *, cef_string_t *)) { return callback__(self, tooltip_text); }
// void gocef_button_set_accessible_name(cef_button_t * self, cef_string_t * name, void (CEF_CALLBACK *callback__)(cef_button_t *, cef_string_t *)) { return callback__(self, name); }
"C"
)
// Button (cef_button_t from include/capi/views/cef_button_capi.h)
// A View representing a button. Depending on the specific type, the button
// could be implemented by a native control or custom rendered. Methods must be
// called on the browser process UI thread unless otherwise indicated.
type Button C.cef_button_t
func (d *Button) toNative() *C.cef_button_t {
return (*C.cef_button_t)(d)
}
// Base (base)
// Base structure.
func (d *Button) Base() *View {
return (*View)(&d.base)
}
// AsLabelButton (as_label_button)
// Returns this Button as a LabelButton or NULL if this is not a LabelButton.
func (d *Button) AsLabelButton() *LabelButton {
return (*LabelButton)(C.gocef_button_as_label_button(d.toNative(), d.as_label_button))
}
// SetState (set_state)
// Sets the current display state of the Button.
func (d *Button) SetState(state ButtonState) {
C.gocef_button_set_state(d.toNative(), C.cef_button_state_t(state), d.set_state)
}
// GetState (get_state)
// Returns the current display state of the Button.
func (d *Button) GetState() ButtonState {
return ButtonState(C.gocef_button_get_state(d.toNative(), d.get_state))
}
// SetInkDropEnabled (set_ink_drop_enabled)
// Sets the Button will use an ink drop effect for displaying state changes.
func (d *Button) SetInkDropEnabled(enabled int32) {
C.gocef_button_set_ink_drop_enabled(d.toNative(), C.int(enabled), d.set_ink_drop_enabled)
}
// SetTooltipText (set_tooltip_text)
// Sets the tooltip text that will be displayed when the user hovers the mouse
// cursor over the Button.
func (d *Button) SetTooltipText(tooltip_text string) {
tooltip_text_ := C.cef_string_userfree_alloc()
setCEFStr(tooltip_text, tooltip_text_)
defer func() {
C.cef_string_userfree_free(tooltip_text_)
}()
C.gocef_button_set_tooltip_text(d.toNative(), (*C.cef_string_t)(tooltip_text_), d.set_tooltip_text)
}
// SetAccessibleName (set_accessible_name)
// Sets the accessible name that will be exposed to assistive technology (AT).
func (d *Button) SetAccessibleName(name string) {
name_ := C.cef_string_userfree_alloc()
setCEFStr(name, name_)
defer func() {
C.cef_string_userfree_free(name_)
}()
C.gocef_button_set_accessible_name(d.toNative(), (*C.cef_string_t)(name_), d.set_accessible_name)
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// int64 gocef_display_get_id(cef_display_t * self, int64 (CEF_CALLBACK *callback__)(cef_display_t *)) { return callback__(self); }
// float gocef_display_get_device_scale_factor(cef_display_t * self, float (CEF_CALLBACK *callback__)(cef_display_t *)) { return callback__(self); }
// void gocef_display_convert_point_to_pixels(cef_display_t * self, cef_point_t * point, void (CEF_CALLBACK *callback__)(cef_display_t *, cef_point_t *)) { return callback__(self, point); }
// void gocef_display_convert_point_from_pixels(cef_display_t * self, cef_point_t * point, void (CEF_CALLBACK *callback__)(cef_display_t *, cef_point_t *)) { return callback__(self, point); }
// cef_rect_t gocef_display_get_bounds(cef_display_t * self, cef_rect_t (CEF_CALLBACK *callback__)(cef_display_t *)) { return callback__(self); }
// cef_rect_t gocef_display_get_work_area(cef_display_t * self, cef_rect_t (CEF_CALLBACK *callback__)(cef_display_t *)) { return callback__(self); }
// int gocef_display_get_rotation(cef_display_t * self, int (CEF_CALLBACK *callback__)(cef_display_t *)) { return callback__(self); }
"C"
)
// Display (cef_display_t from include/capi/views/cef_display_capi.h)
// This structure typically, but not always, corresponds to a physical display
// connected to the system. A fake Display may exist on a headless system, or a
// Display may correspond to a remote, virtual display. All size and position
// values are in density independent pixels (DIP) unless otherwise indicated.
// Methods must be called on the browser process UI thread unless otherwise
// indicated.
type Display C.cef_display_t
func (d *Display) toNative() *C.cef_display_t {
return (*C.cef_display_t)(d)
}
// Base (base)
// Base structure.
func (d *Display) Base() *BaseRefCounted {
return (*BaseRefCounted)(&d.base)
}
// GetId (get_id)
// Returns the unique identifier for this Display.
func (d *Display) GetId() int64 {
return int64(C.gocef_display_get_id(d.toNative(), d.get_id))
}
// GetDeviceScaleFactor (get_device_scale_factor)
// Returns this Display's device pixel scale factor. This specifies how much
// the UI should be scaled when the actual output has more pixels than
// standard displays (which is around 100~120dpi). The potential return values
// differ by platform.
func (d *Display) GetDeviceScaleFactor() float32 {
return float32(C.gocef_display_get_device_scale_factor(d.toNative(), d.get_device_scale_factor))
}
// ConvertPointToPixels (convert_point_to_pixels)
// Convert |point| from density independent pixels (DIP) to pixel coordinates
// using this Display's device scale factor.
func (d *Display) ConvertPointToPixels(point *Point) {
C.gocef_display_convert_point_to_pixels(d.toNative(), point.toNative(&C.cef_point_t{}), d.convert_point_to_pixels)
}
// ConvertPointFromPixels (convert_point_from_pixels)
// Convert |point| from pixel coordinates to density independent pixels (DIP)
// using this Display's device scale factor.
func (d *Display) ConvertPointFromPixels(point *Point) {
C.gocef_display_convert_point_from_pixels(d.toNative(), point.toNative(&C.cef_point_t{}), d.convert_point_from_pixels)
}
// GetBounds (get_bounds)
// Returns this Display's bounds. This is the full size of the display.
func (d *Display) GetBounds() Rect {
cresult__ := C.gocef_display_get_bounds(d.toNative(), d.get_bounds)
var result__ Rect
(&cresult__).intoGo(&result__)
return result__
}
// GetWorkArea (get_work_area)
// Returns this Display's work area. This excludes areas of the display that
// are occupied for window manager toolbars, etc.
func (d *Display) GetWorkArea() Rect {
cresult__ := C.gocef_display_get_work_area(d.toNative(), d.get_work_area)
var result__ Rect
(&cresult__).intoGo(&result__)
return result__
}
// GetRotation (get_rotation)
// Returns this Display's rotation in degrees.
func (d *Display) GetRotation() int32 {
return int32(C.gocef_display_get_rotation(d.toNative(), d.get_rotation))
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
"C"
"unsafe"
)
// FillLayout (cef_fill_layout_t from include/capi/views/cef_fill_layout_capi.h)
// A simple Layout that causes the associated Panel's one child to be sized to
// match the bounds of its parent. Methods must be called on the browser process
// UI thread unless otherwise indicated.
type FillLayout struct {
// Base (base)
// Base structure.
Base *Layout
}
// NewFillLayout creates a new FillLayout.
func NewFillLayout() *FillLayout {
return &FillLayout{}
}
func (d *FillLayout) toNative(native *C.cef_fill_layout_t) *C.cef_fill_layout_t {
native.base = *(*C.cef_layout_t)(unsafe.Pointer(d.Base))
return native
}
func (n *C.cef_fill_layout_t) toGo() *FillLayout {
var d FillLayout
n.intoGo(&d)
return &d
}
func (n *C.cef_fill_layout_t) intoGo(d *FillLayout) {
d.Base = (*Layout)(&n.base)
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// cef_menu_button_t * gocef_label_button_as_menu_button(cef_label_button_t * self, cef_menu_button_t * (CEF_CALLBACK *callback__)(cef_label_button_t *)) { return callback__(self); }
// void gocef_label_button_set_text(cef_label_button_t * self, cef_string_t * text, void (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_string_t *)) { return callback__(self, text); }
// cef_string_userfree_t gocef_label_button_get_text(cef_label_button_t * self, cef_string_userfree_t (CEF_CALLBACK *callback__)(cef_label_button_t *)) { return callback__(self); }
// void gocef_label_button_set_image(cef_label_button_t * self, cef_button_state_t button_state, cef_image_t * image, void (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_button_state_t, cef_image_t *)) { return callback__(self, button_state, image); }
// cef_image_t * gocef_label_button_get_image(cef_label_button_t * self, cef_button_state_t button_state, cef_image_t * (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_button_state_t)) { return callback__(self, button_state); }
// void gocef_label_button_set_text_color(cef_label_button_t * self, cef_button_state_t for_state, cef_color_t color, void (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_button_state_t, cef_color_t)) { return callback__(self, for_state, color); }
// void gocef_label_button_set_enabled_text_colors(cef_label_button_t * self, cef_color_t color, void (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_color_t)) { return callback__(self, color); }
// void gocef_label_button_set_font_list(cef_label_button_t * self, cef_string_t * font_list, void (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_string_t *)) { return callback__(self, font_list); }
// void gocef_label_button_set_horizontal_alignment(cef_label_button_t * self, cef_horizontal_alignment_t alignment, void (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_horizontal_alignment_t)) { return callback__(self, alignment); }
// void gocef_label_button_set_minimum_size(cef_label_button_t * self, cef_size_t * size, void (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_size_t *)) { return callback__(self, size); }
// void gocef_label_button_set_maximum_size(cef_label_button_t * self, cef_size_t * size, void (CEF_CALLBACK *callback__)(cef_label_button_t *, cef_size_t *)) { return callback__(self, size); }
"C"
)
// LabelButton (cef_label_button_t from include/capi/views/cef_label_button_capi.h)
// LabelButton is a button with optional text and/or icon. Methods must be
// called on the browser process UI thread unless otherwise indicated.
type LabelButton C.cef_label_button_t
func (d *LabelButton) toNative() *C.cef_label_button_t {
return (*C.cef_label_button_t)(d)
}
// Base (base)
// Base structure.
func (d *LabelButton) Base() *Button {
return (*Button)(&d.base)
}
// AsMenuButton (as_menu_button)
// Returns this LabelButton as a MenuButton or NULL if this is not a
// MenuButton.
func (d *LabelButton) AsMenuButton() *MenuButton {
return (*MenuButton)(C.gocef_label_button_as_menu_button(d.toNative(), d.as_menu_button))
}
// SetText (set_text)
// Sets the text shown on the LabelButton. By default |text| will also be used
// as the accessible name.
func (d *LabelButton) SetText(text string) {
text_ := C.cef_string_userfree_alloc()
setCEFStr(text, text_)
defer func() {
C.cef_string_userfree_free(text_)
}()
C.gocef_label_button_set_text(d.toNative(), (*C.cef_string_t)(text_), d.set_text)
}
// GetText (get_text)
// Returns the text shown on the LabelButton.
// The resulting string must be freed by calling cef_string_userfree_free().
func (d *LabelButton) GetText() string {
return cefuserfreestrToString(C.gocef_label_button_get_text(d.toNative(), d.get_text))
}
// SetImage (set_image)
// Sets the image shown for |button_state|. When this Button is drawn if no
// image exists for the current state then the image for
// CEF_BUTTON_STATE_NORMAL, if any, will be shown.
func (d *LabelButton) SetImage(button_state ButtonState, image *Image) {
C.gocef_label_button_set_image(d.toNative(), C.cef_button_state_t(button_state), image.toNative(), d.set_image)
}
// GetImage (get_image)
// Returns the image shown for |button_state|. If no image exists for that
// state then the image for CEF_BUTTON_STATE_NORMAL will be returned.
func (d *LabelButton) GetImage(button_state ButtonState) *Image {
return (*Image)(C.gocef_label_button_get_image(d.toNative(), C.cef_button_state_t(button_state), d.get_image))
}
// SetTextColor (set_text_color)
// Sets the text color shown for the specified button |for_state| to |color|.
func (d *LabelButton) SetTextColor(for_state ButtonState, color Color) {
C.gocef_label_button_set_text_color(d.toNative(), C.cef_button_state_t(for_state), C.cef_color_t(color), d.set_text_color)
}
// SetEnabledTextColors (set_enabled_text_colors)
// Sets the text colors shown for the non-disabled states to |color|.
func (d *LabelButton) SetEnabledTextColors(color Color) {
C.gocef_label_button_set_enabled_text_colors(d.toNative(), C.cef_color_t(color), d.set_enabled_text_colors)
}
// SetFontList (set_font_list)
// Sets the font list. The format is "<FONT_FAMILY_LIST>,[STYLES] <SIZE>",
// where: - FONT_FAMILY_LIST is a comma-separated list of font family names, -
// STYLES is an optional space-separated list of style names (case-sensitive
// "Bold" and "Italic" are supported), and
// - SIZE is an integer font size in pixels with the suffix "px".
//
// Here are examples of valid font description strings: - "Arial, Helvetica,
// Bold Italic 14px" - "Arial, 14px"
func (d *LabelButton) SetFontList(font_list string) {
font_list_ := C.cef_string_userfree_alloc()
setCEFStr(font_list, font_list_)
defer func() {
C.cef_string_userfree_free(font_list_)
}()
C.gocef_label_button_set_font_list(d.toNative(), (*C.cef_string_t)(font_list_), d.set_font_list)
}
// SetHorizontalAlignment (set_horizontal_alignment)
// Sets the horizontal alignment; reversed in RTL. Default is
// CEF_HORIZONTAL_ALIGNMENT_CENTER.
func (d *LabelButton) SetHorizontalAlignment(alignment HorizontalAlignment) {
C.gocef_label_button_set_horizontal_alignment(d.toNative(), C.cef_horizontal_alignment_t(alignment), d.set_horizontal_alignment)
}
// SetMinimumSize (set_minimum_size)
// Reset the minimum size of this LabelButton to |size|.
func (d *LabelButton) SetMinimumSize(size *Size) {
C.gocef_label_button_set_minimum_size(d.toNative(), size.toNative(&C.cef_size_t{}), d.set_minimum_size)
}
// SetMaximumSize (set_maximum_size)
// Reset the maximum size of this LabelButton to |size|.
func (d *LabelButton) SetMaximumSize(size *Size) {
C.gocef_label_button_set_maximum_size(d.toNative(), size.toNative(&C.cef_size_t{}), d.set_maximum_size)
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// cef_box_layout_t * gocef_layout_as_box_layout(cef_layout_t * self, cef_box_layout_t * (CEF_CALLBACK *callback__)(cef_layout_t *)) { return callback__(self); }
// cef_fill_layout_t * gocef_layout_as_fill_layout(cef_layout_t * self, cef_fill_layout_t * (CEF_CALLBACK *callback__)(cef_layout_t *)) { return callback__(self); }
// int gocef_layout_is_valid(cef_layout_t * self, int (CEF_CALLBACK *callback__)(cef_layout_t *)) { return callback__(self); }
"C"
)
// Layout (cef_layout_t from include/capi/views/cef_layout_capi.h)
// A Layout handles the sizing of the children of a Panel according to
// implementation-specific heuristics. Methods must be called on the browser
// process UI thread unless otherwise indicated.
type Layout C.cef_layout_t
func (d *Layout) toNative() *C.cef_layout_t {
return (*C.cef_layout_t)(d)
}
// Base (base)
// Base structure.
func (d *Layout) Base() *BaseRefCounted {
return (*BaseRefCounted)(&d.base)
}
// AsBoxLayout (as_box_layout)
// Returns this Layout as a BoxLayout or NULL if this is not a BoxLayout.
func (d *Layout) AsBoxLayout() *BoxLayout {
return (*BoxLayout)(C.gocef_layout_as_box_layout(d.toNative(), d.as_box_layout))
}
// AsFillLayout (as_fill_layout)
// Returns this Layout as a FillLayout or NULL if this is not a FillLayout.
func (d *Layout) AsFillLayout() *FillLayout {
return (C.gocef_layout_as_fill_layout(d.toNative(), d.as_fill_layout)).toGo()
}
// IsValid (is_valid)
// Returns true (1) if this Layout is valid.
func (d *Layout) IsValid() int32 {
return int32(C.gocef_layout_is_valid(d.toNative(), d.is_valid))
}
// Code generated - DO NOT EDIT.
#include "MenuButtonDelegate_gen.h"
#include "_cgo_export.h"
void gocef_set_menu_button_delegate_proxy(cef_menu_button_delegate_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->on_menu_button_pressed = (void *)&gocef_menu_button_delegate_on_menu_button_pressed;
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "MenuButtonDelegate_gen.h"
"C"
"unsafe"
"github.com/richardwilkes/toolbox/errs"
"github.com/richardwilkes/toolbox/log/jot"
)
// MenuButtonDelegateProxy defines methods required for using MenuButtonDelegate.
type MenuButtonDelegateProxy interface {
OnMenuButtonPressed(self *MenuButtonDelegate, menu_button *MenuButton, screen_point *Point, button_pressed_lock *MenuButtonPressedLock)
}
// MenuButtonDelegate (cef_menu_button_delegate_t from include/capi/views/cef_menu_button_delegate_capi.h)
// Implement this structure to handle MenuButton events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
type MenuButtonDelegate C.cef_menu_button_delegate_t
// NewMenuButtonDelegate creates a new MenuButtonDelegate with the specified proxy. Passing
// in nil will result in default handling, if applicable.
func NewMenuButtonDelegate(proxy MenuButtonDelegateProxy) *MenuButtonDelegate {
result := (*MenuButtonDelegate)(unsafe.Pointer(newRefCntObj(C.sizeof_struct__cef_menu_button_delegate_t, proxy)))
if proxy != nil {
C.gocef_set_menu_button_delegate_proxy(result.toNative())
}
return result
}
func (d *MenuButtonDelegate) toNative() *C.cef_menu_button_delegate_t {
return (*C.cef_menu_button_delegate_t)(d)
}
func lookupMenuButtonDelegateProxy(obj *BaseRefCounted) MenuButtonDelegateProxy {
proxy, exists := lookupProxy(obj)
if !exists {
jot.Fatal(1, errs.New("Proxy not found for ID"))
}
actual, ok := proxy.(MenuButtonDelegateProxy)
if !ok {
jot.Fatal(1, errs.New("Proxy was not of type MenuButtonDelegateProxy"))
}
return actual
}
// Base (base)
// Base structure.
func (d *MenuButtonDelegate) Base() *ButtonDelegate {
return (*ButtonDelegate)(&d.base)
}
// OnMenuButtonPressed (on_menu_button_pressed)
// Called when |button| is pressed. Call cef_menu_button_t::show_menu() to
// show a popup menu at |screen_point|. When showing a custom popup such as a
// window keep a reference to |button_pressed_lock| until the popup is hidden
// to maintain the pressed button state.
func (d *MenuButtonDelegate) OnMenuButtonPressed(menu_button *MenuButton, screen_point *Point, button_pressed_lock *MenuButtonPressedLock) {
lookupMenuButtonDelegateProxy(d.Base().Base().Base()).OnMenuButtonPressed(d, menu_button, screen_point, button_pressed_lock)
}
//export gocef_menu_button_delegate_on_menu_button_pressed
func gocef_menu_button_delegate_on_menu_button_pressed(self *C.cef_menu_button_delegate_t, menu_button *C.cef_menu_button_t, screen_point *C.cef_point_t, button_pressed_lock *C.cef_menu_button_pressed_lock_t) {
me__ := (*MenuButtonDelegate)(self)
proxy__ := lookupMenuButtonDelegateProxy(me__.Base().Base().Base())
screen_point_ := screen_point.toGo()
button_pressed_lock_ := button_pressed_lock.toGo()
proxy__.OnMenuButtonPressed(me__, (*MenuButton)(menu_button), screen_point_, button_pressed_lock_)
}
// Code generated - DO NOT EDIT.
#ifndef GOCEF_MenuButtonDelegate_H_
#define GOCEF_MenuButtonDelegate_H_
#pragma once
#include "capi_gen.h"
void gocef_set_menu_button_delegate_proxy(cef_menu_button_delegate_t *self);
#endif // GOCEF_MenuButtonDelegate_H_
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
"C"
"unsafe"
)
// MenuButtonPressedLock (cef_menu_button_pressed_lock_t from include/capi/views/cef_menu_button_delegate_capi.h)
// MenuButton pressed lock is released when this object is destroyed.
type MenuButtonPressedLock struct {
// Base (base)
// Base structure.
Base *BaseRefCounted
}
// NewMenuButtonPressedLock creates a new MenuButtonPressedLock.
func NewMenuButtonPressedLock() *MenuButtonPressedLock {
return &MenuButtonPressedLock{}
}
func (d *MenuButtonPressedLock) toNative(native *C.cef_menu_button_pressed_lock_t) *C.cef_menu_button_pressed_lock_t {
native.base = *(*C.cef_base_ref_counted_t)(unsafe.Pointer(d.Base))
return native
}
func (n *C.cef_menu_button_pressed_lock_t) toGo() *MenuButtonPressedLock {
var d MenuButtonPressedLock
n.intoGo(&d)
return &d
}
func (n *C.cef_menu_button_pressed_lock_t) intoGo(d *MenuButtonPressedLock) {
d.Base = (*BaseRefCounted)(&n.base)
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// void gocef_menu_button_show_menu(cef_menu_button_t * self, cef_menu_model_t * menu_model, cef_point_t * screen_point, cef_menu_anchor_position_t anchor_position, void (CEF_CALLBACK *callback__)(cef_menu_button_t *, cef_menu_model_t *, cef_point_t *, cef_menu_anchor_position_t)) { return callback__(self, menu_model, screen_point, anchor_position); }
// void gocef_menu_button_trigger_menu(cef_menu_button_t * self, void (CEF_CALLBACK *callback__)(cef_menu_button_t *)) { return callback__(self); }
"C"
)
// MenuButton (cef_menu_button_t from include/capi/views/cef_menu_button_capi.h)
// MenuButton is a button with optional text, icon and/or menu marker that shows
// a menu when clicked with the left mouse button. All size and position values
// are in density independent pixels (DIP) unless otherwise indicated. Methods
// must be called on the browser process UI thread unless otherwise indicated.
type MenuButton C.cef_menu_button_t
func (d *MenuButton) toNative() *C.cef_menu_button_t {
return (*C.cef_menu_button_t)(d)
}
// Base (base)
// Base structure.
func (d *MenuButton) Base() *LabelButton {
return (*LabelButton)(&d.base)
}
// ShowMenu (show_menu)
// Show a menu with contents |menu_model|. |screen_point| specifies the menu
// position in screen coordinates. |anchor_position| specifies how the menu
// will be anchored relative to |screen_point|. This function should be called
// from cef_menu_button_delegate_t::on_menu_button_pressed().
func (d *MenuButton) ShowMenu(menu_model *MenuModel, screen_point *Point, anchor_position MenuAnchorPosition) {
C.gocef_menu_button_show_menu(d.toNative(), menu_model.toNative(), screen_point.toNative(&C.cef_point_t{}), C.cef_menu_anchor_position_t(anchor_position), d.show_menu)
}
// TriggerMenu (trigger_menu)
// Show the menu for this button. Results in a call to
// cef_menu_button_delegate_t::on_menu_button_pressed().
func (d *MenuButton) TriggerMenu() {
C.gocef_menu_button_trigger_menu(d.toNative(), d.trigger_menu)
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
"C"
"unsafe"
)
// PanelDelegate (cef_panel_delegate_t from include/capi/views/cef_panel_delegate_capi.h)
// Implement this structure to handle Panel events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
type PanelDelegate struct {
// Base (base)
// Base structure.
Base *ViewDelegate
}
// NewPanelDelegate creates a new PanelDelegate.
func NewPanelDelegate() *PanelDelegate {
return &PanelDelegate{}
}
func (d *PanelDelegate) toNative(native *C.cef_panel_delegate_t) *C.cef_panel_delegate_t {
native.base = *(*C.cef_view_delegate_t)(unsafe.Pointer(d.Base))
return native
}
func (n *C.cef_panel_delegate_t) toGo() *PanelDelegate {
var d PanelDelegate
n.intoGo(&d)
return &d
}
func (n *C.cef_panel_delegate_t) intoGo(d *PanelDelegate) {
d.Base = (*ViewDelegate)(&n.base)
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// cef_window_t * gocef_panel_as_window(cef_panel_t * self, cef_window_t * (CEF_CALLBACK *callback__)(cef_panel_t *)) { return callback__(self); }
// cef_fill_layout_t * gocef_panel_set_to_fill_layout(cef_panel_t * self, cef_fill_layout_t * (CEF_CALLBACK *callback__)(cef_panel_t *)) { return callback__(self); }
// cef_box_layout_t * gocef_panel_set_to_box_layout(cef_panel_t * self, cef_box_layout_settings_t * settings, cef_box_layout_t * (CEF_CALLBACK *callback__)(cef_panel_t *, cef_box_layout_settings_t *)) { return callback__(self, settings); }
// cef_layout_t * gocef_panel_get_layout(cef_panel_t * self, cef_layout_t * (CEF_CALLBACK *callback__)(cef_panel_t *)) { return callback__(self); }
// void gocef_panel_layout(cef_panel_t * self, void (CEF_CALLBACK *callback__)(cef_panel_t *)) { return callback__(self); }
// void gocef_panel_add_child_view(cef_panel_t * self, cef_view_t * view, void (CEF_CALLBACK *callback__)(cef_panel_t *, cef_view_t *)) { return callback__(self, view); }
// void gocef_panel_add_child_view_at(cef_panel_t * self, cef_view_t * view, int index, void (CEF_CALLBACK *callback__)(cef_panel_t *, cef_view_t *, int)) { return callback__(self, view, index); }
// void gocef_panel_reorder_child_view(cef_panel_t * self, cef_view_t * view, int index, void (CEF_CALLBACK *callback__)(cef_panel_t *, cef_view_t *, int)) { return callback__(self, view, index); }
// void gocef_panel_remove_child_view(cef_panel_t * self, cef_view_t * view, void (CEF_CALLBACK *callback__)(cef_panel_t *, cef_view_t *)) { return callback__(self, view); }
// void gocef_panel_remove_all_child_views(cef_panel_t * self, void (CEF_CALLBACK *callback__)(cef_panel_t *)) { return callback__(self); }
// size_t gocef_panel_get_child_view_count(cef_panel_t * self, size_t (CEF_CALLBACK *callback__)(cef_panel_t *)) { return callback__(self); }
// cef_view_t * gocef_panel_get_child_view_at(cef_panel_t * self, int index, cef_view_t * (CEF_CALLBACK *callback__)(cef_panel_t *, int)) { return callback__(self, index); }
"C"
)
// Panel (cef_panel_t from include/capi/views/cef_panel_capi.h)
// A Panel is a container in the views hierarchy that can contain other Views as
// children. Methods must be called on the browser process UI thread unless
// otherwise indicated.
type Panel C.cef_panel_t
func (d *Panel) toNative() *C.cef_panel_t {
return (*C.cef_panel_t)(d)
}
// Base (base)
// Base structure.
func (d *Panel) Base() *View {
return (*View)(&d.base)
}
// AsWindow (as_window)
// Returns this Panel as a Window or NULL if this is not a Window.
func (d *Panel) AsWindow() *Window {
return (*Window)(C.gocef_panel_as_window(d.toNative(), d.as_window))
}
// SetToFillLayout (set_to_fill_layout)
// Set this Panel's Layout to FillLayout and return the FillLayout object.
func (d *Panel) SetToFillLayout() *FillLayout {
return (C.gocef_panel_set_to_fill_layout(d.toNative(), d.set_to_fill_layout)).toGo()
}
// SetToBoxLayout (set_to_box_layout)
// Set this Panel's Layout to BoxLayout and return the BoxLayout object.
func (d *Panel) SetToBoxLayout(settings *BoxLayoutSettings) *BoxLayout {
return (*BoxLayout)(C.gocef_panel_set_to_box_layout(d.toNative(), settings.toNative(&C.cef_box_layout_settings_t{}), d.set_to_box_layout))
}
// GetLayout (get_layout)
// Get the Layout.
func (d *Panel) GetLayout() *Layout {
return (*Layout)(C.gocef_panel_get_layout(d.toNative(), d.get_layout))
}
// Layout (layout)
// Lay out the child Views (set their bounds based on sizing heuristics
// specific to the current Layout).
func (d *Panel) Layout() {
C.gocef_panel_layout(d.toNative(), d.layout)
}
// AddChildView (add_child_view)
// Add a child View.
func (d *Panel) AddChildView(view *View) {
C.gocef_panel_add_child_view(d.toNative(), view.toNative(), d.add_child_view)
}
// AddChildViewAt (add_child_view_at)
// Add a child View at the specified |index|. If |index| matches the result of
// GetChildCount() then the View will be added at the end.
func (d *Panel) AddChildViewAt(view *View, index int32) {
C.gocef_panel_add_child_view_at(d.toNative(), view.toNative(), C.int(index), d.add_child_view_at)
}
// ReorderChildView (reorder_child_view)
// Move the child View to the specified |index|. A negative value for |index|
// will move the View to the end.
func (d *Panel) ReorderChildView(view *View, index int32) {
C.gocef_panel_reorder_child_view(d.toNative(), view.toNative(), C.int(index), d.reorder_child_view)
}
// RemoveChildView (remove_child_view)
// Remove a child View. The View can then be added to another Panel.
func (d *Panel) RemoveChildView(view *View) {
C.gocef_panel_remove_child_view(d.toNative(), view.toNative(), d.remove_child_view)
}
// RemoveAllChildViews (remove_all_child_views)
// Remove all child Views. The removed Views will be deleted if the client
// holds no references to them.
func (d *Panel) RemoveAllChildViews() {
C.gocef_panel_remove_all_child_views(d.toNative(), d.remove_all_child_views)
}
// GetChildViewCount (get_child_view_count)
// Returns the number of child Views.
func (d *Panel) GetChildViewCount() uint64 {
return uint64(C.gocef_panel_get_child_view_count(d.toNative(), d.get_child_view_count))
}
// GetChildViewAt (get_child_view_at)
// Returns the child View at the specified |index|.
func (d *Panel) GetChildViewAt(index int32) *View {
return (*View)(C.gocef_panel_get_child_view_at(d.toNative(), C.int(index), d.get_child_view_at))
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// void gocef_scroll_view_set_content_view(cef_scroll_view_t * self, cef_view_t * view, void (CEF_CALLBACK *callback__)(cef_scroll_view_t *, cef_view_t *)) { return callback__(self, view); }
// cef_view_t * gocef_scroll_view_get_content_view(cef_scroll_view_t * self, cef_view_t * (CEF_CALLBACK *callback__)(cef_scroll_view_t *)) { return callback__(self); }
// cef_rect_t gocef_scroll_view_get_visible_content_rect(cef_scroll_view_t * self, cef_rect_t (CEF_CALLBACK *callback__)(cef_scroll_view_t *)) { return callback__(self); }
// int gocef_scroll_view_has_horizontal_scrollbar(cef_scroll_view_t * self, int (CEF_CALLBACK *callback__)(cef_scroll_view_t *)) { return callback__(self); }
// int gocef_scroll_view_get_horizontal_scrollbar_height(cef_scroll_view_t * self, int (CEF_CALLBACK *callback__)(cef_scroll_view_t *)) { return callback__(self); }
// int gocef_scroll_view_has_vertical_scrollbar(cef_scroll_view_t * self, int (CEF_CALLBACK *callback__)(cef_scroll_view_t *)) { return callback__(self); }
// int gocef_scroll_view_get_vertical_scrollbar_width(cef_scroll_view_t * self, int (CEF_CALLBACK *callback__)(cef_scroll_view_t *)) { return callback__(self); }
"C"
)
// ScrollView (cef_scroll_view_t from include/capi/views/cef_scroll_view_capi.h)
// A ScrollView will show horizontal and/or vertical scrollbars when necessary
// based on the size of the attached content view. Methods must be called on the
// browser process UI thread unless otherwise indicated.
type ScrollView C.cef_scroll_view_t
func (d *ScrollView) toNative() *C.cef_scroll_view_t {
return (*C.cef_scroll_view_t)(d)
}
// Base (base)
// Base structure.
func (d *ScrollView) Base() *View {
return (*View)(&d.base)
}
// SetContentView (set_content_view)
// Set the content View. The content View must have a specified size (e.g. via
// cef_view_t::SetBounds or cef_view_tDelegate::GetPreferredSize).
func (d *ScrollView) SetContentView(view *View) {
C.gocef_scroll_view_set_content_view(d.toNative(), view.toNative(), d.set_content_view)
}
// GetContentView (get_content_view)
// Returns the content View.
func (d *ScrollView) GetContentView() *View {
return (*View)(C.gocef_scroll_view_get_content_view(d.toNative(), d.get_content_view))
}
// GetVisibleContentRect (get_visible_content_rect)
// Returns the visible region of the content View.
func (d *ScrollView) GetVisibleContentRect() Rect {
cresult__ := C.gocef_scroll_view_get_visible_content_rect(d.toNative(), d.get_visible_content_rect)
var result__ Rect
(&cresult__).intoGo(&result__)
return result__
}
// HasHorizontalScrollbar (has_horizontal_scrollbar)
// Returns true (1) if the horizontal scrollbar is currently showing.
func (d *ScrollView) HasHorizontalScrollbar() int32 {
return int32(C.gocef_scroll_view_has_horizontal_scrollbar(d.toNative(), d.has_horizontal_scrollbar))
}
// GetHorizontalScrollbarHeight (get_horizontal_scrollbar_height)
// Returns the height of the horizontal scrollbar.
func (d *ScrollView) GetHorizontalScrollbarHeight() int32 {
return int32(C.gocef_scroll_view_get_horizontal_scrollbar_height(d.toNative(), d.get_horizontal_scrollbar_height))
}
// HasVerticalScrollbar (has_vertical_scrollbar)
// Returns true (1) if the vertical scrollbar is currently showing.
func (d *ScrollView) HasVerticalScrollbar() int32 {
return int32(C.gocef_scroll_view_has_vertical_scrollbar(d.toNative(), d.has_vertical_scrollbar))
}
// GetVerticalScrollbarWidth (get_vertical_scrollbar_width)
// Returns the width of the vertical scrollbar.
func (d *ScrollView) GetVerticalScrollbarWidth() int32 {
return int32(C.gocef_scroll_view_get_vertical_scrollbar_width(d.toNative(), d.get_vertical_scrollbar_width))
}
// Code generated - DO NOT EDIT.
#include "TextfieldDelegate_gen.h"
#include "_cgo_export.h"
void gocef_set_textfield_delegate_proxy(cef_textfield_delegate_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->on_key_event = (void *)&gocef_textfield_delegate_on_key_event;
self->on_after_user_action = (void *)&gocef_textfield_delegate_on_after_user_action;
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "TextfieldDelegate_gen.h"
"C"
"unsafe"
"github.com/richardwilkes/toolbox/errs"
"github.com/richardwilkes/toolbox/log/jot"
)
// TextfieldDelegateProxy defines methods required for using TextfieldDelegate.
type TextfieldDelegateProxy interface {
OnKeyEvent(self *TextfieldDelegate, textfield *Textfield, event *KeyEvent) int32
OnAfterUserAction(self *TextfieldDelegate, textfield *Textfield)
}
// TextfieldDelegate (cef_textfield_delegate_t from include/capi/views/cef_textfield_delegate_capi.h)
// Implement this structure to handle Textfield events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
type TextfieldDelegate C.cef_textfield_delegate_t
// NewTextfieldDelegate creates a new TextfieldDelegate with the specified proxy. Passing
// in nil will result in default handling, if applicable.
func NewTextfieldDelegate(proxy TextfieldDelegateProxy) *TextfieldDelegate {
result := (*TextfieldDelegate)(unsafe.Pointer(newRefCntObj(C.sizeof_struct__cef_textfield_delegate_t, proxy)))
if proxy != nil {
C.gocef_set_textfield_delegate_proxy(result.toNative())
}
return result
}
func (d *TextfieldDelegate) toNative() *C.cef_textfield_delegate_t {
return (*C.cef_textfield_delegate_t)(d)
}
func lookupTextfieldDelegateProxy(obj *BaseRefCounted) TextfieldDelegateProxy {
proxy, exists := lookupProxy(obj)
if !exists {
jot.Fatal(1, errs.New("Proxy not found for ID"))
}
actual, ok := proxy.(TextfieldDelegateProxy)
if !ok {
jot.Fatal(1, errs.New("Proxy was not of type TextfieldDelegateProxy"))
}
return actual
}
// Base (base)
// Base structure.
func (d *TextfieldDelegate) Base() *ViewDelegate {
return (*ViewDelegate)(&d.base)
}
// OnKeyEvent (on_key_event)
// Called when |textfield| recieves a keyboard event. |event| contains
// information about the keyboard event. Return true (1) if the keyboard event
// was handled or false (0) otherwise for default handling.
func (d *TextfieldDelegate) OnKeyEvent(textfield *Textfield, event *KeyEvent) int32 {
return lookupTextfieldDelegateProxy(d.Base().Base()).OnKeyEvent(d, textfield, event)
}
//export gocef_textfield_delegate_on_key_event
func gocef_textfield_delegate_on_key_event(self *C.cef_textfield_delegate_t, textfield *C.cef_textfield_t, event *C.cef_key_event_t) C.int {
me__ := (*TextfieldDelegate)(self)
proxy__ := lookupTextfieldDelegateProxy(me__.Base().Base())
event_ := event.toGo()
return C.int(proxy__.OnKeyEvent(me__, (*Textfield)(textfield), event_))
}
// OnAfterUserAction (on_after_user_action)
// Called after performing a user action that may change |textfield|.
func (d *TextfieldDelegate) OnAfterUserAction(textfield *Textfield) {
lookupTextfieldDelegateProxy(d.Base().Base()).OnAfterUserAction(d, textfield)
}
//export gocef_textfield_delegate_on_after_user_action
func gocef_textfield_delegate_on_after_user_action(self *C.cef_textfield_delegate_t, textfield *C.cef_textfield_t) {
me__ := (*TextfieldDelegate)(self)
proxy__ := lookupTextfieldDelegateProxy(me__.Base().Base())
proxy__.OnAfterUserAction(me__, (*Textfield)(textfield))
}
// Code generated - DO NOT EDIT.
#ifndef GOCEF_TextfieldDelegate_H_
#define GOCEF_TextfieldDelegate_H_
#pragma once
#include "capi_gen.h"
void gocef_set_textfield_delegate_proxy(cef_textfield_delegate_t *self);
#endif // GOCEF_TextfieldDelegate_H_
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// void gocef_textfield_set_password_input(cef_textfield_t * self, int password_input, void (CEF_CALLBACK *callback__)(cef_textfield_t *, int)) { return callback__(self, password_input); }
// int gocef_textfield_is_password_input(cef_textfield_t * self, int (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_set_read_only(cef_textfield_t * self, int read_only, void (CEF_CALLBACK *callback__)(cef_textfield_t *, int)) { return callback__(self, read_only); }
// int gocef_textfield_is_read_only(cef_textfield_t * self, int (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// cef_string_userfree_t gocef_textfield_get_text(cef_textfield_t * self, cef_string_userfree_t (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_set_text(cef_textfield_t * self, cef_string_t * text, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_string_t *)) { return callback__(self, text); }
// void gocef_textfield_append_text(cef_textfield_t * self, cef_string_t * text, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_string_t *)) { return callback__(self, text); }
// void gocef_textfield_insert_or_replace_text(cef_textfield_t * self, cef_string_t * text, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_string_t *)) { return callback__(self, text); }
// int gocef_textfield_has_selection(cef_textfield_t * self, int (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// cef_string_userfree_t gocef_textfield_get_selected_text(cef_textfield_t * self, cef_string_userfree_t (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_select_all(cef_textfield_t * self, int reversed, void (CEF_CALLBACK *callback__)(cef_textfield_t *, int)) { return callback__(self, reversed); }
// void gocef_textfield_clear_selection(cef_textfield_t * self, void (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// cef_range_t gocef_textfield_get_selected_range(cef_textfield_t * self, cef_range_t (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_select_range(cef_textfield_t * self, cef_range_t * range_r, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_range_t *)) { return callback__(self, range_r); }
// size_t gocef_textfield_get_cursor_position(cef_textfield_t * self, size_t (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_set_text_color(cef_textfield_t * self, cef_color_t color, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_color_t)) { return callback__(self, color); }
// cef_color_t gocef_textfield_get_text_color(cef_textfield_t * self, cef_color_t (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_set_selection_text_color(cef_textfield_t * self, cef_color_t color, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_color_t)) { return callback__(self, color); }
// cef_color_t gocef_textfield_get_selection_text_color(cef_textfield_t * self, cef_color_t (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_set_selection_background_color(cef_textfield_t * self, cef_color_t color, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_color_t)) { return callback__(self, color); }
// cef_color_t gocef_textfield_get_selection_background_color(cef_textfield_t * self, cef_color_t (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_set_font_list(cef_textfield_t * self, cef_string_t * font_list, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_string_t *)) { return callback__(self, font_list); }
// void gocef_textfield_apply_text_color(cef_textfield_t * self, cef_color_t color, cef_range_t * range_r, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_color_t, cef_range_t *)) { return callback__(self, color, range_r); }
// void gocef_textfield_apply_text_style(cef_textfield_t * self, cef_text_style_t style, int add, cef_range_t * range_r, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_text_style_t, int, cef_range_t *)) { return callback__(self, style, add, range_r); }
// int gocef_textfield_is_command_enabled(cef_textfield_t * self, int command_id, int (CEF_CALLBACK *callback__)(cef_textfield_t *, int)) { return callback__(self, command_id); }
// void gocef_textfield_execute_command(cef_textfield_t * self, int command_id, void (CEF_CALLBACK *callback__)(cef_textfield_t *, int)) { return callback__(self, command_id); }
// void gocef_textfield_clear_edit_history(cef_textfield_t * self, void (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_set_placeholder_text(cef_textfield_t * self, cef_string_t * text, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_string_t *)) { return callback__(self, text); }
// cef_string_userfree_t gocef_textfield_get_placeholder_text(cef_textfield_t * self, cef_string_userfree_t (CEF_CALLBACK *callback__)(cef_textfield_t *)) { return callback__(self); }
// void gocef_textfield_set_placeholder_text_color(cef_textfield_t * self, cef_color_t color, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_color_t)) { return callback__(self, color); }
// void gocef_textfield_set_accessible_name(cef_textfield_t * self, cef_string_t * name, void (CEF_CALLBACK *callback__)(cef_textfield_t *, cef_string_t *)) { return callback__(self, name); }
"C"
)
// Textfield (cef_textfield_t from include/capi/views/cef_textfield_capi.h)
// A Textfield supports editing of text. This control is custom rendered with no
// platform-specific code. Methods must be called on the browser process UI
// thread unless otherwise indicated.
type Textfield C.cef_textfield_t
func (d *Textfield) toNative() *C.cef_textfield_t {
return (*C.cef_textfield_t)(d)
}
// Base (base)
// Base structure.
func (d *Textfield) Base() *View {
return (*View)(&d.base)
}
// SetPasswordInput (set_password_input)
// Sets whether the text will be displayed as asterisks.
func (d *Textfield) SetPasswordInput(password_input int32) {
C.gocef_textfield_set_password_input(d.toNative(), C.int(password_input), d.set_password_input)
}
// IsPasswordInput (is_password_input)
// Returns true (1) if the text will be displayed as asterisks.
func (d *Textfield) IsPasswordInput() int32 {
return int32(C.gocef_textfield_is_password_input(d.toNative(), d.is_password_input))
}
// SetReadOnly (set_read_only)
// Sets whether the text will read-only.
func (d *Textfield) SetReadOnly(read_only int32) {
C.gocef_textfield_set_read_only(d.toNative(), C.int(read_only), d.set_read_only)
}
// IsReadOnly (is_read_only)
// Returns true (1) if the text is read-only.
func (d *Textfield) IsReadOnly() int32 {
return int32(C.gocef_textfield_is_read_only(d.toNative(), d.is_read_only))
}
// GetText (get_text)
// Returns the currently displayed text.
// The resulting string must be freed by calling cef_string_userfree_free().
func (d *Textfield) GetText() string {
return cefuserfreestrToString(C.gocef_textfield_get_text(d.toNative(), d.get_text))
}
// SetText (set_text)
// Sets the contents to |text|. The cursor will be moved to end of the text if
// the current position is outside of the text range.
func (d *Textfield) SetText(text string) {
text_ := C.cef_string_userfree_alloc()
setCEFStr(text, text_)
defer func() {
C.cef_string_userfree_free(text_)
}()
C.gocef_textfield_set_text(d.toNative(), (*C.cef_string_t)(text_), d.set_text)
}
// AppendText (append_text)
// Appends |text| to the previously-existing text.
func (d *Textfield) AppendText(text string) {
text_ := C.cef_string_userfree_alloc()
setCEFStr(text, text_)
defer func() {
C.cef_string_userfree_free(text_)
}()
C.gocef_textfield_append_text(d.toNative(), (*C.cef_string_t)(text_), d.append_text)
}
// InsertOrReplaceText (insert_or_replace_text)
// Inserts |text| at the current cursor position replacing any selected text.
func (d *Textfield) InsertOrReplaceText(text string) {
text_ := C.cef_string_userfree_alloc()
setCEFStr(text, text_)
defer func() {
C.cef_string_userfree_free(text_)
}()
C.gocef_textfield_insert_or_replace_text(d.toNative(), (*C.cef_string_t)(text_), d.insert_or_replace_text)
}
// HasSelection (has_selection)
// Returns true (1) if there is any selected text.
func (d *Textfield) HasSelection() int32 {
return int32(C.gocef_textfield_has_selection(d.toNative(), d.has_selection))
}
// GetSelectedText (get_selected_text)
// Returns the currently selected text.
// The resulting string must be freed by calling cef_string_userfree_free().
func (d *Textfield) GetSelectedText() string {
return cefuserfreestrToString(C.gocef_textfield_get_selected_text(d.toNative(), d.get_selected_text))
}
// SelectAll (select_all)
// Selects all text. If |reversed| is true (1) the range will end at the
// logical beginning of the text; this generally shows the leading portion of
// text that overflows its display area.
func (d *Textfield) SelectAll(reversed int32) {
C.gocef_textfield_select_all(d.toNative(), C.int(reversed), d.select_all)
}
// ClearSelection (clear_selection)
// Clears the text selection and sets the caret to the end.
func (d *Textfield) ClearSelection() {
C.gocef_textfield_clear_selection(d.toNative(), d.clear_selection)
}
// GetSelectedRange (get_selected_range)
// Returns the selected logical text range.
func (d *Textfield) GetSelectedRange() Range {
cresult__ := C.gocef_textfield_get_selected_range(d.toNative(), d.get_selected_range)
var result__ Range
(&cresult__).intoGo(&result__)
return result__
}
// SelectRange (select_range)
// Selects the specified logical text range.
func (d *Textfield) SelectRange(range_r *Range) {
C.gocef_textfield_select_range(d.toNative(), range_r.toNative(&C.cef_range_t{}), d.select_range)
}
// GetCursorPosition (get_cursor_position)
// Returns the current cursor position.
func (d *Textfield) GetCursorPosition() uint64 {
return uint64(C.gocef_textfield_get_cursor_position(d.toNative(), d.get_cursor_position))
}
// SetTextColor (set_text_color)
// Sets the text color.
func (d *Textfield) SetTextColor(color Color) {
C.gocef_textfield_set_text_color(d.toNative(), C.cef_color_t(color), d.set_text_color)
}
// GetTextColor (get_text_color)
// Returns the text color.
func (d *Textfield) GetTextColor() Color {
return Color(C.gocef_textfield_get_text_color(d.toNative(), d.get_text_color))
}
// SetSelectionTextColor (set_selection_text_color)
// Sets the selection text color.
func (d *Textfield) SetSelectionTextColor(color Color) {
C.gocef_textfield_set_selection_text_color(d.toNative(), C.cef_color_t(color), d.set_selection_text_color)
}
// GetSelectionTextColor (get_selection_text_color)
// Returns the selection text color.
func (d *Textfield) GetSelectionTextColor() Color {
return Color(C.gocef_textfield_get_selection_text_color(d.toNative(), d.get_selection_text_color))
}
// SetSelectionBackgroundColor (set_selection_background_color)
// Sets the selection background color.
func (d *Textfield) SetSelectionBackgroundColor(color Color) {
C.gocef_textfield_set_selection_background_color(d.toNative(), C.cef_color_t(color), d.set_selection_background_color)
}
// GetSelectionBackgroundColor (get_selection_background_color)
// Returns the selection background color.
func (d *Textfield) GetSelectionBackgroundColor() Color {
return Color(C.gocef_textfield_get_selection_background_color(d.toNative(), d.get_selection_background_color))
}
// SetFontList (set_font_list)
// Sets the font list. The format is "<FONT_FAMILY_LIST>,[STYLES] <SIZE>",
// where: - FONT_FAMILY_LIST is a comma-separated list of font family names, -
// STYLES is an optional space-separated list of style names (case-sensitive
// "Bold" and "Italic" are supported), and
// - SIZE is an integer font size in pixels with the suffix "px".
//
// Here are examples of valid font description strings: - "Arial, Helvetica,
// Bold Italic 14px" - "Arial, 14px"
func (d *Textfield) SetFontList(font_list string) {
font_list_ := C.cef_string_userfree_alloc()
setCEFStr(font_list, font_list_)
defer func() {
C.cef_string_userfree_free(font_list_)
}()
C.gocef_textfield_set_font_list(d.toNative(), (*C.cef_string_t)(font_list_), d.set_font_list)
}
// ApplyTextColor (apply_text_color)
// Applies |color| to the specified |range| without changing the default
// color. If |range| is NULL the color will be set on the complete text
// contents.
func (d *Textfield) ApplyTextColor(color Color, range_r *Range) {
C.gocef_textfield_apply_text_color(d.toNative(), C.cef_color_t(color), range_r.toNative(&C.cef_range_t{}), d.apply_text_color)
}
// ApplyTextStyle (apply_text_style)
// Applies |style| to the specified |range| without changing the default
// style. If |add| is true (1) the style will be added, otherwise the style
// will be removed. If |range| is NULL the style will be set on the complete
// text contents.
func (d *Textfield) ApplyTextStyle(style TextStyle, add int32, range_r *Range) {
C.gocef_textfield_apply_text_style(d.toNative(), C.cef_text_style_t(style), C.int(add), range_r.toNative(&C.cef_range_t{}), d.apply_text_style)
}
// IsCommandEnabled (is_command_enabled)
// Returns true (1) if the action associated with the specified command id is
// enabled. See additional comments on execute_command().
func (d *Textfield) IsCommandEnabled(command_id int32) int32 {
return int32(C.gocef_textfield_is_command_enabled(d.toNative(), C.int(command_id), d.is_command_enabled))
}
// ExecuteCommand (execute_command)
// Performs the action associated with the specified command id. Valid values
// include IDS_APP_UNDO, IDS_APP_REDO, IDS_APP_CUT, IDS_APP_COPY,
// IDS_APP_PASTE, IDS_APP_DELETE, IDS_APP_SELECT_ALL, IDS_DELETE_* and
// IDS_MOVE_*. See include/cef_pack_strings.h for definitions.
func (d *Textfield) ExecuteCommand(command_id int32) {
C.gocef_textfield_execute_command(d.toNative(), C.int(command_id), d.execute_command)
}
// ClearEditHistory (clear_edit_history)
// Clears Edit history.
func (d *Textfield) ClearEditHistory() {
C.gocef_textfield_clear_edit_history(d.toNative(), d.clear_edit_history)
}
// SetPlaceholderText (set_placeholder_text)
// Sets the placeholder text that will be displayed when the Textfield is
// NULL.
func (d *Textfield) SetPlaceholderText(text string) {
text_ := C.cef_string_userfree_alloc()
setCEFStr(text, text_)
defer func() {
C.cef_string_userfree_free(text_)
}()
C.gocef_textfield_set_placeholder_text(d.toNative(), (*C.cef_string_t)(text_), d.set_placeholder_text)
}
// GetPlaceholderText (get_placeholder_text)
// Returns the placeholder text that will be displayed when the Textfield is
// NULL.
// The resulting string must be freed by calling cef_string_userfree_free().
func (d *Textfield) GetPlaceholderText() string {
return cefuserfreestrToString(C.gocef_textfield_get_placeholder_text(d.toNative(), d.get_placeholder_text))
}
// SetPlaceholderTextColor (set_placeholder_text_color)
// Sets the placeholder text color.
func (d *Textfield) SetPlaceholderTextColor(color Color) {
C.gocef_textfield_set_placeholder_text_color(d.toNative(), C.cef_color_t(color), d.set_placeholder_text_color)
}
// SetAccessibleName (set_accessible_name)
// Set the accessible name that will be exposed to assistive technology (AT).
func (d *Textfield) SetAccessibleName(name string) {
name_ := C.cef_string_userfree_alloc()
setCEFStr(name, name_)
defer func() {
C.cef_string_userfree_free(name_)
}()
C.gocef_textfield_set_accessible_name(d.toNative(), (*C.cef_string_t)(name_), d.set_accessible_name)
}
// Code generated - DO NOT EDIT.
#include "ViewDelegate_gen.h"
#include "_cgo_export.h"
void gocef_set_view_delegate_proxy(cef_view_delegate_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->get_preferred_size = (void *)&gocef_view_delegate_get_preferred_size;
self->get_minimum_size = (void *)&gocef_view_delegate_get_minimum_size;
self->get_maximum_size = (void *)&gocef_view_delegate_get_maximum_size;
self->get_height_for_width = (void *)&gocef_view_delegate_get_height_for_width;
self->on_parent_view_changed = (void *)&gocef_view_delegate_on_parent_view_changed;
self->on_child_view_changed = (void *)&gocef_view_delegate_on_child_view_changed;
self->on_focus = (void *)&gocef_view_delegate_on_focus;
self->on_blur = (void *)&gocef_view_delegate_on_blur;
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "ViewDelegate_gen.h"
"C"
"unsafe"
"github.com/richardwilkes/toolbox/errs"
"github.com/richardwilkes/toolbox/log/jot"
)
// ViewDelegateProxy defines methods required for using ViewDelegate.
type ViewDelegateProxy interface {
GetPreferredSize(self *ViewDelegate, view *View) Size
GetMinimumSize(self *ViewDelegate, view *View) Size
GetMaximumSize(self *ViewDelegate, view *View) Size
GetHeightForWidth(self *ViewDelegate, view *View, width int32) int32
OnParentViewChanged(self *ViewDelegate, view *View, added int32, parent *View)
OnChildViewChanged(self *ViewDelegate, view *View, added int32, child *View)
OnFocus(self *ViewDelegate, view *View)
OnBlur(self *ViewDelegate, view *View)
}
// ViewDelegate (cef_view_delegate_t from include/capi/views/cef_view_delegate_capi.h)
// Implement this structure to handle view events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
type ViewDelegate C.cef_view_delegate_t
// NewViewDelegate creates a new ViewDelegate with the specified proxy. Passing
// in nil will result in default handling, if applicable.
func NewViewDelegate(proxy ViewDelegateProxy) *ViewDelegate {
result := (*ViewDelegate)(unsafe.Pointer(newRefCntObj(C.sizeof_struct__cef_view_delegate_t, proxy)))
if proxy != nil {
C.gocef_set_view_delegate_proxy(result.toNative())
}
return result
}
func (d *ViewDelegate) toNative() *C.cef_view_delegate_t {
return (*C.cef_view_delegate_t)(d)
}
func lookupViewDelegateProxy(obj *BaseRefCounted) ViewDelegateProxy {
proxy, exists := lookupProxy(obj)
if !exists {
jot.Fatal(1, errs.New("Proxy not found for ID"))
}
actual, ok := proxy.(ViewDelegateProxy)
if !ok {
jot.Fatal(1, errs.New("Proxy was not of type ViewDelegateProxy"))
}
return actual
}
// Base (base)
// Base structure.
func (d *ViewDelegate) Base() *BaseRefCounted {
return (*BaseRefCounted)(&d.base)
}
// GetPreferredSize (get_preferred_size)
// Return the preferred size for |view|. The Layout will use this information
// to determine the display size.
func (d *ViewDelegate) GetPreferredSize(view *View) Size {
return lookupViewDelegateProxy(d.Base()).GetPreferredSize(d, view)
}
//export gocef_view_delegate_get_preferred_size
func gocef_view_delegate_get_preferred_size(self *C.cef_view_delegate_t, view *C.cef_view_t) C.cef_size_t {
me__ := (*ViewDelegate)(self)
proxy__ := lookupViewDelegateProxy(me__.Base())
call__ := proxy__.GetPreferredSize(me__, (*View)(view))
var result__ C.cef_size_t
call__.toNative(&result__)
return result__
}
// GetMinimumSize (get_minimum_size)
// Return the minimum size for |view|.
func (d *ViewDelegate) GetMinimumSize(view *View) Size {
return lookupViewDelegateProxy(d.Base()).GetMinimumSize(d, view)
}
//export gocef_view_delegate_get_minimum_size
func gocef_view_delegate_get_minimum_size(self *C.cef_view_delegate_t, view *C.cef_view_t) C.cef_size_t {
me__ := (*ViewDelegate)(self)
proxy__ := lookupViewDelegateProxy(me__.Base())
call__ := proxy__.GetMinimumSize(me__, (*View)(view))
var result__ C.cef_size_t
call__.toNative(&result__)
return result__
}
// GetMaximumSize (get_maximum_size)
// Return the maximum size for |view|.
func (d *ViewDelegate) GetMaximumSize(view *View) Size {
return lookupViewDelegateProxy(d.Base()).GetMaximumSize(d, view)
}
//export gocef_view_delegate_get_maximum_size
func gocef_view_delegate_get_maximum_size(self *C.cef_view_delegate_t, view *C.cef_view_t) C.cef_size_t {
me__ := (*ViewDelegate)(self)
proxy__ := lookupViewDelegateProxy(me__.Base())
call__ := proxy__.GetMaximumSize(me__, (*View)(view))
var result__ C.cef_size_t
call__.toNative(&result__)
return result__
}
// GetHeightForWidth (get_height_for_width)
// Return the height necessary to display |view| with the provided |width|. If
// not specified the result of get_preferred_size().height will be used by
// default. Override if |view|'s preferred height depends upon the width (for
// example, with Labels).
func (d *ViewDelegate) GetHeightForWidth(view *View, width int32) int32 {
return lookupViewDelegateProxy(d.Base()).GetHeightForWidth(d, view, width)
}
//export gocef_view_delegate_get_height_for_width
func gocef_view_delegate_get_height_for_width(self *C.cef_view_delegate_t, view *C.cef_view_t, width C.int) C.int {
me__ := (*ViewDelegate)(self)
proxy__ := lookupViewDelegateProxy(me__.Base())
return C.int(proxy__.GetHeightForWidth(me__, (*View)(view), int32(width)))
}
// OnParentViewChanged (on_parent_view_changed)
// Called when the parent of |view| has changed. If |view| is being added to
// |parent| then |added| will be true (1). If |view| is being removed from
// |parent| then |added| will be false (0). If |view| is being reparented the
// remove notification will be sent before the add notification. Do not modify
// the view hierarchy in this callback.
func (d *ViewDelegate) OnParentViewChanged(view *View, added int32, parent *View) {
lookupViewDelegateProxy(d.Base()).OnParentViewChanged(d, view, added, parent)
}
//export gocef_view_delegate_on_parent_view_changed
func gocef_view_delegate_on_parent_view_changed(self *C.cef_view_delegate_t, view *C.cef_view_t, added C.int, parent *C.cef_view_t) {
me__ := (*ViewDelegate)(self)
proxy__ := lookupViewDelegateProxy(me__.Base())
proxy__.OnParentViewChanged(me__, (*View)(view), int32(added), (*View)(parent))
}
// OnChildViewChanged (on_child_view_changed)
// Called when a child of |view| has changed. If |child| is being added to
// |view| then |added| will be true (1). If |child| is being removed from
// |view| then |added| will be false (0). If |child| is being reparented the
// remove notification will be sent to the old parent before the add
// notification is sent to the new parent. Do not modify the view hierarchy in
// this callback.
func (d *ViewDelegate) OnChildViewChanged(view *View, added int32, child *View) {
lookupViewDelegateProxy(d.Base()).OnChildViewChanged(d, view, added, child)
}
//export gocef_view_delegate_on_child_view_changed
func gocef_view_delegate_on_child_view_changed(self *C.cef_view_delegate_t, view *C.cef_view_t, added C.int, child *C.cef_view_t) {
me__ := (*ViewDelegate)(self)
proxy__ := lookupViewDelegateProxy(me__.Base())
proxy__.OnChildViewChanged(me__, (*View)(view), int32(added), (*View)(child))
}
// OnFocus (on_focus)
// Called when |view| gains focus.
func (d *ViewDelegate) OnFocus(view *View) {
lookupViewDelegateProxy(d.Base()).OnFocus(d, view)
}
//export gocef_view_delegate_on_focus
func gocef_view_delegate_on_focus(self *C.cef_view_delegate_t, view *C.cef_view_t) {
me__ := (*ViewDelegate)(self)
proxy__ := lookupViewDelegateProxy(me__.Base())
proxy__.OnFocus(me__, (*View)(view))
}
// OnBlur (on_blur)
// Called when |view| loses focus.
func (d *ViewDelegate) OnBlur(view *View) {
lookupViewDelegateProxy(d.Base()).OnBlur(d, view)
}
//export gocef_view_delegate_on_blur
func gocef_view_delegate_on_blur(self *C.cef_view_delegate_t, view *C.cef_view_t) {
me__ := (*ViewDelegate)(self)
proxy__ := lookupViewDelegateProxy(me__.Base())
proxy__.OnBlur(me__, (*View)(view))
}
// Code generated - DO NOT EDIT.
#ifndef GOCEF_ViewDelegate_H_
#define GOCEF_ViewDelegate_H_
#pragma once
#include "capi_gen.h"
void gocef_set_view_delegate_proxy(cef_view_delegate_t *self);
#endif // GOCEF_ViewDelegate_H_
此差异已折叠。
// Code generated - DO NOT EDIT.
#include "WindowDelegate_gen.h"
#include "_cgo_export.h"
void gocef_set_window_delegate_proxy(cef_window_delegate_t *self) {
// Casts to (void *) added to avoid warnings since Go callbacks can't have
// some modifiers, such as 'const' applied to their parameter signatures.
self->on_window_created = (void *)&gocef_window_delegate_on_window_created;
self->on_window_destroyed = (void *)&gocef_window_delegate_on_window_destroyed;
self->get_parent_window = (void *)&gocef_window_delegate_get_parent_window;
self->is_frameless = (void *)&gocef_window_delegate_is_frameless;
self->can_resize = (void *)&gocef_window_delegate_can_resize;
self->can_maximize = (void *)&gocef_window_delegate_can_maximize;
self->can_minimize = (void *)&gocef_window_delegate_can_minimize;
self->can_close = (void *)&gocef_window_delegate_can_close;
self->on_accelerator = (void *)&gocef_window_delegate_on_accelerator;
self->on_key_event = (void *)&gocef_window_delegate_on_key_event;
}
// Code generated - DO NOT EDIT.
package cef
import (
// #include "WindowDelegate_gen.h"
"C"
"unsafe"
"github.com/richardwilkes/toolbox/errs"
"github.com/richardwilkes/toolbox/log/jot"
)
// WindowDelegateProxy defines methods required for using WindowDelegate.
type WindowDelegateProxy interface {
OnWindowCreated(self *WindowDelegate, window *Window)
OnWindowDestroyed(self *WindowDelegate, window *Window)
GetParentWindow(self *WindowDelegate, window *Window, is_menu, can_activate_menu *int32) *Window
IsFrameless(self *WindowDelegate, window *Window) int32
CanResize(self *WindowDelegate, window *Window) int32
CanMaximize(self *WindowDelegate, window *Window) int32
CanMinimize(self *WindowDelegate, window *Window) int32
CanClose(self *WindowDelegate, window *Window) int32
OnAccelerator(self *WindowDelegate, window *Window, command_id int32) int32
OnKeyEvent(self *WindowDelegate, window *Window, event *KeyEvent) int32
}
// WindowDelegate (cef_window_delegate_t from include/capi/views/cef_window_delegate_capi.h)
// Implement this structure to handle window events. The functions of this
// structure will be called on the browser process UI thread unless otherwise
// indicated.
type WindowDelegate C.cef_window_delegate_t
// NewWindowDelegate creates a new WindowDelegate with the specified proxy. Passing
// in nil will result in default handling, if applicable.
func NewWindowDelegate(proxy WindowDelegateProxy) *WindowDelegate {
result := (*WindowDelegate)(unsafe.Pointer(newRefCntObj(C.sizeof_struct__cef_window_delegate_t, proxy)))
if proxy != nil {
C.gocef_set_window_delegate_proxy(result.toNative())
}
return result
}
func (d *WindowDelegate) toNative() *C.cef_window_delegate_t {
return (*C.cef_window_delegate_t)(d)
}
func lookupWindowDelegateProxy(obj *BaseRefCounted) WindowDelegateProxy {
proxy, exists := lookupProxy(obj)
if !exists {
jot.Fatal(1, errs.New("Proxy not found for ID"))
}
actual, ok := proxy.(WindowDelegateProxy)
if !ok {
jot.Fatal(1, errs.New("Proxy was not of type WindowDelegateProxy"))
}
return actual
}
// Base (base)
// Base structure.
func (d *WindowDelegate) Base() *PanelDelegate {
return (&d.base).toGo()
}
// OnWindowCreated (on_window_created)
// Called when |window| is created.
func (d *WindowDelegate) OnWindowCreated(window *Window) {
lookupWindowDelegateProxy(d.Base().Base.Base()).OnWindowCreated(d, window)
}
//export gocef_window_delegate_on_window_created
func gocef_window_delegate_on_window_created(self *C.cef_window_delegate_t, window *C.cef_window_t) {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
proxy__.OnWindowCreated(me__, (*Window)(window))
}
// OnWindowDestroyed (on_window_destroyed)
// Called when |window| is destroyed. Release all references to |window| and
// do not attempt to execute any functions on |window| after this callback
// returns.
func (d *WindowDelegate) OnWindowDestroyed(window *Window) {
lookupWindowDelegateProxy(d.Base().Base.Base()).OnWindowDestroyed(d, window)
}
//export gocef_window_delegate_on_window_destroyed
func gocef_window_delegate_on_window_destroyed(self *C.cef_window_delegate_t, window *C.cef_window_t) {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
proxy__.OnWindowDestroyed(me__, (*Window)(window))
}
// GetParentWindow (get_parent_window)
// Return the parent for |window| or NULL if the |window| does not have a
// parent. Windows with parents will not get a taskbar button. Set |is_menu|
// to true (1) if |window| will be displayed as a menu, in which case it will
// not be clipped to the parent window bounds. Set |can_activate_menu| to
// false (0) if |is_menu| is true (1) and |window| should not be activated
// (given keyboard focus) when displayed.
func (d *WindowDelegate) GetParentWindow(window *Window, is_menu, can_activate_menu *int32) *Window {
return lookupWindowDelegateProxy(d.Base().Base.Base()).GetParentWindow(d, window, is_menu, can_activate_menu)
}
//export gocef_window_delegate_get_parent_window
func gocef_window_delegate_get_parent_window(self *C.cef_window_delegate_t, window *C.cef_window_t, is_menu *C.int, can_activate_menu *C.int) *C.cef_window_t {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
return (proxy__.GetParentWindow(me__, (*Window)(window), (*int32)(is_menu), (*int32)(can_activate_menu))).toNative()
}
// IsFrameless (is_frameless)
// Return true (1) if |window| should be created without a frame or title bar.
// The window will be resizable if can_resize() returns true (1). Use
// cef_window_t::set_draggable_regions() to specify draggable regions.
func (d *WindowDelegate) IsFrameless(window *Window) int32 {
return lookupWindowDelegateProxy(d.Base().Base.Base()).IsFrameless(d, window)
}
//export gocef_window_delegate_is_frameless
func gocef_window_delegate_is_frameless(self *C.cef_window_delegate_t, window *C.cef_window_t) C.int {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
return C.int(proxy__.IsFrameless(me__, (*Window)(window)))
}
// CanResize (can_resize)
// Return true (1) if |window| can be resized.
func (d *WindowDelegate) CanResize(window *Window) int32 {
return lookupWindowDelegateProxy(d.Base().Base.Base()).CanResize(d, window)
}
//export gocef_window_delegate_can_resize
func gocef_window_delegate_can_resize(self *C.cef_window_delegate_t, window *C.cef_window_t) C.int {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
return C.int(proxy__.CanResize(me__, (*Window)(window)))
}
// CanMaximize (can_maximize)
// Return true (1) if |window| can be maximized.
func (d *WindowDelegate) CanMaximize(window *Window) int32 {
return lookupWindowDelegateProxy(d.Base().Base.Base()).CanMaximize(d, window)
}
//export gocef_window_delegate_can_maximize
func gocef_window_delegate_can_maximize(self *C.cef_window_delegate_t, window *C.cef_window_t) C.int {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
return C.int(proxy__.CanMaximize(me__, (*Window)(window)))
}
// CanMinimize (can_minimize)
// Return true (1) if |window| can be minimized.
func (d *WindowDelegate) CanMinimize(window *Window) int32 {
return lookupWindowDelegateProxy(d.Base().Base.Base()).CanMinimize(d, window)
}
//export gocef_window_delegate_can_minimize
func gocef_window_delegate_can_minimize(self *C.cef_window_delegate_t, window *C.cef_window_t) C.int {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
return C.int(proxy__.CanMinimize(me__, (*Window)(window)))
}
// CanClose (can_close)
// Return true (1) if |window| can be closed. This will be called for user-
// initiated window close actions and when cef_window_t::close() is called.
func (d *WindowDelegate) CanClose(window *Window) int32 {
return lookupWindowDelegateProxy(d.Base().Base.Base()).CanClose(d, window)
}
//export gocef_window_delegate_can_close
func gocef_window_delegate_can_close(self *C.cef_window_delegate_t, window *C.cef_window_t) C.int {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
return C.int(proxy__.CanClose(me__, (*Window)(window)))
}
// OnAccelerator (on_accelerator)
// Called when a keyboard accelerator registered with
// cef_window_t::SetAccelerator is triggered. Return true (1) if the
// accelerator was handled or false (0) otherwise.
func (d *WindowDelegate) OnAccelerator(window *Window, command_id int32) int32 {
return lookupWindowDelegateProxy(d.Base().Base.Base()).OnAccelerator(d, window, command_id)
}
//export gocef_window_delegate_on_accelerator
func gocef_window_delegate_on_accelerator(self *C.cef_window_delegate_t, window *C.cef_window_t, command_id C.int) C.int {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
return C.int(proxy__.OnAccelerator(me__, (*Window)(window), int32(command_id)))
}
// OnKeyEvent (on_key_event)
// Called after all other controls in the window have had a chance to handle
// the event. |event| contains information about the keyboard event. Return
// true (1) if the keyboard event was handled or false (0) otherwise.
func (d *WindowDelegate) OnKeyEvent(window *Window, event *KeyEvent) int32 {
return lookupWindowDelegateProxy(d.Base().Base.Base()).OnKeyEvent(d, window, event)
}
//export gocef_window_delegate_on_key_event
func gocef_window_delegate_on_key_event(self *C.cef_window_delegate_t, window *C.cef_window_t, event *C.cef_key_event_t) C.int {
me__ := (*WindowDelegate)(self)
proxy__ := lookupWindowDelegateProxy(me__.Base().Base.Base())
event_ := event.toGo()
return C.int(proxy__.OnKeyEvent(me__, (*Window)(window), event_))
}
// Code generated - DO NOT EDIT.
#ifndef GOCEF_WindowDelegate_H_
#define GOCEF_WindowDelegate_H_
#pragma once
#include "capi_gen.h"
void gocef_set_window_delegate_proxy(cef_window_delegate_t *self);
#endif // GOCEF_WindowDelegate_H_
// Code generated - DO NOT EDIT.
package cef
import (
// #include "capi_gen.h"
// void gocef_window_show(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_hide(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_center_window(cef_window_t * self, cef_size_t * size, void (CEF_CALLBACK *callback__)(cef_window_t *, cef_size_t *)) { return callback__(self, size); }
// void gocef_window_close(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// int gocef_window_is_closed(cef_window_t * self, int (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_activate(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_deactivate(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// int gocef_window_is_active(cef_window_t * self, int (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_bring_to_top(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_set_always_on_top(cef_window_t * self, int on_top, void (CEF_CALLBACK *callback__)(cef_window_t *, int)) { return callback__(self, on_top); }
// int gocef_window_is_always_on_top(cef_window_t * self, int (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_maximize(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_minimize(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_restore(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_set_fullscreen(cef_window_t * self, int fullscreen, void (CEF_CALLBACK *callback__)(cef_window_t *, int)) { return callback__(self, fullscreen); }
// int gocef_window_is_maximized(cef_window_t * self, int (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// int gocef_window_is_minimized(cef_window_t * self, int (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// int gocef_window_is_fullscreen(cef_window_t * self, int (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_set_title(cef_window_t * self, cef_string_t * title, void (CEF_CALLBACK *callback__)(cef_window_t *, cef_string_t *)) { return callback__(self, title); }
// cef_string_userfree_t gocef_window_get_title(cef_window_t * self, cef_string_userfree_t (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_set_window_icon(cef_window_t * self, cef_image_t * image, void (CEF_CALLBACK *callback__)(cef_window_t *, cef_image_t *)) { return callback__(self, image); }
// cef_image_t * gocef_window_get_window_icon(cef_window_t * self, cef_image_t * (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_set_window_app_icon(cef_window_t * self, cef_image_t * image, void (CEF_CALLBACK *callback__)(cef_window_t *, cef_image_t *)) { return callback__(self, image); }
// cef_image_t * gocef_window_get_window_app_icon(cef_window_t * self, cef_image_t * (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_show_menu(cef_window_t * self, cef_menu_model_t * menu_model, cef_point_t * screen_point, cef_menu_anchor_position_t anchor_position, void (CEF_CALLBACK *callback__)(cef_window_t *, cef_menu_model_t *, cef_point_t *, cef_menu_anchor_position_t)) { return callback__(self, menu_model, screen_point, anchor_position); }
// void gocef_window_cancel_menu(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// cef_display_t * gocef_window_get_display(cef_window_t * self, cef_display_t * (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// cef_rect_t gocef_window_get_client_area_bounds_in_screen(cef_window_t * self, cef_rect_t (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_set_draggable_regions(cef_window_t * self, size_t regionsCount, cef_draggable_region_t * regions, void (CEF_CALLBACK *callback__)(cef_window_t *, size_t, cef_draggable_region_t *)) { return callback__(self, regionsCount, regions); }
// void * gocef_window_get_window_handle(cef_window_t * self, void * (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
// void gocef_window_send_key_press(cef_window_t * self, int key_code, uint32 event_flags, void (CEF_CALLBACK *callback__)(cef_window_t *, int, uint32)) { return callback__(self, key_code, event_flags); }
// void gocef_window_send_mouse_move(cef_window_t * self, int screen_x, int screen_y, void (CEF_CALLBACK *callback__)(cef_window_t *, int, int)) { return callback__(self, screen_x, screen_y); }
// void gocef_window_send_mouse_events(cef_window_t * self, cef_mouse_button_type_t button, int mouse_down, int mouse_up, void (CEF_CALLBACK *callback__)(cef_window_t *, cef_mouse_button_type_t, int, int)) { return callback__(self, button, mouse_down, mouse_up); }
// void gocef_window_set_accelerator(cef_window_t * self, int command_id, int key_code, int shift_pressed, int ctrl_pressed, int alt_pressed, void (CEF_CALLBACK *callback__)(cef_window_t *, int, int, int, int, int)) { return callback__(self, command_id, key_code, shift_pressed, ctrl_pressed, alt_pressed); }
// void gocef_window_remove_accelerator(cef_window_t * self, int command_id, void (CEF_CALLBACK *callback__)(cef_window_t *, int)) { return callback__(self, command_id); }
// void gocef_window_remove_all_accelerators(cef_window_t * self, void (CEF_CALLBACK *callback__)(cef_window_t *)) { return callback__(self); }
"C"
"unsafe"
)
// Window (cef_window_t from include/capi/views/cef_window_capi.h)
// A Window is a top-level Window/widget in the Views hierarchy. By default it
// will have a non-client area with title bar, icon and buttons that supports
// moving and resizing. All size and position values are in density independent
// pixels (DIP) unless otherwise indicated. Methods must be called on the
// browser process UI thread unless otherwise indicated.
type Window C.cef_window_t
func (d *Window) toNative() *C.cef_window_t {
return (*C.cef_window_t)(d)
}
// Base (base)
// Base structure.
func (d *Window) Base() *Panel {
return (*Panel)(&d.base)
}
// Show (show)
// Show the Window.
func (d *Window) Show() {
C.gocef_window_show(d.toNative(), d.show)
}
// Hide (hide)
// Hide the Window.
func (d *Window) Hide() {
C.gocef_window_hide(d.toNative(), d.hide)
}
// CenterWindow (center_window)
// Sizes the Window to |size| and centers it in the current display.
func (d *Window) CenterWindow(size *Size) {
C.gocef_window_center_window(d.toNative(), size.toNative(&C.cef_size_t{}), d.center_window)
}
// Close (close)
// Close the Window.
func (d *Window) Close() {
C.gocef_window_close(d.toNative(), d.close)
}
// IsClosed (is_closed)
// Returns true (1) if the Window has been closed.
func (d *Window) IsClosed() int32 {
return int32(C.gocef_window_is_closed(d.toNative(), d.is_closed))
}
// Activate (activate)
// Activate the Window, assuming it already exists and is visible.
func (d *Window) Activate() {
C.gocef_window_activate(d.toNative(), d.activate)
}
// Deactivate (deactivate)
// Deactivate the Window, making the next Window in the Z order the active
// Window.
func (d *Window) Deactivate() {
C.gocef_window_deactivate(d.toNative(), d.deactivate)
}
// IsActive (is_active)
// Returns whether the Window is the currently active Window.
func (d *Window) IsActive() int32 {
return int32(C.gocef_window_is_active(d.toNative(), d.is_active))
}
// BringToTop (bring_to_top)
// Bring this Window to the top of other Windows in the Windowing system.
func (d *Window) BringToTop() {
C.gocef_window_bring_to_top(d.toNative(), d.bring_to_top)
}
// SetAlwaysOnTop (set_always_on_top)
// Set the Window to be on top of other Windows in the Windowing system.
func (d *Window) SetAlwaysOnTop(on_top int32) {
C.gocef_window_set_always_on_top(d.toNative(), C.int(on_top), d.set_always_on_top)
}
// IsAlwaysOnTop (is_always_on_top)
// Returns whether the Window has been set to be on top of other Windows in
// the Windowing system.
func (d *Window) IsAlwaysOnTop() int32 {
return int32(C.gocef_window_is_always_on_top(d.toNative(), d.is_always_on_top))
}
// Maximize (maximize)
// Maximize the Window.
func (d *Window) Maximize() {
C.gocef_window_maximize(d.toNative(), d.maximize)
}
// Minimize (minimize)
// Minimize the Window.
func (d *Window) Minimize() {
C.gocef_window_minimize(d.toNative(), d.minimize)
}
// Restore (restore)
// Restore the Window.
func (d *Window) Restore() {
C.gocef_window_restore(d.toNative(), d.restore)
}
// SetFullscreen (set_fullscreen)
// Set fullscreen Window state.
func (d *Window) SetFullscreen(fullscreen int32) {
C.gocef_window_set_fullscreen(d.toNative(), C.int(fullscreen), d.set_fullscreen)
}
// IsMaximized (is_maximized)
// Returns true (1) if the Window is maximized.
func (d *Window) IsMaximized() int32 {
return int32(C.gocef_window_is_maximized(d.toNative(), d.is_maximized))
}
// IsMinimized (is_minimized)
// Returns true (1) if the Window is minimized.
func (d *Window) IsMinimized() int32 {
return int32(C.gocef_window_is_minimized(d.toNative(), d.is_minimized))
}
// IsFullscreen (is_fullscreen)
// Returns true (1) if the Window is fullscreen.
func (d *Window) IsFullscreen() int32 {
return int32(C.gocef_window_is_fullscreen(d.toNative(), d.is_fullscreen))
}
// SetTitle (set_title)
// Set the Window title.
func (d *Window) SetTitle(title string) {
title_ := C.cef_string_userfree_alloc()
setCEFStr(title, title_)
defer func() {
C.cef_string_userfree_free(title_)
}()
C.gocef_window_set_title(d.toNative(), (*C.cef_string_t)(title_), d.set_title)
}
// GetTitle (get_title)
// Get the Window title.
// The resulting string must be freed by calling cef_string_userfree_free().
func (d *Window) GetTitle() string {
return cefuserfreestrToString(C.gocef_window_get_title(d.toNative(), d.get_title))
}
// SetWindowIcon (set_window_icon)
// Set the Window icon. This should be a 16x16 icon suitable for use in the
// Windows's title bar.
func (d *Window) SetWindowIcon(image *Image) {
C.gocef_window_set_window_icon(d.toNative(), image.toNative(), d.set_window_icon)
}
// GetWindowIcon (get_window_icon)
// Get the Window icon.
func (d *Window) GetWindowIcon() *Image {
return (*Image)(C.gocef_window_get_window_icon(d.toNative(), d.get_window_icon))
}
// SetWindowAppIcon (set_window_app_icon)
// Set the Window App icon. This should be a larger icon for use in the host
// environment app switching UI. On Windows, this is the ICON_BIG used in Alt-
// Tab list and Windows taskbar. The Window icon will be used by default if no
// Window App icon is specified.
func (d *Window) SetWindowAppIcon(image *Image) {
C.gocef_window_set_window_app_icon(d.toNative(), image.toNative(), d.set_window_app_icon)
}
// GetWindowAppIcon (get_window_app_icon)
// Get the Window App icon.
func (d *Window) GetWindowAppIcon() *Image {
return (*Image)(C.gocef_window_get_window_app_icon(d.toNative(), d.get_window_app_icon))
}
// ShowMenu (show_menu)
// Show a menu with contents |menu_model|. |screen_point| specifies the menu
// position in screen coordinates. |anchor_position| specifies how the menu
// will be anchored relative to |screen_point|.
func (d *Window) ShowMenu(menu_model *MenuModel, screen_point *Point, anchor_position MenuAnchorPosition) {
C.gocef_window_show_menu(d.toNative(), menu_model.toNative(), screen_point.toNative(&C.cef_point_t{}), C.cef_menu_anchor_position_t(anchor_position), d.show_menu)
}
// CancelMenu (cancel_menu)
// Cancel the menu that is currently showing, if any.
func (d *Window) CancelMenu() {
C.gocef_window_cancel_menu(d.toNative(), d.cancel_menu)
}
// GetDisplay (get_display)
// Returns the Display that most closely intersects the bounds of this Window.
// May return NULL if this Window is not currently displayed.
func (d *Window) GetDisplay() *Display {
return (*Display)(C.gocef_window_get_display(d.toNative(), d.get_display))
}
// GetClientAreaBoundsInScreen (get_client_area_bounds_in_screen)
// Returns the bounds (size and position) of this Window's client area.
// Position is in screen coordinates.
func (d *Window) GetClientAreaBoundsInScreen() Rect {
cresult__ := C.gocef_window_get_client_area_bounds_in_screen(d.toNative(), d.get_client_area_bounds_in_screen)
var result__ Rect
(&cresult__).intoGo(&result__)
return result__
}
// SetDraggableRegions (set_draggable_regions)
// Set the regions where mouse events will be intercepted by this Window to
// support drag operations. Call this function with an NULL vector to clear
// the draggable regions. The draggable region bounds should be in window
// coordinates.
func (d *Window) SetDraggableRegions(regionsCount uint64, regions *DraggableRegion) {
C.gocef_window_set_draggable_regions(d.toNative(), C.size_t(regionsCount), regions.toNative(&C.cef_draggable_region_t{}), d.set_draggable_regions)
}
// GetWindowHandle (get_window_handle)
// Retrieve the platform window handle for this Window.
func (d *Window) GetWindowHandle() unsafe.Pointer {
return C.gocef_window_get_window_handle(d.toNative(), d.get_window_handle)
}
// SendKeyPress (send_key_press)
// Simulate a key press. |key_code| is the VKEY_* value from Chromium's
// ui/events/keycodes/keyboard_codes.h header (VK_* values on Windows).
// |event_flags| is some combination of EVENTFLAG_SHIFT_DOWN,
// EVENTFLAG_CONTROL_DOWN and/or EVENTFLAG_ALT_DOWN. This function is exposed
// primarily for testing purposes.
func (d *Window) SendKeyPress(key_code int32, event_flags uint32) {
C.gocef_window_send_key_press(d.toNative(), C.int(key_code), C.uint32(event_flags), d.send_key_press)
}
// SendMouseMove (send_mouse_move)
// Simulate a mouse move. The mouse cursor will be moved to the specified
// (screen_x, screen_y) position. This function is exposed primarily for
// testing purposes.
func (d *Window) SendMouseMove(screen_x, screen_y int32) {
C.gocef_window_send_mouse_move(d.toNative(), C.int(screen_x), C.int(screen_y), d.send_mouse_move)
}
// SendMouseEvents (send_mouse_events)
// Simulate mouse down and/or mouse up events. |button| is the mouse button
// type. If |mouse_down| is true (1) a mouse down event will be sent. If
// |mouse_up| is true (1) a mouse up event will be sent. If both are true (1)
// a mouse down event will be sent followed by a mouse up event (equivalent to
// clicking the mouse button). The events will be sent using the current
// cursor position so make sure to call send_mouse_move() first to position
// the mouse. This function is exposed primarily for testing purposes.
func (d *Window) SendMouseEvents(button MouseButtonType, mouse_down, mouse_up int32) {
C.gocef_window_send_mouse_events(d.toNative(), C.cef_mouse_button_type_t(button), C.int(mouse_down), C.int(mouse_up), d.send_mouse_events)
}
// SetAccelerator (set_accelerator)
// Set the keyboard accelerator for the specified |command_id|. |key_code| can
// be any virtual key or character value. cef_window_delegate_t::OnAccelerator
// will be called if the keyboard combination is triggered while this window
// has focus.
func (d *Window) SetAccelerator(command_id, key_code, shift_pressed, ctrl_pressed, alt_pressed int32) {
C.gocef_window_set_accelerator(d.toNative(), C.int(command_id), C.int(key_code), C.int(shift_pressed), C.int(ctrl_pressed), C.int(alt_pressed), d.set_accelerator)
}
// RemoveAccelerator (remove_accelerator)
// Remove the keyboard accelerator for the specified |command_id|.
func (d *Window) RemoveAccelerator(command_id int32) {
C.gocef_window_remove_accelerator(d.toNative(), C.int(command_id), d.remove_accelerator)
}
// RemoveAllAccelerators (remove_all_accelerators)
// Remove all keyboard accelerators.
func (d *Window) RemoveAllAccelerators() {
C.gocef_window_remove_all_accelerators(d.toNative(), d.remove_all_accelerators)
}
......@@ -64,5 +64,25 @@
#include "include/capi/cef_waitable_event_capi.h"
#include "include/capi/cef_web_plugin_capi.h"
#include "include/capi/cef_x509_certificate_capi.h"
#include "include/capi/views/cef_box_layout_capi.h"
#include "include/capi/views/cef_browser_view_capi.h"
#include "include/capi/views/cef_browser_view_delegate_capi.h"
#include "include/capi/views/cef_button_capi.h"
#include "include/capi/views/cef_button_delegate_capi.h"
#include "include/capi/views/cef_display_capi.h"
#include "include/capi/views/cef_fill_layout_capi.h"
#include "include/capi/views/cef_label_button_capi.h"
#include "include/capi/views/cef_layout_capi.h"
#include "include/capi/views/cef_menu_button_capi.h"
#include "include/capi/views/cef_menu_button_delegate_capi.h"
#include "include/capi/views/cef_panel_capi.h"
#include "include/capi/views/cef_panel_delegate_capi.h"
#include "include/capi/views/cef_scroll_view_capi.h"
#include "include/capi/views/cef_textfield_capi.h"
#include "include/capi/views/cef_textfield_delegate_capi.h"
#include "include/capi/views/cef_view_capi.h"
#include "include/capi/views/cef_view_delegate_capi.h"
#include "include/capi/views/cef_window_capi.h"
#include "include/capi/views/cef_window_delegate_capi.h"
#endif // GOCEF_CAPI_H_
......@@ -97,6 +97,24 @@ func BrowserHostCreateBrowserSync(windowInfo *WindowInfo, client *Client, url st
return (*Browser)(C.cef_browser_host_create_browser_sync(windowInfo.toNative(&C.cef_window_info_t{}), client.toNative(), (*C.cef_string_t)(url_), settings.toNative(&C.cef_browser_settings_t{}), request_context.toNative()))
}
// BrowserViewCreate (cef_browser_view_create from include/capi/views/cef_browser_view_capi.h)
// Create a new BrowserView. The underlying cef_browser_t will not be created
// until this view is added to the views hierarchy.
func BrowserViewCreate(client *Client, url string, settings *BrowserSettings, request_context *RequestContext, delegate *BrowserViewDelegate) *BrowserView {
url_ := C.cef_string_userfree_alloc()
setCEFStr(url, url_)
defer func() {
C.cef_string_userfree_free(url_)
}()
return (*BrowserView)(C.cef_browser_view_create(client.toNative(), (*C.cef_string_t)(url_), settings.toNative(&C.cef_browser_settings_t{}), request_context.toNative(), delegate.toNative()))
}
// BrowserViewGetForBrowser (cef_browser_view_get_for_browser from include/capi/views/cef_browser_view_capi.h)
// Returns the BrowserView associated with |browser|.
func BrowserViewGetForBrowser(browser *Browser) *BrowserView {
return (*BrowserView)(C.cef_browser_view_get_for_browser(browser.toNative()))
}
// ClearCrossOriginWhitelist (cef_clear_cross_origin_whitelist from include/capi/cef_origin_whitelist_capi.h)
// Remove all entries from the cross-origin access whitelist. Returns false (0)
// if the whitelist cannot be accessed.
......@@ -186,6 +204,42 @@ func DictionaryValueCreate() *DictionaryValue {
return (*DictionaryValue)(C.cef_dictionary_value_create())
}
// DisplayGetAlls (cef_display_get_alls from include/capi/views/cef_display_capi.h)
// Returns all Displays. Mirrored displays are excluded; this function is
// intended to return distinct, usable displays.
func DisplayGetAlls(displaysCount *uint64, displays **Display) {
displays_ := (*displays).toNative()
C.cef_display_get_alls((*C.size_t)(displaysCount), &displays_)
}
// DisplayGetCount (cef_display_get_count from include/capi/views/cef_display_capi.h)
// Returns the total number of Displays. Mirrored displays are excluded; this
// function is intended to return the number of distinct, usable displays.
func DisplayGetCount() uint64 {
return uint64(C.cef_display_get_count())
}
// DisplayGetMatchingBounds (cef_display_get_matching_bounds from include/capi/views/cef_display_capi.h)
// Returns the Display that most closely intersects |bounds|. Set
// |input_pixel_coords| to true (1) if |bounds| is in pixel coordinates instead
// of density independent pixels (DIP).
func DisplayGetMatchingBounds(bounds *Rect, input_pixel_coords int32) *Display {
return (*Display)(C.cef_display_get_matching_bounds(bounds.toNative(&C.cef_rect_t{}), C.int(input_pixel_coords)))
}
// DisplayGetNearestPoint (cef_display_get_nearest_point from include/capi/views/cef_display_capi.h)
// Returns the Display nearest |point|. Set |input_pixel_coords| to true (1) if
// |point| is in pixel coordinates instead of density independent pixels (DIP).
func DisplayGetNearestPoint(point *Point, input_pixel_coords int32) *Display {
return (*Display)(C.cef_display_get_nearest_point(point.toNative(&C.cef_point_t{}), C.int(input_pixel_coords)))
}
// DisplayGetPrimary (cef_display_get_primary from include/capi/views/cef_display_capi.h)
// Returns the primary Display.
func DisplayGetPrimary() *Display {
return (*Display)(C.cef_display_get_primary())
}
// DoMessageLoopWork (cef_do_message_loop_work from include/capi/cef_app_capi.h)
// Perform a single iteration of CEF message loop processing. This function is
// provided for cases where the CEF message loop must be integrated into an
......@@ -275,18 +329,59 @@ func IsWebPluginUnstable(path string, callback *WebPluginUnstableCallback) {
C.cef_is_web_plugin_unstable((*C.cef_string_t)(path_), callback.toNative())
}
// LabelButtonCreate (cef_label_button_create from include/capi/views/cef_label_button_capi.h)
// Create a new LabelButton. A |delegate| must be provided to handle the button
// click. |text| will be shown on the LabelButton and used as the default
// accessible name. If |with_frame| is true (1) the button will have a visible
// frame at all times, center alignment, additional padding and a default
// minimum size of 70x33 DIP. If |with_frame| is false (0) the button will only
// have a visible frame on hover/press, left alignment, less padding and no
// default minimum size.
func LabelButtonCreate(delegate *ButtonDelegate, text string, with_frame int32) *LabelButton {
text_ := C.cef_string_userfree_alloc()
setCEFStr(text, text_)
defer func() {
C.cef_string_userfree_free(text_)
}()
return (*LabelButton)(C.cef_label_button_create(delegate.toNative(), (*C.cef_string_t)(text_), C.int(with_frame)))
}
// ListValueCreate (cef_list_value_create from include/capi/cef_values_capi.h)
// Creates a new object that is not owned by any other object.
func ListValueCreate() *ListValue {
return (*ListValue)(C.cef_list_value_create())
}
// MenuButtonCreate (cef_menu_button_create from include/capi/views/cef_menu_button_capi.h)
// Create a new MenuButton. A |delegate| must be provided to call show_menu()
// when the button is clicked. |text| will be shown on the MenuButton and used
// as the default accessible name. If |with_frame| is true (1) the button will
// have a visible frame at all times, center alignment, additional padding and a
// default minimum size of 70x33 DIP. If |with_frame| is false (0) the button
// will only have a visible frame on hover/press, left alignment, less padding
// and no default minimum size. If |with_menu_marker| is true (1) a menu marker
// will be added to the button.
func MenuButtonCreate(delegate *MenuButtonDelegate, text string, with_frame, with_menu_marker int32) *MenuButton {
text_ := C.cef_string_userfree_alloc()
setCEFStr(text, text_)
defer func() {
C.cef_string_userfree_free(text_)
}()
return (*MenuButton)(C.cef_menu_button_create(delegate.toNative(), (*C.cef_string_t)(text_), C.int(with_frame), C.int(with_menu_marker)))
}
// MenuModelCreate (cef_menu_model_create from include/capi/cef_menu_model_capi.h)
// Create a new MenuModel with the specified |delegate|.
func MenuModelCreate(delegate *MenuModelDelegate) *MenuModel {
return (*MenuModel)(C.cef_menu_model_create(delegate.toNative()))
}
// PanelCreate (cef_panel_create from include/capi/views/cef_panel_capi.h)
// Create a new Panel.
func PanelCreate(delegate *PanelDelegate) *Panel {
return (*Panel)(C.cef_panel_create(delegate.toNative(&C.cef_panel_delegate_t{})))
}
// PostDataCreate (cef_post_data_create from include/capi/cef_request_capi.h)
// Create a new cef_post_data_t object.
func PostDataCreate() *PostData {
......@@ -570,6 +665,12 @@ func RunMessageLoop() {
C.cef_run_message_loop()
}
// ScrollViewCreate (cef_scroll_view_create from include/capi/views/cef_scroll_view_capi.h)
// Create a new ScrollView.
func ScrollViewCreate(delegate *ViewDelegate) *ScrollView {
return (*ScrollView)(C.cef_scroll_view_create(delegate.toNative()))
}
// ServerCreate (cef_server_create from include/capi/cef_server_capi.h)
// Create a new server that binds to |address| and |port|. |address| must be a
// valid IPv4 or IPv6 address (e.g. 127.0.0.1 or ::1) and |port| must be a port
......@@ -887,6 +988,12 @@ func TaskRunnerGetForThread(threadId ThreadID) *TaskRunner {
return (*TaskRunner)(C.cef_task_runner_get_for_thread(C.cef_thread_id_t(threadId)))
}
// TextfieldCreate (cef_textfield_create from include/capi/views/cef_textfield_capi.h)
// Create a new Textfield.
func TextfieldCreate(delegate *TextfieldDelegate) *Textfield {
return (*Textfield)(C.cef_textfield_create(delegate.toNative()))
}
// TimeDelta (cef_time_delta from include/internal/cef_time.h)
// Retrieve the delta in milliseconds between two time values.
//
......@@ -1109,3 +1216,9 @@ func VisitWebPluginInfo(visitor *WebPluginInfoVisitor) {
func WaitableEventCreate(automatic_reset, initially_signaled int32) *WaitableEvent {
return (*WaitableEvent)(C.cef_waitable_event_create(C.int(automatic_reset), C.int(initially_signaled)))
}
// WindowCreateTopLevel (cef_window_create_top_level from include/capi/views/cef_window_capi.h)
// Create a new Window.
func WindowCreateTopLevel(delegate *WindowDelegate) *Window {
return (*Window)(C.cef_window_create_top_level(delegate.toNative()))
}
......@@ -60,7 +60,7 @@ func lookup{{.GoName}}Proxy(obj *BaseRefCounted) {{.GoName}}Proxy {
{{- end}}
func (d *{{.Owner.GoName}}) {{.Var.GoName}}({{.ParameterList}}) {{if .Var.GoType}}{{.Var.GoType}} {{end}}{
{{- if .Var.FunctionPtr}}
{{if .Var.GoType}}return {{end}}lookup{{.Owner.GoName}}Proxy(d.Base()).{{.Var.GoName}}({{.ParameterNames}})
{{if .Var.GoType}}return {{end}}lookup{{.Owner.GoName}}Proxy(d{{.ToBase}}).{{.Var.GoName}}({{.ParameterNames}})
{{- else}}
{{.ReturnField}}
{{- end}}
......@@ -70,7 +70,7 @@ func (d *{{.Owner.GoName}}) {{.Var.GoName}}({{.ParameterList}}) {{if .Var.GoType
//export {{.TrampolineName}}
func {{.TrampolineName}}({{.CallbackParams}}) {{.CallbackReturnType}} {
me__ := (*{{.Owner.GoName}})(self)
proxy__ := lookup{{.Owner.GoName}}Proxy(me__.Base())
proxy__ := lookup{{.Owner.GoName}}Proxy(me__{{.ToBase}})
{{.Callback}}
}
{{- end}}
......
......@@ -89,6 +89,12 @@ func (f *field) CallFunctionPointer() string {
func (f *field) ReturnField() string {
var buffer strings.Builder
buffer.WriteString("return ")
if f.Var.Name == "base" {
if sdef, exists := sdefsMap[f.Var.BaseType]; exists && !sdef.isClassEquivalent() {
buffer.WriteString("(&d.base).toGo()")
return buffer.String()
}
}
if strings.HasPrefix(f.Var.GoType, "*") {
fmt.Fprintf(&buffer, "(%s)", f.Var.GoType)
} else {
......@@ -117,11 +123,14 @@ func (f *field) ToNative() string {
default:
fmt.Fprintf(&buffer, "native.%s = ", f.Var.Name)
if i := strings.Index(f.Var.CType, " "); i != -1 {
fmt.Fprintf(&buffer, "(%sC.%s)", f.Var.CType[i+1:], f.Var.CType[:i])
if f.Var.Name == "base" {
fmt.Fprintf(&buffer, "*(%sC.%s)(unsafe.Pointer(d.Base))", f.Var.CType[i+1:], f.Var.CType[:i])
} else {
fmt.Fprintf(&buffer, "(%sC.%s)(d.%s)", f.Var.CType[i+1:], f.Var.CType[:i], f.Var.GoName)
}
} else {
fmt.Fprintf(&buffer, "C.%s", f.Var.CType)
fmt.Fprintf(&buffer, "C.%s(d.%s)", f.Var.CType, f.Var.GoName)
}
fmt.Fprintf(&buffer, "(d.%s)", f.Var.GoName)
}
}
return buffer.String()
......@@ -141,12 +150,16 @@ func (f *field) IntoGo() string {
case "cef_string_t *":
fmt.Fprintf(&buffer, "cefstrToString(n.%s)", f.Var.Name)
default:
if strings.HasPrefix(f.Var.GoType, "*") {
fmt.Fprintf(&buffer, "(%s)", f.Var.GoType)
if f.Var.Name == "base" {
fmt.Fprintf(&buffer, "(%s)(&n.base)", f.Var.GoType)
} else {
buffer.WriteString(f.Var.GoType)
if strings.HasPrefix(f.Var.GoType, "*") {
fmt.Fprintf(&buffer, "(%s)", f.Var.GoType)
} else {
buffer.WriteString(f.Var.GoType)
}
fmt.Fprintf(&buffer, "(n.%s)", f.Var.Name)
}
fmt.Fprintf(&buffer, "(n.%s)", f.Var.Name)
}
}
return buffer.String()
......@@ -258,3 +271,21 @@ func (f *field) CallbackReturnType() string {
rt := f.processedCParams([]string{f.Var.CType})[0]
return fmt.Sprintf("%sC.%s", rt.Ptrs, rt.Type)
}
func (f *field) ToBase() string {
var buffer strings.Builder
buffer.WriteString(".Base()")
t := f.Owner.Fields[0].Var.BaseType
for !strings.HasPrefix(t, "cef_base_") {
buffer.WriteString(".Base")
if sdef, exists := sdefsMap[t]; exists {
if sdef.isClassEquivalent() {
buffer.WriteString("()")
}
t = sdef.Fields[0].Var.BaseType
} else {
break
}
}
return buffer.String()
}
......@@ -104,7 +104,7 @@ for i, one := range %[1]s {
func emitReturnForCCall(buffer *strings.Builder, expression string, retVar *variable) {
if retVar.GoType == "" {
buffer.WriteString(expression)
} else if sdef, exists := sdefsMap[retVar.CType]; exists && !sdef.isClassEquivalent() {
} else if sdef, exists := sdefsMap[retVar.BaseType]; exists && !sdef.isClassEquivalent() {
if retVar.Ptrs == "*" {
fmt.Fprintf(buffer, "return (%s).toGo()", expression)
} else {
......
......@@ -145,13 +145,8 @@ func scanStderr(wg *sync.WaitGroup, r io.Reader) {
}
func capiHeaders() []string {
f, err := os.Open(filepath.Join(cefBaseDir, "include", "capi"))
jot.FatalIfErr(err)
list, err := f.Readdir(-1)
jot.FatalIfErr(err)
jot.FatalIfErr(f.Close())
headers := make([]string, 0, len(list))
for _, one := range list {
var headers []string
for _, one := range headerList(filepath.Join(cefBaseDir, "include", "capi")) {
if !one.IsDir() {
name := one.Name()
if name != "cef_parser_capi.h" &&
......@@ -164,10 +159,24 @@ func capiHeaders() []string {
}
}
}
for _, one := range headerList(filepath.Join(cefBaseDir, "include", "capi", "views")) {
if !one.IsDir() {
headers = append(headers, filepath.Join("include", "capi", "views", one.Name()))
}
}
sort.Strings(headers)
return headers
}
func headerList(dir string) []os.FileInfo {
f, err := os.Open(dir)
jot.FatalIfErr(err)
list, err := f.Readdir(-1)
jot.FatalIfErr(err)
jot.FatalIfErr(f.Close())
return list
}
func clangArgs(headers []string) []string {
args := make([]string, 0, len(headers)+7)
args = append(args, "-I")
......
......@@ -47,7 +47,11 @@ func (s *structDef) NeedsUnsafeImport() bool {
return true
}
}
return false
return s.hasInheritance()
}
func (s *structDef) hasInheritance() bool {
return !s.isClassEquivalent() && len(s.Fields) > 0 && s.Fields[0].Var.Name == "base"
}
func (s *structDef) isClassEquivalent() bool {
......
......@@ -71,14 +71,7 @@ func newCVar(name, typeInfo string, pos position) *variable {
typeInfo = strings.TrimPrefix(typeInfo, "struct _")
typeInfo = strings.Replace(typeInfo, "long long", "longlong", -1)
if v.Name == "base" {
switch typeInfo {
case "cef_base_ref_counted_t":
typeInfo = "cef_base_ref_counted_t *"
case "cef_base_scoped_t":
typeInfo = "cef_base_scoped_t *"
default:
jot.Fatal(1, errs.Newf("Unexpected base type: %s", typeInfo))
}
typeInfo += " *"
}
v.CType = typeInfo
if space := strings.Index(typeInfo, " "); space != -1 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册