From 4fba2ab2ddda75a05c70ac95531504edfafdf8c8 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 20 Sep 2011 20:47:19 +0000 Subject: Add TXT_MessageBox convenience function. Subversion-branch: /branches/v2-branch Subversion-revision: 2388 --- textscreen/txt_window.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'textscreen/txt_window.c') diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index cd8a6c7a..8cbddb55 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -20,10 +20,12 @@ // #include +#include #include #include "doomkeys.h" +#include "txt_label.h" #include "txt_desktop.h" #include "txt_gui.h" #include "txt_main.h" @@ -472,3 +474,24 @@ void TXT_SetMouseListener(txt_window_t *window, window->mouse_listener_data = user_data; } +txt_window_t *TXT_MessageBox(char *title, char *message, ...) +{ + txt_window_t *window; + char buf[256]; + va_list args; + + va_start(args, message); + vsnprintf(buf, sizeof(buf), message, args); + va_end(args); + + window = TXT_NewWindow(title); + TXT_AddWidget(window, TXT_NewLabel(buf)); + + TXT_SetWindowAction(window, TXT_HORIZ_LEFT, NULL); + TXT_SetWindowAction(window, TXT_HORIZ_CENTER, + TXT_NewWindowEscapeAction(window)); + TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, NULL); + + return window; +} + -- cgit v1.2.3