// 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
// CPY 6/13/06 QA70-8751 INSERT_TABLE_TO_GRAPH
// EJP 2006-06-19 v8.0431 QA70-8766 NEW_PROJECT_FOLDER_BUTTON
// EJP 2006-11-14 v8.0511 NEW_MERGE_XF
// CPY 11/15/2006 QA70-9112 INSERT_GRAPH_NEW_OC_BASED
// Max 2/15/07 NEW_LAYER_XF
/// ML 4/6/2007 QA70-7024 KEEP_SHEET_NAMES_NEW_BOOK_MATRIX
/// Max 5/18/07 EXTRACT_TO_GRAPHS_XF
// CPY 7/13/07 QA70-9062 ADD_NEW_XYSCALE_OBJ
/// Max 10/25/07 QA70-10581 LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
/// CPY 7/9/08 QA70-11826 ADD_WKS_SHOULD_ALLOW_SELECT_SHEET_FROM_OC_DIALOG
/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
/// AW 04/01/2009 QA80_12712 FULL_VARIABLE_NAME_VALUE_DOES_NOT_WORK
/// Folger 04/03/09 LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
/// Folger 07/09/09 QA80-13631 FIND_AND_REPLACE_UNDER_MENU_EDIT_SHOULD_BRING_UP_NEW_FRAMEWORK_FOR_81
/// Folger 01/19/10 QA81-14945 ADD_UPDATE_LEGEND_ITEM_FOR_GRAPH_AND_LEGEND_CONTEXT_MENU
/// EJP 2010-01-26 QA81-15039 POWERPOINT_AND_SLIDESHOW_TBAR_BUTTONS
//**********************************************


////////////////////////////////////////////////////////////////////////////////
// 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

/// EJP 2006-06-19 v8.0431 QA70-8766 NEW_PROJECT_FOLDER_BUTTON
[NewFolder]
	document -NF $(@PES); // new project subfolder and/or startup window
/// end NEW_PROJECT_FOLDER_BUTTON

[newwks]
	#Menu id = 16
	#Create a new Worksheet with empty X Y columns
	%A = System.Wks.DefTemplate$;
	
	//------ Folger 03/17/08 QA80-11262 SHOULD_RESTORE_SHEET_NAME_WHEN_NEW_BOOK_AS_CP_SUGGESTED
	///// ML 4/6/2007 QA70-7024 KEEP_SHEET_NAMES_NEW_BOOK_MATRIX
	win -T DR "%A";
	//win -T DN "%A";
	///// end KEEP_SHEET_NAMES_NEW_BOOK_MATRIX
	//------

