diff --git a/doc/index.html b/doc/index.html
index 964835d..6b62679 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -41,6 +41,30 @@
#define MwMB_ICONNEWS 0x5
+
+ #define MwMB_BUTTONMASK 0xf0
+
+
+ #define MwMB_BUTTONOK 0x10
+
+
+ #define MwMB_BUTTONCANCEL 0x20
+
+
+ #define MwMB_BUTTONYES 0x40
+
+
+ #define MwMB_BUTTONNO 0x80
+
+
+ MwMB_BUTTONOKCANCEL
+
+
+ MwMB_BUTTONYESNO
+
+
+ MwMB_BUTTONYESNOCANCEL
+
Mw/Core.h
@@ -248,6 +272,12 @@
Mw/MessageBox.h
+
+ MwMessageBox
+
+
+ MwMessageBoxGetChild
+
Mw/Milsko.h
@@ -498,6 +528,62 @@
+#define MwMB_BUTTONMASK 0xf0
+
+-
+ Button mask.
+
+
+
+#define MwMB_BUTTONOK 0x10
+
+-
+ OK button.
+
+
+
+#define MwMB_BUTTONCANCEL 0x20
+
+-
+ Cancel button.
+
+
+
+#define MwMB_BUTTONYES 0x40
+
+-
+ Yes button.
+
+
+
+#define MwMB_BUTTONNO 0x80
+
+-
+ No button.
+
+
+
+#define MwMB_BUTTONOKCANCEL (MwMB_BUTTONCANCEL | MwMB_BUTTONOK)
+
+-
+ Ok and Cancel button.
+
+
+
+#define MwMB_BUTTONYESNO (MwMB_BUTTONYES | MwMB_BUTTONNO)
+
+-
+ Yes and No button.
+
+
+
+#define MwMB_BUTTONYESNOCANCEL (MwMB_BUTTONYES | MwMB_BUTTONNO | MwMB_BUTTONCANCEL)
+
+-
+ Yes, No and Cancel button.
+
+
+
Mw/Core.h
-
@@ -1941,6 +2027,70 @@
+MWDECL MwWidget MwMessageBox (
+ MwWidget handle,
+ const char* text,
+ const char* title,
+ unsigned int flag
+);
+
+-
+ Creates a message box.
+
+-
+ Parameter
handle
+
+-
+ Widget.
+
+-
+ Parameter
text
+
+-
+ Text.
+
+-
+ Parameter
title
+
+-
+ Title text.
+
+-
+ Parameter
flag
+
+-
+ Flag.
+
+-
+ Returns
+
+-
+ Widget.
+
+
+
+MWDECL MwWidget MwMessageBoxGetChild (
+ MwWidget handle,
+ int child
+);
+
+-
+ Gets a child of the message box.
+
+-
+ Parameter
handle
+
+-
+ Widget.
+
+-
+ Parameter
child
+
+-
+ Child.
+
+
+
Mw/Milsko.h
-
diff --git a/include/Mw/Constants.h b/include/Mw/Constants.h
index e7c6734..ab0a0f9 100644
--- a/include/Mw/Constants.h
+++ b/include/Mw/Constants.h
@@ -68,4 +68,44 @@ enum MwALIGNMENT {
*/
#define MwMB_ICONNEWS 0x5
+/*!
+ * %brief Button mask
+ */
+#define MwMB_BUTTONMASK 0xf0
+
+/*!
+ * %brief OK button
+ */
+#define MwMB_BUTTONOK 0x10
+
+/*!
+ * %brief Cancel button
+ */
+#define MwMB_BUTTONCANCEL 0x20
+
+/*!
+ * %brief Yes button
+ */
+#define MwMB_BUTTONYES 0x40
+
+/*!
+ * %brief No button
+ */
+#define MwMB_BUTTONNO 0x80
+
+/*!
+ * %brief Ok and Cancel button
+ */
+#define MwMB_BUTTONOKCANCEL (MwMB_BUTTONCANCEL | MwMB_BUTTONOK)
+
+/*!
+ * %brief Yes and No button
+ */
+#define MwMB_BUTTONYESNO (MwMB_BUTTONYES | MwMB_BUTTONNO)
+
+/*!
+ * %brief Yes, No and Cancel button
+ */
+#define MwMB_BUTTONYESNOCANCEL (MwMB_BUTTONYES | MwMB_BUTTONNO | MwMB_BUTTONCANCEL)
+
#endif
diff --git a/include/Mw/MessageBox.h b/include/Mw/MessageBox.h
index 2342e46..7e2a543 100644
--- a/include/Mw/MessageBox.h
+++ b/include/Mw/MessageBox.h
@@ -14,6 +14,7 @@ extern "C" {
#endif
/*!
+ * %brief Creates a message box
* %param handle Widget
* %param text Text
* %param title Title text
@@ -22,6 +23,13 @@ extern "C" {
*/
MWDECL MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsigned int flag);
+/*!
+ * %brief Gets a child of the message box
+ * %param handle Widget
+ * %param child Child
+ */
+MWDECL MwWidget MwMessageBoxGetChild(MwWidget handle, int child);
+
#ifdef __cplusplus
}
#endif
diff --git a/resource/icon/info.png b/resource/icon/info.png
index b6f543f..65f85c7 100644
Binary files a/resource/icon/info.png and b/resource/icon/info.png differ
diff --git a/resource/icon/news.png b/resource/icon/news.png
index 5cdcc21..4159c5a 100644
Binary files a/resource/icon/news.png and b/resource/icon/news.png differ
diff --git a/resource/icon/note.png b/resource/icon/note.png
index 0bcb4b2..f41d709 100644
Binary files a/resource/icon/note.png and b/resource/icon/note.png differ
diff --git a/resource/icon/question.png b/resource/icon/question.png
index 3a44a59..f81d6e1 100644
Binary files a/resource/icon/question.png and b/resource/icon/question.png differ
diff --git a/resource/icon/warning.png b/resource/icon/warning.png
index 08ba558..f6b92af 100644
Binary files a/resource/icon/warning.png and b/resource/icon/warning.png differ
diff --git a/src/messagebox.c b/src/messagebox.c
index 50710e0..478067d 100644
--- a/src/messagebox.c
+++ b/src/messagebox.c
@@ -1,18 +1,31 @@
/* $Id$ */
#include
-void msgbox_ok_handler(MwWidget handle, void* user, void* call) {
- MwWidget win = user;
+#include "external/stb_ds.h"
- MwDestroyWidget(win);
+typedef struct msgbox {
+ int key;
+ MwWidget value;
+} msgbox_t;
+
+static void spawn_button(MwWidget handle, int x, int y, int id, const char* text) {
+ msgbox_t* mb = handle->opaque;
+ MwWidget widget = MwVaCreateWidget(MwButtonClass, text, handle, x, y, 80, 24,
+ MwNtext, text,
+ NULL);
+
+ hmput(mb, id, widget);
+
+ handle->opaque = mb;
}
MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsigned int flag) {
- MwWidget window, ok;
+ MwWidget window;
MwPoint p;
int w, h;
int left = 8;
int th;
+ int x = 0;
p.x = 0;
p.y = 0;
@@ -20,11 +33,14 @@ 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 - 80, h - 8 - 24, 80, 24,
- MwNtext, "OK",
- NULL);
- MwAddUserHandler(ok, MwNactivateHandler, msgbox_ok_handler, window);
+ window->opaque = NULL;
+
+ if(flag & MwMB_BUTTONOK) spawn_button(window, w - (x += 8 + 80), h - 8 - 24, MwMB_BUTTONOK, "OK");
+ if(flag & MwMB_BUTTONCANCEL) spawn_button(window, w - (x += 8 + 80), h - 8 - 24, MwMB_BUTTONCANCEL, "Cancel");
+
+ if(flag & MwMB_BUTTONNO) spawn_button(window, w - (x += 8 + 80), h - 8 - 24, MwMB_BUTTONNO, "No");
+ if(flag & MwMB_BUTTONYES) spawn_button(window, w - (x += 8 + 80), h - 8 - 24, MwMB_BUTTONYES, "Yes");
if((flag & MwMB_ICONMASK) != 0) {
MwWidget icon;
@@ -75,3 +91,9 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
return window;
}
+
+MwWidget MwMessageBoxGetChild(MwWidget handle, int child) {
+ msgbox_t* mb = handle->opaque;
+
+ return hmget(mb, child);
+}