comparison 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
comparison
equal deleted inserted replaced
2900:fe31d4535270 2901:761b7a12b079
2524 * ...: Additional variables for use in the format. 2524 * ...: Additional variables for use in the format.
2525 */ 2525 */
2526 void API dw_debug(const char *format, ...) 2526 void API dw_debug(const char *format, ...)
2527 { 2527 {
2528 va_list args; 2528 va_list args;
2529 char outbuf[1025] = {0};
2530 2529
2531 va_start(args, format); 2530 va_start(args, format);
2532 vsnprintf(outbuf, 1024, format, args); 2531 vfprintf(stderr, format, args);
2533 va_end(args); 2532 va_end(args);
2534 2533 }
2535 fprintf(stderr, "%s", outbuf); 2534
2535 void API dw_vdebug(const char *format, va_list args)
2536 {
2537 vfprintf(stderr, format, args);
2536 } 2538 }
2537 2539
2538 /* 2540 /*
2539 * Displays a Message Box with given text and title.. 2541 * Displays a Message Box with given text and title..
2540 * Parameters: 2542 * Parameters:
2541 * title: The title of the message box. 2543 * title: The title of the message box.
2542 * flags: Defines buttons and icons to display 2544 * flags: Defines buttons and icons to display
2543 * format: printf style format string. 2545 * format: printf style format string.
2544 * ...: Additional variables for use in the format. 2546 * ...: Additional variables for use in the format.
2545 */ 2547 */
2546 int dw_messagebox(const char *title, int flags, const char *format, ...) 2548 int API dw_messagebox(const char *title, int flags, const char *format, ...)
2549 {
2550 va_list args;
2551 int rc;
2552
2553 va_start(args, format);
2554 rc = dw_vmessagebox(title, flags, format, args);
2555 va_end(args);
2556 return rc;
2557 }
2558
2559 int dw_vmessagebox(const char *title, int flags, const char *format, va_list args)
2547 { 2560 {
2548 HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext; 2561 HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext;
2549 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER; 2562 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER;
2550 DWDialog *dwwait; 2563 DWDialog *dwwait;
2551 va_list args;
2552 char outbuf[1025] = {0}; 2564 char outbuf[1025] = {0};
2553 char **xpm_data = NULL; 2565 char **xpm_data = NULL;
2554 int x, y, extra_width=0,text_width,text_height; 2566 int x, y, extra_width=0,text_width,text_height;
2555 int width,height; 2567 int width,height;
2556 2568
2557 va_start(args, format);
2558 vsnprintf(outbuf, 1024, format, args); 2569 vsnprintf(outbuf, 1024, format, args);
2559 va_end(args);
2560 2570
2561 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle); 2571 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle);
2562 mainbox = dw_box_new(DW_VERT, 10); 2572 mainbox = dw_box_new(DW_VERT, 10);
2563 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0); 2573 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0);
2564 2574