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]

[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);

[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);

[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

Be careful when using this code, it's not being tested!
// 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

Be careful when using this code, it's not being tested!
// 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 ...
        }
    },
    _                       => { }
}

[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]

[src]

Draws the widget to the valid CellAccessor passed

[src]

Aligns the widget with the parent as reference

[src]

Expose the painter trait draw_box for all widgets, which outlines the space enclosed within the widget Read more

[src]

Resize the given widget to new dimensions given by Size

[src]

Return a reference the renderer, Base in general cases

[src]

Return a mutable reference to the renderer, Base in general cases

impl HasSize for Dialog
[src]

[src]