# PBSadmb GUI (last modified: 2014-02-26)
window name=PBSadmb title="PBSadmb for ADMB" #onclose=

#------------------------------------ MENU -------------------------------------
# All OS users see all OS intall instruction
menu nitems=3 label=Install
	menuitem label="ADMB Tools for Windows" function=doAction action="browseURL(`http://www.admb-project.org/tools/admb-tools-for-windows`)"
	menuitem label="ADMB Installation Linux" function=doAction action="browseURL(`http://www.admb-project.org/documentation/install/admb-installation-linux`)"
	menuitem label="ADMB Installation Mac XCode" function=doAction action="browseURL(`http://www.admb-project.org/documentation/install/admb-installation-macos-package-installer`)"

menu nitems=4 label="Edit"
	menuitem label=TPL function=doAction action="editADfile(paste(getWinVal()$prefix,`.tpl`,sep=``))"
	menuitem label=DAT function=doAction action="editADfile(paste(getWinVal()$prefix,`.dat`,sep=``))"
	menuitem label=PIN function=doAction action="editADfile(paste(getWinVal()$prefix,`.pin`,sep=``))"
	menuitem label=R   function=doAction action="editADfile(paste(getWinVal()$prefix,`.r`,sep=``))"

menu nitems=7 label="View"
  menuitem label=LOG function=doAction action="editADfile(paste(getWinVal()$prefix,`.log`,sep=``))"
  menuitem label=COR function=doAction action="editADfile(paste(getWinVal()$prefix,`.cor`,sep=``))"
  menuitem label=PAR function=doAction action="editADfile(paste(getWinVal()$prefix,`.par`,sep=``))"
  menuitem label=REP function=doAction action="editADfile(paste(getWinVal()$prefix,`.rep`,sep=``))"
  menuitem label=STD function=doAction action="editADfile(paste(getWinVal()$prefix,`.std`,sep=``))"
  menuitem label=MC.DAT function=doAction action="editADfile(paste(getWinVal()$prefix,`.mc.dat`,sep=``))"
  menuitem label="*.PLT" function=.win.editPLT

# the Examples menu will be altered by admb()
menu nitems=@nitems label="Examples"
	@menuitems

menu nitems=4 label="Help"
	menu nitems=3 label="Manuals"
		menuitem label="ADMB Manual" function=doAction action="openFile(`doc/admb.pdf`,package=`PBSadmb`)"
		menuitem label="ADMB RE Manual" function=doAction action="openFile(`doc/admb-re.pdf`,package=`PBSadmb`)"
		menuitem label="AUTODIF Library" function=doAction action="openFile(`doc/autodif.pdf`,package=`PBSadmb`)"
	menu nitems=4 label="Online"
		menuitem label="ADMB Project" function=doAction action="browseURL(`http://admb-project.org/`)"
		menuitem label="ADMB Examples" function=doAction action="browseURL(`www.admb-project.org/examples`)"
		menuitem label="ADMB FAQ" function=doAction action="browseURL(`http://www.admb-project.org/documentation/faq`)"
		menuitem label="ADMB IDE Manual" function=doAction action="browseURL(`http://www.admb-project.org/tools/admb-ide/manual`)"
	menuitem label="User Guide" function=doAction action="openFile(`doc/PBSadmb-UG.pdf`,package=`PBSadmb`)"
	menuitem label=About function=doAction action="editADfile(paste(system.file(package=`PBSadmb`),`/DESCRIPTION`,sep=``))"

#----------------------------------- BUTTONS -----------------------------------

Grid 2 3 sticky=E
	label "Current WD:" sticky=W
	droplist name=currentdir value="'' '<change path>'" add=T width=40 func=.changeWDEnter
	grid 1 2 sticky=W
		button text="Set WD" function=.changeWD
		button text="Open" func=doAction action="openFile(\".\")"

	label "Prefix:" sticky=W
	droplist name=prefix mode=character sticky=W width=40 values="" add=T 
	button text="Refresh" sticky=W function=.load.prefix.droplist
		

notebook tabs="Setup Make Run Output" pady="2 0" #selected=3

