From 9266f242c357df49e07f3f234548e873f4d215ae Mon Sep 17 00:00:00 2001 From: Dominik Geyer Date: Tue, 30 Sep 2008 15:52:15 +0000 Subject: [PATCH] implemented gui_messagebox() which displays low-level message-box --- src/base/system.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/base/system.h | 10 ++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/base/system.c b/src/base/system.c index 5a2296edf..460a4ff1f 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -26,6 +26,11 @@ #include #include + + #if defined(CONF_PLATFORM_MACOSX) + #include + #endif + #elif defined(CONF_FAMILY_WINDOWS) #define WIN32_LEAN_AND_MEAN #define _WIN32_WINNT 0x0501 /* required for mingw to get getaddrinfo to work */ @@ -1072,6 +1077,48 @@ void net_stats(NETSTATS *stats_inout) *stats_inout = network_stats; } +void gui_messagebox(const char *title, const char *message) +{ +#if defined(CONF_PLATFORM_MACOSX) + DialogRef theItem; + DialogItemIndex itemIndex; + + /* FIXME: really needed? can we rely on glfw? */ + /* HACK - get events without a bundle */ + ProcessSerialNumber psn; + GetCurrentProcess(&psn); + TransformProcessType(&psn,kProcessTransformToForegroundApplication); + SetFrontProcess(&psn); + /* END HACK */ + + CreateStandardAlert(kAlertStopAlert, + CFSTR(title), + CFSTR(message), + NULL, + &theItem); + + RunStandardAlert(theItem, NULL, &itemIndex); +#elif defined(CONF_FAMILY_UNIX) + static char cmd[1024]; + /* use xmessage which is available on nearly every X11 system */ + snprintf(cmd, 1024, "xmessage -center -title '%s' '%s'", + title, + message); + + system(cmd); +#elif defined(CONF_FAMILY_WINDOWS) + MessageBox(NULL, + message, + title, + MB_ICONEXCLAMATION | MB_OK); +#else + /* this is not critical */ + #warning not implemented +#endif +} + + + #if defined(__cplusplus) } #endif diff --git a/src/base/system.h b/src/base/system.h index 49ab26d6a..9a556341d 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -889,6 +889,16 @@ typedef struct void net_stats(NETSTATS *stats); +/* + Function: gui_messagebox + Display plain OS-dependent message box + + Parameters: + title - title of the message box + message - text to display +*/ +void gui_messagebox(const char *title, const char *message); + #ifdef __cplusplus } #endif