#![allow(non_snake_case)]
use crate::co;
use crate::decl::*;
use crate::kernel::privs::*;
pub enum AccelMenuCtrl {
Accel(u16),
Menu(u16),
Ctrl { notif_code: co::CMD, ctrl_id: u16, ctrl_hwnd: HWND },
}
impl AccelMenuCtrl {
#[must_use]
pub const fn ctrl_id(&self) -> u16 {
use AccelMenuCtrl::*;
match self {
Accel(id) => *id,
Menu(id) => *id,
Ctrl { notif_code: _, ctrl_id, ctrl_hwnd: _ } => *ctrl_id,
}
}
#[must_use]
pub const fn code(&self) -> co::CMD {
use AccelMenuCtrl::*;
match self {
Accel(_) => co::CMD::Accel,
Menu(_) => co::CMD::Menu,
Ctrl { notif_code, ctrl_id: _, ctrl_hwnd: _ } => *notif_code,
}
}
}
#[derive(Clone)]
pub enum AtomStr {
Atom(ATOM),
Str(WString),
}
impl AtomStr {
#[must_use]
pub fn from_str(v: &str) -> Self {
Self::Str(WString::from_str(v))
}
#[must_use]
pub fn as_ptr(&self) -> *const u16 {
use AtomStr::*;
match self {
Atom(atom) => MAKEINTRESOURCE(u16::from(*atom) as _),
Str(ws) => ws.as_ptr(),
}
}
}
pub enum BmpIcon {
Bmp(HBITMAP),
Icon(HICON),
}
impl BmpIcon {
#[must_use]
pub fn as_isize(&self) -> isize {
unsafe {
use BmpIcon::*;
std::mem::transmute(match self {
Bmp(hbmp) => hbmp.ptr(),
Icon(hicon) => hicon.ptr(),
})
}
}
}
pub enum BmpPtrStr {
Bmp(HBITMAP),
Ptr(*const std::ffi::c_void),
Str(WString),
None,
}
impl BmpPtrStr {
#[must_use]
pub fn from_str(v: &str) -> Self {
Self::Str(WString::from_str(v))
}
#[must_use]
pub fn as_ptr(&self) -> *const u16 {
use BmpPtrStr::*;
match self {
Bmp(hbmp) => hbmp.ptr() as _,
Ptr(lp) => *lp as _,
Str(ws) => ws.as_ptr(),
None => std::ptr::null(),
}
}
}
#[derive(Clone, Copy)]
pub enum DispfNup {
Dispf(co::DMDISPLAYFLAGS),
Nup(co::DMNUP),
}
#[derive(Clone, Copy)]
pub enum GmidxEnum {
Gmidx(u32),
Enum(co::ENUM_SETTINGS),
}
impl From<GmidxEnum> for u32 {
fn from(v: GmidxEnum) -> Self {
use GmidxEnum::*;
match v {
Gmidx(idx) => idx,
Enum(es) => es.raw(),
}
}
}
#[derive(Clone, Copy)]
pub enum HwKbMouse {
Hw(HARDWAREINPUT),
Kb(KEYBDINPUT),
Mouse(MOUSEINPUT),
}
pub enum HwndFocus {
Hwnd(HWND),
FocusNext(bool),
}
pub enum HwndHmenu {
Hwnd(HWND),
Hmenu(HMENU),
}
impl HwndHmenu {
#[must_use]
pub fn as_isize(&self) -> isize {
use HwndHmenu::*;
match self {
Hwnd(hwnd) => hwnd.ptr() as _,
Hmenu(hmenu) => hmenu.ptr() as _,
}
}
}
pub enum HwndPlace {
Hwnd(HWND),
Place(co::HWND_PLACE),
None,
}
impl HwndPlace {
#[must_use]
pub fn as_ptr(&self) -> *mut std::ffi::c_void {
use HwndPlace::*;
match self {
Hwnd(hwnd) => hwnd.ptr(),
Place(v) => v.raw() as _,
None => std::ptr::null_mut(),
}
}
}
pub enum HwndPointId {
Hwnd(HWND),
Point(POINT),
Id(u16),
}
impl HwndPointId {
#[must_use]
pub fn as_isize(&self) -> isize {
use HwndPointId::*;
match self {
Hwnd(hwnd) => hwnd.ptr() as _,
Point(pt) => u32::from(*pt) as _,
Id(id) => *id as _,
}
}
}
#[derive(Clone)]
pub enum IdIdcStr {
Id(u16),
Idc(co::IDC),
Str(WString),
}
impl IdIdcStr {
#[must_use]
pub fn from_str(v: &str) -> Self {
Self::Str(WString::from_str(v))
}
#[must_use]
pub fn as_ptr(&self) -> *const u16 {
use IdIdcStr::*;
match self {
Id(id) => MAKEINTRESOURCE(*id as _),
Idc(idc) => MAKEINTRESOURCE(idc.raw() as _),
Str(ws) => ws.as_ptr(),
}
}
}
#[derive(Clone)]
pub enum IdIdiStr {
Id(u16),
Idi(co::IDI),
Str(WString),
}
impl IdIdiStr {
#[must_use]
pub fn from_str(v: &str) -> Self {
Self::Str(WString::from_str(v))
}
#[must_use]
pub fn as_ptr(&self) -> *const u16 {
use IdIdiStr::*;
match self {
Id(id) => MAKEINTRESOURCE(*id as _),
Idi(idi) => MAKEINTRESOURCE(idi.raw() as _),
Str(ws) => ws.as_ptr(),
}
}
}
pub enum IdMenu<'a> {
Id(u16),
Menu(&'a HMENU),
None,
}
impl<'a> IdMenu<'a> {
#[must_use]
pub const fn as_ptr(&self) -> *mut std::ffi::c_void {
use IdMenu::*;
match self {
Id(id) => *id as _,
Menu(hMenu) => hMenu.ptr(),
None => std::ptr::null_mut(),
}
}
#[must_use]
pub fn as_usize(&self) -> usize {
use IdMenu::*;
match self {
Id(id) => *id as _,
Menu(hMenu) => hMenu.ptr() as _,
None => 0,
}
}
}
#[derive(Clone, Copy)]
pub enum IdPos {
Id(u16),
Pos(u32),
}
impl IdPos {
#[must_use]
pub const fn is_by_pos(self) -> bool {
use IdPos::*;
match self {
Id(_) => false,
Pos(_) => true,
}
}
#[must_use]
pub const fn id_or_pos_u32(self) -> u32 {
use IdPos::*;
match self {
Id(id) => id as _,
Pos(pos) => pos,
}
}
#[must_use]
pub const fn mf_flag(self) -> co::MF {
use IdPos::*;
match self {
Id(_) => co::MF::BYCOMMAND,
Pos(_) => co::MF::BYPOSITION,
}
}
}
pub enum MenuItem<'a> {
Entry { cmd_id: u16, text: &'a str },
Separator,
Submenu { submenu: &'a HMENU, text: &'a str },
}
pub enum MenuItemInfo {
Entry { cmd_id: u16, text: String },
Separator,
Submenu { submenu: HMENU, text: String },
}
pub enum NccspRect<'a, 'b> {
Nccsp(&'b mut NCCALCSIZE_PARAMS<'a>),
Rect(&'b mut RECT),
}
pub enum PtsRc<'a> {
Pts(&'a mut [POINT]),
Rc(&'a mut RECT),
}
pub enum SuccessTimeout {
Success,
Timeout,
}