// Filename:	standard.ogs
// Creation:	7/1/95 Microcal Software Tech Support Dept.	
// Purpose:		Standard Toolbar Script	
// Modification log:
//	CPY v3.83 9/17/95 TEMPLATE_SCRIPT
//	JMP v3.85 10/24/95 OPEN_FROM_EMPTY_STATE
//	RKM 11/20/96 removed [SetColumnValues]
//	CPY v4.988 5/21/97 t2247 NEW_PROJ_START_UP 
// SFX 7/17/98 v6.0125 t3969 ADD_SPECTRUM_EXTERN_GRAPH_OBJ
// CPY v6.0291 t2047 6/18/00 SCALE_OBJ_FROM_TOOLBAR
// LAS QA70-3236 4/3/03 ADD_LAYER_TOOLBAR_BUTTON
// RVD 8/7/2003 QA70-4971 v7.0649 MULTI_LEGEND_AUTOUPDATE
//**********************************************


////////////////////////////////////////////////////////////////////////////////
// Standard Toolbar Script
////////////////////////////////////////////////////////////////////////////////

[Open]
	//OPEN_FROM_EMPTY_STATE
	run.section(file,openProject);

[SaveTemp]
	#Menu id =29
	#Save the %H window as the default template
	/// CPY v3.83 9/17/95 TEMPLATE_SCRIPT, old codes are removed 
	run.section(file,SaveTemplate);
	return 0;

[NewProject]
	#Menu id = 14
	#Close this document and create a new empty one
	//--------- CPY v4.988 5/21/97 t2247 NEW_PROJ_START_UP
	//document -N Untitled;Autoexec;
	document -N;
	//--------- NEW_PROJ_START_UP

[newwks]
	#Menu id = 16
	#Create a new Worksheet with empty X Y columns
	%A = System.Wks.DefTemplate$;
	win -T Data "%A";

[newGraph]
	#Menu id = 12
	#Create a new and empty plot window
	%A = System.Graph.DefTemplate$;
	win -T Plot "%A";

[newmatrix]
	#Menu id = 13
	#Create a new and empty matrix
	%A = System.Matrix.DefTemplate$;
	win -T Matrix "%A";

[newfunction]
	#Menu id = 19
	#Create a new function graph
	GetEnumWin Function;
	NewFunction;

[newlayout]
	#Menu id = 1015
	#Create a new Layout Page
	win -T Layout Layout;

[import]
	#Menu id = 3011
	#Import directly into the graph or the worksheet
	if(exist(%H)==3) 
		run.section(file,SingleImport);
	else 
		run.section(file,ImportAscii);

[print]
	#Menu id = 35
	print;

[copy]
	menu -e menu.find(ed,cp);

[cut]
	menu -e menu.find(ed,cu);

[paste]
	menu -e menu.find(ed,pa);


[refresh]
	#Redraws the current active window
	doc -uw;

[rename]
	#Rename the current worksheet
	win -ra;


[duplicate]
	#Creates a duplicate of the active window
	win -d;


[addcol]
	#Menu id = 778
	#Add an empty Y column to the end of the worksheet
	if(run.section(Wks,CheckForSelection, AddColNoSelection)==0)
	{
		worksheet -a 1;
	}
	

[insertcol]
	#Inserts a column at the insertion point
	worksheet -i wks.c1;



[legend]
	Label -p 75 5 -B 0;
	/// RVD 8/7/2003 QA70-4971 v7.0649 MULTI_LEGEND_AUTOUPDATE
	//Legend;
	Legend -s;
	/// end MULTI_LEGEND_AUTOUPDATE

/// YuI 12/17/01 v6.9153 t9655 IMPLEMENT_CATEGORICAL_LEGEND
[EnhancedLegend]
	plot -c;
	Legend -E;
/// end IMPLEMENT_CATEGORICAL_LEGEND
	
/// SFX 7/17/98 v6.0125 t3969 ADD_SPECTRUM_EXTERN_GRAPH_OBJ
[spectrum]
	Spectrum;
