absence_thelab
diff src/nwt/widget.cpp @ 0:1cffe3409164
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 23 Oct 2014 01:46:07 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/nwt/widget.cpp Thu Oct 23 01:46:07 2014 +0300 1.3 @@ -0,0 +1,49 @@ 1.4 +#include "widget.h" 1.5 +#include "nucwin.h" 1.6 + 1.7 +Widget *NWCreateWindow(const char *name, int x, int y, int xsz, int ysz, uint16 flags) { 1.8 + if(x == NWT_CENTERX) { 1.9 + x = (GetSystemMetrics(SM_CXSCREEN) - xsz) >> 1; 1.10 + } 1.11 + if(y == NWT_CENTERY) { 1.12 + y = (GetSystemMetrics(SM_CYSCREEN) - ysz) >> 1; 1.13 + } 1.14 + 1.15 + HINSTANCE AppInstance = GetModuleHandle(0); 1.16 + unsigned long ex_style = flags & NWT_WIN_TOPMOST ? WS_EX_TOPMOST : 0; 1.17 + return CreateWindowEx(ex_style, "NucWin", name, WS_OVERLAPPEDWINDOW | WS_VISIBLE, x, y, xsz, ysz, 0, 0, AppInstance, 0); 1.18 +} 1.19 + 1.20 + 1.21 +void NWResize(Widget *wdg, int nx, int ny) { 1.22 + int xpos = (GetSystemMetrics(SM_CXSCREEN) - nx) >> 1; 1.23 + int ypos = (GetSystemMetrics(SM_CYSCREEN) - ny) >> 1; 1.24 + MoveWindow(wdg, xpos, ypos, nx, ny, true); 1.25 +} 1.26 + 1.27 +void NWResizeClientArea(Widget *wdg, uint32 WinStyle) { 1.28 + RECT rect; 1.29 + GetWindowRect(wdg, &rect); 1.30 + AdjustWindowRectEx(&rect, WinStyle, false, 0); 1.31 + MoveWindow(wdg, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, true); 1.32 +} 1.33 + 1.34 +void NWSetWindowPos(Widget *wdg, const Point &pos) { 1.35 + Point sz = NWGetWindowSize(wdg); 1.36 + MoveWindow(wdg, pos.x, pos.y, sz.x, sz.y, true); 1.37 +} 1.38 + 1.39 +Point NWGetWindowPos(Widget *wdg) { 1.40 + Rect rect; 1.41 + GetWindowRect(wdg, &rect); 1.42 + 1.43 + return Point(rect.left, rect.top); 1.44 +} 1.45 + 1.46 +Point NWGetWindowSize(Widget *wdg) { 1.47 + Rect rect; 1.48 + GetWindowRect(wdg, &rect); 1.49 + 1.50 + return Point(rect.right - rect.left, rect.bottom - rect.top); 1.51 +} 1.52 +