diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-02-08 22:22:00 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-02-08 22:22:00 +0100 |
commit | 728abec962f993309acf3ebb1317b5f3773f18c7 (patch) | |
tree | ab4e22fd914681fa42babfcba184a932956c9667 /plugingui/nativewindow_win32.cc | |
parent | f762a1fbf4ccf565953855695ddd0bf60b34bf8e (diff) |
UI resize refactoring part 1.
Diffstat (limited to 'plugingui/nativewindow_win32.cc')
-rw-r--r-- | plugingui/nativewindow_win32.cc | 26 |
1 files changed, 20 insertions, 6 deletions
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<std::size_t, std::size_t> 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<int, int> NativeWindowWin32::getPosition() +{ + RECT rect; + GetClientRect(m_hwnd, &rect); + return std::make_pair(rect.left, rect.top); +} + void NativeWindowWin32::show() { ShowWindow(m_hwnd, SW_SHOW); |