// Text of project ChezDTS written on 5/22/96 at 8:07 PM
// Beginning of text file ChezDTS constants
/*
**      Newton Developer Technical Support Sample Code
**
**      Chez DTS - How to register application pieces and not waste heap 
**
**      by David Fedor, Newton Developer Technical Support
**
**      Copyright © 1996 by Apple Computer, Inc.  All rights reserved.
**
**      You may incorporate this sample code into your applications without
**      restriction.  This sample code has been provided "AS IS" and the
**      responsibility for its operation is 100% yours.  You are not
**      permitted to modify and redistribute the source as "DTS Sample Code."
**      If you are going to re-distribute the source, we require that you
**      make it clear in the source that the code was descended from
**      Apple-provided sample code, but that you've made changes.
*/

// This is the symbol for the global registry
constant kChezDTSFrame := '|ChezDTSRegistry:DTS|;

// This is the symbol for the main application's base view
constant kChezDTSAppSym := '|ChezDTS:DTS|;



// The kChezDTSRegisterFunc and kChezDTSUnRegisterFunc functions are 
// just called by the auto parts... they're not used by the app at all.

DefConst('kChezDTSRegisterFunc, func(sym, frame) 
	begin
		// create the registry if necessary
		if not IsFrame(GetGlobalVar(kChezDTSFrame)) then
			DefGlobalVar(EnsureInternal(kChezDTSFrame), TotalClone('{}));
		
		// register this object
		GetGlobalVar(kChezDTSFrame).(EnsureInternal(sym)) := frame;
	
		// let the app know things changed.
		AddProcrastinatedCall(kChezDTSAppSym, 
			func() if GetRoot().(kChezDTSAppSym) then
				GetRoot().(kChezDTSAppSym):?ThingsChanged(), nil, 1);
	end);

DefConst('kChezDTSUnRegisterFunc, func(sym) 
	begin
		// unregister this object
		RemoveSlot(GetGlobalVar(kChezDTSFrame), sym);
		
		// let the app know things changed.
		AddProcrastinatedCall(kChezDTSAppSym, 
			func() if GetRoot().(kChezDTSAppSym) then
				GetRoot().(kChezDTSAppSym):?ThingsChanged(), nil, 1);
	end);
// End of text file ChezDTS constants
// Beginning of file ChezDTS form

// Before Script for "baseview"
/*
**      Newton Developer Technical Support Sample Code
**
**      Chez DTS - How to register application pieces and not waste heap 
**
**      by David Fedor, Newton Developer Technical Support
**
**      Copyright © 1996 by Apple Computer, Inc.  All rights reserved.
**
**      You may incorporate this sample code into your applications without
**      restriction.  This sample code has been provided "AS IS" and the
**      responsibility for its operation is 100% yours.  You are not
**      permitted to modify and redistribute the source as "DTS Sample Code."
**      If you are going to re-distribute the source, we require that you
**      make it clear in the source that the code was descended from
**      Apple-provided sample code, but that you've made changes.
*/

baseview :=
    {viewBounds: {left: 15, top: 15, right: 85, bottom: 60},
     viewFlags: 1,
     viewFormat: 50332241,
     declareSelf: 'base,
     ThingsChanged:
       func()
       	begin
       		if thelist then		// We might not be open when this method is called...
       			thelist:RedoDisplay();
       	end,
     reorienttoscreen:
       // Allow the app to work when the screen is rotated.
       // The viewBounds are proportional to the screen size,
       // so we don't care at all what size screen we're on.
       
       ROM_DefRotateFunc	,
     viewJustify: -67108864,
     debug: "baseview",
     viewClass: 74
    };

_view000 :=
    {title: "Chez DTS",
     viewBounds: {left: 0, top: 3, right: 112, bottom: 19},
     viewJustify: 22,
     _proto: @229
    };
AddStepForm(baseview, _view000);



_view001 :=
    {text: "Tonight's specials are:",
     viewBounds: {left: 6, top: 24, right: 150, bottom: 40},
     _proto: @218
    };
AddStepForm(baseview, _view001);



thelist :=
    {viewBounds: {left: 15, top: 40, right: -17, bottom: -20},
     viewFlags: 35,
     viewFont: simpleFont9,
     viewFormat: 337,
     viewLineSpacing: 11,
     redoDisplay:
       func()
       begin
       	local thetext;
       	
       	// just to make sure, check that the frame exists
       	if not IsFrame(GetGlobalVar(kChezDTSFrame)) then
       		thetext := "";
       	else
       		// Get the titles for each installed element, with a carriage return between each one.
       		// (I added a space at the front of each line to make it look a little better.)
       		thetext := Stringer(foreach v in GetGlobalVar(kChezDTSFrame) collect " " & v.title & $\n);
       
       	// stick the list in our paragraph view
       	if strlen(thetext) >0 then
       		SetValue(self, 'text, thetext);
       	else
       		// No auto parts have been registered!  The cupboard is bare!
       		SetValue(self, 'text, "\n\n    (Sorry, we're closed!)");
       	
       end,
     viewSetupFormScript:
       func()
       	begin
       		self:RedoDisplay();
       	end,
     viewJustify: 240,
     debug: "thelist",
     viewClass: 81
    };
AddStepForm(baseview, thelist);
StepDeclare(baseview, thelist, 'thelist);



_view002 := {_proto: @166};
AddStepForm(baseview, _view002);




constant |layout_ChezDTS form| := baseview;
// End of file ChezDTS form



