1 /*
2  * Motif Tools Library, Version 3.1
3  * $Id: MsgDialogs.c,v 1.2 2001/09/19 02:57:18 grmcdorman Exp $
4  *
5  * Written by David Flanagan.
6  * Copyright (c) 1992-2001 by David Flanagan.
7  * All Rights Reserved.  See the file COPYRIGHT for details.
8  * This is open source software.  See the file LICENSE for details.
9  * There is no warranty for this software.  See NO_WARRANTY for details.
10  *
11  * $Log: MsgDialogs.c,v $
12  * Revision 1.2  2001/09/19 02:57:18  grmcdorman
13  * This change makes the following modifications:
14  *   A new program, printConfig, is provided. This is built by a
15  *   simple rule in the Makefile and not installed. It prints
16  *   significant defines from Xmt.tmpl.
17  *
18  *   XmtP.h is now generated from XmtP.h.in using printConfig. As
19  *   a result, code compiled outside of the Xmt Imakefiles will
20  *   have all of the Xmt.tmpl defines.
21  *
22  *   Source files are modified to use XmtP.h instead of Xmt.h.
23  *
24  *   WorkingBox.c is modified to use the new Progress widget.
25  *   It can be compiled in the old style if WORKINGBOX_USE_SCALE is
26  *   defined at compile time.
27  *
28  *   Because XmtP.h is generated dynamically, it is removed from CVS
29  *   with this check-in.
30  *
31  * Revision 1.1.1.1  2001/02/10 13:49:37  motiftools
32  * Initial import of Xmt310 to CVS
33  *
34  *
35  */
36 
37 #include <Xmt/XmtP.h>
38 #include <Xmt/DialogsP.h>
39 #include <Xmt/ScreenP.h>
40 #include <Xmt/Hash.h>
41 #include <Xm/DialogS.h>
42 #include <Xm/MessageB.h>
43 #include <X11/IntrinsicP.h>
44 
45 
46 /*
47  * Message dialogs are cached per-shell.  This is unlike the Askfor
48  * dialogs which are more expensive, are always full_modal, and are cached
49  * per screen.  Given a shell, we look up its cache record in the
50  * shell_to_cache_table hash table, and get a cached dialog from an array
51  * of available dialogs.  (There may be more than one because info dialogs
52  * are modeless.  We also maintain an array of help text strings for each
53  * dialog that is popped up.  This string is freed when the dialog is popped
54  * down.  The popped_up variable is used for the synchronous (AndWait) versions
55  * of the message dialogs.  There only needs to be one variable, because
56  * synchronous dialogs are always modal, locking out all other input to the
57  * shell.
58  */
59 
60 static XmtHashTable shell_to_cache_table;
61 
62 typedef struct {
63     Widget *dialogs;
64     String *help_strings;
65     short num, max, in_use;
66     Boolean popped_up;
67 } MsgDialogCache;
68 
69 
70 #if NeedFunctionPrototypes
Popdown(Widget dialog,MsgDialogCache * cache)71 static void Popdown(Widget dialog, MsgDialogCache *cache)
72 #else
73 static void Popdown(dialog, cache)
74 Widget dialog;
75 MsgDialogCache *cache;
76 #endif
77 {
78     int i;
79 
80     /* first, actually pop down the dialog */
81     XtUnmanageChild(dialog);
82 
83     /* figure out what item in the cache we are. */
84     for(i=0; i < cache->num; i++) if (cache->dialogs[i] == dialog) break;
85 
86     /* free any help text we have */
87     if (cache->help_strings[i]) {
88 	XtFree(cache->help_strings[i]);
89 	cache->help_strings[i] = NULL;
90     }
91 
92     /*
93      * if there is already a free dialog, destroy this one
94      * and remove it from the cache.  Otherwise, just note that
95      * we now have one free.
96      */
97     if (cache->in_use < cache->num) {
98 	XtDestroyWidget(dialog);
99 	/* now compress the remaining array elements */
100 	for(; i < cache->num-1; i++) cache->dialogs[i] = cache->dialogs[i+1];
101 	cache->num--;
102     }
103 
104     cache->in_use--;
105     cache->popped_up = False;  /* stops blocking in ...AndWait functions */
106 }
107 
108 #if NeedFunctionPrototypes
OkCallback(Widget w,XtPointer tag,XtPointer data)109 static void OkCallback(Widget w, XtPointer tag, XtPointer data)
110 #else
111 static void OkCallback(w, tag, data)
112 Widget w;
113 XtPointer tag, data;
114 #endif
115 {
116     MsgDialogCache *cache = (MsgDialogCache *)tag;
117     Widget dialog = XtParent(w);
118 
119     Popdown(dialog, cache);
120 }
121 
122 #if NeedFunctionPrototypes
HelpCallback(Widget w,XtPointer tag,XtPointer data)123 static void HelpCallback(Widget w, XtPointer tag, XtPointer data)
124 #else
125 static void HelpCallback(w, tag, data)
126 Widget w;
127 XtPointer tag, data;
128 #endif
129 {
130     MsgDialogCache *cache = (MsgDialogCache *)tag;
131     Widget dialog = XtParent(w);
132     XmString msg, help, blank, s1, s2;
133     int i;
134 
135     /*
136      * find the dialog in the cache; this locates the help string.
137      */
138     for(i=0; i < cache->num-1; i++)
139 	if (cache->dialogs[i] == dialog) break;
140 
141     XtVaGetValues(dialog, XmNmessageString, &msg, NULL);
142     blank = XmStringSeparatorCreate();
143     help = XmtCreateXmString(cache->help_strings[i]);
144     s1 = XmStringConcat(msg, blank);
145     s2 = XmStringConcat(s1, help);
146     XtVaSetValues(dialog, XmNmessageString, s2, NULL);
147     XmStringFree(msg);
148     XmStringFree(blank);
149     XmStringFree(help);
150     XmStringFree(s1);
151     XmStringFree(s2);
152     XtSetSensitive(w, False);
153 }
154 
155 #if NeedFunctionPrototypes
CloseCallback(Widget w,XtPointer tag,XtPointer data)156 static void CloseCallback(Widget w, XtPointer tag, XtPointer data)
157 #else
158 static void CloseCallback(w, tag, data)
159 Widget w;
160 XtPointer tag, data;
161 #endif
162 {
163     MsgDialogCache *cache = (MsgDialogCache *)tag;
164     Widget dialog = ((CompositeWidget)w)->composite.children[0];
165 
166     Popdown(dialog, cache);
167 }
168 
169 
170 #if NeedFunctionPrototypes
CreateMessageDialog(Widget shell,MsgDialogCache * cache)171 static Widget CreateMessageDialog(Widget shell, MsgDialogCache *cache)
172 #else
173 static Widget CreateMessageDialog(shell, cache)
174 Widget shell;
175 MsgDialogCache *cache;
176 #endif
177 {
178     Widget dshell;
179     Widget dialog;
180     Widget ok, cancel, help;
181     Arg args[5];
182     int i;
183 
184     /*
185      * create the dialog shell
186      */
187     i = 0;
188     XtSetArg(args[i], XmNallowShellResize, True); i++;
189     XtSetArg(args[i], XmNdeleteResponse, XmDO_NOTHING); i++;
190     dshell = XmCreateDialogShell(shell, XmtMESSAGE_DIALOG_SHELL_NAME,
191 				 args, i);
192 
193     /*
194      * Create the message box.
195      * Note that each shell and each message box we create has the
196      * same name.  This is legal, but means that you cannot specify
197      * different resources for different message dialogs from a
198      * resource file.  This is not a problem because these widgets are
199      * cached and the programmer cannot know in advance which on will
200      * be used for what.
201      */
202     i = 0;
203     XtSetArg(args[i], XmNautoUnmanage, False); i++;
204     XtSetArg(args[i], XmNdefaultPosition, False); i++;
205     dialog = XmCreateMessageBox(dshell, XmtMESSAGE_DIALOG_NAME, args, i);
206 
207     /*
208      * Register callbacks on the Ok and Help buttons.
209      * Get rid of the Cancel button; it is unused.
210      */
211     ok = XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON);
212     cancel = XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON);
213     help = XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON);
214     XtAddCallback(ok, XmNactivateCallback, OkCallback, cache);
215     XtAddCallback(help, XmNactivateCallback, HelpCallback, cache);
216     XtUnmanageChild(cancel);
217 
218     /*
219      * register a callback to handle f.close on the dialog
220      */
221     XmtAddDeleteCallback(dshell, XmDO_NOTHING, CloseCallback,(XtPointer)cache);
222 
223     return dialog;
224 }
225 
226 #if NeedFunctionPrototypes
DeleteCacheRecord(Widget w,XtPointer tag,XtPointer data)227 static void DeleteCacheRecord(Widget w, XtPointer tag, XtPointer data)
228 #else
229 static void DeleteCacheRecord(w, tag, data)
230 Widget w;
231 XtPointer tag, data;
232 #endif
233 {
234     MsgDialogCache *cache = (MsgDialogCache *)tag;
235     int i;
236 
237     XtFree((char *)cache->dialogs);  /* the dialogs will be auto. destroyed */
238     for(i=0; i < cache->num; i++) XtFree(cache->help_strings[i]);
239     XtFree((char *)cache->help_strings);
240     XtFree((char *)cache);
241     XmtHashTableDelete(shell_to_cache_table, (XtPointer)w);
242 }
243 
244 #if NeedFunctionPrototypes
GetMessageDialog(Widget shell,StringConst help_text,MsgDialogCache ** cache_return)245 static Widget GetMessageDialog(Widget shell, StringConst help_text,
246 			       MsgDialogCache **cache_return)
247 #else
248 static Widget GetMessageDialog(shell, help_text, cache_return)
249 Widget shell;
250 String help_text;
251 MsgDialogCache **cache_return;
252 #endif
253 {
254     MsgDialogCache *cache;
255     Widget dialog, help_button;
256     String help;
257 
258     /* the first time, create the hash table */
259     if (!shell_to_cache_table)
260 	shell_to_cache_table = XmtHashTableCreate(3);
261 
262     /* go get or create the cache record for this shell */
263     if (!XmtHashTableLookup(shell_to_cache_table, (XtPointer)shell,
264 			    (XtPointer *)&cache)) {
265 	cache = (MsgDialogCache *) XtCalloc(1, sizeof(MsgDialogCache));
266 	XmtHashTableStore(shell_to_cache_table, (XtPointer)shell,
267 			  (XtPointer)cache);
268 	/* set a callback on the shell to remove the cache record */
269 	XtAddCallback(shell, XtNdestroyCallback, DeleteCacheRecord, cache);
270     }
271 
272     /* grow the arrays in the cache, if needed */
273     if (cache->in_use == cache->max) {
274 	cache->max += 4;
275 	cache->dialogs = (Widget *)
276 	    XtRealloc((char *)cache->dialogs, cache->max * sizeof(Widget));
277 	cache->help_strings = (String *)
278 	    XtRealloc((char *)cache->help_strings, cache->max*sizeof(String));
279     }
280 
281     /* make a copy of the help text */
282     help = XtNewString(help_text);
283 
284     /* create a new widget if necessary */
285     if (cache->in_use == cache->num) {
286 	dialog = CreateMessageDialog(shell, cache);
287 	cache->dialogs[cache->num] = dialog;
288 	cache->help_strings[cache->num] = help;
289 	cache->num++;
290     }
291     /* or find one in the cache array */
292     else {
293 	int i;
294 	for(i=0; i < cache->num; i++) {
295 	    if (!XtIsManaged(cache->dialogs[i])) {
296 		dialog = cache->dialogs[i];
297 		cache->help_strings[i] = help;
298 		break;
299 	    }
300 	}
301     }
302 
303     /*
304      * manage or unmanage the Help button, depending on whether
305      * there is any help for this dialog
306      */
307     help_button = XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON);
308     if (help_text) {
309 	XtManageChild(help_button);
310 	XtSetSensitive(help_button, True);
311     }
312     else
313 	XtUnmanageChild(help_button);
314 
315     cache->in_use++;
316     *cache_return = cache;
317     return dialog;
318 }
319 
320 
321 
322 typedef struct {
323     StringConst message;
324     StringConst title;
325     StringConst help;
326     Pixmap icon;
327 } MessageDialogData;
328 
329 static XtResource resources[] = {
330 {XmtNmessage, XmtCMessage, XtRString,
331      sizeof(String), XtOffsetOf(MessageDialogData, message),
332      XtRString, NULL},
333 {XmtNtitle, XmtCTitle, XtRString,
334      sizeof(String), XtOffsetOf(MessageDialogData, title),
335      XtRString, NULL},
336 {XmtNhelpText, XmtCHelpText, XtRString,
337      sizeof(String), XtOffsetOf(MessageDialogData, help),
338      XtRString, NULL},
339 {XmtNicon, XmtCIcon, XtRPixmap,
340      sizeof(Pixmap), XtOffsetOf(MessageDialogData, icon),
341      XtRPixmap, (XtPointer) None},
342 };
343 
344 #if NeedFunctionPrototypes
_XmtDisplayMessage(Widget w,StringConst dialog_name,StringConst dialog_class,StringConst msg_default,va_list * msg_args,StringConst title_default,StringConst help_default,Pixmap icon_default,int type,int style)345 Boolean *_XmtDisplayMessage(Widget w,
346                             StringConst dialog_name, StringConst dialog_class,
347                             StringConst msg_default, va_list *msg_args,
348                             StringConst title_default,
349                             StringConst help_default, Pixmap icon_default,
350                             int type, int style)
351 #else
352 Boolean *_XmtDisplayMessage(w, dialog_name, dialog_class,
353                             msg_default, msg_args,
354                             title_default, help_default, icon_default,
355                             type, style)
356 Widget w;
357 StringConst dialog_name, dialog_class;
358 StringConst msg_default;
359 va_list *msg_args;
360 StringConst title_default, help_default;
361 Pixmap icon_default;
362 int type;
363 int style;
364 #endif
365 {
366     Widget shell;
367     Widget dialog;
368     MessageDialogData data;
369     XmString msg, title;
370     Arg args[5];
371     char buffer[2000];
372     MsgDialogCache *cache;
373     int i;
374     static String message_title_default;
375     static String info_title_default;
376     static String error_title_default;
377     static String warning_title_default;
378 
379     /*
380      * go figure out which shell the dialog is cached for.
381      * make sure it is not a menu shell.
382      */
383     shell = XmtGetShell(w);
384     while(XtIsOverrideShell(shell)) shell = XmtGetShell(XtParent(shell));
385 
386     /* localize title defaults, first time only */
387     if (!message_title_default) {
388 	message_title_default = XmtLocalize2(w,XmtMESSAGE_DIALOG_TITLE_DEFAULT,
389 					     "XmtDisplayMessage",
390 					     "messageTitle");
391 	info_title_default = XmtLocalize2(w, XmtINFO_DIALOG_TITLE_DEFAULT,
392 					  "XmtDisplayMessage", "helpTitle");
393 	error_title_default = XmtLocalize2(w, XmtERROR_DIALOG_TITLE_DEFAULT,
394 					   "XmtDisplayMessage", "errorTitle");
395 	warning_title_default = XmtLocalize2(w,XmtWARNING_DIALOG_TITLE_DEFAULT,
396 					     "XmtDisplayMessage",
397 					     "warningTitle");
398     }
399 
400     /* If NULL arguments were supplied, set up defaults */
401     if (msg_default == NULL) msg_default = "";
402     if (title_default == NULL) {
403 	switch(type) {
404 	case XmDIALOG_MESSAGE:
405 	    title_default = message_title_default; break;
406 	case XmDIALOG_INFORMATION:
407 	    title_default = info_title_default; break;
408 	case XmDIALOG_ERROR:
409 	    title_default = error_title_default; break;
410 	case XmDIALOG_WARNING:
411 	    title_default = warning_title_default; break;
412 	}
413     }
414 
415     if ((dialog_class == NULL)&& (dialog_name != NULL)) {
416 	switch(type) {
417 	case XmDIALOG_MESSAGE:
418 	    dialog_class = XmtCMessageDialog;
419 	    break;
420 	case XmDIALOG_INFORMATION:
421 	    dialog_class = XmtCInformationDialog;
422 	    break;
423    	case XmDIALOG_ERROR:
424 	    dialog_class = XmtCErrorDialog;
425 	    break;
426 	case XmDIALOG_WARNING:
427 	    dialog_class = XmtCWarningDialog;
428 	    break;
429 	}
430     }
431 
432     /*
433      * If this message has a name, look up its resources.
434      * Note that we look up resources under whatever shell is closest
435      * to the widget that requested this dialog.
436      */
437     if (dialog_name != NULL) {
438 	resources[0].default_addr = (XtPointer) msg_default;
439 	resources[1].default_addr = (XtPointer) title_default;
440 	resources[2].default_addr = (XtPointer) help_default;
441 	resources[3].default_addr = (XtPointer) icon_default;
442 	XtGetSubresources(shell, (XtPointer)&data,
443 			  dialog_name, dialog_class,
444 			  resources, XtNumber(resources), NULL, 0);
445     }
446     else { /* otherwise set them ourselves */
447 	data.message = msg_default;
448 	data.title = title_default;
449 	data.help = help_default;
450 	data.icon = icon_default;
451     }
452 
453     /* find a dialog to reuse or create a new one */
454     dialog = GetMessageDialog(shell, data.help, &cache);
455 
456     /*
457      * if there were printf args, sprintf the message.
458      * If there was a default message, and it was overridden,
459      * check whether the arguments of the new message match
460      * so we don't get a core dump
461      */
462     if (msg_args) {
463 	if (msg_default && (msg_default != data.message)) {
464 	    if (!XmtCheckPrintfFormat(msg_default, data.message)) {
465 		XmtWarningMsg("XmtDisplayMessage", "badfmt",
466 			      "message specified for dialog '%s' has bad format.\n\tUsing default message.",
467 			      dialog_name);
468 		data.message = msg_default;
469 	    }
470 	}
471 	vsprintf(buffer, data.message, *msg_args);
472 	data.message = buffer;
473     }
474 
475     /* create XmStrings */
476     msg = XmtCreateXmString(data.message);
477     title = XmtCreateXmString(data.title);
478 
479     /*
480      * reset the type of the dialog so that the next call will change it.
481      * This is reqired to reset a custom icon back to the default icon
482      * when the type doesn't change
483      */
484     XtSetArg(args[0], XmNdialogType, XmDIALOG_MESSAGE);
485     XtSetValues(dialog, args, 1);
486 
487     /* set the message and title and dialog type */
488     i = 0;
489     XtSetArg(args[i], XmNdialogTitle, title); i++;
490     XtSetArg(args[i], XmNmessageString, msg); i++;
491     XtSetArg(args[i], XmNdialogType, type); i++;
492     XtSetArg(args[i], XmNdialogStyle, style); i++;
493     if (data.icon || type == XmDIALOG_MESSAGE) {
494 	XtSetArg(args[i], XmNsymbolPixmap,
495 		 data.icon?data.icon:XmUNSPECIFIED_PIXMAP);
496 	i++;
497     }
498     XtSetValues(dialog, args, i);
499 
500     /* free the XmStrings */
501     XmStringFree(msg);
502     XmStringFree(title);
503 
504     /* tell the dialog who it is transient for */
505     XtVaSetValues(XtParent(dialog), XtNtransientFor, shell, NULL);
506 
507     /* Now position the dialog over the shell and pop it up */
508     XmtDialogPosition(dialog, shell);
509     cache->popped_up = True;
510     XtManageChild(dialog);
511     return &cache->popped_up;
512 }
513 
514 #if NeedVarargsPrototypes
XmtDisplayMessage(Widget w,StringConst name,StringConst class,StringConst message,StringConst title,StringConst help,Pixmap icon,int modality,int type,...)515 void XmtDisplayMessage(Widget w, StringConst name, StringConst class,
516 		       StringConst message, StringConst title,
517 		       StringConst help, Pixmap icon,
518 		       int modality, int type, ...)
519 #else
520 void XmtDisplayMessage(w, name, class, message, title, help, icon,
521 		       modality, type, va_alist)
522 Widget w;
523 String name, class, message, title, help;
524 Pixmap icon;
525 int modality, type;
526 va_dcl
527 #endif
528 {
529     va_list args;
530 
531     Va_start(args, type);
532     _XmtDisplayMessage(w, name, class, message, &args, title, help, icon,
533 		       type, modality);
534     va_end(args);
535 }
536 
537 #if NeedFunctionPrototypes
XmtDisplayMessageVaList(Widget w,StringConst name,StringConst class,StringConst message,StringConst title,StringConst help,Pixmap icon,int modality,int type,va_list args)538 void XmtDisplayMessageVaList(Widget w, StringConst name, StringConst class,
539 			     StringConst message, StringConst title,
540 			     StringConst help, Pixmap icon,
541 			     int modality, int type, va_list args)
542 #else
543 void XmtDisplayMessageVaList(w, name, class, message, title, help, icon,
544 			     modality, type, args)
545 Widget w;
546 String name, class, message, title, help;
547 Pixmap icon;
548 int modality, type;
549 va_list args;
550 #endif
551 {
552     _XmtDisplayMessage(w, name, class, message, &args, title, help, icon,
553 		       type, modality);
554 }
555 
556 
557 #if NeedVarargsPrototypes
XmtDisplayMessageAndWait(Widget w,StringConst name,StringConst class,StringConst message,StringConst title,StringConst help,Pixmap icon,int modality,int type,...)558 void XmtDisplayMessageAndWait(Widget w, StringConst name, StringConst class,
559 			      StringConst message, StringConst title,
560 			      StringConst help, Pixmap icon,
561 			      int modality, int type, ...)
562 #else
563 void XmtDisplayMessageAndWait(w, name, class, message, title, help, icon,
564 			      modality, type, va_alist)
565 Widget w;
566 String name, class, message, title, help;
567 Pixmap icon;
568 int modality, type;
569 va_dcl
570 #endif
571 {
572     va_list args;
573     Boolean *block;
574 
575     if (modality == XmDIALOG_MODELESS) {
576 	XmtWarningMsg("XmtDisplayMessageAndWait", "modality",
577 		      "Can't use a modeless dialog with a blocking function.");
578 	modality = XmDIALOG_PRIMARY_APPLICATION_MODAL;
579     }
580 
581     Va_start(args, type);
582     block = _XmtDisplayMessage(w, name, class, message, &args,
583 			       title, help, icon, type, modality);
584     va_end(args);
585     XmtBlock(w, block);
586 }
587 
588 
589 #if NeedFunctionPrototypes
XmtDisplayMessageAndWaitVaList(Widget w,StringConst name,StringConst class,StringConst message,StringConst title,StringConst help,Pixmap icon,int modality,int type,va_list args)590 void XmtDisplayMessageAndWaitVaList(Widget w, StringConst name,
591 				    StringConst class,
592 				    StringConst message, StringConst title,
593 				    StringConst help, Pixmap icon,
594 				    int modality, int type, va_list args)
595 #else
596 void XmtDisplayMessageAndWaitVaList(w, name, class, message, title, help, icon,
597 				    modality, type, args)
598 Widget w;
599 String name, class, message, title, help;
600 Pixmap icon;
601 int modality, type;
602 va_list args;
603 #endif
604 {
605     Boolean *block;
606 
607     if (modality == XmDIALOG_MODELESS) {
608 	XmtWarningMsg("XmtDisplayMessageAndWaitVaList", "modality",
609 		      "Can't use a modeless dialog with a blocking function.");
610 	modality = XmDIALOG_PRIMARY_APPLICATION_MODAL;
611     }
612 
613     block = _XmtDisplayMessage(w, name, class, message, &args,
614 			       title, help, icon, type, modality);
615     XmtBlock(w, block);
616 }
617 
618 
619 #if NeedFunctionPrototypes
XmtDisplayInformation(Widget w,StringConst dialog_name,StringConst msg_default,StringConst title_default)620 void XmtDisplayInformation(Widget w, StringConst dialog_name,
621 			   StringConst msg_default, StringConst title_default)
622 #else
623 void XmtDisplayInformation(w, dialog_name, msg_default, title_default)
624 Widget w;
625 StringConst dialog_name;
626 StringConst msg_default;
627 StringConst title_default;
628 #endif
629 {
630     (void)_XmtDisplayMessage(w, dialog_name, XmtCInformationDialog,
631 			     msg_default, NULL,
632 			     title_default, NULL, None,
633 		             XmDIALOG_INFORMATION, XmDIALOG_MODELESS);
634 }
635 
636 #if NeedFunctionPrototypes
XmtDisplayWarning(Widget w,StringConst dialog_name,StringConst msg_default)637 void XmtDisplayWarning(Widget w, StringConst dialog_name,
638 		       StringConst msg_default)
639 #else
640 void XmtDisplayWarning(w, dialog_name, msg_default)
641 Widget w;
642 StringConst dialog_name;
643 StringConst msg_default;
644 #endif
645 {
646     (void)_XmtDisplayMessage(w, dialog_name, XmtCWarningDialog,
647 			     msg_default, NULL, NULL, NULL,
648 			     None, XmDIALOG_WARNING,
649 			     XmDIALOG_PRIMARY_APPLICATION_MODAL);
650 }
651 
652 #if NeedFunctionPrototypes
XmtDisplayError(Widget w,StringConst dialog_name,StringConst msg_default)653 void XmtDisplayError(Widget w, StringConst dialog_name,
654 		     StringConst msg_default)
655 #else
656 void XmtDisplayError(w, dialog_name, msg_default)
657 Widget w;
658 StringConst dialog_name;
659 StringConst msg_default;
660 #endif
661 {
662       (void)_XmtDisplayMessage(w, dialog_name, XmtCErrorDialog,
663 			       msg_default, NULL, NULL, NULL,
664 			       None, XmDIALOG_ERROR,
665 			       XmDIALOG_PRIMARY_APPLICATION_MODAL);
666 }
667 
668 
669 #if NeedVarargsPrototypes
XmtDisplayWarningMsg(Widget w,StringConst name,StringConst msg_default,StringConst title_default,StringConst help_default,...)670 void XmtDisplayWarningMsg(Widget w, StringConst name,
671 			  StringConst msg_default,
672 			  StringConst title_default,
673 			  StringConst help_default,
674 			  ...)
675 #else
676 void XmtDisplayWarningMsg(w, name, msg_default, title_default, help_default,
677 			  va_alist)
678 Widget w;
679 String name, title_default, help_default, msg_default;
680 va_dcl
681 #endif
682 {
683     va_list args;
684 
685     Va_start(args, help_default);
686     (void)_XmtDisplayMessage(w, name, XmtCWarningDialog,
687 			     msg_default, &args,
688 			     title_default, help_default, None,
689 			     XmDIALOG_WARNING,
690 			     XmDIALOG_PRIMARY_APPLICATION_MODAL);
691     va_end(args);
692 }
693 
694 #if NeedVarargsPrototypes
XmtDisplayErrorMsg(Widget w,StringConst name,StringConst msg_default,StringConst title_default,StringConst help_default,...)695 void XmtDisplayErrorMsg(Widget w, StringConst name,
696 			StringConst msg_default,
697 			StringConst title_default,
698 			StringConst help_default,
699 			...)
700 #else
701 void XmtDisplayErrorMsg(w, name, msg_default, title_default, help_default,
702 			va_alist)
703 Widget w;
704 String name, title_default, help_default, msg_default;
705 va_dcl
706 #endif
707 {
708     va_list args;
709 
710     Va_start(args, help_default);
711     (void)_XmtDisplayMessage(w, name, XmtCErrorDialog,
712 			     msg_default, &args,
713 			     title_default, help_default, None,
714 			     XmDIALOG_ERROR,
715 			     XmDIALOG_PRIMARY_APPLICATION_MODAL);
716     va_end(args);
717 }
718 
719 #if NeedVarargsPrototypes
XmtDisplayInformationMsg(Widget w,StringConst name,StringConst msg_default,StringConst title_default,StringConst help_default,...)720 void XmtDisplayInformationMsg(Widget w, StringConst name,
721 			      StringConst msg_default,
722 			      StringConst title_default,
723 			      StringConst help_default,
724 			      ...)
725 #else
726 void XmtDisplayInformationMsg(w, name,
727 			      msg_default, title_default, help_default,
728 			      va_alist)
729 Widget w;
730 String name, title_default, help_default, msg_default;
731 va_dcl
732 #endif
733 {
734     va_list args;
735 
736     Va_start(args, help_default);
737     (void)_XmtDisplayMessage(w, name, XmtCInformationDialog,
738 			     msg_default, &args,
739 			     title_default, help_default, None,
740 			     XmDIALOG_INFORMATION, XmDIALOG_MODELESS);
741     va_end(args);
742 }
743 
744 #if NeedVarargsPrototypes
XmtDisplayWarningMsgAndWait(Widget w,StringConst name,StringConst msg_default,StringConst title_default,StringConst help_default,...)745 void XmtDisplayWarningMsgAndWait(Widget w, StringConst name,
746 				 StringConst msg_default,
747 				 StringConst title_default,
748 				 StringConst help_default,
749 				 ...)
750 #else
751 void XmtDisplayWarningMsgAndWait(w, name,
752 				 msg_default, title_default, help_default,
753 				 va_alist)
754 Widget w;
755 String name, title_default, help_default, msg_default;
756 va_dcl
757 #endif
758 {
759     va_list args;
760     Boolean *block;
761 
762     Va_start(args, help_default);
763     block = _XmtDisplayMessage(w, name, XmtCWarningDialog,
764 			       msg_default, &args,
765 			       title_default, help_default, None,
766 			       XmDIALOG_WARNING,
767 			       XmDIALOG_PRIMARY_APPLICATION_MODAL);
768     va_end(args);
769     XmtBlock(w, block);
770 }
771 
772 #if NeedVarargsPrototypes
XmtDisplayErrorMsgAndWait(Widget w,StringConst name,StringConst msg_default,StringConst title_default,StringConst help_default,...)773 void XmtDisplayErrorMsgAndWait(Widget w, StringConst name,
774 			       StringConst msg_default,
775 			       StringConst title_default,
776 			       StringConst help_default,
777 			       ...)
778 #else
779 void XmtDisplayErrorMsgAndWait(w, name,
780 			       msg_default, title_default, help_default,
781 			       va_alist)
782 Widget w;
783 String name, title_default, help_default, msg_default;
784 va_dcl
785 #endif
786 {
787     va_list args;
788     Boolean *block;
789 
790     Va_start(args, help_default);
791     block = _XmtDisplayMessage(w, name, XmtCErrorDialog,
792 			       msg_default, &args,
793 			       title_default, help_default, None,
794 			       XmDIALOG_ERROR,
795 			       XmDIALOG_PRIMARY_APPLICATION_MODAL);
796     va_end(args);
797     XmtBlock(w, block);
798 }
799 
800