use std::cell::Cell;
use std::rc::Rc;
#[allow(unused_imports)]
use std::marker::PhantomData;
#[allow(unused_imports)]
use std::os::raw::c_void;
#[allow(unused_imports)]
use std::mem::transmute;
#[allow(unused_imports)]
use std::ffi::{CStr, CString};
use rute_ffi_base::*;
#[allow(unused_imports)]
use auto::*;
#[derive(Clone)]
pub struct Rect<'a> {
#[doc(hidden)]
pub data: Rc<Cell<Option<*const RUBase>>>,
#[doc(hidden)]
pub all_funcs: *const RURectAllFuncs,
#[doc(hidden)]
pub owned: bool,
#[doc(hidden)]
pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}
impl<'a> Rect<'a> {
pub fn new() -> Rect<'a> {
let data = Rc::new(Cell::new(None));
let ffi_data = unsafe {
((*rute_ffi_get()).create_rect)(
::std::ptr::null(),
transmute(rute_object_delete_callback as usize),
Rc::into_raw(data.clone()) as *const c_void,
)
};
data.set(Some(ffi_data.qt_data));
Rect {
data,
all_funcs: ffi_data.all_funcs,
owned: true,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_rc(ffi_data: RURect) -> Rect<'a> {
Rect {
data: unsafe { Rc::from_raw(ffi_data.host_data as *const Cell<Option<*const RUBase>>) },
all_funcs: ffi_data.all_funcs,
owned: false,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_owned(ffi_data: RURect) -> Rect<'a> {
Rect {
data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
all_funcs: ffi_data.all_funcs,
owned: true,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_temporary(ffi_data: RURect) -> Rect<'a> {
Rect {
data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
all_funcs: ffi_data.all_funcs,
owned: false,
_marker: PhantomData,
}
}
pub fn is_null(&self) -> bool {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).is_null)(obj_data);
ret_val
}
}
pub fn is_empty(&self) -> bool {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).is_empty)(obj_data);
ret_val
}
}
pub fn is_valid(&self) -> bool {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).is_valid)(obj_data);
ret_val
}
}
pub fn left(&self) -> i32 {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).left)(obj_data);
ret_val
}
}
pub fn top(&self) -> i32 {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).top)(obj_data);
ret_val
}
}
pub fn right(&self) -> i32 {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).right)(obj_data);
ret_val
}
}
pub fn bottom(&self) -> i32 {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).bottom)(obj_data);
ret_val
}
}
pub fn normalized(&self) -> Rect {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).normalized)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Rect::new_from_rc(t);
} else {
ret_val = Rect::new_from_owned(t);
}
ret_val
}
}
pub fn x(&self) -> i32 {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).x)(obj_data);
ret_val
}
}
pub fn y(&self) -> i32 {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).y)(obj_data);
ret_val
}
}
pub fn set_left(&self, pos: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_left)(obj_data, pos);
}
self
}
pub fn set_top(&self, pos: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_top)(obj_data, pos);
}
self
}
pub fn set_right(&self, pos: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_right)(obj_data, pos);
}
self
}
pub fn set_bottom(&self, pos: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_bottom)(obj_data, pos);
}
self
}
pub fn set_x(&self, x: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_x)(obj_data, x);
}
self
}
pub fn set_y(&self, y: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_y)(obj_data, y);
}
self
}
pub fn set_top_left<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_top_left)(obj_data, obj_p_1);
}
self
}
pub fn set_bottom_right<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_bottom_right)(obj_data, obj_p_1);
}
self
}
pub fn set_top_right<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_top_right)(obj_data, obj_p_1);
}
self
}
pub fn set_bottom_left<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_bottom_left)(obj_data, obj_p_1);
}
self
}
pub fn top_left(&self) -> Point {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).top_left)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Point::new_from_rc(t);
} else {
ret_val = Point::new_from_owned(t);
}
ret_val
}
}
pub fn bottom_right(&self) -> Point {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).bottom_right)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Point::new_from_rc(t);
} else {
ret_val = Point::new_from_owned(t);
}
ret_val
}
}
pub fn top_right(&self) -> Point {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).top_right)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Point::new_from_rc(t);
} else {
ret_val = Point::new_from_owned(t);
}
ret_val
}
}
pub fn bottom_left(&self) -> Point {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).bottom_left)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Point::new_from_rc(t);
} else {
ret_val = Point::new_from_owned(t);
}
ret_val
}
}
pub fn center(&self) -> Point {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).center)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Point::new_from_rc(t);
} else {
ret_val = Point::new_from_owned(t);
}
ret_val
}
}
pub fn move_left(&self, pos: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_left)(obj_data, pos);
}
self
}
pub fn move_top(&self, pos: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_top)(obj_data, pos);
}
self
}
pub fn move_right(&self, pos: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_right)(obj_data, pos);
}
self
}
pub fn move_bottom(&self, pos: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_bottom)(obj_data, pos);
}
self
}
pub fn move_top_left<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_top_left)(obj_data, obj_p_1);
}
self
}
pub fn move_bottom_right<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_bottom_right)(obj_data, obj_p_1);
}
self
}
pub fn move_top_right<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_top_right)(obj_data, obj_p_1);
}
self
}
pub fn move_bottom_left<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_bottom_left)(obj_data, obj_p_1);
}
self
}
pub fn move_center<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_center)(obj_data, obj_p_1);
}
self
}
pub fn move_to(&self, x: i32, t: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_to)(obj_data, x, t);
}
self
}
pub fn move_to_2<P: PointTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).move_to_2)(obj_data, obj_p_1);
}
self
}
pub fn set_rect(&self, x: i32, y: i32, w: i32, h: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_rect)(obj_data, x, y, w, h);
}
self
}
pub fn set_coords(&self, x1: i32, y1: i32, x2: i32, y2: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_coords)(obj_data, x1, y1, x2, y2);
}
self
}
pub fn adjust(&self, x1: i32, y1: i32, x2: i32, y2: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).adjust)(obj_data, x1, y1, x2, y2);
}
self
}
pub fn adjusted(&self, x1: i32, y1: i32, x2: i32, y2: i32) -> Rect {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).adjusted)(obj_data, x1, y1, x2, y2);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Rect::new_from_rc(t);
} else {
ret_val = Rect::new_from_owned(t);
}
ret_val
}
}
pub fn size(&self) -> Size {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).size)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Size::new_from_rc(t);
} else {
ret_val = Size::new_from_owned(t);
}
ret_val
}
}
pub fn width(&self) -> i32 {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).width)(obj_data);
ret_val
}
}
pub fn height(&self) -> i32 {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).height)(obj_data);
ret_val
}
}
pub fn set_width(&self, w: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_width)(obj_data, w);
}
self
}
pub fn set_height(&self, h: i32) -> &Self {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_height)(obj_data, h);
}
self
}
pub fn set_size<S: SizeTrait<'a>>(&self, s: &S) -> &Self {
let (obj_s_1, _funcs) = s.get_size_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
((*funcs).set_size)(obj_data, obj_s_1);
}
self
}
pub fn contains<R: RectTrait<'a>>(&self, r: &R, proper: bool) -> bool {
let (obj_r_1, _funcs) = r.get_rect_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).contains)(obj_data, obj_r_1, proper);
ret_val
}
}
pub fn contains_2<P: PointTrait<'a>>(&self, p: &P, proper: bool) -> bool {
let (obj_p_1, _funcs) = p.get_point_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).contains_2)(obj_data, obj_p_1, proper);
ret_val
}
}
pub fn contains_3(&self, x: i32, y: i32) -> bool {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).contains_3)(obj_data, x, y);
ret_val
}
}
pub fn contains_4(&self, x: i32, y: i32, proper: bool) -> bool {
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).contains_4)(obj_data, x, y, proper);
ret_val
}
}
pub fn united<R: RectTrait<'a>>(&self, other: &R) -> Rect {
let (obj_other_1, _funcs) = other.get_rect_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).united)(obj_data, obj_other_1);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Rect::new_from_rc(t);
} else {
ret_val = Rect::new_from_owned(t);
}
ret_val
}
}
pub fn intersected<R: RectTrait<'a>>(&self, other: &R) -> Rect {
let (obj_other_1, _funcs) = other.get_rect_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).intersected)(obj_data, obj_other_1);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Rect::new_from_rc(t);
} else {
ret_val = Rect::new_from_owned(t);
}
ret_val
}
}
pub fn intersects<R: RectTrait<'a>>(&self, r: &R) -> bool {
let (obj_r_1, _funcs) = r.get_rect_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).intersects)(obj_data, obj_r_1);
ret_val
}
}
pub fn margins_added<M: MarginsTrait<'a>>(&self, margins: &M) -> Rect {
let (obj_margins_1, _funcs) = margins.get_margins_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).margins_added)(obj_data, obj_margins_1);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Rect::new_from_rc(t);
} else {
ret_val = Rect::new_from_owned(t);
}
ret_val
}
}
pub fn margins_removed<M: MarginsTrait<'a>>(&self, margins: &M) -> Rect {
let (obj_margins_1, _funcs) = margins.get_margins_obj_funcs();
let (obj_data, funcs) = self.get_rect_obj_funcs();
unsafe {
let ret_val = ((*funcs).margins_removed)(obj_data, obj_margins_1);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Rect::new_from_rc(t);
} else {
ret_val = Rect::new_from_owned(t);
}
ret_val
}
}
pub fn build(&self) -> Self {
self.clone()
}
}
pub trait RectTrait<'a> {
#[inline]
#[doc(hidden)]
fn get_rect_obj_funcs(&self) -> (*const RUBase, *const RURectFuncs);
}
impl<'a> RectTrait<'a> for Rect<'a> {
#[doc(hidden)]
fn get_rect_obj_funcs(&self) -> (*const RUBase, *const RURectFuncs) {
let obj = self.data.get().unwrap();
unsafe { (obj, (*self.all_funcs).rect_funcs) }
}
}