pub fn build(self, layout: &GridLayout) -> Result<(), NwgError> {
        use winapi::um::winuser::WM_SIZE;
        use winapi::shared::minwindef::{HIWORD, LOWORD};

        if self.layout.base.is_null() {
            return Err(NwgError::layout_create("Gridlayout does not have a parent."));
        }

        // Checks if the layouts cell or row are outside max_column or max_row
        if let Some(max_row) = self.layout.row_count {
            if let Some(item) = self.layout.children.iter().find(|c| c.row >= max_row) {
                return Err(NwgError::layout_create(format!("A layout item row is bigger or equal than the max number of row. {} >= {}", item.row, max_row)));
            }
        }

        if let Some(max_column) = self.layout.column_count {
            if let Some(item) = self.layout.children.iter().find(|c| c.col >= max_column) {
                return Err(NwgError::layout_create(format!("A layout item column is bigger or equal than the max number of column. {} >= {}", item.col, max_column)));
            }
        }
        
        let (w, h) = unsafe { wh::get_window_size(self.layout.base) };
        let base_handle = ControlHandle::Hwnd(self.layout.base);

        // Saves the new layout. TODO: should free the old one too (if any)
        {
            let mut layout_inner = layout.inner.borrow_mut();
            *layout_inner = self.layout;        
        }

        // Initial layout update
        layout.update_layout(w, h);
       
        // Bind the event handler
        let event_layout = layout.clone();
        let cb = move |_h, msg, _w, l| {
            if msg == WM_SIZE {
                let size = l as u32;
                let width = LOWORD(size) as i32;
                let height = HIWORD(size) as i32;
                let (w, h) = unsafe { crate::win32::high_dpi::physical_to_logical(width, height) };
                GridLayout::update_layout(&event_layout, w as u32, h as u32);
            }
            None
        };

        /// Keep generating ids so that multiple layouts can be applied to the same parent
        use std::sync::atomic::{AtomicUsize, Ordering};
        static BOX_LAYOUT_ID: AtomicUsize = AtomicUsize::new(0x8FFF); 
        bind_raw_event_handler_inner(&base_handle, BOX_LAYOUT_ID.fetch_add(1, Ordering::SeqCst), cb).unwrap();

        Ok(())
    }
/// Build the layout object and bind the callback.
/// Children must only contains window object otherwise this method will panic.
Build the layout object and bind the callback.
Children must only contains window object otherwise this method will panic.
Build the layout object and bind the callback . Children must only contains window object otherwise this method will panic .
pub fn build(self, layout: &GridLayout) -> Result<(), NwgError> {
        use winapi::um::winuser::WM_SIZE;
        use winapi::shared::minwindef::{HIWORD, LOWORD};
        if self.layout.base.is_null() {
            return Err(NwgError::layout_create("Gridlayout does not have a parent."));
        }
        // Checks if the layouts cell or row are outside max_column or max_row
        if let Some(max_row) = self.layout.row_count {
            if let Some(item) = self.layout.children.iter().find(|c| c.row >= max_row) {
                return Err(NwgError::layout_create(format!("A layout item row is bigger or equal than the max number of row. {} >= {}", item.row, max_row)));
            }
        }
        if let Some(max_column) = self.layout.column_count {
            if let Some(item) = self.layout.children.iter().find(|c| c.col >= max_column) {
                return Err(NwgError::layout_create(format!("A layout item column is bigger or equal than the max number of column. {} >= {}", item.col, max_column)));
            }
        }
        let (w, h) = unsafe { wh::get_window_size(self.layout.base) };
        let base_handle = ControlHandle::Hwnd(self.layout.base);
        // Saves the new layout. TODO: should free the old one too (if any)
        {
            let mut layout_inner = layout.inner.borrow_mut();
            *layout_inner = self.layout;        
        }
        // Initial layout update
        layout.update_layout(w, h);
        // Bind the event handler
        let event_layout = layout.clone();
        let cb = move |_h, msg, _w, l| {
            if msg == WM_SIZE {
                let size = l as u32;
                let width = LOWORD(size) as i32;
                let height = HIWORD(size) as i32;
                let (w, h) = unsafe { crate::win32::high_dpi::physical_to_logical(width, height) };
                GridLayout::update_layout(&event_layout, w as u32, h as u32);
            }
            None
        };
        /// Keep generating ids so that multiple layouts can be applied to the same parent
        use std::sync::atomic::{AtomicUsize, Ordering};
        static BOX_LAYOUT_ID: AtomicUsize = AtomicUsize::new(0x8FFF); 
        bind_raw_event_handler_inner(&base_handle, BOX_LAYOUT_ID.fetch_add(1, Ordering::SeqCst), cb).unwrap();
        Ok(())
    }
pub fn build ( self , layout : & GridLayout ) -> Result < ( ) , NwgError > { use winapi :: um :: winuser :: WM_SIZE ; use winapi :: shared :: minwindef :: { HIWORD , LOWORD } ; if self . layout . base . is_null ( ) { return Err ( NwgError :: layout_create ( " " ) ) ; } // Checks if the layouts cell or row are outside max_column or max_row if let Some ( max_row ) = self . layout . row_count { if let Some ( item ) = self . layout . children . iter ( ) . find ( | c | c . row >= max_row ) { return Err ( NwgError :: layout_create ( format ! ( " " item row max_row ) ) ) ; } } if let Some ( max_column ) = self . layout . column_count { if let Some ( item ) = self . layout . children . iter ( ) . find ( | c | c . col >= max_column ) { return Err ( NwgError :: layout_create ( format ! ( " " item col max_column ) ) ) ; } } let ( w , h ) = unsafe { wh :: get_window_size ( self . layout . base ) } ; let base_handle = ControlHandle :: Hwnd ( self . layout . base ) ; // Saves the new layout. TODO: should free the old one too (if any) { let mut layout_inner = layout . inner . borrow_mut ( ) ; * layout_inner = self . layout ; } // Initial layout update layout . update_layout ( w , h ) ; // Bind the event handler let event_layout = layout . clone ( ) ; let cb = move | _h , msg , _w , l | { if msg == WM_SIZE { let size = l as u32 ; let width = LOWORD ( size ) as i32 ; let height = HIWORD ( size ) as i32 ; let ( w , h ) = unsafe { crate :: win32 :: high_dpi :: physical_to_logical ( width , height ) } ; GridLayout :: update_layout ( & event_layout , w as u32 , h as u32 ) ; } None } ; /// Keep generating ids so that multiple layouts can be applied to the same parent use std :: sync :: atomic :: { AtomicUsize , Ordering } ; static BOX_LAYOUT_ID : AtomicUsize = AtomicUsize :: new ( 0x8FFF ) ; bind_raw_event_handler_inner ( & base_handle , BOX_LAYOUT_ID . fetch_add ( 1 , Ordering :: SeqCst ) , cb ) . unwrap ( ) ; Ok ( ( ) ) }
Build the layout object and bind the callback.
Build the layout object and bind the callback .
self
layout
&GridLayout