File: xmpi_misc.c

package info (click to toggle)
xmpi 2.2-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,232 kB
  • ctags: 1,656
  • sloc: ansic: 13,738; sh: 1,799; makefile: 233
file content (810 lines) | stat: -rw-r--r-- 17,897 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
/*
 * Copyright 1998-1999, University of Notre Dame.
 * Authors: Brian W. Barrett, Arun F. Rodrigues, Jeffrey M. Squyres,
 * 	 and Andrew Lumsdaine
 *
 * This file is part of XMPI
 *
 * You should have received a copy of the License Agreement for XMPI 
 * along with the software; see the file LICENSE.  If not, contact 
 * Office of Research, University of Notre Dame, Notre Dame, IN 46556.
 *
 * Permission to modify the code and to distribute modified code is
 * granted, provided the text of this NOTICE is retained, a notice that
 * the code was modified is included with the above COPYRIGHT NOTICE and
 * with the COPYRIGHT NOTICE in the LICENSE file, and that the LICENSE
 * file is distributed with the modified code.
 *
 * LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.
 * By way of example, but not limitation, Licensor MAKES NO
 * REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY
 * PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS
 * OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS
 * OR OTHER RIGHTS.
 *
 * Additional copyrights may follow.

 *
 *	$Id: xmpi_misc.c,v 1.11 1999/11/11 05:32:05 arodrig6 Exp $
 * 
 *	Function:	- miscellaneous XMPI functions
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define _NO_PROTO

#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xm/Label.h>
#include <Xm/MessageB.h>
#include <Xm/PushB.h>
#include <Xm/SashP.h>
#include <X11/cursorfont.h>

#include "xmpi.h"
#include "Bitmaps/stipple.xbm"

/*
 * global functions
 */
void			xmpi_atexit();
void			xmpi_fail();
void			xmpi_busy_widget();
void			xmpi_unbusy_widget();
void			xmpi_formattach();
void			xmpi_setlabel();
void			xmpi_nosash();
void			xmpi_vstr_extent();
void			xmpi_vstr_draw();
Widget			xmpi_mkpixbutton();
Widget			xmpi_mkcolpixbutton();
Widget			xmpi_mklabel __ARGS((Widget, char *, int, int));
int			xmpi_yesno();
int			xmpi_coll2pt();

/*
 * local functions
 */
static Pixmap		make_stippled();
static void		wait_cb();

/*
 * local variables
 */
static Cursor		busycursor = 0;		/* busy cursor */

/*
 * local macros and defines
 */
#define YES	1
#define NO	2


/*
 *	xmpi_atexit
 *
 *	Function:	- wrapper for atexit()
 */
void
xmpi_atexit(func)

void			(*func)();

{
#if HAVE_ATEXIT
	atexit(func);
#else
	on_exit((int ((*)())) func, (char *) 0);
#endif
}

/*
 *	xmpi_fail
 *
 *	Function:	- print error message and exit
 *	Accepts:	- error message
 */
void
xmpi_fail(msg)

char			*msg;

{
	perror(msg);
	exit(errno);
}

/*
 *      xmpi_coll2pt
 *
 *      Function:       - change context ID from collective to pt2pt
 *      Accepts:        - collective context ID
 *      Returns:        - pt2pt context ID
 */
int
xmpi_coll2pt(cid)

int                     cid;

{
        return((cid >= 0) ? cid : -(cid + 1));
}

/*
 * 	xmpi_flush
 *
 *	Function:	- flush and update display
 */
void
xmpi_flush()

{
	XFlush(XtDisplay(xmpi_shell));
	XmUpdateDisplay(xmpi_shell);
}

/*
 *	xmpi_busy_widget
 *
 *	Function:	- switches windows cursor to a busy indicator
 *	Accepts:	- any widget in the window
 */
void
xmpi_busy_widget(w)

Widget			w;

