Struct native_windows_gui::GridLayout
source · [−]pub struct GridLayout { /* private fields */ }
Expand description
A layout that lays out widgets in a grid NWG layouts use interior mutability to manage their controls.
A GridLayouts has the following properties:
- margin - The top, right, bottom, left margins of the layout - (default: [5, 5, 5, 5])
- spacing - The spacing between children controls - (default: 5)
- min_size - The minimum size of the layout - (default: [0, 0])
- max_size - The maximum size of the layout - (default: [u32::max_value(), u32::max_value()])
- max_column - Number of columns - (default: None),
- max_row - Number of rows - (default: None),
use native_windows_gui as nwg;
fn layout(layout: &nwg::GridLayout, window: &nwg::Window, item1: &nwg::Button, item2: &nwg::Button) {
nwg::GridLayout::builder()
.parent(window)
.max_row(Some(6))
.spacing(5)
.margin([0,0,0,0])
.child(0, 0, item1)
.child_item(nwg::GridLayoutItem::new(item2, 1, 0, 2, 1))
.build(&layout);
}
Implementations
sourceimpl GridLayout
impl GridLayout
pub fn builder() -> GridLayoutBuilder
sourcepub fn add_child<W: Into<ControlHandle>>(&self, col: u32, row: u32, c: W)
pub fn add_child<W: Into<ControlHandle>>(&self, col: u32, row: u32, c: W)
Add a children control to the grid layout.
This is a simplified interface over add_child_item
Panic:
- If the layout is not initialized
- If the control is not window-like (HWND handle)
sourcepub fn add_child_item(&self, i: GridLayoutItem)
pub fn add_child_item(&self, i: GridLayoutItem)
Add a children control to the grid layout.
Panic: - If the layout is not initialized - If the control is not window-like (HWND handle)
sourcepub fn remove_child<W: Into<ControlHandle>>(&self, c: W)
pub fn remove_child<W: Into<ControlHandle>>(&self, c: W)
Remove the children control in the layout. See also remove_child_by_pos
.
Note that the child control won’t be hidden after being removed from the control.
This method won’t do anything if there is no control at the specified position.
Panic:
- If the layout is not initialized
sourcepub fn remove_child_by_pos(&self, col: u32, row: u32)
pub fn remove_child_by_pos(&self, col: u32, row: u32)
Remove the children control in the layout. See also remove_child_by_pos
.
Note that the child control won’t be hidden after being removed from the control.
This method won’t do anything if there is no control at the specified position.
Panic:
- If the layout is not initialized
sourcepub fn move_child<W: Into<ControlHandle>>(&self, c: W, col: u32, row: u32)
pub fn move_child<W: Into<ControlHandle>>(&self, c: W, col: u32, row: u32)
Move the selected control to a new position in the grid layout. The old position
becomes empty (as if remove_child
was called). However it won’t remove the control
at the new position if there is one.
This method won’t do anything if there is no control at the specified position.
Panic:
- If the layout is not initialized
sourcepub fn move_child_by_pos<W: Into<ControlHandle>>(
&self,
col: u32,
row: u32,
new_col: u32,
new_row: u32
)
pub fn move_child_by_pos<W: Into<ControlHandle>>(
&self,
col: u32,
row: u32,
new_col: u32,
new_row: u32
)
Move the selected control to a new position in the grid layout. The old position
becomes empty (as if remove_child
was called). However it won’t remove the control
at the new position if there is one.
This method won’t do anything if there is no control at the specified position.
Panic:
- If the layout is not initialized
sourcepub fn has_child<W: Into<ControlHandle>>(&self, c: W) -> bool
pub fn has_child<W: Into<ControlHandle>>(&self, c: W) -> bool
Check if a window control is a children of the layout
Panic:
- If the layout is not initialized
- If the child is not a window-like control
sourcepub fn resize(&self, w: u32, h: u32)
pub fn resize(&self, w: u32, h: u32)
Resize the layout as if the parent window had the specified size.
Arguments: w: New width of the layout h: New height of the layout
Panic:
- The layout must have been successfully built otherwise this function will panic.
sourcepub fn fit(&self)
pub fn fit(&self)
Resize the layout to fit the parent window size
Panic:
- The layout must have been successfully built otherwise this function will panic.
sourcepub fn margin(&self, m: [u32; 4])
pub fn margin(&self, m: [u32; 4])
Set the margins of the layout. The four values are in this order: top, right, bottom, left.
sourcepub fn spacing(&self, sp: u32)
pub fn spacing(&self, sp: u32)
Set the size of the space between the children in the layout. Default value is 5.
sourcepub fn max_column(&self, count: Option<u32>)
pub fn max_column(&self, count: Option<u32>)
Set the number of column in the layout
Trait Implementations
sourceimpl Clone for GridLayout
impl Clone for GridLayout
sourcefn clone(&self) -> GridLayout
fn clone(&self) -> GridLayout
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Default for GridLayout
impl Default for GridLayout
sourcefn default() -> GridLayout
fn default() -> GridLayout
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for GridLayout
impl !Send for GridLayout
impl !Sync for GridLayout
impl Unpin for GridLayout
impl !UnwindSafe for GridLayout
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more