pub struct SmartTable { /* private fields */ }
Expand description
Smart table widget
Implementations§
Source§impl SmartTable
impl SmartTable
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
Construct a new SmartTable widget using coords, size and label
Sourcepub fn default_fill() -> Self
pub fn default_fill() -> Self
Create a SmartTable the size of the parent widget
Sourcepub fn with_opts(self, opts: TableOpts) -> Self
pub fn with_opts(self, opts: TableOpts) -> Self
Instantiate with TableOpts
Examples found in repository?
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 let mut table = SmartTable::default()
13 .with_size(790, 590)
14 .center_of_parent()
15 .with_opts(TableOpts {
16 rows: 30,
17 cols: 15,
18 ..Default::default()
19 });
20
21 wind.end();
22 wind.show();
23
24 for i in 0..30 {
25 table.set_row_header_value(i, &(i + 100).to_string());
26 }
27
28 for i in 0..15 {
29 table.set_col_header_value(i, &i.to_string());
30 }
31
32 app.run().unwrap();
33}
More examples
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 30,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 // set the value at the row,column 4,5 to "another", notice that indices start at 0
27 table.set_cell_value(3, 4, "another");
28 assert_eq!(table.cell_value(3, 4), "another");
29
30 // To avoid closing the window on hitting the escape key
31 wind.set_callback(move |_| {
32 if app::event() == enums::Event::Close {
33 app.quit();
34 }
35 });
36
37 app.run().unwrap();
38}
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 1000,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 table
27 .input()
28 .as_mut()
29 .unwrap()
30 .set_type(input::InputType::Int);
31
32 // set the value at the row,column 4,5 to "another", notice that indices start at 0
33 table.set_cell_value(3, 4, "10");
34 assert_eq!(table.cell_value(3, 4), "10");
35
36 // To avoid closing the window on hitting the escape key
37 wind.set_callback(move |_| {
38 if app::event() == enums::Event::Close {
39 app.quit();
40 }
41 });
42
43 app.run().unwrap();
44}
9fn main() {
10 let app = app::App::default().with_scheme(app::Scheme::Gtk);
11 let mut wind = window::Window::default().with_size(800, 600);
12
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 15,
19 cell_selection_color: Color::Red.inactive(),
20 header_frame: FrameType::FlatBox,
21 header_color: Color::BackGround.lighter(),
22 cell_border_color: Color::White,
23 ..Default::default()
24 });
25
26 wind.end();
27 wind.show();
28
29 // Just filling the vec with some values
30 for i in 0..30 {
31 for j in 0..15 {
32 table.set_cell_value(i, j, &(i + j).to_string());
33 }
34 }
35 table.redraw();
36
37 // To avoid closing the window on hitting the escape key
38 wind.set_callback(move |_| {
39 if app::event() == Event::Close {
40 app.quit();
41 }
42 });
43
44 app.run().unwrap();
45}
Sourcepub fn input(&mut self) -> &mut Option<Input>
pub fn input(&mut self) -> &mut Option<Input>
Get the input widget
Examples found in repository?
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 1000,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 table
27 .input()
28 .as_mut()
29 .unwrap()
30 .set_type(input::InputType::Int);
31
32 // set the value at the row,column 4,5 to "another", notice that indices start at 0
33 table.set_cell_value(3, 4, "10");
34 assert_eq!(table.cell_value(3, 4), "10");
35
36 // To avoid closing the window on hitting the escape key
37 wind.set_callback(move |_| {
38 if app::event() == enums::Event::Close {
39 app.quit();
40 }
41 });
42
43 app.run().unwrap();
44}
Sourcepub fn set_cell_value(&mut self, row: i32, col: i32, val: &str)
pub fn set_cell_value(&mut self, row: i32, col: i32, val: &str)
Set the cell value, using the row and column to index the data
Examples found in repository?
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 30,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 // set the value at the row,column 4,5 to "another", notice that indices start at 0
27 table.set_cell_value(3, 4, "another");
28 assert_eq!(table.cell_value(3, 4), "another");
29
30 // To avoid closing the window on hitting the escape key
31 wind.set_callback(move |_| {
32 if app::event() == enums::Event::Close {
33 app.quit();
34 }
35 });
36
37 app.run().unwrap();
38}
More examples
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 1000,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 table
27 .input()
28 .as_mut()
29 .unwrap()
30 .set_type(input::InputType::Int);
31
32 // set the value at the row,column 4,5 to "another", notice that indices start at 0
33 table.set_cell_value(3, 4, "10");
34 assert_eq!(table.cell_value(3, 4), "10");
35
36 // To avoid closing the window on hitting the escape key
37 wind.set_callback(move |_| {
38 if app::event() == enums::Event::Close {
39 app.quit();
40 }
41 });
42
43 app.run().unwrap();
44}
9fn main() {
10 let app = app::App::default().with_scheme(app::Scheme::Gtk);
11 let mut wind = window::Window::default().with_size(800, 600);
12
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 15,
19 cell_selection_color: Color::Red.inactive(),
20 header_frame: FrameType::FlatBox,
21 header_color: Color::BackGround.lighter(),
22 cell_border_color: Color::White,
23 ..Default::default()
24 });
25
26 wind.end();
27 wind.show();
28
29 // Just filling the vec with some values
30 for i in 0..30 {
31 for j in 0..15 {
32 table.set_cell_value(i, j, &(i + j).to_string());
33 }
34 }
35 table.redraw();
36
37 // To avoid closing the window on hitting the escape key
38 wind.set_callback(move |_| {
39 if app::event() == Event::Close {
40 app.quit();
41 }
42 });
43
44 app.run().unwrap();
45}
Sourcepub fn cell_value(&self, row: i32, col: i32) -> String
pub fn cell_value(&self, row: i32, col: i32) -> String
Get the cell value, using the row and column to index the data
Examples found in repository?
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 30,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 // set the value at the row,column 4,5 to "another", notice that indices start at 0
27 table.set_cell_value(3, 4, "another");
28 assert_eq!(table.cell_value(3, 4), "another");
29
30 // To avoid closing the window on hitting the escape key
31 wind.set_callback(move |_| {
32 if app::event() == enums::Event::Close {
33 app.quit();
34 }
35 });
36
37 app.run().unwrap();
38}
More examples
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 1000,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 table
27 .input()
28 .as_mut()
29 .unwrap()
30 .set_type(input::InputType::Int);
31
32 // set the value at the row,column 4,5 to "another", notice that indices start at 0
33 table.set_cell_value(3, 4, "10");
34 assert_eq!(table.cell_value(3, 4), "10");
35
36 // To avoid closing the window on hitting the escape key
37 wind.set_callback(move |_| {
38 if app::event() == enums::Event::Close {
39 app.quit();
40 }
41 });
42
43 app.run().unwrap();
44}
Sourcepub fn set_cell_color(&mut self, row: i32, col: i32, color: Color)
pub fn set_cell_color(&mut self, row: i32, col: i32, color: Color)
Set the cell value, using the row and column to index the data
Sourcepub fn set_cell_selection_color(&mut self, row: i32, col: i32, color: Color)
pub fn set_cell_selection_color(&mut self, row: i32, col: i32, color: Color)
Set the cell value, using the row and column to index the data
Sourcepub fn set_cell_font_color(&mut self, row: i32, col: i32, color: Color)
pub fn set_cell_font_color(&mut self, row: i32, col: i32, color: Color)
Set the cell value, using the row and column to index the data
Sourcepub fn set_cell_border_color(&mut self, row: i32, col: i32, color: Color)
pub fn set_cell_border_color(&mut self, row: i32, col: i32, color: Color)
Set the cell value, using the row and column to index the data
Sourcepub fn set_cell_font(&mut self, row: i32, col: i32, font: Font)
pub fn set_cell_font(&mut self, row: i32, col: i32, font: Font)
Set the cell value, using the row and column to index the data
Sourcepub fn set_cell_font_size(&mut self, row: i32, col: i32, sz: i32)
pub fn set_cell_font_size(&mut self, row: i32, col: i32, sz: i32)
Set the cell value, using the row and column to index the data
Sourcepub fn set_cell_align(&mut self, row: i32, col: i32, align: Align)
pub fn set_cell_align(&mut self, row: i32, col: i32, align: Align)
Set the cell value, using the row and column to index the data
Sourcepub fn set_row_header_value(&mut self, row: i32, val: &str)
pub fn set_row_header_value(&mut self, row: i32, val: &str)
Set the row header value at the row index
Examples found in repository?
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 let mut table = SmartTable::default()
13 .with_size(790, 590)
14 .center_of_parent()
15 .with_opts(TableOpts {
16 rows: 30,
17 cols: 15,
18 ..Default::default()
19 });
20
21 wind.end();
22 wind.show();
23
24 for i in 0..30 {
25 table.set_row_header_value(i, &(i + 100).to_string());
26 }
27
28 for i in 0..15 {
29 table.set_col_header_value(i, &i.to_string());
30 }
31
32 app.run().unwrap();
33}
Sourcepub fn set_col_header_value(&mut self, col: i32, val: &str)
pub fn set_col_header_value(&mut self, col: i32, val: &str)
Set the column header value at the column index
Examples found in repository?
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 let mut table = SmartTable::default()
13 .with_size(790, 590)
14 .center_of_parent()
15 .with_opts(TableOpts {
16 rows: 30,
17 cols: 15,
18 ..Default::default()
19 });
20
21 wind.end();
22 wind.show();
23
24 for i in 0..30 {
25 table.set_row_header_value(i, &(i + 100).to_string());
26 }
27
28 for i in 0..15 {
29 table.set_col_header_value(i, &i.to_string());
30 }
31
32 app.run().unwrap();
33}
Sourcepub fn row_header_value(&mut self, row: i32) -> String
pub fn row_header_value(&mut self, row: i32) -> String
Get the row header value at the row index
Sourcepub fn col_header_value(&mut self, col: i32) -> String
pub fn col_header_value(&mut self, col: i32) -> String
Get the column header value at the column index
Sourcepub fn insert_empty_row(&mut self, row: i32, row_header: &str)
pub fn insert_empty_row(&mut self, row: i32, row_header: &str)
Insert an empty row at the row index
Sourcepub fn insert_row(&mut self, row: i32, row_header: &str, vals: &[&str])
pub fn insert_row(&mut self, row: i32, row_header: &str, vals: &[&str])
Append a row to your table
Sourcepub fn append_empty_row(&mut self, row_header: &str)
pub fn append_empty_row(&mut self, row_header: &str)
Append an empty row to your table
Sourcepub fn append_row(&mut self, row_header: &str, vals: &[&str])
pub fn append_row(&mut self, row_header: &str, vals: &[&str])
Append a row to your table
Sourcepub fn insert_empty_col(&mut self, col: i32, col_header: &str)
pub fn insert_empty_col(&mut self, col: i32, col_header: &str)
Insert an empty column at the column index
Sourcepub fn insert_col(&mut self, col: i32, col_header: &str, vals: &[&str])
pub fn insert_col(&mut self, col: i32, col_header: &str, vals: &[&str])
Append a column to your table
Sourcepub fn append_empty_col(&mut self, col_header: &str)
pub fn append_empty_col(&mut self, col_header: &str)
Append an empty column to your table
Sourcepub fn append_col(&mut self, col_header: &str, vals: &[&str])
pub fn append_col(&mut self, col_header: &str, vals: &[&str])
Append a column to your table
Sourcepub fn remove_row(&mut self, row: i32)
pub fn remove_row(&mut self, row: i32)
Remove a row at the row index
Sourcepub fn remove_col(&mut self, col: i32)
pub fn remove_col(&mut self, col: i32)
Remove a column at the column index
Sourcepub fn set_callback<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)
pub fn set_callback<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)
Set a callback for the SmartTable
Sourcepub fn set_on_update_callback<F: FnMut(i32, i32, String) + Send + 'static>(
&mut self,
cb: F,
)
pub fn set_on_update_callback<F: FnMut(i32, i32, String) + Send + 'static>( &mut self, cb: F, )
Set a callback for on user input callback function takes the values row, col, and the new value of the cell
Sourcepub fn column_count(&self) -> i32
pub fn column_count(&self) -> i32
Returns the column count
Sourcepub fn row_height(&self, row: i32) -> i32
pub fn row_height(&self, row: i32) -> i32
Get the row’s height
Sourcepub fn set_col_width(&mut self, col: i32, width: i32)
pub fn set_col_width(&mut self, col: i32, width: i32)
Set column’s width
Sourcepub fn set_row_height(&mut self, row: i32, height: i32)
pub fn set_row_height(&mut self, row: i32, height: i32)
Set the row’s height
Sourcepub fn col_header_height(&self) -> i32
pub fn col_header_height(&self) -> i32
Get the column header height
Sourcepub fn row_header_width(&self) -> i32
pub fn row_header_width(&self) -> i32
Get the row header width
Sourcepub fn set_col_header_height(&mut self, height: i32)
pub fn set_col_header_height(&mut self, height: i32)
Set column header height
Sourcepub fn set_row_header_width(&mut self, width: i32)
pub fn set_row_header_width(&mut self, width: i32)
Set the row header width
Source§impl SmartTable
impl SmartTable
Sourcepub fn with_size(self, width: i32, height: i32) -> Self
pub fn with_size(self, width: i32, height: i32) -> Self
Initialize to size width, height
Examples found in repository?
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 let mut table = SmartTable::default()
13 .with_size(790, 590)
14 .center_of_parent()
15 .with_opts(TableOpts {
16 rows: 30,
17 cols: 15,
18 ..Default::default()
19 });
20
21 wind.end();
22 wind.show();
23
24 for i in 0..30 {
25 table.set_row_header_value(i, &(i + 100).to_string());
26 }
27
28 for i in 0..15 {
29 table.set_col_header_value(i, &i.to_string());
30 }
31
32 app.run().unwrap();
33}
More examples
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 30,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 // set the value at the row,column 4,5 to "another", notice that indices start at 0
27 table.set_cell_value(3, 4, "another");
28 assert_eq!(table.cell_value(3, 4), "another");
29
30 // To avoid closing the window on hitting the escape key
31 wind.set_callback(move |_| {
32 if app::event() == enums::Event::Close {
33 app.quit();
34 }
35 });
36
37 app.run().unwrap();
38}
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 1000,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 table
27 .input()
28 .as_mut()
29 .unwrap()
30 .set_type(input::InputType::Int);
31
32 // set the value at the row,column 4,5 to "another", notice that indices start at 0
33 table.set_cell_value(3, 4, "10");
34 assert_eq!(table.cell_value(3, 4), "10");
35
36 // To avoid closing the window on hitting the escape key
37 wind.set_callback(move |_| {
38 if app::event() == enums::Event::Close {
39 app.quit();
40 }
41 });
42
43 app.run().unwrap();
44}
9fn main() {
10 let app = app::App::default().with_scheme(app::Scheme::Gtk);
11 let mut wind = window::Window::default().with_size(800, 600);
12
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 15,
19 cell_selection_color: Color::Red.inactive(),
20 header_frame: FrameType::FlatBox,
21 header_color: Color::BackGround.lighter(),
22 cell_border_color: Color::White,
23 ..Default::default()
24 });
25
26 wind.end();
27 wind.show();
28
29 // Just filling the vec with some values
30 for i in 0..30 {
31 for j in 0..15 {
32 table.set_cell_value(i, j, &(i + j).to_string());
33 }
34 }
35 table.redraw();
36
37 // To avoid closing the window on hitting the escape key
38 wind.set_callback(move |_| {
39 if app::event() == Event::Close {
40 app.quit();
41 }
42 });
43
44 app.run().unwrap();
45}
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
Examples found in repository?
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 let mut table = SmartTable::default()
13 .with_size(790, 590)
14 .center_of_parent()
15 .with_opts(TableOpts {
16 rows: 30,
17 cols: 15,
18 ..Default::default()
19 });
20
21 wind.end();
22 wind.show();
23
24 for i in 0..30 {
25 table.set_row_header_value(i, &(i + 100).to_string());
26 }
27
28 for i in 0..15 {
29 table.set_col_header_value(i, &i.to_string());
30 }
31
32 app.run().unwrap();
33}
More examples
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 30,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 // set the value at the row,column 4,5 to "another", notice that indices start at 0
27 table.set_cell_value(3, 4, "another");
28 assert_eq!(table.cell_value(3, 4), "another");
29
30 // To avoid closing the window on hitting the escape key
31 wind.set_callback(move |_| {
32 if app::event() == enums::Event::Close {
33 app.quit();
34 }
35 });
36
37 app.run().unwrap();
38}
8fn main() {
9 let app = app::App::default().with_scheme(app::Scheme::Gtk);
10 let mut wind = window::Window::default().with_size(800, 600);
11
12 // We pass the rows and columns thru the TableOpts field
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 1000,
19 editable: true,
20 ..Default::default()
21 });
22
23 wind.end();
24 wind.show();
25
26 table
27 .input()
28 .as_mut()
29 .unwrap()
30 .set_type(input::InputType::Int);
31
32 // set the value at the row,column 4,5 to "another", notice that indices start at 0
33 table.set_cell_value(3, 4, "10");
34 assert_eq!(table.cell_value(3, 4), "10");
35
36 // To avoid closing the window on hitting the escape key
37 wind.set_callback(move |_| {
38 if app::event() == enums::Event::Close {
39 app.quit();
40 }
41 });
42
43 app.run().unwrap();
44}
9fn main() {
10 let app = app::App::default().with_scheme(app::Scheme::Gtk);
11 let mut wind = window::Window::default().with_size(800, 600);
12
13 let mut table = SmartTable::default()
14 .with_size(790, 590)
15 .center_of_parent()
16 .with_opts(TableOpts {
17 rows: 30,
18 cols: 15,
19 cell_selection_color: Color::Red.inactive(),
20 header_frame: FrameType::FlatBox,
21 header_color: Color::BackGround.lighter(),
22 cell_border_color: Color::White,
23 ..Default::default()
24 });
25
26 wind.end();
27 wind.show();
28
29 // Just filling the vec with some values
30 for i in 0..30 {
31 for j in 0..15 {
32 table.set_cell_value(i, j, &(i + j).to_string());
33 }
34 }
35 table.redraw();
36
37 // To avoid closing the window on hitting the escape key
38 wind.set_callback(move |_| {
39 if app::event() == Event::Close {
40 app.quit();
41 }
42 });
43
44 app.run().unwrap();
45}
Sourcepub fn size_of_parent(self) -> Self
pub fn size_of_parent(self) -> Self
Initialize to the size of the parent
Methods from Deref<Target = TableRow>§
Sourcepub fn row_selected(&mut self, row: i32) -> bool
pub fn row_selected(&mut self, row: i32) -> bool
Returns whether a row was selected
Sourcepub fn select_row(
&mut self,
row: i32,
selection_flag: TableRowSelectFlag,
) -> Result<(), FltkError>
pub fn select_row( &mut self, row: i32, selection_flag: TableRowSelectFlag, ) -> Result<(), FltkError>
Sourcepub fn select_all_rows(&mut self, selection_flag: TableRowSelectFlag)
pub fn select_all_rows(&mut self, selection_flag: TableRowSelectFlag)
Selects all rows
Trait Implementations§
Source§impl Clone for SmartTable
impl Clone for SmartTable
Source§fn clone(&self) -> SmartTable
fn clone(&self) -> SmartTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more