From 728abec962f993309acf3ebb1317b5f3773f18c7 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 8 Feb 2017 22:22:00 +0100 Subject: UI resize refactoring part 1. --- plugingui/nativewindow_win32.cc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'plugingui/nativewindow_win32.cc') diff --git a/plugingui/nativewindow_win32.cc b/plugingui/nativewindow_win32.cc index 172850d..873a334 100644 --- a/plugingui/nativewindow_win32.cc +++ b/plugingui/nativewindow_win32.cc @@ -335,7 +335,7 @@ NativeWindowWin32::~NativeWindowWin32() free(m_className); } -void NativeWindowWin32::setFixedSize(int width, int height) +void NativeWindowWin32::setFixedSize(std::size_t width, std::size_t height) { resize(width, height); LONG style = GetWindowLong(m_hwnd, GWL_STYLE); @@ -343,22 +343,36 @@ void NativeWindowWin32::setFixedSize(int width, int height) SetWindowLong(m_hwnd, GWL_STYLE, style); } -void NativeWindowWin32::resize(int width, int height) +void NativeWindowWin32::resize(std::size_t width, std::size_t height) { SetWindowPos(m_hwnd, nullptr, -1, -1, (int)width, (int)height, SWP_NOMOVE); - RECT r; - GetClientRect(m_hwnd, &r); - int w = width - r.right; - int h = height - r.bottom; + RECT rect; + GetClientRect(m_hwnd, &rect); + int w = width - rect.right; + int h = height - rect.bottom; SetWindowPos(m_hwnd, nullptr, -1, -1, width + w, height + h, SWP_NOMOVE); } +std::pair NativeWindowWin32::getSize() +{ + RECT rect; + GetClientRect(m_hwnd, &rect); + return std::make_pair(rect.right - rect.left, rect.bottom - rect.top); +} + void NativeWindowWin32::move(int x, int y) { SetWindowPos(m_hwnd, nullptr, (int)x, (int)y, -1, -1, SWP_NOSIZE); } +std::pair NativeWindowWin32::getPosition() +{ + RECT rect; + GetClientRect(m_hwnd, &rect); + return std::make_pair(rect.left, rect.top); +} + void NativeWindowWin32::show() { ShowWindow(m_hwnd, SW_SHOW); -- cgit v1.2.3