#
#
#	Create a Motif "standard" dialog, consisting of an control area,
#	an action area, and a bunch of buttons with callbacks in the action
#	area.
#
#	Typical use:
#		XrerCreateStandardDialog dialog $topLevel \
#                                OK      ok_cb \
#                                Cancel  cancel_cb \
#                                Help    help_cb
#		XtCreateManagedWidget table table xmpTable $dialog_ca
#		...
#		XtManageChildren $dialog_ca
#		XtManageChildren $dialog
#		XtRealizeWidget $topLevel
#		XtMainLoop
#
function XrerCreateStandardDialog
# var parent [blabel bcallback] ...
{
	typeset Var=$1
	typeset Parent=$2
	typeset Tightness=20
	typeset pane ca sep aa
	typeset i l la r ra nbut fraction_base

	shift 2

	((nbut = $# / 2))
	((fraction_base = $Tightness * $nbut - 1))

	XmCreateForm $Var $Parent pane
	eval pane=\$$Var

	XtCreateWidget ${Var}_aa aa form $pane  \
                                leftAttachment:attach_form \
                                rightAttachment:attach_form \
                                bottomAttachment:attach_form \
                                fractionBase:$fraction_base \

	eval aa=\$${Var}_aa

	XtCreateManagedWidget ${Var}_sep panesep separator $pane \
                                leftAttachment:attach_form \
                                rightAttachment:attach_form \
                                bottomAttachment:attach_widget \
                                bottomWidget:$aa \

	eval sep=\$${Var}_sep

	XtCreateWidget ${Var}_ca ca form $pane \
                                topAttachment:attach_form \
                                leftAttachment:attach_form \
                                rightAttachment:attach_form \
                                bottomAttachment:attach_widget \
                                bottomWidget:$sep \

	eval ca=\$${Var}_ca

	((i=1))
	while (($# >= 2))
	do
		((r = $Tightness * i - 1))
		((l = $Tightness * (i-1) ))
		if (($i == 1)); then
			la=attach_form; else la=attach_position; fi
		if (($i == nbut)); then
			ra=attach_form; else ra=attach_position; fi
		cmw ${Var}_item[$i] ${Var}_item$i pushButton $aa \
			labelString:"$1" \
			activateCallback:"$2" \
			topAttachment:attach_form \
			bottomAttachment:attach_form \
			rightAttachment:$ra \
			rightPosition:$r \
			leftAttachment:$la \
			leftPosition:$l \

		shift 2
		((i=i+1))
	done

	XtManageChildren $aa
}
