1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::guard::*;
6use crate::kernel::privs::*;
7use crate::ole::privs::*;
8use crate::prelude::*;
9use crate::uxtheme::ffi;
10
11handle! { HTHEME;
12 }
15
16impl HTHEME {
17 pub fn DrawThemeBackground(
20 &self,
21 hdc: &HDC,
22 part_state: co::VS,
23 rc: RECT,
24 rc_clip: Option<RECT>,
25 ) -> HrResult<()> {
26 ok_to_hrresult(unsafe {
27 ffi::DrawThemeBackground(
28 self.ptr(),
29 hdc.ptr(),
30 part_state.part,
31 part_state.state,
32 pcvoid(&rc),
33 pcvoid_or_null(rc_clip.as_ref()),
34 )
35 })
36 }
37
38 #[must_use]
41 pub fn GetThemeAppProperties() -> co::STAP {
42 unsafe { co::STAP::from_raw(ffi::GetThemeAppProperties()) }
43 }
44
45 #[must_use]
48 pub fn GetThemeBackgroundContentRect(
49 &self,
50 hdc: &HDC,
51 part_state: co::VS,
52 bounds: RECT,
53 ) -> HrResult<RECT> {
54 let mut rc_content = RECT::default();
55 ok_to_hrresult(unsafe {
56 ffi::GetThemeBackgroundContentRect(
57 self.ptr(),
58 hdc.ptr(),
59 part_state.part,
60 part_state.state,
61 pcvoid(&bounds),
62 pvoid(&mut rc_content),
63 )
64 })
65 .map(|_| rc_content)
66 }
67
68 #[must_use]
71 pub fn GetThemeBackgroundExtent(
72 &self,
73 hdc: &HDC,
74 part_state: co::VS,
75 rc_content: RECT,
76 ) -> HrResult<RECT> {
77 let mut rc_extent = RECT::default();
78
79 ok_to_hrresult(unsafe {
80 ffi::GetThemeBackgroundExtent(
81 self.ptr(),
82 hdc.ptr(),
83 part_state.part,
84 part_state.state,
85 pcvoid(&rc_content),
86 pvoid(&mut rc_extent),
87 )
88 })
89 .map(|_| rc_extent)
90 }
91
92 #[must_use]
95 pub fn GetThemeBackgroundRegion(
96 &self,
97 hdc: &HDC,
98 part_state: co::VS,
99 rc: RECT,
100 ) -> HrResult<DeleteObjectGuard<HRGN>> {
101 let mut hrgn = HRGN::NULL;
102 unsafe {
103 ok_to_hrresult(ffi::GetThemeBackgroundRegion(
104 self.ptr(),
105 hdc.ptr(),
106 part_state.part,
107 part_state.state,
108 pcvoid(&rc),
109 hrgn.as_mut(),
110 ))
111 .map(|_| DeleteObjectGuard::new(hrgn))
112 }
113 }
114
115 #[must_use]
118 pub fn GetThemeColor(&self, part_state: co::VS, prop: co::TMT) -> HrResult<COLORREF> {
119 let mut color = COLORREF::default();
120 ok_to_hrresult(unsafe {
121 ffi::GetThemeColor(
122 self.ptr(),
123 part_state.part,
124 part_state.state,
125 prop.raw(),
126 color.as_mut(),
127 )
128 })
129 .map(|_| color)
130 }
131
132 #[must_use]
135 pub fn GetThemeMargins(
136 &self,
137 hdc_fonts: Option<&HDC>,
138 part_state: co::VS,
139 prop: co::TMT,
140 draw_dest: Option<&RECT>,
141 ) -> HrResult<MARGINS> {
142 let mut margins = MARGINS::default();
143 ok_to_hrresult(unsafe {
144 ffi::GetThemeMargins(
145 self.ptr(),
146 hdc_fonts.map_or(std::ptr::null_mut(), |h| h.ptr()),
147 part_state.part(),
148 part_state.state(),
149 prop.raw(),
150 pcvoid_or_null(draw_dest),
151 pvoid(&mut margins),
152 )
153 })
154 .map(|_| margins)
155 }
156
157 #[must_use]
160 pub fn GetThemeMetric(
161 &self,
162 hdc_fonts: Option<&HDC>,
163 part_state: co::VS,
164 prop: co::TMT,
165 ) -> HrResult<i32> {
166 let mut val = 0i32;
167 ok_to_hrresult(unsafe {
168 ffi::GetThemeMetric(
169 self.ptr(),
170 hdc_fonts.map_or(std::ptr::null_mut(), |h| h.ptr()),
171 part_state.part(),
172 part_state.state(),
173 prop.raw(),
174 &mut val,
175 )
176 })
177 .map(|_| val)
178 }
179
180 #[must_use]
183 pub fn GetThemePartSize(
184 &self,
185 hdc_fonts: Option<&HDC>,
186 part_state: co::VS,
187 draw_dest: Option<&RECT>,
188 esize: co::THEMESIZE,
189 ) -> HrResult<SIZE> {
190 let mut sz = SIZE::default();
191 ok_to_hrresult(unsafe {
192 ffi::GetThemePartSize(
193 self.ptr(),
194 hdc_fonts.map_or(std::ptr::null_mut(), |h| h.ptr()),
195 part_state.part(),
196 part_state.state(),
197 pcvoid_or_null(draw_dest),
198 esize.raw(),
199 pvoid(&mut sz),
200 )
201 })
202 .map(|_| sz)
203 }
204
205 #[must_use]
208 pub fn GetThemePosition(&self, part_state: co::VS, prop: co::TMT) -> HrResult<POINT> {
209 let mut pt = POINT::default();
210 ok_to_hrresult(unsafe {
211 ffi::GetThemePosition(
212 self.ptr(),
213 part_state.part(),
214 part_state.state(),
215 prop.raw(),
216 pvoid(&mut pt),
217 )
218 })
219 .map(|_| pt)
220 }
221
222 #[must_use]
225 pub fn GetThemePropertyOrigin(
226 &self,
227 part_state: co::VS,
228 prop: co::TMT,
229 ) -> HrResult<co::PROPERTYORIGIN> {
230 let mut origin = co::PROPERTYORIGIN::default();
231 ok_to_hrresult(unsafe {
232 ffi::GetThemePropertyOrigin(
233 self.ptr(),
234 part_state.part(),
235 part_state.state(),
236 prop.raw(),
237 origin.as_mut(),
238 )
239 })
240 .map(|_| origin)
241 }
242
243 #[must_use]
246 pub fn GetThemeRect(&self, part_state: co::VS, prop: co::TMT) -> HrResult<RECT> {
247 let mut rc = RECT::default();
248 ok_to_hrresult(unsafe {
249 ffi::GetThemeRect(
250 self.ptr(),
251 part_state.part(),
252 part_state.state(),
253 prop.raw(),
254 pvoid(&mut rc),
255 )
256 })
257 .map(|_| rc)
258 }
259
260 #[must_use]
263 pub fn IsThemeBackgroundPartiallyTransparent(&self, part_state: co::VS) -> bool {
264 unsafe {
265 ffi::IsThemeBackgroundPartiallyTransparent(
266 self.ptr(),
267 part_state.part,
268 part_state.state,
269 ) != 0
270 }
271 }
272
273 #[must_use]
276 pub fn IsThemePartDefined(&self, part_state: co::VS) -> bool {
277 unsafe { ffi::IsThemePartDefined(self.ptr(), part_state.part, part_state.state) != 0 }
278 }
279}