#! /usr/dt/bin/dtksh
#
# ident "@(#)bberror.sh	1.1 00/09/13 SMI"
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
# All rights reserved.
#                         
######################################################################
#
#     dterror.ds
#
#     This file is used by datatype definitions to
#     output an error message. It uses dtksh.
#
#    (c) Copyright 1993, 1994 Hewlett-Packard Company
#    (c) Copyright 1993, 1994 International Business Machines Corp.
#    (c) Copyright 1993, 1994 Sun Microsystems, Inc.
#    (c) Copyright 1993, 1994 Novell, Inc.
#
#
######################################################################

# When the OK button is pressed, lets exit out
QuitCB()
{
   exit 0
}

################## Create the Main UI #################################
XtInitialize TOPLEVEL ps_error PSError "$@"

XmCreateMessageBox MYDIALOG $TOPLEVEL mydialog \
messageString:"$(print $1)" \
dialogTitle:"$(print $2)" \
okLabelString:"$(print $3)" \
dialogType:DIALOG_ERROR

if  [ "$#" == "4" ];then 
	TIME=$4
else
	TIME=0
fi

XtAddCallback $MYDIALOG okCallback QuitCB 

XmMessageBoxGetChild CANCEL_BUTTON $MYDIALOG DIALOG_CANCEL_BUTTON
XmMessageBoxGetChild HELP_BUTTON $MYDIALOG DIALOG_HELP_BUTTON

XtUnmanageChild $CANCEL_BUTTON
XtUnmanageChild $HELP_BUTTON

#     Add in a Close Handler so that when the user closes the window
#     Using the Close button (ALT-F4) under the window, it tells the 
#     application that the user closes the window. The Window manager
#     informs the application using the WM_DELETE_WINDOW atom.
XtDisplay DISP $TOPLEVEL
if [ $TIME != 0 ]; then
	XtAddTimeOut $MYDIALOG `expr $TIME \* 1000` QuitCB 
fi
XmInternAtom CLOSE_ATOM $DISP WM_DELETE_WINDOW false
XmAddWMProtocolCallback $TOPLEVEL $CLOSE_ATOM QuitCB
 
#     Also set the Application not to destory any of its widget when
#     WM_DELETE_WINDOW is received. Let the rest of the script does
#     all the necessary processing and exiting.
	
XtSetValues $TOPLEVEL deleteResponse:DO_NOTHING

XtManageChild $MYDIALOG

XtRealizeWidget $TOPLEVEL

XtMainLoop
