Struct CheckButton

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

Implementations§

Source§

impl CheckButton

A simple check button that manages an internal state which determines if the button is to be checked or not. The actual checking is handled by the user during an event loop.

§Examples

use oxide::core::{HorizontalAlign, VerticalAlign, ButtonResult, Widget, Button};
use oxide::{Dialog, CheckButton};

let mut dlg = Dialog::new(60, 10);

let mut b1 = CheckButton::new("Foo", 'f', ButtonResult::Ok);
b1.pack(&dlg, HorizontalAlign::Left, VerticalAlign::Bottom, (1,1));
// Change the initial state of the button to checked
b1.pressed();

dlg.add_button(b1);

// Now switch the state of the button bound to Ok, which unchecks b1
dlg.button_pressed(ButtonResult::Ok);
Source

pub fn new(text: &str, accel: char, result: ButtonResult) -> CheckButton

Constructs a new CheckButton, asking for the text to be displayed by the button, the key to map to, and the result returned when the key is detected.

§Examples
use oxide::core::ButtonResult;
use oxide::CheckButton;

let mut b1 = CheckButton::new("Foo", 'f', ButtonResult::Ok);

Trait Implementations§

Source§

impl Button for CheckButton

Source§

fn accel(&self) -> char

Return the char that is acting as the key in the Button
Source§

fn result(&self) -> ButtonResult

Return the ButtonResult which would be returned if the key is detected
Source§

fn pressed(&mut self)

If a button is to do some special action upon being pressed, then this function will do so. StdButton for example does nothing when pressed, while CheckButton changes it’s ballot
Source§

fn state(&self) -> bool

If a button has a state involved, e.g. needs to keep track of a certain event, this function will return the state of the button.
Source§

impl Widget for CheckButton

Source§

fn draw(&mut self, parent: &mut dyn CellAccessor)

Draws the widget to the valid CellAccessor passed
Source§

fn pack( &mut self, parent: &dyn HasSize, halign: HorizontalAlign, valign: VerticalAlign, margin: (usize, usize), )

Aligns the widget with the parent as reference
Source§

fn draw_box(&mut self)

Expose the painter trait draw_box for all widgets, which outlines the space enclosed within the widget
Source§

fn resize(&mut self, new_size: Size)

Resize the given widget to new dimensions given by Size
Source§

fn frame(&self) -> &Frame

Return a reference the renderer, Base in general cases
Source§

fn frame_mut(&mut self) -> &mut Frame

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

Auto Trait Implementations§

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.