#! ../mofe --f
mergeResources topLevel *background gray75
set light gray90 

scriptNeeds XmGraph "This script needs the XmGraph Widget!"

proc entity {name args} {
  eval XmPushButton $name g fontList \
      -adobe-helvetica-bold-r-normal--18-180-75-75-p-103-iso8859-1 $args
}

proc attribute {name type args} {
  global light
  eval XmToggleButton $type$name g labelString $name background $light $args 
  XmArc a$type$name g from $type$name to $type
}

proc relation {name args} {
  eval XmLabel $name g $args width 65 height 31
  changePixmap $name backgroundPixmap relation.xpm
}

 XmMainWindow main topLevel

  XmMenuBar menu_bar main 
    XmPulldownMenu mp1 menu_bar unmanaged
      XmPushButton Edit     mp1 activateCallback "sV g editable true"
      XmPushButton NoEdit   mp1 activateCallback "sV g editable false"
      XmPushButton reOrient mp1 activateCallback "sV g reorient true"
      XmPushButton Quit     mp1 activateCallback quit
    XmCascadeButton Actions menu_bar subMenuId mp1

    XmPulldownMenu mp2 menu_bar unmanaged
      XmPushButton Help    mp2 activateCallback "manageChild helpbox"
      XmPushButton Version mp2 activateCallback "manageChild versionbox"
    XmCascadeButton Help menu_bar subMenuId mp2
    sV menu_bar menuHelpWidget Help

    XmGraph g main  \
	autoLayoutMode false reLayout false background $light \
	width 370 height 135
    entity Person   x 40 y 70
    entity Project  x 260 y 70


 XmMainWindowSetAreas main menu_bar NULL NULL NULL g
 realize

    relation works  x 160 y 70
    attribute Date works x 165 y 20

    attribute Ssn Person x 20 y 20
    attribute Name Person x 70 y 20

    attribute Pnr Project x 245 y 20
    attribute Name Project x 295 y 20

    XmArc worker g from works to Person labelString n mapLabel true
    XmArc theWork g from works to Project labelString 1 mapLabel true

XmMessageDialog versionbox Version unmanaged \
	dialogTitle "Motif Demo Program using XmGraph" \
	okLabelString "Close" \
	messageString "@(#)m-er Version 0.00001, Jan 15, 1993"

XmMessageDialog helpbox Help unmanaged \
	dialogTitle "m-er Help" \
	okLabelString "Close" \
	messageString "\
This program is a simple demo program showing an er diagram. \n\
It is implemented using the XmGraph widget and using a xpm pixmap \n\
with a clip mask for relationship types. The Layout can be rearranged \n\
by using the items from the Actions menu"


unmanageChild \
	[XmMessageBoxGetChild versionbox DIALOG_CANCEL_BUTTON] \
	[XmMessageBoxGetChild versionbox DIALOG_HELP_BUTTON] 
unmanageChild \
	[XmMessageBoxGetChild helpbox DIALOG_CANCEL_BUTTON] \
	[XmMessageBoxGetChild helpbox DIALOG_HELP_BUTTON] 
