map window points

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@58 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-29 05:58:28 +00:00
parent e7582cd646
commit 29b344f831
6 changed files with 61 additions and 10 deletions

View File

@@ -20,6 +20,12 @@ static void lldownhandler(MwLL handle) {
h->pressed = 1;
}
static void llresizehandler(MwLL handle) {
MwWidget h = (MwWidget)handle->user;
MwDispatchUserHandler(h, MwNresizeHandler, NULL);
}
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
MwWidget h = malloc(sizeof(*h));
@@ -32,10 +38,11 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
h->widget_class = widget_class;
h->pressed = 0;
h->lowlevel->user = h;
h->lowlevel->handler->draw = lldrawhandler;
h->lowlevel->handler->up = lluphandler;
h->lowlevel->handler->down = lldownhandler;
h->lowlevel->user = h;
h->lowlevel->handler->draw = lldrawhandler;
h->lowlevel->handler->up = lluphandler;
h->lowlevel->handler->down = lldownhandler;
h->lowlevel->handler->resize = llresizehandler;
if(parent != NULL) arrput(parent->children, h);

View File

@@ -24,6 +24,8 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
SetCapture(NULL);
MwLLDispatch(u->ll, up);
InvalidateRect(hWnd, NULL, FALSE);
} else if(msg == WM_SIZE) {
MwLLDispatch(u->ll, resize);
} else if(msg == WM_ERASEBKGND) {
} else if(msg == WM_NCHITTEST) {
return HTCLIENT;
@@ -140,6 +142,7 @@ void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h)
RECT rc;
GetClientRect(handle->hWnd, &rc);
MapWindowPoints(handle->hWnd, GetParent(handle->hWnd), (LPPOINT)&rc, 2);
*x = rc.left;
*y = rc.top;
@@ -149,10 +152,12 @@ void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h)
void MwLLSetXY(MwLL handle, int x, int y) {
SetWindowPos(handle->hWnd, NULL, x, y, 0, 0, SWP_NOSIZE);
InvalidateRect(handle->hWnd, NULL, FALSE);
}
void MwLLSetWH(MwLL handle, int w, int h) {
SetWindowPos(handle->hWnd, NULL, 0, 0, w, h, SWP_NOMOVE);
InvalidateRect(handle->hWnd, NULL, FALSE);
}
void MwLLSetTitle(MwLL handle, const char* title) {

View File

@@ -105,7 +105,7 @@ int MwLLPending(MwLL handle) {
void MwLLNextEvent(MwLL handle) {
XEvent ev;
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
while(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
if(ev.type == Expose) {
MwLLDispatch(handle, draw);
} else if(ev.type == ButtonPress) {
@@ -118,6 +118,8 @@ void MwLLNextEvent(MwLL handle) {
MwLLDispatch(handle, up);
MwLLDispatch(handle, draw);
}
} else if(ev.type == ConfigureNotify) {
MwLLDispatch(handle, resize);
}
}
}