Struct rustty_oxide::Dialog
[−]
[src]
pub struct Dialog { /* fields omitted */ }
Pack labels, buttons and other widgets into dialogs
Examples
use oxide::core::{VerticalAlign, HorizontalAlign, ButtonResult, Widget}; use oxide::{Dialog, StdButton}; let mut maindlg = Dialog::new(60, 10); let mut b1 = StdButton::new("Quit", 'q', ButtonResult::Ok); b1.pack(&maindlg, HorizontalAlign::Left, VerticalAlign::Middle, (1,1)); maindlg.draw_box(); // draw to terminal // maindlg.draw(&mut term);
Methods
impl Dialog
[src]
fn new(cols: usize, rows: usize) -> Dialog
[src]
Construct a new Dialog widget cols
wide by rows
high.
Examples
use oxide::Dialog; let mut maindlg = Dialog::new(60, 10);
[src]
Add an existing widget that implements the Button trait.
Examples
use oxide::core::{Widget, ButtonResult, HorizontalAlign, VerticalAlign}; use oxide::{Dialog, StdButton}; let mut maindlg = Dialog::new(60, 10); let mut b1 = StdButton::new("Quit", 'q', ButtonResult::Ok); b1.pack(&maindlg, HorizontalAlign::Middle, VerticalAlign::Middle, (1,1)); maindlg.add_button(b1);
fn add_layout<T: Layout + 'static>(&mut self, layout: T)
[src]
Add an existing widget that implements the Layout trait. NEEDS A REWORK, the way of passing in a vector of buttons is ugly and a very bad API.
Examples
use oxide::core::{HorizontalAlign, VerticalAlign, ButtonResult, Button, Widget}; use oxide::{Dialog, StdButton, VerticalLayout}; let mut maindlg = Dialog::new(60, 10); let b1 = StdButton::new("Foo", 'f', ButtonResult::Ok); let b2 = StdButton::new("Bar", 'b', ButtonResult::Cancel); let vec = vec![b1, b2].into_iter().map(Box::new).map(|x| x as Box<Button>).collect(); let mut vlayout = VerticalLayout::from_vec(vec, 0); vlayout.pack(&maindlg, HorizontalAlign::Middle, VerticalAlign::Middle, (0,0)); maindlg.add_layout(vlayout);
fn add_label(&mut self, label: Label)
[src]
Add an existing label that contains some text.
Examples
use oxide::core::{HorizontalAlign, VerticalAlign, Widget}; use oxide::{Dialog, Label}; let mut maindlg = Dialog::new(60, 10); let mut lbl = Label::from_str("Foo"); lbl.pack(&maindlg, HorizontalAlign::Middle, VerticalAlign::Middle, (0,0)); maindlg.add_label(lbl);
[src]
Change the state of an existing CheckButton, if any exists, within the dialog. If an invalid button result is given, the function will panic. Note StdButtons are still valid handles for this function, however they will not actually do anything. This function is for buttons that perform some action upon being pressed.
Examples
// match character for dialog match dialog.result_for_key(ch) { Some(ButtonResult::Ok) => { dialog.button_pressed(ButtonResult::Custom(i)); // do stuff ... }, _ => { } }
[src]
For buttons that have a state manager, this function will return the current state of the button. CheckButton for example uses a state to manage whether the button is checked, different actions can be taken depending on the state once read.
Examples
// match character for dialog match dialog.result_for_key(ch) { Some(ButtonResult::Ok) => { dialog.button_pressed(ButtonResult::Custom(i)); if dialog.is_button_pressed(ButtonResult::Custom(i)) { // do ... } else { // do else ... } }, _ => { } }
fn result_for_key(&self, key: char) -> Option<ButtonResult>
[src]
Checks whether the char passed is a valid key for any buttons currently
drawn within the dialog, if so the corresponding ButtonResult
is returned
Trait Implementations
impl Widget for Dialog
[src]
fn draw(&mut self, parent: &mut CellAccessor)
[src]
Draws the widget to the valid CellAccessor
passed
fn pack(
&mut self,
parent: &HasSize,
halign: HorizontalAlign,
valign: VerticalAlign,
margin: (usize, usize)
)
[src]
&mut self,
parent: &HasSize,
halign: HorizontalAlign,
valign: VerticalAlign,
margin: (usize, usize)
)
Aligns the widget with the parent
as reference
fn draw_box(&mut self)
[src]
Expose the painter trait draw_box
for all widgets, which outlines the space enclosed within the widget Read more
fn resize(&mut self, new_size: Size)
[src]
Resize the given widget to new dimensions given by Size
fn frame(&self) -> &Frame
[src]
Return a reference the renderer, Base
in general cases
fn frame_mut(&mut self) -> &mut Frame
[src]
Return a mutable reference to the renderer, Base
in general cases