use windows::Win32::{ Foundation::*, Graphics::Gdi::InvalidateRect, UI::WindowsAndMessaging::{CloseWindow, GetClientRect, ShowWindow, SW_SHOW}, }; use super::Platform; #[derive(Clone, Copy)] pub struct WinRef<'a>(pub &'a HWND); impl<'a> types::WinRef for WinRef<'a> { fn raw(&self) -> Option { use core::ffi::c_void; let view = self.0 .0 as *const c_void; let view = view as *mut c_void; return Some(WinRaw::from(view)); } fn show(&self) { _ = unsafe { ShowWindow(*self.0, SW_SHOW) }; } fn close(&self) { _ = unsafe { CloseWindow(*self.0) }; } fn fresh(&self, _: &str) { _ = unsafe { InvalidateRect(*self.0, None, FALSE) }; } fn size(&self) -> (u32, u32) { let mut rect = RECT::default(); _ = unsafe { GetClientRect(*self.0, &mut rect) }; ((rect.right - rect.left).max(0) as _, (rect.bottom - rect.top).max(0) as _) } fn density(&self) -> f32 { // TODO 1. } } #[derive(Debug)] pub struct WinHandle(pub HWND); impl types::WinHandle for WinHandle { fn with(&self, mut fun: impl FnMut(WinRef<'_>)) { fun(WinRef(&self.0)); } } mod win; pub use win::*; mod raw; pub use raw::*; mod event; pub use event::*;