use crate::DOMElement;
use crate::DOMEventTarget;
use crate::DOMHTMLElement;
use crate::DOMNode;
use crate::DOMObject;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib::wrapper! {
#[doc(alias = "WebKitDOMHTMLCanvasElement")]
pub struct DOMHTMLCanvasElement(Object<ffi::WebKitDOMHTMLCanvasElement, ffi::WebKitDOMHTMLCanvasElementClass>) @extends DOMHTMLElement, DOMElement, DOMNode, DOMObject, @implements DOMEventTarget;
match fn {
type_ => || ffi::webkit_dom_html_canvas_element_get_type(),
}
}
impl DOMHTMLCanvasElement {
pub const NONE: Option<&'static DOMHTMLCanvasElement> = None;
}
pub trait DOMHTMLCanvasElementExt: 'static {
#[cfg_attr(feature = "v2_22", deprecated = "Since 2.22")]
#[doc(alias = "webkit_dom_html_canvas_element_get_height")]
#[doc(alias = "get_height")]
fn height(&self) -> libc::c_long;
#[cfg_attr(feature = "v2_22", deprecated = "Since 2.22")]
#[doc(alias = "webkit_dom_html_canvas_element_get_width")]
#[doc(alias = "get_width")]
fn width(&self) -> libc::c_long;
#[cfg_attr(feature = "v2_22", deprecated = "Since 2.22")]
#[doc(alias = "webkit_dom_html_canvas_element_set_height")]
fn set_height(&self, value: libc::c_long);
#[cfg_attr(feature = "v2_22", deprecated = "Since 2.22")]
#[doc(alias = "webkit_dom_html_canvas_element_set_width")]
fn set_width(&self, value: libc::c_long);
#[doc(alias = "height")]
fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "width")]
fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<DOMHTMLCanvasElement>> DOMHTMLCanvasElementExt for O {
fn height(&self) -> libc::c_long {
unsafe {
ffi::webkit_dom_html_canvas_element_get_height(self.as_ref().to_glib_none().0)
}
}
fn width(&self) -> libc::c_long {
unsafe {
ffi::webkit_dom_html_canvas_element_get_width(self.as_ref().to_glib_none().0)
}
}
fn set_height(&self, value: libc::c_long) {
unsafe {
ffi::webkit_dom_html_canvas_element_set_height(self.as_ref().to_glib_none().0, value);
}
}
fn set_width(&self, value: libc::c_long) {
unsafe {
ffi::webkit_dom_html_canvas_element_set_width(self.as_ref().to_glib_none().0, value);
}
}
fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_height_trampoline<P: IsA<DOMHTMLCanvasElement>, F: Fn(&P) + 'static>(this: *mut ffi::WebKitDOMHTMLCanvasElement, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(DOMHTMLCanvasElement::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::height\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(notify_height_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_width_trampoline<P: IsA<DOMHTMLCanvasElement>, F: Fn(&P) + 'static>(this: *mut ffi::WebKitDOMHTMLCanvasElement, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(DOMHTMLCanvasElement::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::width\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(notify_width_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
impl fmt::Display for DOMHTMLCanvasElement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("DOMHTMLCanvasElement")
}
}