1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
use widget_prelude::*;
use std::ffi::CString;
use std::ptr;
pub struct Label(IUPPtr);
impl Label {
    
    pub fn new<S: Into<String>>(text: S) -> Label {
        let c_text = CString::new(text.into()).unwrap();
         unsafe {
            let ptr = ::iup_sys::IupLabel(c_text.as_ptr());
            Self::from_ptr(ptr)
        }
    }
    
    pub fn new_empty() -> Label {
        unsafe { 
            let ptr = ::iup_sys::IupLabel(ptr::null());
            Self::from_ptr(ptr)       
        }
    }
    
    
    
    
    pub fn set_text(self, text: &str) -> Self {
        self.set_str_attribute(::attrs::TITLE, text);
        self
    }
    
    pub fn get_text(&self) -> WidgetStr {
        self.get_str_attribute(::attrs::TITLE)
            .expect("This widget should have a text pointer even if it's empty!")
    }
}
impl_widget! { Label, "label" }
impl ::image::ImageContainer for Label {}
pub struct TextBox(IUPPtr);
impl TextBox {
    
    pub fn new() -> TextBox {
        unsafe {
            let ptr = ::iup_sys::IupText(ptr::null());
            Self::from_ptr(ptr)
        }
    }
    
    
    
    
    
    pub fn set_multiline(self, multiline: bool) -> Self {
        self.set_bool_attribute(::attrs::MULTILINE, multiline);
        self
    }
    
    
    
    
    pub fn set_visible_columns(self, cols: u32) -> Self {
        self.set_int_attribute(::attrs::VISIBLE_COLUMNS, cols as i32);
        self
    }
    
    
    
    
    pub fn set_visible_lines(self, lines: u32) ->  Self {
        self.set_int_attribute(::attrs::VISIBLE_LINES, lines as i32);
        self
    }
    
    
    
    
    pub fn set_text(self, value: &str) -> Self {
        self.set_str_attribute(::attrs::VALUE, value);
        self
    }
    
    pub fn get_text(&self) -> WidgetStr {
        self.get_str_attribute(::attrs::VALUE)
            .expect("This string should be present even if it's empty!")
    }    
}
impl_widget! { TextBox, "text" }
impl_on_value_change! { TextBox }