// Text of project testNewtLabelPicker written on 5/22/96 at 5:28 PM
// Beginning of text file Constants.f
/*
**      Newton Developer Technical Support Sample Code
**
**      newtLabelPicker, a label picker for newtApps
**
**      by Maurice Sharp, Newton Developer Technical Support
**
**      Copyright © 1995 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.
*/

//------------------------------------------------------------
// 	Application wide constants
//------------------------------------------------------------

DefConst('kSoupName, SPrintObject(kAppSymbol)) ;
constant kClassSymbol := kAppSymbol ;

constant kUserSoupName := kAppName ;
constant kSoupDescription := "Data for the " & kAppName & " application.";


//------------------------------------------------------------
// 	Soup data constants
//------------------------------------------------------------

// array of choices for popper1 slot
constant kPopper1Labels := '[
	"First value", "Second value", "Another value", "Burma!!!!"] ;
	
// array for choices for the popper2 slot
constant kPopper2Labels := '[
	"The operation", "The other operation", "The other other operation"] ;


//------------------------------------------------------------
// 	Install/Remove Scripts
//------------------------------------------------------------

InstallScript := func(partFrame)
begin
	local theForm := partFrame.theForm ;
	partFrame.removeFrame := theForm:NewtInstallScript(theForm) ;
end ;

RemoveScript := func(partFrame)
begin
	local removeFrame := partFrame.removeFrame ;
	removeFrame:NewtRemoveScript(removeFrame) ;
end ;
// End of text file Constants.f
// Beginning of file newtLabelPicker

// Before Script for "_userproto000"
// Copyright ©1996 Apple Computer, Inc. All rights reserved.


