// Text of project Cardfile Extensions written on 11/22/95 at 6:38 PM
// Beginning of file Social Security Stationery

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


_view000 :=
    {viewBounds: {left: 0, top: 0, right: 0, bottom: 0},
     viewFlags: 1,
     viewFormat: 0,
     viewJustify: 240,
     name: "Social Security",
     infoFrame:
       {
       	checkPrefix: '[true, nil],				// single-instance appears in top level of soup entry
       											// no multiple-instance since socsecnum is unique
       	checkPaths: '[|socialSecurity:PIEDTS|],	// slot where data is stored
       	formatFunc: func(data) begin 			// <data> will be an array with one elt, <soupentry>.socsecnum
       		if StrFilled(data[0]) then
       			ParamStr("Soc sec #: ^0", data);	// return string to show in All Info view
       		else
       			"";									// must return a string
       	end,
       },
     protection:
       'private		// only show up in Names, not in IOBox
       ,
     symbol: '|socialSecurity:PIEDTS|,
     type:
       'editor		// so it will show up in "Add" menu
       ,
     viewClass: 74
    };

_view001 :=
    {path: '|socialSecurity:PIEDTS|,
     viewBounds: {left: 0, top: 0, right: 0, bottom: 40},
     label: "Social Security",
     viewLineSpacing: 32,
     _proto: @422
    };
AddStepForm(_view000, _view001);




constant |layout_Social Security Stationery| := _view000;
// End of file Social Security Stationery
// Beginning of file Cars Stationery

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


_view002 :=
    {viewBounds: {left: 0, top: 0, right: 0, bottom: 0},
     viewFlags: 1,
     viewFormat: 0,
     viewJustify: 240,
     name:
       "Car"	// what will appear in the Add menu
       ,
     infoFrame:
       {
       	checkPrefix: '[nil, [pathExpr: |cars:PIEDTS|]],	// multiple-instances appear in array called 'cars
       	checkPaths: '[make, model],						// slots in car frame where data is stored
       	formatFunc: func(data) begin 					// <data> will be [cars.make, cars.model] for one car
       		ParamStr("Car: ^?0^0 ||^1", data);			// return string to show in All Info view
       	end,
       },
     protection:
       'private		// only show in Names, not in IOBox
       ,
     symbol: '|cars:PIEDTS|,
     type:
       'editor		// editors will show up in Add menu
       ,
     viewClass: 74
    };