{
	if (busycursor == 0) {
		busycursor = XCreateFontCursor(XtDisplay(w), XC_watch);
	}

	XDefineCursor(XtDisplay(w), XtWindow(w), busycursor);
	xmpi_flush();
}

/*
 *	xmpi_unbusy_widget
 *
 *	Function:	- switches windoews cursor back to normal value
 *	Accepts:	- any widget in the window
 */
void
xmpi_unbusy_widget(w)

Widget			w;

{
	XUndefineCursor(XtDisplay(w), XtWindow(w));
}

/*
 *	xmpi_vstr_extent
 *
 *	Function:	- get extent of vertical text
 *	Accepts:	- text string
 *			- text font
 *			- text width (out)
 *			- text height (out)
 *	Returns:	- 
 */
void
xmpi_vstr_extent(str, font, width, height)

char			*str;
XFontStruct		*font;
int			*width;
int			*height;

{
	int		dir;			/* string direction */
	int		ascent;			/* font ascent */
	int		descent;		/* font descent */
	XCharStruct	fmtinfo;		/* string font info */

	XTextExtents(font, str, strlen(str),
			&dir, &ascent, &descent, &fmtinfo);

	*height = fmtinfo.width;
	*width = fmtinfo.ascent + fmtinfo.descent;
}

/*
 *	xmpi_vstr_draw
 *
 *	Function:	- draw vertical text
 *	Accepts:	- display
 *			- drawable text is to be drawn into
 *			- graphics context to draw with
 *			- x position of text in drawable
 *			- y position of text on drawable
 *			- text string
 *			- text font (must be that in the GC)
 */
void
xmpi_vstr_draw(disp, draw, gc, x, y, str, font)

Display 		*disp;
Drawable		draw;
GC			gc;
int			x;
int			y;
char			*str;
XFontStruct		*font;

{
	XImage		*hori, *vert;
	int		xp, yp;
	Pixmap		pix;
	int 		w, h;
	int		dir;			/* string direction */
	int		ascent;			/* font ascent */
	int		descent;		/* font descent */
	XCharStruct	fmtinfo;		/* string font info */
	XGCValues	gcval;			/* graphic context info */
	Pixel		fg;			/* foreground */
	unsigned long	pixel;
	unsigned int	depth;

	memset(&gcval,0,sizeof(gcval));

	depth = DefaultDepth(disp, DefaultScreen(disp));

	XTextExtents(font, str, strlen(str),
			&dir, &ascent, &descent, &fmtinfo);

	w = fmtinfo.width;
	h = fmtinfo.ascent + fmtinfo.descent;

	pix = XCreatePixmap(disp, draw, w, h, depth);

	XGetGCValues(disp, gc, GCForeground, &gcval);
	fg = gcval.foreground;

	gcval.foreground = gcval.background;
	XChangeGC(disp, gc, GCForeground, &gcval);

	XFillRectangle(disp, pix, gc, 0, 0, w, h);

	gcval.foreground = fg;
	XChangeGC(disp, gc, GCForeground, &gcval);

	XDrawImageString(disp, pix, gc, 0, fmtinfo.ascent, str, strlen(str));

	hori = XCreateImage(disp,
			DefaultVisual(disp, DefaultScreen(disp)),
			depth, XYPixmap, 0, XtMalloc(((w + 7) / 8) * (h+1) * depth),
			w, h, 8, 0);

	XGetSubImage(disp, pix, 0, 0, w, h, AllPlanes, XYPixmap, hori, 0, 0);

	vert = XCreateImage(disp,
			DefaultVisual(disp, DefaultScreen(disp)),
			depth, XYPixmap, 0, XtMalloc(((h + 7) / 8) * (w+1) * depth),
			h, w, 8, 0);

	for (xp = 0; xp < w; xp++) {
		for (yp = 0; yp < h; yp++) {
			pixel = XGetPixel(hori, xp, yp);
			XPutPixel(vert, yp, w - 1 - xp, pixel);
		}
	}

	XPutImage(disp, draw, gc, vert, 0, 0, x, y, h, w);

	XDestroyImage(hori);
	XDestroyImage(vert);
	XFreePixmap(disp, pix);
}