_userproto000 :=
    {labelCommands: ["item 1","item 2"],
     text: "Label",
     viewBounds: {left: 9, top: 17, right: 231, bottom: 47},
     TargetData:
       // TargetData method - returns either the value from
       // your data entry or some defaultValue.
       // it MUST return something that is a string, NIL will cause an exception
       
       func()
       begin
       	if target AND path then
       		if target.(path) then
       			Clone(target.(path)) ;
       		else
       			nilValueText ;
       	else
       		defaultValue;
       end,
     defaultValue:
       // defaultValue slot - the default value for a data entry. It MUST
       // be a string. Ideally it should correspond to something
       // on your labelCommands list (as per the protoListPicker).
       
       "<NO-VALUE>"		// This could be a constant in a constant file.
       					// For this sample, choose not to so this proto 
       					// was a stand alone proto.
       ,
     ReTarget:
       // ReTarget method - updates the labelPicker value based on the
       // data in the entry or some default value (see TargetData)
       
       func()
       begin
       	inReTarget := true;
       	self:UpdateText(self:TargetData());
       	inReTarget := nil;
       end,
     inReTarget:
       // inReTarget slot - used by ReTarget to prevent continual updating
       
       nil,
     path:
       // path slot - used to find the correct slot in a data entry
       
       'popper // just an default
       		// whenever this proto is used, a specific path should be selected
       ,
     textChanged:
       // textChanged method - updates the slot in the data entry
       
       func()
       begin
       	if NOT inReTarget then
       	begin
       		local theValue := Clone(self.entryLine.text) ;
       	
       		// check to see if the target data should be NIL
       		if StrEqual(theValue, nilValueText) then
       			theValue := nil ;
       	
       		target.(path) := theValue ;
       		:StartFlush();
       	end;
       end,
     viewSetupDoneScript:
       // viewSetupDoneScript method - sets up the initial value for the picker
       
       func()
       begin
       	inherited:?viewSetupDoneScript();
       	self:Retarget();
       end,
     JamFromEntry:
       // jamFromEntry method - used in conjunction with the smart input lines
       
       func( otherEntry )
       begin
       	if jamSlot then
       	begin
       		target.(path) := nil;
       		if otherEntry then
       			target.(path) := otherEntry.(jamSlot);
       	end;
       end;,
     jamSlot:
       // jamSlot slot - used by the jamFromEntry method
       
       nil	 // just an example, though highly likely
       ,
     nilValueText:
       // text to show if the value of the slot is NIL
       
       "<NO-VALUE>"		// This could be a constant in a constant file.
       					// For this sample, choose not to so this proto 
       					// was a stand alone proto.
       ,
     showNILValue:
       // boolean to show a NIL value choice in the popup
       // if TRUE will have a choice in the popup that corresponds to nilValueText
       true,
     pickerSetup:
       func()
       begin
       	if showNILValue then
       	begin
       		local pop := Clone(labelCommands) ;
       		AddArraySlot(pop, 'pickSeparator) ;
       		AddArraySlot(pop, nilValueText) ;
       		labelCommands := pop ;
       	end ;
       
       	true; // show the popup
       end ;,
     _proto: @190
    };


constant |layout_newtLabelPicker| := _userproto000;
// End of file newtLabelPicker
// Beginning of file default.t

// Before Script for "_view000"
// Copyright ©1996 Apple Computer, Inc. All rights reserved.


_view000 :=
    {viewBounds: {left: 0, top: 20, right: 0, bottom: -25},
     masterSoupSlot: 'Mysoup,
     name: "Layout",
     viewJustify: 240,
     _proto: @402
    };

_view001 :=
    {viewBounds: {left: 0, top: 0, right: 0, bottom: 0},
     viewJustify: 240,
     _proto: @406
    };
AddStepForm(_view000, _view001);

popper1Value :=
    {viewBounds: {left: 9, top: 25, right: 231, bottom: 55},
     path:
       // path slot - used to find the correct slot in a data entry
       
       'popper1,
     labelCommands: kPopper1Labels,
     debug: "popper1Value",
     _proto: _userproto000
    };
AddStepForm(_view001, popper1Value);



popper2Value :=
    {viewBounds: {left: 9, top: 73, right: 231, bottom: 103},
     path:
       // path slot - used to find the correct slot in a data entry
       
       'popper2,
     labelCommands: kPopper2Labels,
     debug: "popper2Value",
     _proto: _userproto000
    };
AddStepForm(_view001, popper2Value);






constant |layout_default.t| := _view000;
// End of file default.t
// Beginning of file overview.t

// Before Script for "_view002"
// Copyright ©1996 Apple Computer, Inc. All rights reserved.


_view002 :=
    {viewBounds: {left: 0, top: 20, right: 0, bottom: -25},
     masterSoupSlot: 'Mysoup,
     name: "Layout",
     Abstract:
       func(item,bBox)
       begin
       	local tempStr := if item.popper1 then item.popper1 else "<NO-VALUE>" ;
       	tempStr := tempStr && if item.popper2 then item.popper2 else "<NO-VALUE>" ;
       	
       	MakeText(tempStr, bbox.left + 18, bbox.top, bbox.right, bbox.bottom - 18) ;
       end,
     _proto: @405
    };


constant |layout_overview.t| := _view002;
// End of file overview.t
// Beginning of file testNewtLabelPicker.t

// Before Script for "_view003"
// Copyright ©1996 Apple Computer, Inc. All rights reserved.


_view003 :=
    {
     allLayouts:
       // Must contain at least a default and overview layout.
       {
       	default: GetLayout("default.t"),
       	overview: GetLayout("overview.t"),
       },
     allSoups:
       {	
       	mySoup: {
       		_proto: newtSoup,
       		soupName: kSoupName,
       		soupIndices: [],
       		soupQuery: {},
       		
       		// returns a blank soup entry
       		CreateBlankEntry: func()
       		{
       			popper1: nil,
       			popper2: nil,
       			class: kClassSymbol,
       			labels: nil,
       		},
       		
       		// make sure soup has a user visible name
       		// that makes sense
       		MakeSoup: func(appSymbol)
       		begin
       			self.appSymbol := appSymbol ;
       			self.theSoup := RegUnionSoup(appSymbol, {
       				name: soupName,
       				userName: kUserSoupName,
       				ownerApp: appSymbol,
       				userDescr: kSoupDescription,
       				indexes: soupIndices}) ;
       			
       			if Length(theSoup:GetSoupList()) = 0 then
       				:FillNewSoup() ;
       		end,
       	}
       },
     appAll: "All Items",
     appObject: ["Item", "Items"],
     appSymbol: kAppSymbol,
     title: kAppName,
     viewBounds: {left: 0, top: 0, right: 0, bottom: 0},
     viewFlags: 5,
     viewJustify: 240,
     _proto: @398
    };

_view004 := {_proto: @162};
AddStepForm(_view003, _view004);



_view005 :=
    {menuLeftButtons: [newtInfoButton],
     menuRightButtons: [newtActionButton, newtFilingButton],
     _proto: @401
    };
AddStepForm(_view003, _view005);




constant |layout_testNewtLabelPicker.t| := _view003;
// End of file testNewtLabelPicker.t