#Setup--------------------------------------------------------------------------
grid 7 1 sticky=E
	grid 1 3 sticky=W
		label "Path Setup" sticky=W fg=purple3 font="bold 11" padx="0 230"
		#null padx=129
		button text=Suggest   width=6 bg=aliceblue sticky=E function=.win.suggestPath action=suggest
		#button text=pathfile  width=6 bg=lightblue1 sticky=E function=.win.readADpaths action=@pathfile
		label text=test name=chkstat width=4 bg=lightgoldenrodyellow sticky=E
	grid 1 2 sticky=E
		entry name=admbpath value="" label="ADMB home:" width=45 mode=character func=setGUIoptions action=admbpath
		button text=">" func=doAction action="selectDir(usewidget=\"admbpath\")"
	grid 1 2 sticky=E
		entry name=gccpath value="" label="Win MinGW home:" width=45 mode=character func=setGUIoptions action=gccpath
		button text=">" func=doAction action="selectDir(usewidget=\"gccpath\")"
	grid 1 2 sticky=E
		entry name=editor value="" label=Editor: width=45 mode=character func=setGUIoptions action=editor
		button text=">" func=doAction action="selectFile(usewidget=\"editor\")"
	grid 1 3 sticky=E
		entry name=admbver value="" label="admb version" width=10 mode=character func=setGUIoptions action=admbver
		entry name=gccver value="" label="g++ version" width=10 mode=character func=setGUIoptions action=gccver padx="2 0"
		button name=checkbutton text="Verify" func=.win.makeADopts action=check bg=moccasin padx="10 0"

	label "Load/Save Paths from/to File" sticky=W fg=purple3 font="bold 11" pady="5 0"
	grid 1 5 sticky=E
		label text="Path File: "
		entry name=optfile value="" label="" width=30 mode=character action=optfile
		button text=">" func=doAction action="optfile=selectFile(filetype=list(c(`.txt`)),usewidget=NULL); setWinVal(list(optfile=basename(optfile)))"
		button text="Load" func=.win.readADpaths bg=palegoldenrod
		button text="Save"  func=.win.saveADpaths bg=gold

#Make---------------------------------------------------------------------------
grid 4 1 sticky=""
	#grid 1 4 sticky=W
	#	label text=Make font="bold 11" sticky=W fg=blue
	#	label text="        " font="Courier 8"
	#	label "Prefix:"
	#	droplist name=prefix mode=character sticky=W width=20 values="" add=T

	grid 1 8 sticky=W
		label text=Make font="bold 11" sticky=W fg=blue padx="0 10"
		button text="tpl" func=doAction action="editAD(getWinVal()$prefix,c(`.tpl`))" 
		button text="dat pin" func=doAction action="editAD(getWinVal()$prefix,c(`.dat`,`.pin`))" 
		button text="cpp log" func=doAction action="editAD(getWinVal()$prefix,c(`.cpp`,`.log`))" 
		button text="r" width=1 func=doAction action="editADfile(paste(getWinVal()$prefix,`.r`,sep=``))"
		button text="Rcode" func=doAction action="viewCode(pkg=`PBSadmb`)"
		button text="WDF" func=doAction action="openFile(`@wdf`)"
		button text=Docs func=doAction action="openUG(pkg=`PBSadmb`)"
		#label text=" " font="Courier 8"
		#label text="      Make times\nUsr        Sys        Elap" sticky=E
		#label text="" font="Courier 8"
	grid 1 2 sticky=W pady="5 0"
		grid 4 3 sticky=W
			label text=Operation: sticky=NW
			radio name=safe mode=logical value=TRUE  text=Safe sticky=W
			radio name=safe mode=logical value=FALSE text=Optimize sticky=W
			label text="Ran Eff:" sticky=NW
			radio name=raneff mode=logical value=FALSE text=No  sticky=W
			radio name=raneff mode=logical value=TRUE  text=Yes sticky=W
			label text="create DLL:" sticky=NW
			radio name=dll mode=logical value=FALSE text=No  sticky=W
			radio name=dll mode=logical value=TRUE  text=Yes sticky=W
			label text="debug symbols:" sticky=NW
			radio name=debugsymbols mode=logical value=FALSE text=No  sticky=W
			radio name=debugsymbols mode=logical value=TRUE  text=Yes sticky=W
		grid 2 1
			label text="         Make times\nUsr          Sys           Elap  " sticky=E
			matrix nrow=3 ncol=3 names=Mtime rowlabels=NULL collabels=NULL width=7 entrybg=grey94 sticky=N
	grid 1 7
		button text=Make    func=.win.makeAD  width=7 bg="#b9d7ff"
		null padx=1 pady=5
		button text=Convert func=.win.convAD  width=7 bg="#cae1ff"
		button text=Compile func=.win.compAD  width=7 bg="#d2e6ff"
		button text=Link    func=.win.linkAD  width=7 bg="#dfeeff"
		null padx=1
		button text=Clean   func=.win.cleanAD width=7 bg=aliceblue
	grid 1 4
		label text="Output:" 
		check name=logfile text=logfile checked=T sticky=W
		check name=add text=add checked=F sticky=W
		check name=verbose text=verbose checked=T sticky=W

