# Copyright (c) 2003, 2009 Oscar Garcia
# MIT OSI License.  See License.txt file.

# interface generated by SpecTcl version 1.1 from C:/EasySDE/modelinfo.ui
#   root     is the parent window for this user interface

proc modelinfo_ui {root args} {

	# this treats "." as a special case

	if {$root == "."} {
	    set base ""
	} else {
	    set base $root
	}
    
	frame $base.frame#8 \
		-borderwidth 2 \
		-relief groove

	frame $base.globalsFrame \
		-borderwidth 2 \
		-relief groove

	frame $base.frame#9 \
		-borderwidth 2 \
		-relief groove

	frame $base.frame#11 \
		-borderwidth 2 \
		-relief groove

	frame $base.frame#12

	frame $base.localsFrame \
		-borderwidth 2 \
		-relief groove

	label $base.label#18 \
		-text Title:

	entry $base.titleEntry \
		-cursor {} \
		-textvariable globinfo(title)

	checkbutton $base.binariesCheckbutton \
		-command Binaries \
		-text {Use previous binary files} \
		-variable globinfo(binaries)

	label $base.dataFileLabel \
		-text {Data file:}

	entry $base.dataFileEntry \
		-cursor {} \
		-textvariable globinfo(dataFile)

	button $base.dataFileButton \
		-command DataFile \
		-text Browse

	label $base.scalingLabel \
		-text Scaling:

	label $base.ageLabel \
		-text Age

	entry $base.ageEntry \
		-cursor {} \
		-textvariable globinfo(ageScale) \
		-width 6

	label $base.heightLabel \
		-text Height

	entry $base.heightEntry \
		-cursor {} \
		-textvariable globinfo(htScale) \
		-width 6

	label $base.headerLabel \
		-bitmap @parms.xbm \
		-padx 22
	catch {
		$base.headerLabel configure \
			-font {-*-Courier New-Medium-R-Normal-*-*-120-*-*-*-*-*-*}
	}

	label $base.modelLabel \
		-text Model:

	menubutton $base.modelMenubutton \
		-activebackground white \
		-background white \
		-menu "$base.modelMenubutton.m" \
		-padx 22 \
		-relief sunken \
		-textvariable buttlabel
	catch {
		$base.modelMenubutton configure \
			-font {-*-Courier New-Medium-R-Normal-*-*-120-*-*-*-*-*-*}
#was:			-font -*-Courier-Medium-R-Normal-*-*-120-*-*-*-*-*-*
	}

	label $base.label#28 \
		-text {Initial estimates}

	label $base.g1Label \
		-text G1

	entry $base.g1Entry \
		-cursor {} \
		-textvariable globinfo(g1) \
		-width 14

	label $base.g2Label \
		-text G2

	entry $base.g2Entry \
		-cursor {} \
		-textvariable globinfo(g2) \
		-width 14

	label $base.g3Label \
		-text G3

	entry $base.g3Entry \
		-cursor {} \
		-textvariable globinfo(g3) \
		-width 14

	label $base.g4Label \
		-text G4

	entry $base.g4Entry \
		-cursor {} \
		-textvariable globinfo(g4) \
		-width 14

	label $base.g5Label \
		-text G5

	entry $base.g5Entry \
		-cursor {} \
		-textvariable globinfo(g5) \
		-width 14

	label $base.g6Label \
		-text G6

	entry $base.g6Entry \
		-cursor {} \
		-textvariable globinfo(g6) \
		-width 14

	label $base.l1Label \
		-text L1

	entry $base.l1Entry \
		-cursor {} \
		-textvariable globinfo(l1) \
		-width 14

	label $base.l2Label \
		-text L2

	entry $base.l2Entry \
		-cursor {} \
		-textvariable globinfo(l2) \
		-width 14

	button $base.helpButton \
		-command Help \
		-padx 8 \
		-pady 3 \
		-text Help
	catch {
		$base.helpButton configure \
			-font {-*-MS Sans Serif-Bold-R-Normal-*-*-120-*-*-*-*-*-*}
	}

	button $base.quitButton \
		-command {exit 1} \
		-padx 8 \
		-pady 3 \
		-text Quit
	catch {
		$base.quitButton configure \
			-font {-*-MS Sans Serif-Bold-R-Normal-*-*-120-*-*-*-*-*-*}
	}

	button $base.nextButton \
		-command Next \
		-padx 8 \
		-pady 3 \
		-text Next
	catch {
		$base.nextButton configure \
			-font {-*-MS Sans Serif-Bold-R-Normal-*-*-120-*-*-*-*-*-*}
	}


	# Geometry management

	grid $base.frame#8 -in $root	-row 3 -column 1  \
		-sticky ew
	grid $base.globalsFrame -in $root	-row 6 -column 1  \
		-sticky ew
	grid $base.frame#9 -in $root	-row 4 -column 1  \
		-sticky ew
	grid $base.frame#11 -in $root	-row 1 -column 1  \
		-sticky ew
	grid $base.frame#12 -in $root	-row 8 -column 1  \
		-sticky e
	grid $base.localsFrame -in $root	-row 7 -column 1  \
		-sticky ew
	grid $base.label#18 -in $base.frame#11	-row 1 -column 1 
	grid $base.titleEntry -in $base.frame#11	-row 1 -column 2  \
		-sticky ew
	grid $base.binariesCheckbutton -in $root	-row 2 -column 1  \
		-sticky w
	grid $base.dataFileLabel -in $base.frame#8	-row 1 -column 1 
	grid $base.dataFileEntry -in $base.frame#8	-row 1 -column 2  \
		-columnspan 7 \
		-sticky ew
	grid $base.dataFileButton -in $base.frame#8	-row 1 -column 9  \
		-sticky w
	grid $base.scalingLabel -in $base.frame#8	-row 2 -column 1 
	grid $base.ageLabel -in $base.frame#8	-row 2 -column 3  \
		-sticky e
	grid $base.ageEntry -in $base.frame#8	-row 2 -column 4  \
		-sticky w
	grid $base.heightLabel -in $base.frame#8	-row 2 -column 6  \
		-sticky e
	grid $base.heightEntry -in $base.frame#8	-row 2 -column 7  \
		-sticky w
	grid $base.headerLabel -in $base.frame#9	-row 1 -column 2  \
		-ipadx 60 \
		-sticky w
	grid $base.modelLabel -in $base.frame#9	-row 2 -column 1 
	grid $base.modelMenubutton -in $base.frame#9	-row 2 -column 2  \
		-sticky w
	grid $base.label#28 -in $root	-row 5 -column 1 
	grid $base.g1Label -in $base.globalsFrame	-row 1 -column 1 
	grid $base.g1Entry -in $base.globalsFrame	-row 1 -column 2  \
		-sticky w
	grid $base.g2Label -in $base.globalsFrame	-row 1 -column 3 
	grid $base.g2Entry -in $base.globalsFrame	-row 1 -column 4  \
		-sticky w
	grid $base.g3Label -in $base.globalsFrame	-row 2 -column 1 
	grid $base.g3Entry -in $base.globalsFrame	-row 2 -column 2  \
		-sticky w
	grid $base.g4Label -in $base.globalsFrame	-row 2 -column 3 
	grid $base.g4Entry -in $base.globalsFrame	-row 2 -column 4  \
		-sticky w
	grid $base.g5Label -in $base.globalsFrame	-row 3 -column 1 
	grid $base.g5Entry -in $base.globalsFrame	-row 3 -column 2  \
		-sticky w
	grid $base.g6Label -in $base.globalsFrame	-row 3 -column 3 
	grid $base.g6Entry -in $base.globalsFrame	-row 3 -column 4  \
		-sticky w
	grid $base.l1Label -in $base.localsFrame	-row 1 -column 1 
	grid $base.l1Entry -in $base.localsFrame	-row 1 -column 2  \
		-sticky w
	grid $base.l2Label -in $base.localsFrame	-row 1 -column 3 
	grid $base.l2Entry -in $base.localsFrame	-row 1 -column 4  \
		-sticky w
	grid $base.helpButton -in $base.frame#12	-row 1 -column 1 
	grid $base.quitButton -in $base.frame#12	-row 1 -column 2 
	grid $base.nextButton -in $base.frame#12	-row 1 -column 3 

	# Resize behavior management

	grid rowconfigure $base.frame#11 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#11 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#11 2 -weight 1 -minsize 30

	grid rowconfigure $base.frame#12 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#12 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#12 2 -weight 0 -minsize 30
	grid columnconfigure $base.frame#12 3 -weight 0 -minsize 30

	grid rowconfigure $root 1 -weight 0 -minsize 30
	grid rowconfigure $root 2 -weight 0 -minsize 30
	grid rowconfigure $root 3 -weight 0 -minsize 30
	grid rowconfigure $root 4 -weight 0 -minsize 30
	grid rowconfigure $root 5 -weight 0 -minsize 30
	grid rowconfigure $root 6 -weight 0 -minsize 30
	grid rowconfigure $root 7 -weight 0 -minsize 30
	grid rowconfigure $root 8 -weight 1 -minsize 30
	grid columnconfigure $root 1 -weight 0 -minsize 30

	grid rowconfigure $base.localsFrame 1 -weight 0 -minsize 30
	grid columnconfigure $base.localsFrame 1 -weight 0 -minsize 30
	grid columnconfigure $base.localsFrame 2 -weight 1 -minsize 30
	grid columnconfigure $base.localsFrame 3 -weight 0 -minsize 30
	grid columnconfigure $base.localsFrame 4 -weight 1 -minsize 30

	grid rowconfigure $base.frame#8 1 -weight 0 -minsize 30
	grid rowconfigure $base.frame#8 2 -weight 0 -minsize 30
	grid columnconfigure $base.frame#8 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#8 2 -weight 1 -minsize 30
	grid columnconfigure $base.frame#8 3 -weight 0 -minsize 30
	grid columnconfigure $base.frame#8 4 -weight 0 -minsize 30
	grid columnconfigure $base.frame#8 5 -weight 1 -minsize 30
	grid columnconfigure $base.frame#8 6 -weight 0 -minsize 30
	grid columnconfigure $base.frame#8 7 -weight 0 -minsize 30
	grid columnconfigure $base.frame#8 8 -weight 1 -minsize 30
	grid columnconfigure $base.frame#8 9 -weight 0 -minsize 56

	grid rowconfigure $base.globalsFrame 1 -weight 0 -minsize 30
	grid rowconfigure $base.globalsFrame 2 -weight 0 -minsize 30
	grid rowconfigure $base.globalsFrame 3 -weight 0 -minsize 30
	grid columnconfigure $base.globalsFrame 1 -weight 0 -minsize 30
	grid columnconfigure $base.globalsFrame 2 -weight 1 -minsize 30
	grid columnconfigure $base.globalsFrame 3 -weight 0 -minsize 30
	grid columnconfigure $base.globalsFrame 4 -weight 1 -minsize 30

	grid rowconfigure $base.frame#9 1 -weight 0 -minsize 30
	grid rowconfigure $base.frame#9 2 -weight 0 -minsize 30
	grid columnconfigure $base.frame#9 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#9 2 -weight 1 -minsize 30
# additional interface code
# Interface code for modelinfo

global globinfo nextFlag models base2 header

set base2 $base

set globinfo(binaries) 0

#set header 	"     ID        a     b   c  S0   S  Sm  t0  H0c" 
set models {
	{ 1 4 1 " 1. ALOCAL    L1    G1  G2   0  G3  G4   0   0"}
	{ 2 5 1 " 2. A-T0      L1    G1  G2   0  G3  G4  G5   0"}
	{ 3 5 1 " 3. A-H0      L1    G1  G2   0  G3  G4   0  G5"}
	{ 4 5 1 " 4. A-S0      L1    G1  G2  G3  G4  G5   0   0"}
	{ 5 6 1 " 5. A-T0S0    L1    G1  G2  G3  G4  G5  G6   0"}
	{ 6 4 1 " 6. BLOCAL    G1    L1  G2   0  G3  G4   0   0"}
	{ 7 5 1 " 7. B-T0      G1    L1  G2   0  G3  G4  G5   0"}
	{ 8 5 1 " 8. B-H0      G1    L1  G2   0  G3  G4   0  G5"}
	{ 9 5 1 " 9. B-S0      G1    L1  G2  G3  G4  G5   0   0"}
	{10 6 1 "10. B-T0S0    G1    L1  G2  G3  G4  G5  G6   0"}
	{11 5 1 "11. LINEAR G1+G2*L1 L1  G3   0  G4  G5   0   0"}
	{12 5 1 "12. POWER  G1*L1^G2 L1  G3   0  G4  G5   0   0"}
	{13 3 2 "13. ABLOCALS  L1    L2  G1   0  G2  G3   0   0"}
	{14 4 1 "14. ALOCBH    L1    G1  G2   0  G3  G4  bt bh^c"}
	{15 4 1 "15. BLOCBH    G1    L1  G2   0  G3  G4  bt bh^c"}
	{16 5 1 "16. LINBH  G1+G2*L1 L1  G3   0  G4  G5  bt bh^c"}
	{17 5 1 "17. POWBH  G1*L1^G2 L1  G3   0  G4  G5  bt bh^c"}
	{18 3 2 "18. ABLOCBH   L1    L2  G1   0  G2  G3  bt bh^c"}
}

proc SetModel {n} {
	global globinfo models
	set modlist [lindex $models $n]
	set globinfo(model) [lindex $modlist 0]
	set globinfo(nglobals) [lindex $modlist 1]
	set globinfo(nlocals) [lindex $modlist 2]
	if {$globinfo(binaries)} {
		ParStates $globinfo(nglobals) 0
	} else {
		ParStates $globinfo(nglobals) $globinfo(nlocals)
	}
} 

proc Binaries {} {
	global globinfo base2
	if {$globinfo(binaries)} {
		# disable widgets
		$base2.dataFileLabel configure -state disabled
		$base2.dataFileEntry configure -state disabled
		$base2.dataFileButton configure -state disabled
		$base2.scalingLabel configure -state disabled
		$base2.ageLabel configure -state disabled
		$base2.ageEntry configure -state disabled
		$base2.heightLabel configure -state disabled
		$base2.heightEntry configure -state disabled
		# disable locals
#		$base2.lInitialLabel configure -state disabled
		ParStates $globinfo(nglobals) 0
	} else {
		# enable widgets
		$base2.dataFileLabel configure -state normal
		$base2.dataFileEntry configure -state normal
		$base2.dataFileButton configure -state normal
		$base2.scalingLabel configure -state normal
		$base2.ageLabel configure -state normal
		$base2.ageEntry configure -state normal
		$base2.heightLabel configure -state normal
		$base2.heightEntry configure -state normal
		# enable locals
#		$base2.lInitialLabel configure -state normal
		ParStates $globinfo(nglobals) $globinfo(nlocals)
	}
}

proc State {var n} {
	if {$var > $n} {
		return normal
	} else {
		return disabled
	}
}

proc ParStates {nglobals nlocals} {
	global base2
	$base2.g1Label configure -state [State $nglobals 0]
	$base2.g1Entry configure -state [State $nglobals 0]
	$base2.g2Label configure -state [State $nglobals 1]
	$base2.g2Entry configure -state [State $nglobals 1]
	$base2.g3Label configure -state [State $nglobals 2]
	$base2.g3Entry configure -state [State $nglobals 2]
	$base2.g4Label configure -state [State $nglobals 3]
	$base2.g4Entry configure -state [State $nglobals 3]
	$base2.g5Label configure -state [State $nglobals 4]
	$base2.g5Entry configure -state [State $nglobals 4]
	$base2.g6Label configure -state [State $nglobals 5]
	$base2.g6Entry configure -state [State $nglobals 5]
	$base2.l1Label configure -state [State $nlocals 0]
	$base2.l1Entry configure -state [State $nlocals 0]
	$base2.l2Label configure -state [State $nlocals 1]
	$base2.l2Entry configure -state [State $nlocals 1]
}

proc DataFile {} {
	global globinfo
	set types {
		{{Data Files} {.dat}}
		{{Text Files} {.txt}}
		{{All Files} * }
	}
	set globinfo(dataFile) [tk_getOpenFile -filetypes $types -initialdir Work]
}

proc Next {} {
	global nextFlag
	set nextFlag 1
}

menu $base2.modelMenubutton.m -tearoff 0 -background white -relief sunken \
	-font {-*-Courier New-Medium-R-Normal-*-*-120-*-*-*-*-*-*}
for {set i 0} {$i < [llength $models]} {incr i} {
	$base2.modelMenubutton.m add radio -variable buttlabel -value ""  \
		-label [lindex [lindex $models $i] 3] -command "SetModel $i"
}

$base2.modelMenubutton.m invoke 0
































# end additional interface code

}


# Allow interface to be run "stand-alone" for testing

catch {
    if [info exists embed_args] {
	# we are running in the plugin
	modelinfo_ui .
    } else {
	# we are running in stand-alone mode
	if {$argv0 == [info script]} {
	    wm title . "Testing modelinfo_ui"
	    modelinfo_ui .
	}
    }
}
