pub struct Grid { /* private fields */ }
Expand description
A grid widget
Implementations§
source§impl Grid
impl Grid
sourcepub fn new<S: Into<Option<&'static str>>>(
x: i32,
y: i32,
w: i32,
h: i32,
label: S
) -> Self
pub fn new<S: Into<Option<&'static str>>>( x: i32, y: i32, w: i32, h: i32, label: S ) -> Self
Creates a new grid widget
sourcepub fn default_fill() -> Self
pub fn default_fill() -> Self
Creates a default value grid widget filling the parent
Examples found in repository?
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
fn main() {
let a = app::App::default();
let mut win = window::Window::default().with_size(800, 600);
let mut grid = Grid::default_fill();
grid.debug(false);
grid.set_layout(1, 2);
let mut panel1 = Panel::default();
let mut panel2 = Panel::default();
grid.insert_grid(&mut *panel1, 0, 0);
grid.insert_grid(&mut *panel2, 0, 1);
win.end();
win.make_resizable(true);
win.show();
a.run().unwrap();
}
More examples
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
pub fn default() -> Self {
let mut grid = Grid::default_fill();
grid.set_layout(10, 5); // construct a new grid
let name = input::Input::default();
let age = input::IntInput::default();
let occupation = input::Input::default();
let btn = button::Button::default().with_label("Submit");
let mut g = Self {
grid,
name,
age,
occupation,
btn,
};
g.fill();
g
}
4 5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
let a = app::App::default().with_scheme(app::Scheme::Gtk);
let mut win = window::Window::default().with_size(500, 300);
let mut grid = Grid::default_fill();
grid.debug(false); // set to true to show cell outlines and numbers
grid.set_layout(5, 5); // 5 rows, 5 columns
grid.insert(&mut button::Button::default(), 0, 1); // widget, row, col
grid.insert(&mut button::Button::default(), 2..3, 1..4); // widget, row range, col range
// or
// grid.insert_ext(&mut button::Button::default(), 2, 1, 3, 1); // widget, row, col, row_span, col_span
win.end();
win.show();
a.run().unwrap();
}
sourcepub fn set_layout(&mut self, rows: i32, cols: i32)
pub fn set_layout(&mut self, rows: i32, cols: i32)
Sets the rows and columns of the widget
Examples found in repository?
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
pub fn default() -> Self {
let mut grid = Grid::default_fill();
grid.set_layout(10, 5); // construct a new grid
let name = input::Input::default();
let age = input::IntInput::default();
let occupation = input::Input::default();
let btn = button::Button::default().with_label("Submit");
let mut g = Self {
grid,
name,
age,
occupation,
btn,
};
g.fill();
g
}
More examples
4 5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
let a = app::App::default().with_scheme(app::Scheme::Gtk);
let mut win = window::Window::default().with_size(500, 300);
let mut grid = Grid::default_fill();
grid.debug(false); // set to true to show cell outlines and numbers
grid.set_layout(5, 5); // 5 rows, 5 columns
grid.insert(&mut button::Button::default(), 0, 1); // widget, row, col
grid.insert(&mut button::Button::default(), 2..3, 1..4); // widget, row range, col range
// or
// grid.insert_ext(&mut button::Button::default(), 2, 1, 3, 1); // widget, row, col, row_span, col_span
win.end();
win.show();
a.run().unwrap();
}
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
pub fn default() -> Self {
let mut grid = Grid::default();
grid.debug(false);
grid.set_layout(6, 1);
let mut label = frame::Frame::default().with_label("ARTERY:");
let mut cb1 = button::CheckButton::default().with_label("Normal");
let mut cb2 = button::CheckButton::default().with_label("Normal");
let cbvec = vec![cb1.clone(), cb2.clone()];
let mut btn = button::Button::default().with_label("Submit");
grid.insert(&mut label, 0, 0);
grid.insert(&mut cb1, 1, 0);
grid.insert(&mut cb2, 2, 0);
grid.insert(&mut btn, 5, 0);
btn.set_callback(move |btn| {
for cb in cbvec.clone() {
println!(
"CB status: {}",
if cb.is_checked() {
"Checked"
} else {
"Not_checked"
}
);
}
println!("--------------");
});
Panel {
grid,
label,
cb1,
cb2,
btn,
}
} // end default fn;
} // end impl Panel;
fltk::widget_extends!(Panel, Grid, grid);
fn main() {
let a = app::App::default();
let mut win = window::Window::default().with_size(800, 600);
let mut grid = Grid::default_fill();
grid.debug(false);
grid.set_layout(1, 2);
let mut panel1 = Panel::default();
let mut panel2 = Panel::default();
grid.insert_grid(&mut *panel1, 0, 0);
grid.insert_grid(&mut *panel2, 0, 1);
win.end();
win.make_resizable(true);
win.show();
a.run().unwrap();
}
sourcepub fn insert_ext<W: 'static + Clone + WidgetExt>(
&mut self,
widget: &mut W,
row: i32,
col: i32,
row_span: i32,
col_span: i32
)
pub fn insert_ext<W: 'static + Clone + WidgetExt>( &mut self, widget: &mut W, row: i32, col: i32, row_span: i32, col_span: i32 )
Adds a widget to the grid. The row_span refers to the passed row value and is counted in columns. The col_span refers to the passed column value and is counted in rows.
sourcepub fn insert<W: 'static + Clone + WidgetExt>(
&mut self,
widget: &mut W,
row: impl Into<GridRange>,
col: impl Into<GridRange>
)
pub fn insert<W: 'static + Clone + WidgetExt>( &mut self, widget: &mut W, row: impl Into<GridRange>, col: impl Into<GridRange> )
Insert a widget with a single span
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
let a = app::App::default().with_scheme(app::Scheme::Gtk);
let mut win = window::Window::default().with_size(500, 300);
let mut grid = Grid::default_fill();
grid.debug(false); // set to true to show cell outlines and numbers
grid.set_layout(5, 5); // 5 rows, 5 columns
grid.insert(&mut button::Button::default(), 0, 1); // widget, row, col
grid.insert(&mut button::Button::default(), 2..3, 1..4); // widget, row range, col range
// or
// grid.insert_ext(&mut button::Button::default(), 2, 1, 3, 1); // widget, row, col, row_span, col_span
win.end();
win.show();
a.run().unwrap();
}
More examples
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn fill(&mut self) {
let grid = &mut self.grid;
grid.debug(false); // set to true to see cell outlines
let mut title = frame::Frame::default().with_label("Employee Form");
title.set_frame(enums::FrameType::FlatBox);
title.set_color(enums::Color::Red);
title.set_label_color(enums::Color::White);
grid.insert(
// insert widgets
&mut title,
0,
1..4,
);
grid.insert(&mut frame::Frame::default().with_label("Name"), 2, 1);
grid.insert(&mut self.name, 2, 3);
grid.insert(&mut frame::Frame::default().with_label("Age"), 4, 1);
grid.insert(&mut self.age, 4, 3);
grid.insert(&mut frame::Frame::default().with_label("Occupation"), 6, 1);
grid.insert(&mut self.occupation, 6, 3);
grid.insert(&mut self.btn, 8, 2);
}
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
pub fn default() -> Self {
let mut grid = Grid::default();
grid.debug(false);
grid.set_layout(6, 1);
let mut label = frame::Frame::default().with_label("ARTERY:");
let mut cb1 = button::CheckButton::default().with_label("Normal");
let mut cb2 = button::CheckButton::default().with_label("Normal");
let cbvec = vec![cb1.clone(), cb2.clone()];
let mut btn = button::Button::default().with_label("Submit");
grid.insert(&mut label, 0, 0);
grid.insert(&mut cb1, 1, 0);
grid.insert(&mut cb2, 2, 0);
grid.insert(&mut btn, 5, 0);
btn.set_callback(move |btn| {
for cb in cbvec.clone() {
println!(
"CB status: {}",
if cb.is_checked() {
"Checked"
} else {
"Not_checked"
}
);
}
println!("--------------");
});
Panel {
grid,
label,
cb1,
cb2,
btn,
}
}
sourcepub fn insert_grid_ext(
&mut self,
widget: &mut Grid,
row: i32,
col: i32,
row_span: i32,
col_span: i32
)
pub fn insert_grid_ext( &mut self, widget: &mut Grid, row: i32, col: i32, row_span: i32, col_span: i32 )
Adds a widget to the grid. The row_span refers to the passed row value and is counted in columns. The col_span refers to the passed column value and is counted in rows.
sourcepub fn insert_grid(
&mut self,
widget: &mut Grid,
row: impl Into<GridRange>,
col: impl Into<GridRange>
)
pub fn insert_grid( &mut self, widget: &mut Grid, row: impl Into<GridRange>, col: impl Into<GridRange> )
Insert a widget with a single span
Examples found in repository?
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
fn main() {
let a = app::App::default();
let mut win = window::Window::default().with_size(800, 600);
let mut grid = Grid::default_fill();
grid.debug(false);
grid.set_layout(1, 2);
let mut panel1 = Panel::default();
let mut panel2 = Panel::default();
grid.insert_grid(&mut *panel1, 0, 0);
grid.insert_grid(&mut *panel2, 0, 1);
win.end();
win.make_resizable(true);
win.show();
a.run().unwrap();
}
sourcepub fn debug(&mut self, flag: bool)
pub fn debug(&mut self, flag: bool)
Show cell outlines and numbering
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
let a = app::App::default().with_scheme(app::Scheme::Gtk);
let mut win = window::Window::default().with_size(500, 300);
let mut grid = Grid::default_fill();
grid.debug(false); // set to true to show cell outlines and numbers
grid.set_layout(5, 5); // 5 rows, 5 columns
grid.insert(&mut button::Button::default(), 0, 1); // widget, row, col
grid.insert(&mut button::Button::default(), 2..3, 1..4); // widget, row range, col range
// or
// grid.insert_ext(&mut button::Button::default(), 2, 1, 3, 1); // widget, row, col, row_span, col_span
win.end();
win.show();
a.run().unwrap();
}
More examples
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
fn fill(&mut self) {
let grid = &mut self.grid;
grid.debug(false); // set to true to see cell outlines
let mut title = frame::Frame::default().with_label("Employee Form");
title.set_frame(enums::FrameType::FlatBox);
title.set_color(enums::Color::Red);
title.set_label_color(enums::Color::White);
grid.insert(
// insert widgets
&mut title,
0,
1..4,
);
grid.insert(&mut frame::Frame::default().with_label("Name"), 2, 1);
grid.insert(&mut self.name, 2, 3);
grid.insert(&mut frame::Frame::default().with_label("Age"), 4, 1);
grid.insert(&mut self.age, 4, 3);
grid.insert(&mut frame::Frame::default().with_label("Occupation"), 6, 1);
grid.insert(&mut self.occupation, 6, 3);
grid.insert(&mut self.btn, 8, 2);
}
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
pub fn default() -> Self {
let mut grid = Grid::default();
grid.debug(false);
grid.set_layout(6, 1);
let mut label = frame::Frame::default().with_label("ARTERY:");
let mut cb1 = button::CheckButton::default().with_label("Normal");
let mut cb2 = button::CheckButton::default().with_label("Normal");
let cbvec = vec![cb1.clone(), cb2.clone()];
let mut btn = button::Button::default().with_label("Submit");
grid.insert(&mut label, 0, 0);
grid.insert(&mut cb1, 1, 0);
grid.insert(&mut cb2, 2, 0);
grid.insert(&mut btn, 5, 0);
btn.set_callback(move |btn| {
for cb in cbvec.clone() {
println!(
"CB status: {}",
if cb.is_checked() {
"Checked"
} else {
"Not_checked"
}
);
}
println!("--------------");
});
Panel {
grid,
label,
cb1,
cb2,
btn,
}
} // end default fn;
} // end impl Panel;
fltk::widget_extends!(Panel, Grid, grid);
fn main() {
let a = app::App::default();
let mut win = window::Window::default().with_size(800, 600);
let mut grid = Grid::default_fill();
grid.debug(false);
grid.set_layout(1, 2);
let mut panel1 = Panel::default();
let mut panel2 = Panel::default();
grid.insert_grid(&mut *panel1, 0, 0);
grid.insert_grid(&mut *panel2, 0, 1);
win.end();
win.make_resizable(true);
win.show();
a.run().unwrap();
}
source§impl Grid
impl Grid
sourcepub fn with_label(self, title: &str) -> Self
pub fn with_label(self, title: &str) -> Self
Initialize with a label
sourcepub fn with_align(self, align: Align) -> Self
pub fn with_align(self, align: Align) -> Self
Initialize with alignment
sourcepub fn with_type<T: WidgetType>(self, typ: T) -> Self
pub fn with_type<T: WidgetType>(self, typ: T) -> Self
Initialize with type
sourcepub fn below_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
pub fn below_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize at bottom of another widget
sourcepub fn above_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
pub fn above_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize above of another widget
sourcepub fn right_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
pub fn right_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize right of another widget
sourcepub fn left_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
pub fn left_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize left of another widget
sourcepub fn center_x<W: WidgetExt>(self, w: &W) -> Self
pub fn center_x<W: WidgetExt>(self, w: &W) -> Self
Initialize center of another widget on the x axis
sourcepub fn center_y<W: WidgetExt>(self, w: &W) -> Self
pub fn center_y<W: WidgetExt>(self, w: &W) -> Self
Initialize center of another widget on the y axis
sourcepub fn center_of_parent(self) -> Self
pub fn center_of_parent(self) -> Self
Initialize center of parent
sourcepub fn size_of_parent(self) -> Self
pub fn size_of_parent(self) -> Self
Initialize to the size of the parent