absence_thelab
view 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 source
1 #include "widget.h"
2 #include "nucwin.h"
4 Widget *NWCreateWindow(const char *name, int x, int y, int xsz, int ysz, uint16 flags) {
5 if(x == NWT_CENTERX) {
6 x = (GetSystemMetrics(SM_CXSCREEN) - xsz) >> 1;
7 }
8 if(y == NWT_CENTERY) {
9 y = (GetSystemMetrics(SM_CYSCREEN) - ysz) >> 1;
10 }
12 HINSTANCE AppInstance = GetModuleHandle(0);
13 unsigned long ex_style = flags & NWT_WIN_TOPMOST ? WS_EX_TOPMOST : 0;
14 return CreateWindowEx(ex_style, "NucWin", name, WS_OVERLAPPEDWINDOW | WS_VISIBLE, x, y, xsz, ysz, 0, 0, AppInstance, 0);
15 }
18 void NWResize(Widget *wdg, int nx, int ny) {
19 int xpos = (GetSystemMetrics(SM_CXSCREEN) - nx) >> 1;
20 int ypos = (GetSystemMetrics(SM_CYSCREEN) - ny) >> 1;
21 MoveWindow(wdg, xpos, ypos, nx, ny, true);
22 }
24 void NWResizeClientArea(Widget *wdg, uint32 WinStyle) {
25 RECT rect;
26 GetWindowRect(wdg, &rect);
27 AdjustWindowRectEx(&rect, WinStyle, false, 0);
28 MoveWindow(wdg, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, true);
29 }
31 void NWSetWindowPos(Widget *wdg, const Point &pos) {
32 Point sz = NWGetWindowSize(wdg);
33 MoveWindow(wdg, pos.x, pos.y, sz.x, sz.y, true);
34 }
36 Point NWGetWindowPos(Widget *wdg) {
37 Rect rect;
38 GetWindowRect(wdg, &rect);
40 return Point(rect.left, rect.top);
41 }
43 Point NWGetWindowSize(Widget *wdg) {
44 Rect rect;
45 GetWindowRect(wdg, &rect);
47 return Point(rect.right - rect.left, rect.bottom - rect.top);
48 }