use std::cell::Cell;
use newt_sys::*;
use crate::component::Component;
use crate::constants::{GRID_COMPONENT,GRID_SUBGRID};
#[derive(Grid)]
pub struct SimpleWindow<'a> {
co: Cell<newtGrid>,
added_to_parent: Cell<bool>,
children: Vec<&'a dyn Component>
}
impl<'a> SimpleWindow<'a> {
pub fn new(text: &'a dyn Component, middle: &'a dyn Component,
buttons: &'a dyn Component)
-> SimpleWindow<'a>
{
assert_eq!(text.grid_element_type(), GRID_COMPONENT);
assert_eq!(middle.grid_element_type(), GRID_COMPONENT);
assert_eq!(buttons.grid_element_type(), GRID_SUBGRID);
let grid = unsafe {
newtGridSimpleWindow(text.co(), middle.co(), buttons.grid_ptr())
};
let children: Vec<&'a dyn Component> =
vec![text, middle, buttons];
SimpleWindow {
co: Cell::new(grid),
added_to_parent: Cell::new(false),
children
}
}
}