Struct Form

Source
pub struct Form { /* private fields */ }

Implementations§

Source§

impl Form

Source

pub fn new<S: Into<Option<&'static str>>>( x: i32, y: i32, w: i32, h: i32, label: S, ) -> Self

Source

pub fn default_fill() -> Self

Source

pub fn set_data<T: FltkForm>(&mut self, data: T)

Source

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}
Source

pub fn set_data_view<T: FltkForm>(&mut self, data: T)

Source

pub fn from_data_view<T: FltkForm>(self, data: T) -> Self

Source

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}
Source

pub fn set_prop(&mut self, prop: &str, value: &str) -> Result<(), FltkFormError>

Source

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}
Source

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}
Source

pub fn get_widget(&self, prop: &str) -> Option<Box<dyn WidgetExt>>

Source§

impl Form

Source

pub fn with_pos(self, x: i32, y: i32) -> Self

Initialize to position x, y

Source

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}
Source

pub fn with_label(self, title: &str) -> Self

Initialize with a label

Source

pub fn with_align(self, align: Align) -> Self

Initialize with alignment

Source

pub fn with_type<T: WidgetType>(self, typ: T) -> Self

Initialize with type

Source

pub fn below_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self

Initialize at bottom of another widget

Source

pub fn above_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self

Initialize above of another widget

Source

pub fn right_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self

Initialize right of another widget

Source

pub fn left_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self

Initialize left of another widget

Source

pub fn center_of<W: WidgetExt>(self, w: &W) -> Self

Initialize center of another widget

Source

pub fn center_x<W: WidgetExt>(self, w: &W) -> Self

Initialize center of another widget on the x axis

Source

pub fn center_y<W: WidgetExt>(self, w: &W) -> Self

Initialize center of another widget on the y axis

Source

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}
Source

pub fn size_of<W: WidgetExt>(self, w: &W) -> Self

Initialize to the size of another widget

Source

pub fn size_of_parent(self) -> Self

Initialize to the size of the parent

Trait Implementations§

Source§

impl Clone for Form

Source§

fn clone(&self) -> Form

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Form

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Form

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for Form

Source§

type Target = Group

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Form

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.