pub struct Form { /* private fields */ }
Implementations§
Source§impl Form
impl Form
pub fn new<S: Into<Option<&'static str>>>( x: i32, y: i32, w: i32, h: i32, label: S, ) -> Self
pub fn default_fill() -> Self
pub fn set_data<T: FltkForm>(&mut self, data: T)
Sourcepub fn from_data<T: FltkForm>(self, data: T) -> Self
pub fn from_data<T: FltkForm>(self, data: T) -> Self
Examples found in repository?
examples/form_widget.rs (line 46)
35fn main() {
36 let my_struct = MyStruct::default(); // <-- instantiate your struct
37
38 let a = app::App::default().with_scheme(app::Scheme::Gtk);
39 app::set_background_color(222, 222, 222);
40
41 let mut win = window::Window::default().with_size(400, 300);
42
43 let mut form = Form::default()
44 .with_size(200, 200)
45 .center_of_parent()
46 .from_data(my_struct);
47
48 let mut btn = button::Button::default()
49 .with_label("print")
50 .with_size(80, 30)
51 .below_of(&*form, 5)
52 .center_x(&*form);
53 win.end();
54 win.show();
55
56 form.rename_prop("a", "Longer name");
57 let x = form.x() + 50;
58 let y = form.y();
59 form.set_pos(x, y);
60
61 let v = form.get_prop("b"); // <-- get a single property
62 assert_eq!(v, Some("3.0".to_owned()));
63
64 btn.set_callback(move |_| {
65 println!("{:?}", form.get_props()); // <-- get a HashMap of the properties
66 });
67
68 a.run().unwrap();
69}
pub fn set_data_view<T: FltkForm>(&mut self, data: T)
pub fn from_data_view<T: FltkForm>(self, data: T) -> Self
Sourcepub fn get_prop(&self, prop: &str) -> Option<String>
pub fn get_prop(&self, prop: &str) -> Option<String>
Examples found in repository?
examples/form_widget.rs (line 61)
35fn main() {
36 let my_struct = MyStruct::default(); // <-- instantiate your struct
37
38 let a = app::App::default().with_scheme(app::Scheme::Gtk);
39 app::set_background_color(222, 222, 222);
40
41 let mut win = window::Window::default().with_size(400, 300);
42
43 let mut form = Form::default()
44 .with_size(200, 200)
45 .center_of_parent()
46 .from_data(my_struct);
47
48 let mut btn = button::Button::default()
49 .with_label("print")
50 .with_size(80, 30)
51 .below_of(&*form, 5)
52 .center_x(&*form);
53 win.end();
54 win.show();
55
56 form.rename_prop("a", "Longer name");
57 let x = form.x() + 50;
58 let y = form.y();
59 form.set_pos(x, y);
60
61 let v = form.get_prop("b"); // <-- get a single property
62 assert_eq!(v, Some("3.0".to_owned()));
63
64 btn.set_callback(move |_| {
65 println!("{:?}", form.get_props()); // <-- get a HashMap of the properties
66 });
67
68 a.run().unwrap();
69}
pub fn set_prop(&mut self, prop: &str, value: &str) -> Result<(), FltkFormError>
Sourcepub fn get_props(&self) -> HashMap<String, String>
pub fn get_props(&self) -> HashMap<String, String>
Examples found in repository?
examples/form_widget.rs (line 65)
35fn main() {
36 let my_struct = MyStruct::default(); // <-- instantiate your struct
37
38 let a = app::App::default().with_scheme(app::Scheme::Gtk);
39 app::set_background_color(222, 222, 222);
40
41 let mut win = window::Window::default().with_size(400, 300);
42
43 let mut form = Form::default()
44 .with_size(200, 200)
45 .center_of_parent()
46 .from_data(my_struct);
47
48 let mut btn = button::Button::default()
49 .with_label("print")
50 .with_size(80, 30)
51 .below_of(&*form, 5)
52 .center_x(&*form);
53 win.end();
54 win.show();
55
56 form.rename_prop("a", "Longer name");
57 let x = form.x() + 50;
58 let y = form.y();
59 form.set_pos(x, y);
60
61 let v = form.get_prop("b"); // <-- get a single property
62 assert_eq!(v, Some("3.0".to_owned()));
63
64 btn.set_callback(move |_| {
65 println!("{:?}", form.get_props()); // <-- get a HashMap of the properties
66 });
67
68 a.run().unwrap();
69}
Sourcepub fn rename_prop(&self, prop: &str, new_name: &str)
pub fn rename_prop(&self, prop: &str, new_name: &str)
Examples found in repository?
examples/form_widget.rs (line 56)
35fn main() {
36 let my_struct = MyStruct::default(); // <-- instantiate your struct
37
38 let a = app::App::default().with_scheme(app::Scheme::Gtk);
39 app::set_background_color(222, 222, 222);
40
41 let mut win = window::Window::default().with_size(400, 300);
42
43 let mut form = Form::default()
44 .with_size(200, 200)
45 .center_of_parent()
46 .from_data(my_struct);
47
48 let mut btn = button::Button::default()
49 .with_label("print")
50 .with_size(80, 30)
51 .below_of(&*form, 5)
52 .center_x(&*form);
53 win.end();
54 win.show();
55
56 form.rename_prop("a", "Longer name");
57 let x = form.x() + 50;
58 let y = form.y();
59 form.set_pos(x, y);
60
61 let v = form.get_prop("b"); // <-- get a single property
62 assert_eq!(v, Some("3.0".to_owned()));
63
64 btn.set_callback(move |_| {
65 println!("{:?}", form.get_props()); // <-- get a HashMap of the properties
66 });
67
68 a.run().unwrap();
69}
pub fn get_widget(&self, prop: &str) -> Option<Box<dyn WidgetExt>>
Source§impl Form
impl Form
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?
examples/form_widget.rs (line 44)
35fn main() {
36 let my_struct = MyStruct::default(); // <-- instantiate your struct
37
38 let a = app::App::default().with_scheme(app::Scheme::Gtk);
39 app::set_background_color(222, 222, 222);
40
41 let mut win = window::Window::default().with_size(400, 300);
42
43 let mut form = Form::default()
44 .with_size(200, 200)
45 .center_of_parent()
46 .from_data(my_struct);
47
48 let mut btn = button::Button::default()
49 .with_label("print")
50 .with_size(80, 30)
51 .below_of(&*form, 5)
52 .center_x(&*form);
53 win.end();
54 win.show();
55
56 form.rename_prop("a", "Longer name");
57 let x = form.x() + 50;
58 let y = form.y();
59 form.set_pos(x, y);
60
61 let v = form.get_prop("b"); // <-- get a single property
62 assert_eq!(v, Some("3.0".to_owned()));
63
64 btn.set_callback(move |_| {
65 println!("{:?}", form.get_props()); // <-- get a HashMap of the properties
66 });
67
68 a.run().unwrap();
69}
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?
examples/form_widget.rs (line 45)
35fn main() {
36 let my_struct = MyStruct::default(); // <-- instantiate your struct
37
38 let a = app::App::default().with_scheme(app::Scheme::Gtk);
39 app::set_background_color(222, 222, 222);
40
41 let mut win = window::Window::default().with_size(400, 300);
42
43 let mut form = Form::default()
44 .with_size(200, 200)
45 .center_of_parent()
46 .from_data(my_struct);
47
48 let mut btn = button::Button::default()
49 .with_label("print")
50 .with_size(80, 30)
51 .below_of(&*form, 5)
52 .center_x(&*form);
53 win.end();
54 win.show();
55
56 form.rename_prop("a", "Longer name");
57 let x = form.x() + 50;
58 let y = form.y();
59 form.set_pos(x, y);
60
61 let v = form.get_prop("b"); // <-- get a single property
62 assert_eq!(v, Some("3.0".to_owned()));
63
64 btn.set_callback(move |_| {
65 println!("{:?}", form.get_props()); // <-- get a HashMap of the properties
66 });
67
68 a.run().unwrap();
69}
Sourcepub fn size_of_parent(self) -> Self
pub fn size_of_parent(self) -> Self
Initialize to the size of the parent
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Form
impl RefUnwindSafe for Form
impl Send for Form
impl Sync for Form
impl Unpin for Form
impl UnwindSafe for Form
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more