From 14a697b272ab74058e9aa375851c13c18f07731e Mon Sep 17 00:00:00 2001 From: Tomaka17 Date: Sun, 27 Jul 2014 22:36:44 +0200 Subject: Implement get_*_size() for win32 --- src/win32/mod.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/win32/mod.rs') diff --git a/src/win32/mod.rs b/src/win32/mod.rs index b5e507b..8f3ae91 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -222,11 +222,31 @@ impl Window { } pub fn get_inner_size(&self) -> (uint, uint) { - unimplemented!() + use std::{mem, os}; + let mut rect: ffi::RECT = unsafe { mem::uninitialized() }; + + if unsafe { ffi::GetClientRect(self.window, &mut rect) } == 0 { + fail!("GetClientRect failed: {}", os::error_string(os::errno() as uint)); + } + + ( + (rect.right - rect.left) as uint, + (rect.bottom - rect.top) as uint + ) } pub fn get_outer_size(&self) -> (uint, uint) { - unimplemented!() + use std::{mem, os}; + let mut rect: ffi::RECT = unsafe { mem::uninitialized() }; + + if unsafe { ffi::GetWindowRect(self.window, &mut rect) } == 0 { + fail!("GetWindowRect failed: {}", os::error_string(os::errno() as uint)); + } + + ( + (rect.right - rect.left) as uint, + (rect.bottom - rect.top) as uint + ) } pub fn set_inner_size(&self, x: uint, y: uint) { -- cgit v1.2.3