Expand description
Methods for easily arranging component placement.
Grids can be used to automatically arrange widgets in a window without
having to manually specify their positions. The standard Grid
can be used to place components in specific arrangements. There are also
horizontal and vertical flavors to easily build
rows or columns of components. The ButtonBar will build
a horizontal Grid full of Buttons when provided with a list of strings to
use as Button labels.
Simple window management involving grids is also provided.
grid::wrapped_window and grid::wrapped_window_at
will create a titled window wrapping a Grid for quick information
display. SimpleWindow and BasicWindow include
ButtonBars as well for simple user interaction.
§Example
extern crate newt;
use newt::grid::*;
use newt::prelude::*;
pub fn main() {
    newt::init().unwrap();
    newt::cls();
    let rv;
    let l1 = Label::new(0, 0, "Hello");
    let l2 = Label::new(0, 0, "World");
    let stacked = HorizontalGrid::new(&[&l1, &l2]);
    let button_bar = ButtonBar::new(&["Yes", "No", "Maybe"]);
    let mut grid = Grid::new(2, 2);
    grid.set_field(1, 0, &stacked, 1, 1, 1, 1, 0, 0);
    grid.set_field(0, 1, &button_bar, 1, 1, 1, 1, 0, 0);
    wrapped_window(&grid, "Grids");
    let mut form = Form::new(None, 0);
    grid.add_to_form(&mut form).unwrap();
    rv = form.run().unwrap();
    newt::finished();
    for (i, button) in button_bar.buttons().iter().enumerate() {
        if rv == *button {
            println!("Button {} pressed.", i);
        }
    }
}Modules§
Structs§
- BasicWindow 
- Create a simple window using sub-grids.
- ButtonBar 
- Creates a row of buttons.
- Grid
- Arrange Components and sub-grids within a two-dimensional grid.
- HorizontalGrid 
- Arrange components horizontally.
- SimpleWindow 
- Create a simple window for a single Component.
- VerticalGrid 
- Arrange components vertically.
Traits§
- GridFns
- Implements functions shared by Grids.
Functions§
- wrapped_window 
- Wrap a Gridin a centered window.
- wrapped_window_ at 
- Wrap a Gridin a window at a specified location.