use crate::co;
use crate::decl::*;
use crate::kernel::privs::*;
use crate::msg::*;
use crate::prelude::*;
use crate::user::privs::*;
pub struct HdmClearFilter {
pub filter: Option<u32>,
}
impl MsgSend for HdmClearFilter {
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::HDM::CLEARFILTER.into(),
wparam: self.filter.map_or(-1, |f| f as i32) as _,
lparam: 0,
}
}
}
pub struct HdmCreateDragImage {
pub index: u32,
}
impl MsgSend for HdmCreateDragImage {
type RetType = SysResult<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|p| unsafe { HIMAGELIST::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::HDM::CREATEDRAGIMAGE.into(),
wparam: self.index as _,
lparam: 0,
}
}
}
pub struct HdmDeleteItem {
pub index: u32,
}
impl MsgSend for HdmDeleteItem {
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::HDM::DELETEITEM.into(),
wparam: self.index as _,
lparam: 0,
}
}
}
pub struct HdmEditFilter {
pub index: u32,
pub discard_changes: bool,
}
impl MsgSend for HdmEditFilter {
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::HDM::EDITFILTER.into(),
wparam: self.index as _,
lparam: self.discard_changes as _,
}
}
}
pub struct HdmGetBitmapMargin {}
impl MsgSend for HdmGetBitmapMargin {
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::HDM::GETBITMAPMARGIN.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct HdmGetFocusedItem {}
impl MsgSend for HdmGetFocusedItem {
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::HDM::GETFOCUSEDITEM.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct HdmGetImageList {
pub kind: co::HDSIL,
}
impl MsgSend for HdmGetImageList {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HIMAGELIST::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::HDM::GETIMAGELIST.into(),
wparam: self.kind.raw() as _,
lparam: 0,
}
}
}
pub struct HdmGetItem<'a, 'b> {
pub index: u32,
pub hditem: &'b mut HDITEM<'a>,
}
impl<'a, 'b> MsgSend for HdmGetItem<'a, 'b> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
() }
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::HDM::GETITEM.into(),
wparam: self.index as _,
lparam: self.hditem as *mut _ as _,
}
}
}
pub struct HdmGetItemCount {}
impl MsgSend for HdmGetItemCount {
type RetType = SysResult<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::HDM::GETITEMCOUNT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct HdmGetItemDropDownRect<'a> {
pub index: u32,
pub rect: &'a mut RECT,
}
impl<'a> MsgSend for HdmGetItemDropDownRect<'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::HDM::GETITEMDROPDOWNRECT.into(),
wparam: self.index as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct HdmGetItemRect<'a> {
pub index: u32,
pub rect: &'a mut RECT,
}
impl<'a> MsgSend for HdmGetItemRect<'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::HDM::GETITEMRECT.into(),
wparam: self.index as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct HdmGetOrderArray<'a> {
pub buffer: &'a mut [u32],
}
impl<'a> MsgSend for HdmGetOrderArray<'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::HDM::GETORDERARRAY.into(),
wparam: self.buffer.len(),
lparam: self.buffer.as_mut_ptr() as _,
}
}
}
pub struct HdmGetOverflowRect<'a> {
pub rect: &'a mut RECT,
}
impl<'a> MsgSend for HdmGetOverflowRect<'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::HDM::GETOVERFLOWRECT.into(),
wparam: 0,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct HdmGetUnicodeFormat {}
impl MsgSend for HdmGetUnicodeFormat {
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::HDM::GETUNICODEFORMAT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct HdmHitTest<'a> {
pub test_info: &'a mut HDHITTESTINFO,
}
impl<'a> MsgSend for HdmHitTest<'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::HDM::HITTEST.into(),
wparam: 0,
lparam: self.test_info as *mut _ as _,
}
}
}
pub struct HdmInsertItem<'a, 'b> {
pub index_after: u32,
pub item: &'b HDITEM<'a>,
}
impl<'a, 'b> MsgSend for HdmInsertItem<'a, 'b> {
type RetType = SysResult<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::HDM::INSERTITEM.into(),
wparam: self.index_after as _,
lparam: self.item as *const _ as _,
}
}
}
pub struct HdmLayout<'a, 'b, 'c> {
pub hdlayout: &'c mut HDLAYOUT<'a, 'b>,
}
impl<'a, 'b, 'c> MsgSend for HdmLayout<'a, 'b, 'c> {
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::HDM::LAYOUT.into(),
wparam: 0,
lparam: self.hdlayout as *mut _ as _,
}
}
}
pub struct HdmOrderToIndex {
pub order: u32,
}
impl MsgSend for HdmOrderToIndex {
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::HDM::ORDERTOINDEX.into(),
wparam: self.order as _,
lparam: 0,
}
}
}
pub struct HdmSetBitmapMargin {
pub width: u32,
}
impl MsgSend for HdmSetBitmapMargin {
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::HDM::SETBITMAPMARGIN.into(),
wparam: self.width as _,
lparam: 0,
}
}
}
pub struct HdmSetFilterChangeTimeout {
pub timeout_ms: u32,
}
impl MsgSend for HdmSetFilterChangeTimeout {
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::HDM::SETFILTERCHANGETIMEOUT.into(),
wparam: self.timeout_ms as _,
lparam: 0,
}
}
}
pub struct HdmSetFocusedItem {
pub index: u32,
}
impl MsgSend for HdmSetFocusedItem {
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::HDM::SETFILTERCHANGETIMEOUT.into(),
wparam: 0,
lparam: self.index as _,
}
}
}
pub struct HdmSetHotDivider {
pub value: PtIdx,
}
impl MsgSend for HdmSetHotDivider {
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::HDM::SETHOTDIVIDER.into(),
wparam: match self.value {
PtIdx::Pt(_) => true,
PtIdx::Idx(_) => false,
} as _,
lparam: match self.value {
PtIdx::Pt(pt) => pt.into(),
PtIdx::Idx(idx) => idx,
} as _,
}
}
}
pub struct HdmSetImageList {
pub kind: co::HDSIL,
pub himagelist: Option<HIMAGELIST>,
}
impl MsgSend for HdmSetImageList {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HIMAGELIST::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::HDM::SETIMAGELIST.into(),
wparam: self.kind.raw() as _,
lparam: self.himagelist.as_ref().map_or(0, |h| h.ptr() as _),
}
}
}
pub struct HdmSetItem<'a, 'b> {
pub index: u32,
pub hditem: &'b HDITEM<'a>,
}
impl<'a, 'b> MsgSend for HdmSetItem<'a, 'b> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
() }
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::HDM::SETITEM.into(),
wparam: self.index as _,
lparam: self.hditem as *const _ as _,
}
}
}
pub struct HdmSetOrderArray<'a> {
pub buffer: &'a [u32],
}
impl<'a> MsgSend for HdmSetOrderArray<'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::HDM::SETORDERARRAY.into(),
wparam: self.buffer.len(),
lparam: vec_ptr(self.buffer) as _,
}
}
}
pub struct HdmSetUnicodeFormat {
pub use_unicode: bool,
}
impl MsgSend for HdmSetUnicodeFormat {
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::HDM::SETUNICODEFORMAT.into(),
wparam: self.use_unicode as _,
lparam: 0,
}
}
}