#Run----------------------------------------------------------------------------
grid 5 1 sticky=W
	grid 1 2 sticky=W
		label text=Run font="bold 11" sticky=W fg=forestgreen
		#label text="         " font="Courier 8"
		matrix nrow=1 ncol=3 names=Rtime rowlabels="'Run times'" collabels=NULL width=8 entrybg=grey94 padx="10 0"
	grid 2 4  sticky=W
		label text="Options:" 
		radio name=runType text=Normal   value=normal mode=character func=.win.showGUIargs selected=T 
		radio name=runType text=MCMC     value=mcmc   mode=character func=.win.showGUIargs
		radio name=runType text=Profile  value=lprof  mode=character func=.win.showGUIargs
		#radio name=runType text=Custom   value=custom mode=character func=.win.showGUIargs
		label text="Output:" 
		check name=logfile text=logfile checked=T sticky=W
		check name=add text=add checked=T sticky=W
		check name=verbose text=verbose checked=T sticky=W
		#null
	grid 1 3 sticky=W pady="15 0"
		label text="MCMC:" 
		entry name=nsims label=Sims value=10000 sticky=W width=15
		entry name=nthin label=Thin value=100 sticky=W width=10
	grid 1 3  sticky=W
		label text="AD args" 
		entry name=argvec value="" label="" width=40 mode=character entrybg=ghostwhite #grey94
		button text="All args" func=.win.showADargs width=6 bg=mistyrose padx="5 0" #width=6
	button text=Run func=.win.run bg=green font="bold 9" width=5 sticky=E

#Output-------------------------------------------------------------------------
grid 3 1 sticky=""
	grid 1 3 sticky=W
		label text=Output font="bold 11" sticky=NW fg=orangered
		vector length=6 names=toView mode=logical labels="log cor par rep std mc.dat" sticky=NW \
			values="F F F F F F" vecnames="log cor par rep std mc.dat" action=check func=.win.viewRep 
		vector length=1 names=pltView mode=logical labels="*.plt" sticky=NW values="F" vecnames="plt" action=check func=.win.viewRep
	grid 1 6 sticky=E
		label text=Reports: sticky=NW
		radio name=allnone text=None value=0 func=.win.viewRep sticky=W action="allnone" selected=TRUE
		radio name=allnone text=All value=1 func=.win.viewRep sticky=W action="allnone"
		button text=View func=.win.viewRep action="open"
		button text=Import func=.win.readRep action="import"
		button text="Clean WD"  func=cleanAD bg=ghostwhite
	grid 1 8 sticky=W pady="25 0"
		label text=MCMC sticky=NW
		button text="Pairs" func=.win.plotMC action="pairs" bg="#ffb3b3"
		button text="Eggs" func=.win.plotMC action="eggs" bg="#ffe6e6"
		button text="ACF" func=.win.plotMC action="acf" bg="#ffb3b3"
		button text="Trace" func=.win.plotMC action="trace" bg="#ffe6e6"
		button text="Density" func=.win.plotMC action="dens" bg="#ffb3b3"
		entry name=pthin label=Thin value=1 sticky=W width=4
		button text=Var func=.chooseCols

