mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-10 03:13:28 +00:00
menu kinda works
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@108 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
27
src/core.c
27
src/core.c
@@ -3,36 +3,49 @@
|
||||
|
||||
#include "stb_ds.h"
|
||||
|
||||
static void lldrawhandler(MwLL handle) {
|
||||
static void lldrawhandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->user;
|
||||
|
||||
(void)data;
|
||||
|
||||
MwDispatch(h, draw);
|
||||
}
|
||||
|
||||
static void lluphandler(MwLL handle) {
|
||||
static void lluphandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->user;
|
||||
|
||||
(void)data;
|
||||
|
||||
h->pressed = 0;
|
||||
|
||||
MwDispatch(h, click);
|
||||
}
|
||||
|
||||
static void lldownhandler(MwLL handle) {
|
||||
MwWidget h = (MwWidget)handle->user;
|
||||
h->pressed = 1;
|
||||
static void lldownhandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->user;
|
||||
MwPoint* p = data;
|
||||
h->pressed = 1;
|
||||
h->pressed_point.x = p->x;
|
||||
h->pressed_point.y = p->y;
|
||||
}
|
||||
|
||||
static void llresizehandler(MwLL handle) {
|
||||
static void llresizehandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->user;
|
||||
int i;
|
||||
|
||||
(void)data;
|
||||
|
||||
MwDispatchUserHandler(h, MwNresizeHandler, NULL);
|
||||
for(i = 0; i < arrlen(h->children); i++) {
|
||||
MwDispatch(h->children[i], parent_resize);
|
||||
}
|
||||
}
|
||||
|
||||
static void llclosehandler(MwLL handle) {
|
||||
static void llclosehandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->user;
|
||||
|
||||
(void)data;
|
||||
|
||||
h->close = 1;
|
||||
}
|
||||
|
||||
|
||||
20
src/gdi.c
20
src/gdi.c
@@ -27,7 +27,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||
ReleaseDC(hWnd, dc);
|
||||
|
||||
u->ll->hDC = hbdc;
|
||||
MwLLDispatch(u->ll, draw);
|
||||
MwLLDispatch(u->ll, draw, NULL);
|
||||
|
||||
dc = BeginPaint(hWnd, &ps);
|
||||
StretchBlt(dc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hbdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SRCCOPY);
|
||||
@@ -37,25 +37,33 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||
DeleteObject(hbmp);
|
||||
} else {
|
||||
u->ll->hDC = BeginPaint(hWnd, &ps);
|
||||
MwLLDispatch(u->ll, draw);
|
||||
MwLLDispatch(u->ll, draw, NULL);
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
} else if(msg == WM_LBUTTONDOWN) {
|
||||
MwPoint p;
|
||||
p.x = LOWORD(lp);
|
||||
p.y = HIWORD(lp);
|
||||
|
||||
SetCapture(hWnd);
|
||||
MwLLDispatch(u->ll, down);
|
||||
MwLLDispatch(u->ll, down, &p);
|
||||
InvalidateRect(hWnd, NULL, FALSE);
|
||||
} else if(msg == WM_LBUTTONUP) {
|
||||
MwPoint p;
|
||||
p.x = LOWORD(lp);
|
||||
p.y = HIWORD(lp);
|
||||
|
||||
SetCapture(NULL);
|
||||
MwLLDispatch(u->ll, up);
|
||||
MwLLDispatch(u->ll, up, &p);
|
||||
InvalidateRect(hWnd, NULL, FALSE);
|
||||
} else if(msg == WM_SIZE) {
|
||||
MwLLDispatch(u->ll, resize);
|
||||
MwLLDispatch(u->ll, resize, NULL);
|
||||
} else if(msg == WM_ERASEBKGND) {
|
||||
return 1;
|
||||
} else if(msg == WM_NCHITTEST) {
|
||||
return HTCLIENT;
|
||||
} else if(msg == WM_DESTROY) {
|
||||
MwLLDispatch(u->ll, close);
|
||||
MwLLDispatch(u->ll, close, NULL);
|
||||
PostQuitMessage(0);
|
||||
} else if(msg == WM_CLOSE) {
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
10
src/menu.c
10
src/menu.c
@@ -82,9 +82,19 @@ static void draw(MwWidget handle) {
|
||||
MwDrawRect(handle, &r, base);
|
||||
for(i = 0; i < arrlen(m->sub); i++) {
|
||||
int tw = MwTextWidth(handle, m->sub[i]->name);
|
||||
int th = MwTextHeight(handle, m->sub[i]->name);
|
||||
|
||||
p.x += tw / 2;
|
||||
|
||||
r.x = p.x - tw / 2 - 5;
|
||||
r.y = p.y - th / 2 - 5;
|
||||
r.width = tw + 10;
|
||||
r.height = th + 10;
|
||||
|
||||
if(handle->pressed && r.x <= handle->pressed_point.x && r.y <= handle->pressed_point.y && handle->pressed_point.x <= (int)(r.x + r.width) && handle->pressed_point.y <= (int)(r.y + r.height)) {
|
||||
MwDrawFrame(handle, &r, base, 0);
|
||||
}
|
||||
|
||||
MwDrawText(handle, &p, m->sub[i]->name, 1, text);
|
||||
|
||||
p.x += tw / 2 + 20;
|
||||
|
||||
18
src/x11.c
18
src/x11.c
@@ -145,16 +145,24 @@ void MwLLNextEvent(MwLL handle) {
|
||||
render = 1;
|
||||
} else if(ev.type == ButtonPress) {
|
||||
if(ev.xbutton.button == Button1) {
|
||||
MwLLDispatch(handle, down);
|
||||
MwPoint p;
|
||||
p.x = ev.xbutton.x;
|
||||
p.y = ev.xbutton.y;
|
||||
|
||||
MwLLDispatch(handle, down, &p);
|
||||
render = 1;
|
||||
}
|
||||
} else if(ev.type == ButtonRelease) {
|
||||
if(ev.xbutton.button == Button1) {
|
||||
MwLLDispatch(handle, up);
|
||||
MwPoint p;
|
||||
p.x = ev.xbutton.x;
|
||||
p.y = ev.xbutton.y;
|
||||
|
||||
MwLLDispatch(handle, up, &p);
|
||||
render = 1;
|
||||
}
|
||||
} else if(ev.type == ConfigureNotify) {
|
||||
MwLLDispatch(handle, resize);
|
||||
MwLLDispatch(handle, resize, NULL);
|
||||
|
||||
if(handle->width != (unsigned int)ev.xconfigure.width || handle->height != (unsigned int)ev.xconfigure.height) {
|
||||
destroy_pixmap(handle);
|
||||
@@ -165,7 +173,7 @@ void MwLLNextEvent(MwLL handle) {
|
||||
handle->height = ev.xconfigure.height;
|
||||
} else if(ev.type == ClientMessage) {
|
||||
if(ev.xclient.data.l[0] == (long)handle->wm_delete) {
|
||||
MwLLDispatch(handle, close);
|
||||
MwLLDispatch(handle, close, NULL);
|
||||
}
|
||||
}
|
||||
if(render) {
|
||||
@@ -174,7 +182,7 @@ void MwLLNextEvent(MwLL handle) {
|
||||
|
||||
MwLLGetXYWH(handle, &x, &y, &w, &h);
|
||||
|
||||
MwLLDispatch(handle, draw);
|
||||
MwLLDispatch(handle, draw, NULL);
|
||||
if(handle->copy_buffer) XCopyArea(handle->display, handle->pixmap, handle->window, handle->gc, 0, 0, w, h, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user