/*
 *	xmpi_mkpixbutton
 *
 *	Function:	- make a button with pixmap
 *			- creates pixmaps for the regular and armed
 *			  button, and for "insensitive" mode if needed
 *			- pixmaps are not created if "bits" is NULL
 *	Accepts:	- parent widget
 *			- activate callback function (or NULL)
 *			- activate argument (or NULL)
 *			- arm callback function (or NULL)
 *			- arm argument (or NULL)
 *			- disarm callback function (or NULL)
 *			- disarm argument (or NULL)
 *			- pixmap bits
 *			- pixmap width
 *			- pixmap height
 *			- insensitive flag
 *	Returns:	- button widget
 */
Widget
xmpi_mkpixbutton(parent_w, act_cb, act_arg, arm_cb, arm_arg,
		dis_cb, dis_arg, pixbits, pixwidth, pixheight, fl_insensitive)

Widget			parent_w;
void			(*act_cb)();
char			*act_arg;
void			(*arm_cb)();
char			*arm_arg;
void			(*dis_cb)();
char			*dis_arg;
unsigned char		*pixbits;
int			pixwidth;
int			pixheight;
int			fl_insensitive;

{
	Widget		w;			/* favourite widget */
	Pixmap		pix;			/* button pixmap */
	Pixmap		clipmask;		/* clipmask bitmap */
	Pixmap		stipple;		/* stipple bitmap */
	Pixel		fg, bg, ag;		/* button colours */
	GC		pen;			/* stipple pen */
	XGCValues	val;			/* pen values */
	Display		*display;		/* display pointer */
	Drawable	root;			/* root of screen */
	unsigned int	depth;			/* depth of screen */
/*
 * Create the button.
 */
	w = XtVaCreateManagedWidget("ctl_btn",
			xmPushButtonWidgetClass, parent_w,
			NULL);
/*
 * Set the callback functions.
 */
	if (act_cb) XtAddCallback(w, XmNactivateCallback, act_cb, act_arg);
	if (arm_cb) XtAddCallback(w, XmNarmCallback, arm_cb, arm_arg);
	if (dis_cb) XtAddCallback(w, XmNdisarmCallback, dis_cb, dis_arg);
/*
 * If needed, create/attach the pixmap.
 */
	if (pixbits) {
		XtVaGetValues(parent_w,
				XmNforeground, &fg, XmNbackground, &bg, NULL);

		display = XtDisplay(parent_w);
		root = RootWindowOfScreen(XtScreen(parent_w));
		depth = DefaultDepthOfScreen(XtScreen(parent_w));

		pix = XCreatePixmapFromBitmapData(display, root,
				(char *)pixbits, pixwidth, pixheight, fg, bg, depth);

		XtVaSetValues(w, XmNlabelType, XmPIXMAP,
				XmNlabelPixmap, pix, NULL);
/*
 * Create the armed-mode pixmap.
 */
		XtVaGetValues(w, XmNarmColor, &ag, NULL);

		pix = XCreatePixmapFromBitmapData(display, root,
				(char *)pixbits, pixwidth, pixheight, fg, ag, depth);

		XtVaSetValues(w, XmNarmPixmap, pix, NULL);
/*
 * Create the insensitive-mode pixmap if needed.
 */
		if (fl_insensitive) {

			pix = XCreatePixmap(display, root,
						(int)pixwidth, pixheight, depth);

			val.foreground = bg;
			pen = XCreateGC(display, pix, GCForeground, &val);

			XFillRectangle(display, pix, pen,
						0, 0, pixwidth, pixheight);

			clipmask = XCreateBitmapFromData(display, root,
						(char *)pixbits, pixwidth, pixheight);

			stipple = XCreateBitmapFromData(display, root,
						(char *)stipple_bits, stipple_width,
						stipple_height);

			val.foreground = fg;
			val.background = bg;
			val.fill_style = FillStippled;
			val.stipple = stipple;
			val.clip_mask = clipmask;

			XChangeGC(display, pen,
					GCForeground | GCBackground |
					GCFillStyle | GCStipple | GCClipMask,
					&val);

			XFillRectangle(display, pix, pen,
						0, 0, pixwidth, pixheight);

			XtVaSetValues(w, XmNlabelInsensitivePixmap, pix, NULL);

			XFreeGC(display, pen);
			XFreePixmap(display, stipple);
			XFreePixmap(display, clipmask);
		}
	}

	return(w);
}

