Struct rustty_oxide::Label
[−]
[src]
pub struct Label { /* fields omitted */ }
Display text to widgets
Examples
use oxide::core::{VerticalAlign, HorizontalAlign, Widget}; use oxide::{Dialog, Label}; let mut maindlg = Dialog::new(60, 10); let mut label = Label::from_str("Hi, this is an example!"); label.pack(&maindlg, HorizontalAlign::Middle, VerticalAlign::Middle, (0,0)); maindlg.add_label(label); maindlg.draw_box();
Methods
impl Label
[src]
fn new(cols: usize, rows: usize) -> Label
[src]
Construct a new Label widget cols
wide by rols
high. Initial text is empty
and left aligned
Examples
use oxide::Label; let mut label = Label::new(60, 10);
fn from_str<S: Into<String>>(s: S) -> Label
[src]
Construct a new label widget from an existing string s. s can either be a
&str
or String
, and a label will be constructed that is the size of the
length of characters in s. Text is left aligned by default
Examples
use oxide::Label; let mut label1 = Label::from_str("This is a label"); // label is size (15x1) let s = "Here's another label".to_string(); let mut label2 = Label::from_str(s); // label is size (20x1)
fn from_str_ref(s: &str) -> Label
[src]
Construct a new label widget from an existing string s. s can either be a
&str
or String
, and a label will be constructed that is the size of the
length of characters in s. Text is left aligned by default
Examples
use oxide::Label; let mut label1 = Label::from_str("This is a label"); // label is size (15x1) let s = "Here's another label".to_string(); let mut label2 = Label::from_str(s); // label is size (20x1)
fn align_text(
&mut self,
halign: HorizontalAlign,
valign: VerticalAlign,
margin: (usize, usize)
)
[src]
&mut self,
halign: HorizontalAlign,
valign: VerticalAlign,
margin: (usize, usize)
)
Specify a custom alignment for the text within the widget. Each line drawn within the label will adhere to the alignments passed for the text. *note that text alignment is with respect to the label
Examples
use oxide::core::{HorizontalAlign, VerticalAlign}; use oxide::Label; let mut label = Label::new(20, 3); label.set_text("Centered"); label.align_text(HorizontalAlign::Middle, VerticalAlign::Middle, (0,0));
fn set_text<S: Into<String>>(&mut self, new_str: S)
[src]
Set the text of the widget to the passed &str
or String
. If the
widget does not have enough room to display the new text, the label
will only show the truncated text. resize() must be called to extend
the size of the label.
Examples
use rustty::HasSize; use oxide::core::Widget; use oxide::Label; let mut label1 = Label::new(20, 3); label1.set_text("Initial text");
Trait Implementations
impl Widget for Label
[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