add icons

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@258 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-11 07:25:16 +00:00
parent 22b6c60f45
commit 83eda35643
13 changed files with 205 additions and 158 deletions

View File

@@ -1,10 +1,18 @@
/* $Id$ */
#include <Mw/Milsko.h>
void msgbox_ok_handler(MwWidget handle, void* user, void* call) {
MwWidget win = user;
MwDestroyWidget(win);
}
MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsigned int flag) {
MwWidget window, ok;
MwPoint p;
int w, h;
int left = 8;
int th;
p.x = 0;
p.y = 0;
@@ -12,16 +20,18 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
window = MwVaCreateWidget(MwWindowClass, "messagebox", handle, 0, 0, (w = 512), (h = 32 * 4),
MwNtitle, title,
NULL);
ok = MwVaCreateWidget(MwButtonClass, "ok", window, w - 8 - 64, h - 8 - 24, 64, 24,
ok = MwVaCreateWidget(MwButtonClass, "ok", window, w - 8 - 80, h - 8 - 24, 80, 24,
MwNtext, "OK",
NULL);
MwAddUserHandler(ok, MwNactivateHandler, msgbox_ok_handler, window);
if((flag & MwMB_ICONMASK) != 0) {
MwWidget icon;
MwLLPixmap px;
char** data = NULL;
icon = MwCreateWidget(MwImageClass, "image", window, 16, (h - 48) / 2, 48, 48);
icon = MwCreateWidget(MwImageClass, "image", window, 8, (h - 48) / 2, 48, 48);
switch(flag & MwMB_ICONMASK) {
case MwMB_ICONWARNING: {
@@ -45,8 +55,16 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
px = MwLoadXPM(icon, data);
MwSetVoid(icon, MwNpixmap, px);
left = 8 + 48 + 8;
}
th = MwTextHeight(handle, text);
(void)MwVaCreateWidget(MwLabelClass, "label", window, left, (h - th) / 2, w - left - 8, th,
MwNtext, text,
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwLLDetach(window->lowlevel, &p);
MwLLSetSizeHints(window->lowlevel, w, h, w, h);
MwLLMakePopup(window->lowlevel, handle->lowlevel);