use crate::co;
use crate::decl::*;
use crate::gui::privs::*;
use crate::prelude::*;
pub trait GuiEventsPropSheetPage: GuiEventsParent {
fn psn_apply<F>(&self, func: F)
where
F: Fn() -> AnyResult<co::PSNRET> + 'static,
{
self.wm_notify(0u16, co::PSN::APPLY, move |_| Ok(func()?.raw() as _));
}
fn psn_get_object<F>(&self, func: F)
where
F: Fn(&NMOBJECTNOTIFY) -> AnyResult<()> + 'static,
{
let def_proc_val = self.wnd_ty().def_proc_val();
self.wm_notify(0u16, co::PSN::GETOBJECT, move |p| {
func(unsafe { p.cast_nmhdr_mut::<NMOBJECTNOTIFY>() })?;
Ok(def_proc_val)
});
}
fn psn_help<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<()> + 'static,
{
let def_proc_val = self.wnd_ty().def_proc_val();
self.wm_notify(0u16, co::PSN::HELP, move |p| {
func(unsafe { p.cast_nmhdr_mut::<PSHNOTIFY>() })?;
Ok(def_proc_val)
});
}
fn psn_kill_active<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<bool> + 'static,
{
self.wm_notify(0u16, co::PSN::KILLACTIVE, move |p| {
Ok(func(unsafe { p.cast_nmhdr::<PSHNOTIFY>() })? as _)
});
}
fn psn_query_cancel<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<bool> + 'static,
{
self.wm_notify(0u16, co::PSN::QUERYCANCEL, move |p| {
Ok(func(unsafe { p.cast_nmhdr::<PSHNOTIFY>() })? as _)
});
}
fn psn_query_initial_focus<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<Option<HWND>> + 'static,
{
self.wm_notify(0u16, co::PSN::QUERYINITIALFOCUS, move |p| {
Ok(func(unsafe { p.cast_nmhdr::<PSHNOTIFY>() })?.map_or(0, |h| h.ptr() as _))
});
}
fn psn_reset<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<()> + 'static,
{
let def_proc_val = self.wnd_ty().def_proc_val();
self.wm_notify(0u16, co::PSN::RESET, move |p| {
func(unsafe { p.cast_nmhdr_mut::<PSHNOTIFY>() })?;
Ok(def_proc_val)
});
}
fn psn_set_active<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<i32> + 'static,
{
self.wm_notify(0u16, co::PSN::SETACTIVE, move |p| {
Ok(func(unsafe { p.cast_nmhdr::<PSHNOTIFY>() })? as _)
});
}
fn psn_translate_accelerator<F>(&self, func: F)
where
F: Fn() -> AnyResult<co::PSNRET> + 'static,
{
self.wm_notify(0u16, co::PSN::TRANSLATEACCELERATOR, move |_| Ok(func()?.raw() as _));
}
fn psn_wiz_back<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<i32> + 'static,
{
self.wm_notify(0u16, co::PSN::WIZBACK, move |p| {
Ok(func(unsafe { p.cast_nmhdr::<PSHNOTIFY>() })? as _)
});
}
fn psn_wiz_finish<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<bool> + 'static,
{
self.wm_notify(0u16, co::PSN::WIZFINISH, move |p| {
Ok(func(unsafe { p.cast_nmhdr::<PSHNOTIFY>() })? as _)
});
}
fn psn_wiz_next<F>(&self, func: F)
where
F: Fn(&PSHNOTIFY) -> AnyResult<i32> + 'static,
{
self.wm_notify(0u16, co::PSN::WIZNEXT, move |p| {
Ok(func(unsafe { p.cast_nmhdr::<PSHNOTIFY>() })? as _)
});
}
}
impl GuiEventsPropSheetPage for BaseWndEvents {}