use objc::runtime::*;
use objc::*;
use super::PLYView;
use crate::foundation::NSAttributedString;
use crate::Raw;
pub struct PLYLabel {
pub(super) object: *mut Object,
}
impl PLYLabel {
pub fn new() -> PLYLabel {
unsafe {
let mut object: *mut Object = msg_send![class!(PLYLabel), alloc];
object = msg_send![object, init];
PLYLabel { object }
}
}
pub fn set_attributed_text(&mut self, string: &NSAttributedString) {
unsafe {
let _: () = msg_send![self.object, setAttributedText: string.as_raw()];
}
}
pub fn to_view(&self) -> PLYView {
unsafe { PLYView::from_raw_retain(self.object) }
}
}
impl Raw for PLYLabel {
unsafe fn from_raw(object: *mut Object) -> Self {
PLYLabel { object }
}
unsafe fn as_raw(&self) -> *mut Object {
self.object
}
}
impl Clone for PLYLabel {
fn clone(&self) -> Self {
unsafe { Self::from_raw_retain(self.as_raw()) }
}
}
impl Drop for PLYLabel {
fn drop(&mut self) {
unsafe { objc_release(self.object) }
}
}