absence_thelab

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