/*
 *	xmpi_mkcolpixbutton
 *
 *	Function:	- make a button with coloured pixmap
 *			- creates pixmaps for the regular and armed
 *			  button, and for "insensitive" mode if needed
 *	Accepts:	- parent widget
 *			- activate callback function (or NULL)
 *			- activate argument (or NULL)
 *			- arm callback function (or NULL)
 *			- arm argument (or NULL)
 *			- disarm callback function (or NULL)
 *			- disarm argument (or NULL)
 *			- pixmap xpm
 *			- insensitive flag
 *	Returns:	- button widget or 0 if pixmap could not be created
 */
Widget
xmpi_mkcolpixbutton(parent_w, act_cb, act_arg, arm_cb, arm_arg,
		dis_cb, dis_arg, xpm, fl_insensitive)

Widget			parent_w;
void			(*act_cb)();
char			*act_arg;
void			(*arm_cb)();
char			*arm_arg;
void			(*dis_cb)();
char			*dis_arg;
char			*xpm[];
int			fl_insensitive;

{
	Widget		w;			/* favourite widget */
	Pixmap		pix;			/* button pixmap */
	Pixel		fg, bg;			/* button colours */
	Display		*display;		/* display pointer */
	Drawable	root;			/* root of screen */
	int		width;			/* width of button pixmap */
	int		height;			/* height of button pixmap */
/*
 * Create the button.
 */
	w = XtVaCreateManagedWidget("ctl_btn",
			xmPushButtonWidgetClass, parent_w, NULL);
/*
 * Set the callback functions.
 */
	if (act_cb) XtAddCallback(w, XmNactivateCallback, act_cb, act_arg);
	if (arm_cb) XtAddCallback(w, XmNarmCallback, arm_cb, arm_arg);
	if (dis_cb) XtAddCallback(w, XmNdisarmCallback, dis_cb, dis_arg);
/*
 * Create/attach the pixmap.
 */
	display = XtDisplay(parent_w);
	root = RootWindowOfScreen(XtScreen(parent_w));

	XtVaGetValues(parent_w, XmNforeground, &fg, XmNbackground, &bg, NULL);

	xpm_build(w, xpm, bg, &pix, &width, &height);
/*
 * Destroy the widget and bail out if the pixmap couldn't be made.
 */
	if (pix == XmUNSPECIFIED_PIXMAP) {
		XtDestroyWidget(w);
		return(0);
	}

	XtVaSetValues(w, XmNlabelType, XmPIXMAP, XmNlabelPixmap, pix,
			XmNhighlightColor, bg, NULL);
/*
 * Create the insensitive-mode pixmap if needed.
 */
	if (fl_insensitive) {
		pix = make_stippled(display, root, w, bg, pix);
		XtVaSetValues(w, XmNlabelInsensitivePixmap, pix, NULL);
	}

	return(w);
}

/*
 *	xmpi_formattach
 *
 *	Function:	- attach widget to Form (fractionBase) positions
 *			- work around SUN SDK Motif bug
 *			- negative positions are not attached
 *	Accepts:	- widget
 *			- top/bottom/left/right positions
 */
void
xmpi_formattach(w, top, bottom, left, right)

Widget			w;
int			top;
int			bottom;
int			left;
int			right;