[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$;
	
	//------ Folger 03/17/08 QA80-11262 SHOULD_RESTORE_SHEET_NAME_WHEN_NEW_BOOK_AS_CP_SUGGESTED
	///// ML 4/6/2007 QA70-7024 KEEP_SHEET_NAMES_NEW_BOOK_MATRIX
	win -T MR "%A";
	//win -T MN "%A";
	///// end KEEP_SHEET_NAMES_NEW_BOOK_MATRIX
	//------

[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)==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
	
///------ Folger 01/19/10 QA81-14945 ADD_UPDATE_LEGEND_ITEM_FOR_GRAPH_AND_LEGEND_CONTEXT_MENU
[UpdateLegend]
	run -xf legendupdate -d;
///------ End ADD_UPDATE_LEGEND_ITEM_FOR_GRAPH_AND_LEGEND_CONTEXT_MENU

/// 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_Old]
	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
//------ CPY 7/13/07 QA70-9062 ADD_NEW_XYSCALE_OBJ
[XYScale]
	add_xyscale_obj;
//------
//---------------------------------------------------------


[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
	//---- CPY 11/15/2006 QA70-9112 INSERT_GRAPH_NEW_OC_BASED
	//dotool -pg;
	/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//add_graph_to_graph;
	run -xf add_graph_to_graph;
	/// END CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//----

[addwks]
	#Add a picture of a worksheet from existing worksheets
	//------ CPY 7/9/08 QA70-11826 ADD_WKS_SHOULD_ALLOW_SELECT_SHEET_FROM_OC_DIALOG
	//dotool -pw;
	/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//add_wks_to_graph;
	run -xf add_wks_to_graph;
	/// END CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//------

[FullScreen]
	// Full Screen in View Menu
	//type -b $EXEMessage.FullScreen;
	ty -m RestoreFromFullScreen;
	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.
	/// Max 5/18/07 EXTRACT_TO_GRAPHS_XF
	/// Max 10/25/07 QA70-10581 LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	//layextract -d;
	run -xf layextract -d;
	/// END LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	//if(page.nlayers<=1) {type -b $General.ExtractGraphs;return 1;}
	//page -j;
	/// END EXTRACT_TO_GRAPHS_XF

[Merge]
	/// EJP 2006-11-14 v8.0511 NEW_MERGE_XF
	///win -ma;
	///run.section(Graph,ArrangeAllLayers);
	/// Max 10/25/07 QA70-10581 LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	//merge_graph -d;
	run -xf merge_graph -d;
	/// END LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	/// end NEW_MERGE_XF

/// Max 2/15/07 NEW_LAYER_XF	
//[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;
	
[BottomXLeftY]
	/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//layadd type:=normal;
	///------ Folger 04/03/09 LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	//run -xf layadd type:=normal;
	run -xf layadd type:=normal offset:=1;
	///------ End LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	/// END CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
[TopX]
	/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//layadd type:=topx;
	///------ Folger 04/03/09 LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	//run -xf layadd type:=topx;
	run -xf layadd type:=topx offset:=1 linkto:=-1;
	///------ End LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	/// END CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	
[RightY]
	/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//layadd type:=righty;
	///------ Folger 04/03/09 LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	//run -xf layadd type:=righty;
	run -xf layadd type:=righty offset:=1 linkto:=-1;
	///------ End LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	/// END CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
[TopXRightY]
	/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//layadd type:=txry;
	///------ Folger 04/03/09 LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	//run -xf layadd type:=txry;
	run -xf layadd type:=txry offset:=1 linkto:=-1;
	///------ End LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	/// END CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	
[Inset]
	/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//layadd type:=inset;
	///------ Folger 04/03/09 LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	//run -xf layadd type:=inset;
	run -xf layadd type:=inset offset:=1 linkto:=-1;
	///------ End LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	/// END CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	
[InsetData]
	/// Max 12/31/08 QA70-10581 CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF
	//layadd type:=insetdata;
	///------ Folger 04/03/09 LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET
	///// AW 04/01/2009 QA80_12712 FULL_VARIABLE_NAME_VALUE_DOES_NOT_WORK	
	////run -xf layadd type:=insetdata;
	//run -xf layadd type:=datainset;
	///// END FULL_VARIABLE_NAME_VALUE_DOES_NOT_WORK
	run -xf layadd type:=insetdata offset:=1 linkto:=-1;
	///------ End LAYADD_CALL_FROM_TOOLBAR_SHOULD_AUTO_OFFSET

	/// END CLEAN_UP_TO_USE_NEW_LT_WAY_TO_RUN_XF

/// END NEW_LAYER_XF		
	
//------ CPY 6/13/06 QA70-8751 INSERT_TABLE_TO_GRAPH
[Table]
	/// Max 10/25/07 QA70-10581 LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
	//add_table_to_graph -d;
	run -xf add_table_to_graph -d;
	/// END LANGUAGE_SWITCH_CRASH_IN_J_LEAD_TO_NEW_LT_WAY_TO_RUN_XF
//-----

///------ Folger 07/09/09 QA80-13631 FIND_AND_REPLACE_UNDER_MENU_EDIT_SHOULD_BRING_UP_NEW_FRAMEWORK_FOR_81
[FindAndReplace]
	run -xf findreplace %1;
///------ End FIND_AND_REPLACE_UNDER_MENU_EDIT_SHOULD_BRING_UP_NEW_FRAMEWORK_FOR_81

/// EJP 2010-01-26 QA81-15039 POWERPOINT_AND_SLIDESHOW_TBAR_BUTTONS
[GraphsToPowerPoint]
	run -xf pef_pptslide -d;
[SlideShow]
	run -xf pef_slideshow -d;
/// end POWERPOINT_AND_SLIDESHOW_TBAR_BUTTONS