use crate::co;
use crate::decl::*;
use crate::kernel::privs::*;
use crate::msg::*;
use crate::prelude::*;
use crate::user::privs::*;
pub struct UdmGetAccel<'a> {
pub info: &'a mut [UDACCEL],
}
impl<'a> MsgSend for UdmGetAccel<'a> {
type RetType = u32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::GETACCEL.into(),
wparam: self.info.len(),
lparam: self.info.as_mut_ptr() as _,
}
}
}
pub struct UdmGetBase {}
impl MsgSend for UdmGetBase {
type RetType = u8;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::GETBASE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct UdmGetBuddy {}
impl MsgSend for UdmGetBuddy {
type RetType = Option<HWND>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HWND::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::GETBUDDY.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct UdmGetPos {}
impl MsgSend for UdmGetPos {
type RetType = SysResult<i16>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
match HIWORD(v as _) {
0 => Ok(LOWORD(v as _) as _),
_ => Err(co::ERROR::BAD_ARGUMENTS),
}
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::GETPOS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct UdmGetPos32<'a> {
pub success_flag: Option<&'a mut i32>,
}
impl<'a> MsgSend for UdmGetPos32<'a> {
type RetType = i32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::GETPOS32.into(),
wparam: 0,
lparam: self.success_flag.as_mut().map_or(0, |f| f as *mut _ as _),
}
}
}
pub struct UdmGetRange {}
impl MsgSend for UdmGetRange {
type RetType = (i16, i16);
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
(LOWORD(v as _) as _, HIWORD(v as _) as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::GETRANGE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct UdmGetRange32<'a, 'b> {
pub min: &'a mut i32,
pub max: &'b mut i32,
}
impl<'a, 'b> MsgSend for UdmGetRange32<'a, 'b> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::GETRANGE32.into(),
wparam: self.min as *mut _ as _,
lparam: self.max as *mut _ as _,
}
}
}
pub struct UdmGetUnicodeFormat {}
impl MsgSend for UdmGetUnicodeFormat {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::GETUNICODEFORMAT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct UdmSetAccel<'a> {
pub info: &'a [UDACCEL],
}
impl<'a> MsgSend for UdmSetAccel<'a> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::SETACCEL.into(),
wparam: self.info.len(),
lparam: vec_ptr(self.info) as _,
}
}
}
pub struct UdmSetBase {
pub base: u8,
}
impl MsgSend for UdmSetBase {
type RetType = SysResult<u8>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::SETBASE.into(),
wparam: self.base as _,
lparam: 0,
}
}
}
pub struct UdmSetBuddy<'a> {
pub hbuddy: &'a HWND,
}
impl<'a> MsgSend for UdmSetBuddy<'a> {
type RetType = Option<HWND>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HWND::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::SETBUDDY.into(),
wparam: self.hbuddy.ptr() as _,
lparam: 0,
}
}
}
pub struct UdmSetPos {
pub pos: i16,
}
impl MsgSend for UdmSetPos {
type RetType = i16;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::SETPOS.into(),
wparam: 0,
lparam: self.pos as _,
}
}
}
pub struct UdmSetPos32 {
pub pos: i32,
}
impl MsgSend for UdmSetPos32 {
type RetType = i32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::SETPOS32.into(),
wparam: 0,
lparam: self.pos as _,
}
}
}
pub struct UdmSetRange {
pub min: i16,
pub max: i16,
}
impl MsgSend for UdmSetRange {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::SETRANGE.into(),
wparam: 0,
lparam: MAKEDWORD(self.max as _, self.min as _) as _,
}
}
}
pub struct UdmSetRange32 {
pub min: i32,
pub max: i32,
}
impl MsgSend for UdmSetRange32 {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::SETRANGE32.into(),
wparam: self.min as _,
lparam: self.max as _,
}
}
}
pub struct UdmSetUnicodeFormat {
pub use_unicode: bool,
}
impl MsgSend for UdmSetUnicodeFormat {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::UDM::SETUNICODEFORMAT.into(),
wparam: self.use_unicode as _,
lparam: 0,
}
}
}