{
	int		frac;			/* Form fractionBase */

	XtVaGetValues(XtParent(w), XmNfractionBase, &frac, NULL);

	if (top == 0) {
		XtVaSetValues(w, XmNtopAttachment, XmATTACH_FORM, NULL);
	} else if (top > 0) {
		XtVaSetValues(w, XmNtopAttachment, XmATTACH_POSITION,
				XmNtopPosition, top, NULL);
	}

	if (left == 0) {
		XtVaSetValues(w, XmNleftAttachment, XmATTACH_FORM, NULL);
	} else if (left > 0) {
		XtVaSetValues(w, XmNleftAttachment, XmATTACH_POSITION,
				XmNleftPosition, left, NULL);
	}

	if (bottom == frac) {
		XtVaSetValues(w, XmNbottomAttachment, XmATTACH_FORM, NULL);
	} else if (bottom > 0) {
		XtVaSetValues(w, XmNbottomAttachment, XmATTACH_POSITION,
				XmNbottomPosition, bottom, NULL);
	}

	if (right == frac) {
		XtVaSetValues(w, XmNrightAttachment, XmATTACH_FORM, NULL);
	} else if (right > 0) {
		XtVaSetValues(w, XmNrightAttachment, XmATTACH_POSITION,
				XmNrightPosition, right, NULL);
	}
}

/*
 *	xmpi_mklabel
 *
 *	Function:	- create a label with or without a frame
 *	Accepts:	- parent widget
 *			- label string
 *			- label alignment
 *			- frame flag
 *	Returns:	- label widget
 */
#ifdef __STDC__
Widget
xmpi_mklabel(Widget parent_w, char *string, int align, int fl_frame)
#else
Widget
xmpi_mklabel(parent_w, string, align, fl_frame)

Widget			parent_w;
char			*string;
int			align;
int			fl_frame;
#endif
{
	Widget		lbl_w;			/* label widget */
	Widget		frm_w;			/* frame widget */

	if (string == 0) string = " ";

	if (fl_frame) {
		frm_w = XtVaCreateManagedWidget("label_frame",
				xmFrameWidgetClass, parent_w,
				XmNshadowType, XmSHADOW_IN,
				XmNshadowThickness, 2,
				NULL);

		parent_w = frm_w;
	}

	lbl_w = XtVaCreateManagedWidget(string,
			xmLabelWidgetClass, parent_w,
			XmNalignment, align,
			NULL);

	return(lbl_w);
}

/*
 *	xmpi_setlabel
 *
 *	Function:	- set the contents of a label
 *	Accepts:	- label widget
 *			- string
 */
void
xmpi_setlabel(lbl_w, string)

Widget			lbl_w;
char			*string;

{
	XtVaSetValues(lbl_w, XtVaTypedArg, XmNlabelString, XmRString,
		string, strlen(string) + 1, NULL);
}

/*
 *	make_stippled
 *
 *	Function:	- create a stippled version of a pixmap
 *	Accepts:	- X display
 *			- root drawable
 *			- pushbutton on which pixmap is to be used
 *			- background colour
 *			- pixmap to be stippled
 *	Returns:	- stippled pixmap
 */
static Pixmap
make_stippled(display, root, pushbutton, bg, pix)

Display			*display;
Drawable		root;
Widget			pushbutton;
Pixel			bg;
Pixmap			pix;