make :=
    {
     path:
       nil		// will be set dynamically by viewSetupFormScript
       ,
     viewJustify: 8240,
     viewBounds: {left: 0, top: 0, right: 0, bottom: 40},
     label: "Make",
     viewLineSpacing: 32,
     flavor:
       {
               _proto: newtCustomFilter,
               recFlags: vVisible + vClickable + vGesturesAllowed + vPunctuationAllowed + vCapsRequired,
       },
     viewSetupFormScript:
       func()
       begin
       	if IsSymbol(selectedPath) then
       		self.path := [pathExpr: selectedPath]
       	else
       		self.path := Clone(selectedPath);
       	AddArraySlot(path, 'make);
       	inherited:?viewSetupFormScript();
       end,
     debug: "make",
     _proto: @422
    };
AddStepForm(_view002, make);



model :=
    {
     path:
       nil		// will be set dynamically by viewSetupFormScript
       ,
     viewJustify: 8240,
     viewBounds: {left: 0, top: 0, right: 0, bottom: 40},
     flavor:
       {
               _proto: newtCustomFilter,
               recFlags: vVisible + vClickable + vGesturesAllowed + vPunctuationAllowed + vCapsRequired,
       },
     label: "Model",
     viewLineSpacing: 32,
     viewSetupFormScript:
       func()
       begin
       	if IsSymbol(selectedPath) then
       		self.path := [pathExpr: selectedPath]
       	else
       		self.path := Clone(selectedPath);
       	AddArraySlot(path, 'model);
       	inherited:?viewSetupFormScript();
       end,
     debug: "model",
     _proto: @422
    };
AddStepForm(_view002, model);




constant |layout_Cars Stationery| := _view002;
// End of file Cars Stationery
// Beginning of file Sorton Layout

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


_view003 :=
    {
     masterSoupSlot:
       'Names		// will be a layout for the cardfile soup
       ,
     name: "Sorton",
     viewFlags: 1,
     viewFormat: 0,
     forceNewEntry: nil,
     protection:
       'public			// show up in IOBox too
       ,
     symbol: '|sortonLayout:PIEDTS|,
     type:
       'viewer		// show up in "Show" menu
       ,
     viewBounds: {left: 0, top: 0, right: 0, bottom: 0},
     viewJustify: 240,
     _proto: @402
    };

_view004 :=
    {viewBounds: {left: 5, top: 5, right: 0, bottom: 28},
     viewJustify: 240,
     _proto: @406
    };
AddStepForm(_view003, _view004);

_view005 :=
    {path: 'sorton,
     viewJustify: 8388656,
     viewBounds: {left: 8, top: 16, right: 24, bottom: 32}
     ,
     viewFont: userFont18,
     _proto: @414
    };
AddStepForm(_view004, _view005);






constant |layout_Sorton Layout| := _view003;
// End of file Sorton Layout
// Beginning of file Car DataDef

// Before Script for "_view006"
// Copyright 1995 Apple Computer, Inc.  All rights reserved.


_view006 :=
    {symbol: '|car:PIEDTS|,
     name:
       "Car"		// appears in the "New" menu
       ,
     description:
       "Car"		// long description of data (unused by Names app)
       ,
     superSymbol:
       'names		// stationery for card file
       ,
     icon: GetPictAsBits("CarIcon", nil),
     overviewIcon: GetPictAsBits("CarOverviewIcon", nil),
     MakeNewEntry:
       func()
       	Clone('{version: 2, class: |car:PIEDTS|});,
     TextScript:
       func()
       	// this call works if infoFrame's formatFunc is correct.
       	GetRoot().cardfile:kGenericTextFunc(target);,
     StringExtract:
       func(entry, nLines)
       	ParamStr("^0", [entry.carName]);,
     viewsToDisplay:
       // this is required only for CardFile dataDefs (same with overviewIcon)
       ['default, '|carMakeModel:PIEDTS|]	// viewDefs to show in Add button.
       
       // could use an empty array here, you'd still get all the views,
       // but the ones that appear in the array will be first in the list,
       // and in the order the appear in the array.
       ,
     _proto: @451
    };


constant |layout_Car DataDef| := _view006;
// End of file Car DataDef
// Beginning of file Car Name ViewDef

// Before Script for "_view007"
// Copyright 1995 Apple Computer, Inc.  All rights reserved.


_view007 :=
    {viewBounds: {left: 0, top: 0, right: 0, bottom: 0},
     viewFlags: 1,
     viewFormat: 0,
     viewJustify: 240,
     infoFrame:
       {
       	checkPrefix: '[true, nil],				// each car has one name
       	checkPaths: '[carname],					// slot in entry where data is stored
       											// don't need suffix in this case, because we control the
       											// entire soup entry (via the 'class slot)
       	formatFunc: func(data) begin 			// <data> will be [<entry>.carname]
       		ParamStr("^0", data);				// return string to show in All Info view
       	end,
       },
     protection:
       'private		// show up only in Names, not in IOBox
       ,
     symbol:
       'default		// every dataDef must have at least one 'default viewDef
       ,
     type:
       'editor		// will show up in "Add" menu
       ,
     name: "Name",
     viewClass: 74
    };

name :=
    {path: 'carname,
     viewJustify: 8240,
     viewBounds: {left: 0, top: 0, right: 0, bottom: 40},
     viewLineSpacing: 32,
     flavor:
       {
               _proto: newtCustomFilter,
               recFlags: vVisible + vClickable + vGesturesAllowed + vPunctuationAllowed + vCapsRequired,
       },
     viewQuitScript:
       func()
       	begin
       		target.sorton := target.(path);		// Names soup requires a value in 'sorton
       		inherited:?viewQuitScript();		// this method is defined internally
       	end,
     debug: "name",
     _proto: @422
    };
AddStepForm(_view007, name);




constant |layout_Car Name ViewDef| := _view007;
// End of file Car Name ViewDef
// Beginning of file Car Make/Model ViewDef

// Before Script for "_view008"
// Copyright 1995 Apple Computer, Inc.  All rights reserved.


_view008 :=
    {viewBounds: {left: 0, top: 0, right: 0, bottom: 0},
     viewFlags: 1,
     viewFormat: 0,
     viewJustify: 240,
     name: "Car Info",
     infoFrame:
       {
       	checkPrefix: '[true, nil],				// each car has one make and model, at top level
       	checkPaths: '[make, model],				// slots in entry where data is stored
       	formatFunc: func(data) begin 			// <data> will be [<entry>.make, <entry>.model]
       		ParamStr("Car: ^?0^0 ||^1", data);		// return string to show in All Info view
       	end,
       },
     protection:
       'private		// show up in Names only, not IOBox
       ,
     symbol: '|carMakeModel:PIEDTS|,
     type:
       'editor			// show up in "Add" menu
       ,
     viewClass: 74
    };

make :=
    {path: 'make,
     viewJustify: 8240,
     viewBounds: {left: 0, top: 0, right: 0, bottom: 40},
     flavor:
       {
               _proto: newtCustomFilter,
               recFlags: vVisible + vClickable + vGesturesAllowed + vPunctuationAllowed + vCapsRequired,
       },
     viewLineSpacing: 32,
     label: "Make",
     debug: "make",
     _proto: @422
    };
AddStepForm(_view008, make);



model :=
    {path: 'model,
     viewJustify: 8240,
     viewBounds: {left: 0, top: 0, right: 0, bottom: 40},
     flavor:
       {
               _proto: newtCustomFilter,
               recFlags: vVisible + vClickable + vGesturesAllowed + vPunctuationAllowed + vCapsRequired,
       },
     viewLineSpacing: 32,
     label: "Model",
     debug: "model",
     _proto: @422
    };
AddStepForm(_view008, model);




constant |layout_Car Make/Model ViewDef| := _view008;
// End of file Car Make/Model ViewDef
// Beginning of file Car Bizcard ViewDef

// Before Script for "_view009"
// Copyright 1995 Apple Computer, Inc.  All rights reserved.


_view009 :=
    {viewBounds: {left: 0, top: 0, right: 240, bottom: 160},
     viewFlags: 33,
     viewFormat: 0,
     viewJustify: 80,
     bizCardIcon: nil,
     bizCardNum:
       1001	// cardType that corresponds to this format
       ,
     name:
       "CarDef Bizcard"		// not currently used by Names application
       ,
     symbol: '|carBizCard:PIEDTS|,
     type:
       'bizcard		// means something special to Names app -- small, readonly view
       ,
     viewClass: 74
    };

carname :=
    {
     text:
       nil		// set by viewSetupFormScript
       ,
     viewBounds: {left: 5, top: 5, right: 0, bottom: 28},
     viewSetupFormScript:
       func()
       	begin
       		self.text := target.carname;	// get data out of soup entry
       		inherited:?viewSetupFormScript();
       	end,
     viewFont: userFont18,
     viewJustify: 8388656,
     debug: "carname",
     _proto: @218
    };
AddStepForm(_view009, carname);




constant |layout_Car Bizcard ViewDef| := _view009;
// End of file Car Bizcard ViewDef
// Beginning of text file Install & Remove Scripts.f
// Copyright 1995 Apple Computer, Inc.  All rights reserved.


// use this to guarantee that this package will not be installed on
// a unit which does not include exactly version 2.0 of the Card File application.
// If the version is > 2, then these APIs are *not* guaranteed to work, so we check for this...
SetPartFrameSlot('DoNotInstall, func()
	not getroot().cardfile or (getroot().cardfile.version and getroot().cardfile.version > 2));

InstallScript := func(partFrame, removeFrame)
	begin
		// stationery that takes just one value
		RegisterViewDef(GetLayout("Social Security Stationery"), EnsureInternal('person));
		
		// stationery that can have multiple values
		RegisterViewDef(GetLayout("Cars Stationery"), EnsureInternal('person));
		RegisterViewDef(GetLayout("Cars Stationery"), EnsureInternal('company));

		// add a new layout window to "Show" menu
		GetRoot().cardfile:AddLayout(GetLayout("Sorton Layout"));
		
		// new data type for cardfile (not 'person, 'group)
		local dataDefSym := EnsureInternal('|car:PIEDTS|);
		RegDataDef(dataDefSym, GetLayout("Car DataDef"));
		RegisterViewDef(GetLayout("Car Name ViewDef"), dataDefSym);
		RegisterViewDef(GetLayout("Car Make/Model ViewDef"), dataDefSym);
		RegisterViewDef(GetLayout("Car Bizcard ViewDef"), dataDefSym);
		RegisterViewDef(GetViewDefs('person).allInfo, dataDefSym);	// steal AllInfo view from cardfile

	end;
	
RemoveScript := func(removeFrame)
	begin
		UnregisterViewDef('|socialSecurity:PIEDTS|, 'person);
		// call kXMitViewDefChangeFunc with ('|socialSecurity:PIEDTS|, 'person, 'remove, kAppSymbol);

		UnregisterViewDef('|cars:PIEDTS|, 'person);
		UnregisterViewDef('|cars:PIEDTS|, 'company);
		
		// don't use GetRoot().cardfile:RemoveLayout('|sortonLayout:PIEDTS|);
		call kCardFileSafeRemoveLayoutFunc with ('|sortonLayout:PIEDTS|);
		
		UnRegDataDef('|car:PIEDTS|);
		// Removal is currently unsafe.  There is no notification to the application that
		// may be using the stationery that it has been removed.
		// Newton Engineering is working on a solution, which will be something like this:
		// call kXmitDataDefChangeFunc with ('|car:PIEDTS|, 'remove, kAppSymbol);
		UnregisterViewDef('default, '|car:PIEDTS|);
		UnregisterViewDef('|carMakeModel:PIEDTS|, '|car:PIEDTS|);
		UnregisterViewDef('|carBizCard:PIEDTS|, '|car:PIEDTS|);
		UnregisterViewDef('allinfo, '|car:PIEDTS|);
	end;
// End of text file Install & Remove Scripts.f



