winsafe\gdi/
enums.rs

1use crate::co;
2use crate::decl::*;
3use crate::kernel::privs::*;
4
5/// Variant parameter for:
6///
7/// * [`HDC::GetCurrentObject`](crate::HDC::GetCurrentObject)
8///
9/// The enum values match those in [`co::CUR_OBJ`](crate::co::CUR_OBJ) constant
10/// type.
11pub enum CurObj {
12	Bitmap(HBITMAP),
13	Brush(HBRUSH),
14	Font(HFONT),
15	Pal(HPALETTE),
16	Pen(HPEN),
17}
18
19/// Variant parameter for:
20///
21/// * [`HINSTANCE::LoadImageBitmap`](crate::HINSTANCE::LoadImageBitmap)
22#[derive(Clone)]
23pub enum IdObmStr {
24	/// A resource ID.
25	Id(u16),
26	/// A [`co::OBM`](crate::co::OBM) constant for an OEM bitmap.
27	Obm(co::OBM),
28	/// A resource string identifier or file path.
29	Str(WString),
30}
31
32impl IdObmStr {
33	/// Constructs the enum directly from a string.
34	#[must_use]
35	pub fn from_str(v: &str) -> Self {
36		Self::Str(WString::from_str(v))
37	}
38
39	/// Returns a pointer to the raw data content, or null if no content.
40	#[must_use]
41	pub fn as_ptr(&self) -> *const u16 {
42		match self {
43			Self::Id(id) => MAKEINTRESOURCE(*id as _),
44			Self::Obm(obm) => MAKEINTRESOURCE(obm.raw() as _),
45			Self::Str(ws) => ws.as_ptr(),
46		}
47	}
48}
49
50/// Variant parameter for:
51///
52/// * [`HINSTANCE::LoadImageCursor`](crate::HINSTANCE::LoadImageCursor)
53#[derive(Clone)]
54pub enum IdOcrStr {
55	/// A resource ID.
56	Id(u16),
57	/// A [`co::OCR`](crate::co::OCR) constant for an OEM cursor.
58	Ocr(co::OCR),
59	/// A resource string identifier or file path.
60	Str(WString),
61}
62
63impl IdOcrStr {
64	/// Constructs the enum directly from a string.
65	#[must_use]
66	pub fn from_str(v: &str) -> Self {
67		Self::Str(WString::from_str(v))
68	}
69
70	/// Returns a pointer to the raw data content, or null if no content.
71	#[must_use]
72	pub fn as_ptr(&self) -> *const u16 {
73		match self {
74			Self::Id(id) => MAKEINTRESOURCE(*id as _),
75			Self::Ocr(ocr) => MAKEINTRESOURCE(ocr.raw() as _),
76			Self::Str(ws) => ws.as_ptr(),
77		}
78	}
79}
80
81/// Variant parameter for:
82///
83/// * [`HINSTANCE::LoadImageIcon`](crate::HINSTANCE::LoadImageIcon)
84#[derive(Clone)]
85pub enum IdOicStr {
86	/// A resource ID.
87	Id(u16),
88	/// A [`co::OIC`](crate::co::OIC) constant for an OEM icon.
89	Oic(co::OIC),
90	/// A resource string identifier or file path.
91	Str(WString),
92}
93
94impl IdOicStr {
95	/// Constructs the enum directly from a string.
96	#[must_use]
97	pub fn from_str(v: &str) -> Self {
98		Self::Str(WString::from_str(v))
99	}
100
101	/// Returns a pointer to the raw data content, or null if no content.
102	#[must_use]
103	pub fn as_ptr(&self) -> *const u16 {
104		match self {
105			Self::Id(id) => MAKEINTRESOURCE(*id as _),
106			Self::Oic(oic) => MAKEINTRESOURCE(oic.raw() as _),
107			Self::Str(ws) => ws.as_ptr(),
108		}
109	}
110}