{
	static unsigned char stipplebitmap[8] = { 0x55, 0xAA, 0x55, 0xAA,
					     0x55, 0xAA, 0x55, 0xAA };
	Pixmap		stipple;
	Pixmap		inspix;
	GC        	gc;
        XGCValues 	gcvalues;
	Window		rootwindow;
	int		x, y;
	unsigned int	width, height;
	unsigned int	border;
	unsigned int	depth;
	
	stipple = XCreateBitmapFromData(display, root, (char *)stipplebitmap, 8, 8);

	gcvalues.foreground = bg;
	gcvalues.fill_style = FillStippled;
	gcvalues.stipple    = stipple;
	
	gc = XtGetGC(pushbutton, GCForeground | GCFillStyle | GCStipple,
			&gcvalues);

	XGetGeometry(display, pix, &rootwindow, &x, &y, &width, &height,
			&border, &depth);
	
	inspix = XCreatePixmap(display, root, width, height, depth);
	
	XCopyArea(display, pix, inspix, gc, 0, 0, width, height, 0, 0);
	
	XFillRectangle(display, inspix, gc, 0, 0, width, height);
	
	XtReleaseGC(pushbutton, gc);
	XFreePixmap(display, stipple);

	return(inspix);
}

/*
 *	xmpi_nosash
 *
 *	Function:	- removes sashes from paned manager
 *	Accepts:	- paned widget
 */
void
xmpi_nosash(paned)

Widget			paned;

{
	Widget		*pchildren;	/* children of paned mgr */
	int		nchildren;	/* # paned children */
/*
 * Remove separators and make sashes microscopic.
 */
#if 0
	XtVaSetValues(paned,
		XmNsashWidth, 1,
		XmNsashHeight, 1,
		XmNseparatorOn, False,
		NULL);
#endif

/*
 * Remove the sashes from tab traversal.
 */
	XtVaGetValues(paned,
		XmNchildren, &pchildren,
		XmNnumChildren, &nchildren,
		NULL);

	while (nchildren-- > 0) {

		if (XmIsSash(pchildren[nchildren])) {
			XtVaSetValues(pchildren[nchildren],
				XmNtraversalOn, False,
				NULL);
		}
	}
}

/*
 *	xmpi_yesno
 *
 *	Function:	- pop up dialog asking a yes/no type question, wait
 *			  for and return the users response
 *	Accepts:	- parent widget
 *			- text of the question
 *	Returns:	- 1 if user responds YES, else 0
 */
int
xmpi_yesno(parent, question)

Widget 			parent;
char			*question;

{
	Widget		dialog_w;		/* question dialog */
	XmString	str1, str2, str3;	/* various strings */
	Arg		args[5];
	int		response = 0;		/* response to question */

	str1 = XmStringCreateSimple(question);
	str2 = XmStringCreateSimple("Yes");
	str3 = XmStringCreateSimple("No");

	XtSetArg(args[0], XmNmessageString, str1);
	XtSetArg(args[1], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
	XtSetArg(args[2], XmNautoUnmanage, False);
	XtSetArg(args[3], XmNokLabelString, str2);
	XtSetArg(args[4], XmNcancelLabelString, str3);
	
	dialog_w = XmCreateQuestionDialog(xmpi_wmshell(parent),
						"wait_pop", args, 5);
	
	XmStringFree(str1);
	XmStringFree(str2);
	XmStringFree(str3);

	XtAddCallback(dialog_w, XmNokCallback, wait_cb, &response);
	XtAddCallback(dialog_w, XmNcancelCallback, wait_cb, &response);

	XtUnmanageChild(XmMessageBoxGetChild(dialog_w, XmDIALOG_HELP_BUTTON));
	XtManageChild(dialog_w);
	XtPopup(XtParent(dialog_w), XtGrabNone);

/*
 * Wait until a response has been selected.
 */
	while (! response) {
		XtAppProcessEvent( XtWidgetToApplicationContext(parent),
			XtIMAll);
	}

	return(response == YES);
}

/*
 *	wait_cb
 *
 *	Function:	- set users response
 *			  callback for xmpi_yesno
 *	Accepts:	- callback parms
 */
static void
wait_cb(w, answer, cbs)

Widget			w;
int			*answer;
XmAnyCallbackStruct	*cbs;

{
	switch (cbs->reason) {

	case XmCR_OK:
		*answer = YES;
		break;
	default:
		*answer = NO;
	}
	
	XtDestroyWidget(w);
}