#! ../mofe --f

# for X11R4 users...  fallbackResources are new in R5 ....
if [string match "" [info command fallbackResources]] {
    alias fallbackResources mergeResources
}

fallbackResources topLevel \
        *XmPushButtonGadget*fontList  \
	    -*-helvetica-medium-r-normal-*-12-*-iso8859-1 \
	*rc*XmDialogShell*fontList \
            -adobe-helvetica-bold-r-*-*-*-180-*-*-*-*-*-* \
	*rc*XmDialogShell*XmToggleButton.fontList \
	    -adobe-helvetica-medium-r-*-*-*-180-*-*-*-*-*-* \
	*rc*XmDialogShell*XmPushButton.fontList \
	    -adobe-helvetica-medium-r-*-*-*-180-*-*-*-*-*-* \
	\
	*rc*XmDialogShell.mappedWhenManaged      false \
	*rc*XmDialogShell*frame.shadowThickness  4     \
	*rc*XmDialogShell*frame.marginWidth	 15    \
	*rc*XmDialogShell*frame.marginHeight	 15    \
	\
	*btn1.labelString               "Text, caption right" \
        *btn1.activateCallback          "captionExample caption1 %W text" \
	*caption1*cw.labelString        Caption  \
	*caption1*cw.labelPosition      right    \
	*caption1*cw.labelAlignment     center   \
	*caption1*cw.spacing            30       \
	\
	*btn2.labelString               "ButtonBox, caption top center" \
        *btn2.activateCallback          "captionExample caption2 %W buttons" \
	*caption2*cw.wcClassName	XbaeCaption \
	*caption2*cw.labelString	Caption \
	*caption2*cw.labelPosition	top \
	*caption2*cw.labelAlignment	center \
	*caption2*cw.labelOffset	-15 \
	*caption2*cw.Offset		10 \
	*caption2*cw.leftAttachment	attach_form \
	*caption2*cw.rightAttachment	attach_form \
	*caption2*cw.bottomAttachment	attach_form \
	*caption2*cw.topAttachment	attach_form \
	*caption2*rc.orientation	vertical \
	*caption2*button.labelString	PushButton \
	\
	*btn3.labelString               "ButtonBox, multiline caption left" \
        *btn3.activateCallback          "captionExample caption3 %W buttons" \
	*caption3*cw.wcClassName XbaeCaption \
	*caption3*cw.labelString Multi\nLine\nCaption \
	*caption3*cw.labelPosition      left \
	*caption3*cw.labelAlignment 	top  \
        *caption3*cw.labelOffset	5 \
	*caption3*cw.labelTextAlignment alignment_end \
        *caption3*cw.Offset	        10 \
        *caption3*cw.leftAttachment     attach_form \
        *caption3*cw.rightAttachment	attach_form \
        *caption3*cw.bottomAttachment	attach_form \
        *caption3*cw.topAttachment	attach_form \
	*caption3*rc.orientation	vertical    \
	*caption3*button.labelString	PushButton  \
	\
	*btn4.labelString               "Text, caption left" \
        *btn4.activateCallback          "captionExample caption4 %W text" \
	*caption4*cw.labelString        Caption:    \
	*caption4*cw.labelOffset        5           \
	*caption4*columns               10          \
	\
	*btn5.labelString               "Double toggle boxes" \
        *btn5.activateCallback          "captionExample caption5 %W toggles" \
	*caption5*rc.spacing                   20   \
	*caption5*rc.marginWidth               10   \
	*caption5*rc.marginHeight              10   \
	*caption5*XbaeCaption.labelPosition    top  \
	*caption5*XbaeCaption.labelAlignment   left \
        *caption5*XbaeCaption.labelOffset      -15  \
        *caption5*Xbae.Offset		       10   \
	*caption5*cw1.labelString              "ToggleBox 1" \
        *caption5*cw2.labelString	       "ToggleBox 2" \
	\
	*menu_bar*background gray75 \
	*.background gray90 \
	*.foreground black 

XmMainWindow main topLevel
 XmMenuBar menu_bar main 
    XmPulldownMenu mpa menu_bar unmanaged
      XmPushButtonGadget Quit mpa activateCallback quit
    XmCascadeButton Actions menu_bar subMenuId mpa

    XmPulldownMenu mph menu_bar unmanaged
      XmPushButtonGadget Help mph activateCallback "manageChild helpbox"
    XmCascadeButton Help menu_bar subMenuId mph
    sV menu_bar menuHelpWidget Help

 XmMessageDialog helpbox Help unmanaged \
	dialogTitle "$argv0 Help" okLabelString "Close" messageString "
 This small example script  demonstrates XbaeCaption widget class 
 from the Xbae Widget set. This widget class provides easy to use 
 means to label other widgets.
 
 This script requires mofe compiled with Xbae support
 
 Gustaf Neumann                  Mohegan Lake, Sat, Nov  5 1994"
  unmanageChild \
	[XmMessageBoxGetChild helpbox DIALOG_CANCEL_BUTTON] \
	[XmMessageBoxGetChild helpbox DIALOG_HELP_BUTTON] 

#-------------------- here starts the real work -----------------

if [string match "" [info command XbaeCaption]] {
  set msg {
    This program can only be used, when mofe was compiled 
    with support for the Xbae widgets (XBAE). Your 
    version of mofe supports currently the following packages:
  }
  append msg \n $PACKAGES
  XmLabel l main labelString $msg recomputeSize false width 500 height 300 
  XmPushButton quit main activateCallback quit
  sV main messageWindow quit
} else {
  XmRowColumn rc main
  foreach b {btn1 btn2 btn3 btn4 btn5} { XmPushButton $b rc }
  sV main workWindow rc
}

realize

proc captionExample { name parent type } {
  set sh [XmDialogShell $name $parent unmanaged]

  switch $type {
    text {
      set co [XbaeCaption cw $sh unmanaged]
      XmTextField text $co
    }
    buttons {
      set co [XmForm form $sh unmanaged]
      set rb [XmRowColumn buttons [XmFrame frame [XbaeCaption cw $co]]]
      foreach b {one two three} {
	XmPushButton $b $rb labelString "Button $b"
    } }
    toggles {
      set co [XmRowColumn rc $sh unmanaged]
      foreach box {1 2} {
	set rb [XmRadioBox radio [XmFrame frame [XbaeCaption cw$box $co]]]
	foreach b {one two three four} {
	  XmToggleButton $b $rb labelString "Toggle $b"
    } } }
  }

  manageChild $co
  callback $sh popupCallback positionCursor 0
  popup $sh none
}
