Mercurial > dwindows
diff gtk/dw.c @ 2901:761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
dw_vdebug() and dw_vmessagebox() work similarly to the standard library versions.
DW::App:Debug() and DW::App:MessageBox() use them for variable arguments.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 25 Dec 2022 00:20:49 +0000 |
parents | 9daee9d58956 |
children | 2b7babf491e1 |
line wrap: on
line diff
--- a/gtk/dw.c Sat Dec 24 14:28:39 2022 +0000 +++ b/gtk/dw.c Sun Dec 25 00:20:49 2022 +0000 @@ -2526,13 +2526,15 @@ void API dw_debug(const char *format, ...) { va_list args; - char outbuf[1025] = {0}; va_start(args, format); - vsnprintf(outbuf, 1024, format, args); + vfprintf(stderr, format, args); va_end(args); - - fprintf(stderr, "%s", outbuf); +} + +void API dw_vdebug(const char *format, va_list args) +{ + vfprintf(stderr, format, args); } /* @@ -2543,20 +2545,28 @@ * format: printf style format string. * ...: Additional variables for use in the format. */ -int dw_messagebox(const char *title, int flags, const char *format, ...) +int API dw_messagebox(const char *title, int flags, const char *format, ...) +{ + va_list args; + int rc; + + va_start(args, format); + rc = dw_vmessagebox(title, flags, format, args); + va_end(args); + return rc; +} + +int dw_vmessagebox(const char *title, int flags, const char *format, va_list args) { HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext; ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER; DWDialog *dwwait; - va_list args; char outbuf[1025] = {0}; char **xpm_data = NULL; int x, y, extra_width=0,text_width,text_height; int width,height; - va_start(args, format); vsnprintf(outbuf, 1024, format, args); - va_end(args); entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle); mainbox = dw_box_new(DW_VERT, 10);