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
use iup_sys;
use std::ptr;
use std::ffi::CString;
use Element;
pub struct Toggle(*mut iup_sys::Ihandle);
impl Toggle {
pub fn new() -> Toggle {
unsafe { Toggle::from_raw(iup_sys::IupToggle(ptr::null_mut(), ptr::null_mut())) }
}
pub fn with_title<S: Into<String>>(title: S) -> Toggle {
let ctitle = CString::new(title.into()).unwrap();
unsafe { Toggle::from_raw(iup_sys::IupToggle(ctitle.as_ptr(), ptr::null_mut())) }
}
}
impl_widget!(Toggle, "toggle");
impl ::callback::MapCb for Toggle {}
impl ::callback::UnmapCb for Toggle {}
impl ::callback::GetFocusCb for Toggle {}
impl ::callback::KillFocusCb for Toggle {}
impl ::callback::EnterWindowCb for Toggle {}
impl ::callback::LeaveWindowCb for Toggle {}
impl ::callback::HelpCb for Toggle {}
impl ::callback::ValueChangedCb for Toggle {}
impl self::ToggleAction for Toggle {}
impl_callback! {
#[doc="Action generated when the toggle's state (on/off) was changed."]
#[doc=""]
#[doc="The callback boolean parameter represents the state the toggle was switched to."]
#[doc=""]
#[doc="`CallbackReturn::Close` will be processed"]
pub trait ToggleAction where Self: Element {
let name = "ACTION";
extern fn listener(ih: *mut iup_sys::Ihandle, state: c_int) -> CallbackReturn;
fn set_action<F: Callback(Self, bool)>(&mut self, cb: F) -> Self;
fn remove_action(&mut self) -> Option<Box<_>>;
}
}