milsko/examples/basic/subwindow.c

52 lines
1.2 KiB
C
Raw Normal View History

2026-05-02 02:00:51 +09:00
#include <Mw/Milsko.h>
2026-05-02 21:51:51 +09:00
#define Shift 16
2026-05-06 04:16:35 +09:00
static void MWAPI resize(MwWidget handle, void* user, void* client) {
2026-05-02 02:00:51 +09:00
MwWidget f = MwSubWindowGetFrame(handle);
MwVaApply(user,
MwNwidth, MwGetInteger(f, MwNwidth),
MwNheight, MwGetInteger(f, MwNheight),
NULL);
}
int main() {
MwWidget w;
int i;
MwLLPixmap px[6];
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 800, 600,
MwNtitle, "subwindow",
NULL);
px[0] = MwLoadIcon(w, MwIconClock);
px[1] = MwLoadIcon(w, MwIconError);
px[2] = MwLoadIcon(w, MwIconInfo);
px[3] = MwLoadIcon(w, MwIconNews);
px[4] = MwLoadIcon(w, MwIconNote);
px[5] = MwLoadIcon(w, MwIconWarning);
for(i = 0; i < 16; i++) {
char buf[32];
MwWidget sw, f, img;
sprintf(buf, "Sub window %d", i);
2026-05-02 21:51:51 +09:00
sw = MwVaCreateWidget(MwSubWindowClass, "swnd", w, i * Shift, i * Shift, 128, 128,
2026-05-02 02:00:51 +09:00
MwNtitle, buf,
2026-05-06 04:53:24 +09:00
MwNiconPixmap, px[rand() % 6],
2026-05-02 02:00:51 +09:00
NULL);
f = MwSubWindowGetFrame(sw);
img = MwVaCreateWidget(MwImageClass, "img", f, 0, 0, MwGetInteger(f, MwNwidth), MwGetInteger(f, MwNheight),
MwNpixmap, px[rand() % 6],
NULL);
MwAddUserHandler(sw, MwNresizeHandler, resize, img);
}
MwLoop(w);
}