Struct ListBoxBuilder

Source
pub struct ListBoxBuilder<'a, D: Display + Default> { /* private fields */ }

Implementations§

Source§

impl<'a, D: Display + Default> ListBoxBuilder<'a, D>

Source

pub fn flags(self, flags: ListBoxFlags) -> ListBoxBuilder<'a, D>

Source

pub fn ex_flags(self, flags: u32) -> ListBoxBuilder<'a, D>

Source

pub fn size(self, size: (i32, i32)) -> ListBoxBuilder<'a, D>

Source

pub fn position(self, pos: (i32, i32)) -> ListBoxBuilder<'a, D>

Source

pub fn font(self, font: Option<&'a Font>) -> ListBoxBuilder<'a, D>

Source

pub fn parent<C: Into<ControlHandle>>(self, p: C) -> ListBoxBuilder<'a, D>

Examples found in repository?
examples/partials.rs (line 145)
132        fn build_ui(mut data: PartialDemo) -> Result<Rc<PartialDemoUi>, nwg::NwgError> {
133            use nwg::Event as E;
134            
135            // Controls
136            nwg::Window::builder()
137                .size((500, 400))
138                .position((300, 300))
139                .title("Many UI")
140                .build(&mut data.window)?;
141
142            nwg::ListBox::builder()
143                .collection(vec!["People", "Animals", "Food"])
144                .focus(true)
145                .parent(&data.window)
146                .build(&mut data.menu)?;
147
148            nwg::Frame::builder()
149                .parent(&data.window)
150                .build(&mut data.frame1)?;
151
152            nwg::Frame::builder()
153                .flags(nwg::FrameFlags::BORDER)
154                .parent(&data.window)
155                .build(&mut data.frame2)?;
156
157            nwg::Frame::builder()
158                .flags(nwg::FrameFlags::BORDER)
159                .parent(&data.window)
160                .build(&mut data.frame3)?;
161
162            // Partials
163            PeopleUi::build_partial(&mut data.people_ui, Some(&data.frame1))?;
164            AnimalUi::build_partial(&mut data.animal_ui, Some(&data.frame2))?;
165            FoodUi::build_partial(&mut data.food_ui, Some(&data.frame3))?;
166
167            // Wrap-up
168            let ui = Rc::new(PartialDemoUi {
169                inner: data,
170                default_handler: Default::default()
171            });
172
173            // Events
174            let mut window_handles = vec![&ui.window.handle];
175            window_handles.append(&mut ui.people_ui.handles());
176            window_handles.append(&mut ui.animal_ui.handles());
177            window_handles.append(&mut ui.food_ui.handles());
178
179            for handle in window_handles.iter() {
180                let evt_ui = ui.clone();
181                let handle_events = move |evt, evt_data, handle| {
182                    evt_ui.people_ui.process_event(evt, &evt_data, handle);
183                    evt_ui.animal_ui.process_event(evt, &evt_data, handle);
184                    evt_ui.food_ui.process_event(evt, &evt_data, handle);
185                    
186                    match evt {
187                        E::OnListBoxSelect => 
188                            if &handle == &evt_ui.menu {
189                                PartialDemo::change_interface(&evt_ui.inner);
190                            },
191                        E::OnWindowClose => 
192                            if &handle == &evt_ui.window {
193                                PartialDemo::exit(&evt_ui.inner);
194                            },
195                        E::OnButtonClick => 
196                            if &handle == &evt_ui.people_ui.save_btn || &handle == &evt_ui.animal_ui.save_btn ||&handle == &evt_ui.food_ui.save_btn  {
197                                PartialDemo::save(&evt_ui.inner);
198                            },
199                        _ => {}
200                    }
201                };
202
203                ui.default_handler.borrow_mut().push(
204                    nwg::full_bind_event_handler(handle, handle_events)
205                );
206            }
207
208            // Layout
209            use nwg::stretch::{geometry::Size, style::Dimension as D};
210
211           nwg::FlexboxLayout::builder()
212                .parent(&ui.window)
213                .child(&ui.menu)
214                    .child_size(Size { width: D::Percent(0.3), height: D::Auto })
215                .child(&ui.frame1)
216                    .child_size(Size { width: D::Percent(1.0), height: D::Auto })
217                .build(&ui.layout)?;
218            
219            return Ok(ui);
220        }
Source

pub fn collection(self, collection: Vec<D>) -> ListBoxBuilder<'a, D>

Examples found in repository?
examples/partials.rs (line 143)
132        fn build_ui(mut data: PartialDemo) -> Result<Rc<PartialDemoUi>, nwg::NwgError> {
133            use nwg::Event as E;
134            
135            // Controls
136            nwg::Window::builder()
137                .size((500, 400))
138                .position((300, 300))
139                .title("Many UI")
140                .build(&mut data.window)?;
141
142            nwg::ListBox::builder()
143                .collection(vec!["People", "Animals", "Food"])
144                .focus(true)
145                .parent(&data.window)
146                .build(&mut data.menu)?;
147
148            nwg::Frame::builder()
149                .parent(&data.window)
150                .build(&mut data.frame1)?;
151
152            nwg::Frame::builder()
153                .flags(nwg::FrameFlags::BORDER)
154                .parent(&data.window)
155                .build(&mut data.frame2)?;
156
157            nwg::Frame::builder()
158                .flags(nwg::FrameFlags::BORDER)
159                .parent(&data.window)
160                .build(&mut data.frame3)?;
161
162            // Partials
163            PeopleUi::build_partial(&mut data.people_ui, Some(&data.frame1))?;
164            AnimalUi::build_partial(&mut data.animal_ui, Some(&data.frame2))?;
165            FoodUi::build_partial(&mut data.food_ui, Some(&data.frame3))?;
166
167            // Wrap-up
168            let ui = Rc::new(PartialDemoUi {
169                inner: data,
170                default_handler: Default::default()
171            });
172
173            // Events
174            let mut window_handles = vec![&ui.window.handle];
175            window_handles.append(&mut ui.people_ui.handles());
176            window_handles.append(&mut ui.animal_ui.handles());
177            window_handles.append(&mut ui.food_ui.handles());
178
179            for handle in window_handles.iter() {
180                let evt_ui = ui.clone();
181                let handle_events = move |evt, evt_data, handle| {
182                    evt_ui.people_ui.process_event(evt, &evt_data, handle);
183                    evt_ui.animal_ui.process_event(evt, &evt_data, handle);
184                    evt_ui.food_ui.process_event(evt, &evt_data, handle);
185                    
186                    match evt {
187                        E::OnListBoxSelect => 
188                            if &handle == &evt_ui.menu {
189                                PartialDemo::change_interface(&evt_ui.inner);
190                            },
191                        E::OnWindowClose => 
192                            if &handle == &evt_ui.window {
193                                PartialDemo::exit(&evt_ui.inner);
194                            },
195                        E::OnButtonClick => 
196                            if &handle == &evt_ui.people_ui.save_btn || &handle == &evt_ui.animal_ui.save_btn ||&handle == &evt_ui.food_ui.save_btn  {
197                                PartialDemo::save(&evt_ui.inner);
198                            },
199                        _ => {}
200                    }
201                };
202
203                ui.default_handler.borrow_mut().push(
204                    nwg::full_bind_event_handler(handle, handle_events)
205                );
206            }
207
208            // Layout
209            use nwg::stretch::{geometry::Size, style::Dimension as D};
210
211           nwg::FlexboxLayout::builder()
212                .parent(&ui.window)
213                .child(&ui.menu)
214                    .child_size(Size { width: D::Percent(0.3), height: D::Auto })
215                .child(&ui.frame1)
216                    .child_size(Size { width: D::Percent(1.0), height: D::Auto })
217                .build(&ui.layout)?;
218            
219            return Ok(ui);
220        }
Source

pub fn selected_index(self, index: Option<usize>) -> ListBoxBuilder<'a, D>

Source

pub fn multi_selection(self, select: Vec<usize>) -> ListBoxBuilder<'a, D>

Source

pub fn enabled(self, enabled: bool) -> ListBoxBuilder<'a, D>

Source

pub fn focus(self, focus: bool) -> ListBoxBuilder<'a, D>

Examples found in repository?
examples/partials.rs (line 144)
132        fn build_ui(mut data: PartialDemo) -> Result<Rc<PartialDemoUi>, nwg::NwgError> {
133            use nwg::Event as E;
134            
135            // Controls
136            nwg::Window::builder()
137                .size((500, 400))
138                .position((300, 300))
139                .title("Many UI")
140                .build(&mut data.window)?;
141
142            nwg::ListBox::builder()
143                .collection(vec!["People", "Animals", "Food"])
144                .focus(true)
145                .parent(&data.window)
146                .build(&mut data.menu)?;
147
148            nwg::Frame::builder()
149                .parent(&data.window)
150                .build(&mut data.frame1)?;
151
152            nwg::Frame::builder()
153                .flags(nwg::FrameFlags::BORDER)
154                .parent(&data.window)
155                .build(&mut data.frame2)?;
156
157            nwg::Frame::builder()
158                .flags(nwg::FrameFlags::BORDER)
159                .parent(&data.window)
160                .build(&mut data.frame3)?;
161
162            // Partials
163            PeopleUi::build_partial(&mut data.people_ui, Some(&data.frame1))?;
164            AnimalUi::build_partial(&mut data.animal_ui, Some(&data.frame2))?;
165            FoodUi::build_partial(&mut data.food_ui, Some(&data.frame3))?;
166
167            // Wrap-up
168            let ui = Rc::new(PartialDemoUi {
169                inner: data,
170                default_handler: Default::default()
171            });
172
173            // Events
174            let mut window_handles = vec![&ui.window.handle];
175            window_handles.append(&mut ui.people_ui.handles());
176            window_handles.append(&mut ui.animal_ui.handles());
177            window_handles.append(&mut ui.food_ui.handles());
178
179            for handle in window_handles.iter() {
180                let evt_ui = ui.clone();
181                let handle_events = move |evt, evt_data, handle| {
182                    evt_ui.people_ui.process_event(evt, &evt_data, handle);
183                    evt_ui.animal_ui.process_event(evt, &evt_data, handle);
184                    evt_ui.food_ui.process_event(evt, &evt_data, handle);
185                    
186                    match evt {
187                        E::OnListBoxSelect => 
188                            if &handle == &evt_ui.menu {
189                                PartialDemo::change_interface(&evt_ui.inner);
190                            },
191                        E::OnWindowClose => 
192                            if &handle == &evt_ui.window {
193                                PartialDemo::exit(&evt_ui.inner);
194                            },
195                        E::OnButtonClick => 
196                            if &handle == &evt_ui.people_ui.save_btn || &handle == &evt_ui.animal_ui.save_btn ||&handle == &evt_ui.food_ui.save_btn  {
197                                PartialDemo::save(&evt_ui.inner);
198                            },
199                        _ => {}
200                    }
201                };
202
203                ui.default_handler.borrow_mut().push(
204                    nwg::full_bind_event_handler(handle, handle_events)
205                );
206            }
207
208            // Layout
209            use nwg::stretch::{geometry::Size, style::Dimension as D};
210
211           nwg::FlexboxLayout::builder()
212                .parent(&ui.window)
213                .child(&ui.menu)
214                    .child_size(Size { width: D::Percent(0.3), height: D::Auto })
215                .child(&ui.frame1)
216                    .child_size(Size { width: D::Percent(1.0), height: D::Auto })
217                .build(&ui.layout)?;
218            
219            return Ok(ui);
220        }
Source

pub fn build(self, out: &mut ListBox<D>) -> Result<(), NwgError>

Examples found in repository?
examples/partials.rs (line 146)
132        fn build_ui(mut data: PartialDemo) -> Result<Rc<PartialDemoUi>, nwg::NwgError> {
133            use nwg::Event as E;
134            
135            // Controls
136            nwg::Window::builder()
137                .size((500, 400))
138                .position((300, 300))
139                .title("Many UI")
140                .build(&mut data.window)?;
141
142            nwg::ListBox::builder()
143                .collection(vec!["People", "Animals", "Food"])
144                .focus(true)
145                .parent(&data.window)
146                .build(&mut data.menu)?;
147
148            nwg::Frame::builder()
149                .parent(&data.window)
150                .build(&mut data.frame1)?;
151
152            nwg::Frame::builder()
153                .flags(nwg::FrameFlags::BORDER)
154                .parent(&data.window)
155                .build(&mut data.frame2)?;
156
157            nwg::Frame::builder()
158                .flags(nwg::FrameFlags::BORDER)
159                .parent(&data.window)
160                .build(&mut data.frame3)?;
161
162            // Partials
163            PeopleUi::build_partial(&mut data.people_ui, Some(&data.frame1))?;
164            AnimalUi::build_partial(&mut data.animal_ui, Some(&data.frame2))?;
165            FoodUi::build_partial(&mut data.food_ui, Some(&data.frame3))?;
166
167            // Wrap-up
168            let ui = Rc::new(PartialDemoUi {
169                inner: data,
170                default_handler: Default::default()
171            });
172
173            // Events
174            let mut window_handles = vec![&ui.window.handle];
175            window_handles.append(&mut ui.people_ui.handles());
176            window_handles.append(&mut ui.animal_ui.handles());
177            window_handles.append(&mut ui.food_ui.handles());
178
179            for handle in window_handles.iter() {
180                let evt_ui = ui.clone();
181                let handle_events = move |evt, evt_data, handle| {
182                    evt_ui.people_ui.process_event(evt, &evt_data, handle);
183                    evt_ui.animal_ui.process_event(evt, &evt_data, handle);
184                    evt_ui.food_ui.process_event(evt, &evt_data, handle);
185                    
186                    match evt {
187                        E::OnListBoxSelect => 
188                            if &handle == &evt_ui.menu {
189                                PartialDemo::change_interface(&evt_ui.inner);
190                            },
191                        E::OnWindowClose => 
192                            if &handle == &evt_ui.window {
193                                PartialDemo::exit(&evt_ui.inner);
194                            },
195                        E::OnButtonClick => 
196                            if &handle == &evt_ui.people_ui.save_btn || &handle == &evt_ui.animal_ui.save_btn ||&handle == &evt_ui.food_ui.save_btn  {
197                                PartialDemo::save(&evt_ui.inner);
198                            },
199                        _ => {}
200                    }
201                };
202
203                ui.default_handler.borrow_mut().push(
204                    nwg::full_bind_event_handler(handle, handle_events)
205                );
206            }
207
208            // Layout
209            use nwg::stretch::{geometry::Size, style::Dimension as D};
210
211           nwg::FlexboxLayout::builder()
212                .parent(&ui.window)
213                .child(&ui.menu)
214                    .child_size(Size { width: D::Percent(0.3), height: D::Auto })
215                .child(&ui.frame1)
216                    .child_size(Size { width: D::Percent(1.0), height: D::Auto })
217                .build(&ui.layout)?;
218            
219            return Ok(ui);
220        }

Auto Trait Implementations§

§

impl<'a, D> Freeze for ListBoxBuilder<'a, D>

§

impl<'a, D> RefUnwindSafe for ListBoxBuilder<'a, D>
where D: RefUnwindSafe,

§

impl<'a, D> !Send for ListBoxBuilder<'a, D>

§

impl<'a, D> !Sync for ListBoxBuilder<'a, D>

§

impl<'a, D> Unpin for ListBoxBuilder<'a, D>
where D: Unpin,

§

impl<'a, D> UnwindSafe for ListBoxBuilder<'a, D>
where D: UnwindSafe,

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> 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<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.