/// end ADD_SPECTRUM_EXTERN_GRAPH_OBJ

//---------------------------------------------------------
//-------- CPY v6.0291 t2047 6/18/00 SCALE_OBJ_FROM_TOOLBAR
[XYScale]
	x = x1 + (x2-x1)*(0.2 + 0.15*rnd());	// provide initial location with some random vairations
			// debug show values, @B=1 will turn it on.
			#!x=;
	y = y1 + (y2-y1)*(0.5 + 0.2*rnd());
			#!y=;
	draw -n scale -p x y -ps 50 30 -e scale;
	draw -nl A;// get actual name: scale, scale1 etc into %A;
			#!%A=;
	%A.xrange=x3; //set scale range to axes major increment
	%A.yrange=y3;
//-------- end CPY v6.0291 t2047 6/18/00
//---------------------------------------------------------


[plot2D]
	#Opens the plot 2D toolbar
	dotool -w 2D;

[rescale]
	#Menu id = 382
	#Rescale both the X and Y axes to show all the data in the layer
	layer -all Ask;

[zoomin]
	#Zoom in on the region surrounding the last point click on the page
	page.zoomin=1;

[zoomout]
	#Zoom out of the region surrounding the last point click on the page
	page.zoomout=1;

[zoomwhole]
	#Restore the view to the whole page
	page.zoomwhole=1;

[addplot]
	#Add a picture of a graph from existing graphs
	dotool -pg;

[addwks]
	#Add a picture of a worksheet from existing worksheets
	dotool -pw;

[FullScreen]
	// Full Screen in View Menu
	type -b $EXEMessage.FullScreen;
	plot -screen;

[DateTime]
	//Add a time/date stamp
	label -s -sa -d (.6*page.width) (.05*page.height) -n timestamp $(@D,D10);
	plot -c;

[NewNotes]
	#Create a new notes window
	win -n Notes;

[ExtractLayers]
	//Extract each data plot in the current graph window to seperate layers.
	count=0;doc -e DY {count++;};
	if(count<=1) {type -b $General.ExtractLayers;return 1;}
	layer -j;
	run.section(Graph,ArrangeAllLayers);

[ExtractGraphs]
	//Extract each layer in the current graph window to seperate graph windows.
	if(page.nlayers<=1) {type -b $General.ExtractGraphs;return 1;}
	page -j;

[Merge]
	win -ma;
	run.section(Graph,ArrangeAllLayers);
	
[BottomXLeftY]
	layer -new;
	layer -b a 0;
	layer -b c 1;
	
[TopX]
	layer -new x;
	layer -b a 0;
	layer -b c 1;
	
[RightY]
	layer -new y;
	layer -b a 0;
	layer -b c 1;
	
[TopXRightY]
	layer -new Both;
	layer -b a 0;
	layer -b c 1;
	
[Inset]
	layer -s page.active; /*select the active layer*/
	layer -new both; /*adds a linked layer to the active layer*/
	layer -b a 0;
	layer -b c 1;
	layer.x.showaxes=1;
	layer.y.showaxes=1;
	layer.x.showlabels=1;
	layer.y.showlabels=1;
	layer.x.type=LayerTool!Tab.Add.XScale.choice;
	layer.y.type=LayerTool!Tab.Add.YScale.choice;
	layer.left=75;
	layer.width=25;
	layer.height=25;
	
[InsetData]
	layer -s page.active; /*select the active layer*/
	layer -c; /*concatenate the names of all datasets into %Z*/
	layer -new both; /*adds a linked layer to the active layer*/
	layer -b a 0;
	layer -b c 1;
	layer.x.showaxes=1;
	layer.y.showaxes=1;
	layer.x.showlabels=1;
	layer.y.showlabels=1;
	layer.x.type=LayerTool!Tab.Add.XScale.choice;
	layer.y.type=LayerTool!Tab.Add.YScale.choice;
	layer.left=75;
	layer.width=25;
	layer.height=25;
	layer -i %Z; /*include datasets in layer*/
	%Z="";
	layer -all;