#! ../mofe --f

scriptNeeds XbaeMatrix {
  This program can only be used, when mofe was compiled 
  with support for the Xbae widgets (XBAE). 
}

fallbackResources topLevel \
    *XmPushButtonGadget*fontList -*-helvetica-medium-r-normal-*-14-*-*-* \
    *XmCascadeButton.fontList    -*-helvetica-bold-o-normal-*-14-*-*-*   \
    *fontList                -*-helvetica-medium-r-*-*-*-140-*-*-*-*-*-* \
    \
    *m.boldLabels           true              \
    *m.visibleRows          5                 \
    *m.evenRowBackground    white             \
    *m.oddRowBackground     antiquewhite      \
    *m.background 	    gray90            \
    *m.highlightColor       red               \
    *m.gridType		    XmGRID_SHADOW_IN  \
    *m.rowLabels	    "1:, 2:, 3:, 4:, 5:, 6:, 7:, 8:, 9:, 10:"   \
    *m.columnLabels         "Part\nNumber, Description, Quantity"       \
    *m.columnAlignments \
        "alignment_beginning, alignment_beginning, alignment_end"       \
    *m.columnLabelAlignments \
        "alignment_beginning, alignment_center, alignment_end"          \
    \
    *menu_bar*background gray75 \
    *.background gray90 \
    *.foreground black 

set cells {{SARS-10  "Spring Bolt"                13 } 
           {SA-10-31 "Seal Ring"                   3 } 
           {SA-14-75 "Shaft Nut"                  50 } 
           {SA-11-25 "Shaft Washer"               50 }
           {F-44     "Rotary Transmission Grear"   1 }
           {SA-2449A "Spring Clip"                 7 }
           {SARS-288 "Brace Collar"                2 }
	  }

XmMainWindow main topLevel width 675
 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 XbaeMatrix widget class 
 from the Xbae Widget set. This widget class provides spreadsheet 
 like layout and editing facilities. In the last column only 
 digits may be entered
 
 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 -----------------
proc insertNumber {col string} {
  if ![string compare $col 2] {
    XbaeModifyVerifyCBset [regexp {^[0-9]*$} $string match] \
	-1 -1 -1 $string
  }
}

XbaeMatrix m main \
    rows 10 columns 3 \
    columnWidths "10, 20, 5" \
    modifyVerifyCallback {insertNumber %c "%s" } 

set row 0 
foreach line $cells {
  set col 0
  foreach cell $line { XbaeMatrixSetCell m $row $col $cell; incr col }
  incr row
}
sV m topRow 2
XbaeMatrixEditCell m 4 1
realize
