// Text of project FalseAlarm written on 5/12/95 at 5:49 PM // Beginning of text file Project Data /* ** Newton Developer Technical Support Sample Code ** ** False Alarm, Alarm Functions demo ** ** by Mike Engber, Newton Developer Technical Support ** ** Copyright © 1994-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. version history v1 - initial release v2 - uses new alarm stub - bug fix - if the FalseAlarm app was closed when the alarm went off, DoAlarm blindly sent messages to a child view (that didn't exist since FalseAlarm was closed) v3 - updated for NTK 1.5 */ refNum := OpenResFileX( Home & "FalseAlarm.rsrc"); DefConst('kAlarmSound,GetSound("dadadadadada")); CloseResFileX(refNum); DefConst('kAlarmFn, func() begin if GetRoot().(kAppSymbol) exists then GetRoot().(kAppSymbol):DoAlarm() else GetRoot():Notify(kNotifyAlert,"FalseAlarm","App not installed."); end ); DefConst('kPopUpList,[ { item: "1 minute", dt: 1, }, { item: "2 minutes", dt: 2, }, { item: "5 minutes", dt: 5, }, { item: "10 minutes", dt: 10,}, ]); "Reg the llama"; // End of text file Project Data // Beginning of file FalseAlarm.t // Before Script for "FalseAlarmBase" // Copyright © 1994 by Apple Computer, Inc. All rights reserved. FalseAlarmBase := {title: "False Alarm", viewBounds: {left: 1, top: 10, right: 203, bottom: 246}, viewJustify: 16, pickActionScript: func(index) begin local time := Time() + kPopUpList[index].dt; call kAddAlarmFunc with (kAppString,time,nil,kAlarmFn,[]); AlarmButton:Close(); TimeArea:Open(); SetValue(alarmTime,'text,HourMinute(time)); SetValue(curTime,'text,HourMinute(Time()) && TimeInSeconds() MOD 60); :SetUpIdle(1000); end, DoAlarm: func() begin PlaySound(kAlarmSound); if call kViewIsOpenFunc with (self) then begin AlarmButton:Open(); TimeArea:Close(); :SetUpIdle(0); end end, viewIdleScript: func() begin SetValue(curTime,'text,HourMinute(Time()) && TimeInSeconds() MOD 60); 1000; end, debug: "FalseAlarmBase", _proto: @157 }; alarmButton := {text: "Set Alarm", buttonClickScript: func() begin DoPopUp(kPopUpList,:LocalBox().right,0,GetRoot().(kAppSymbol)); //see the PickActionScript of FalseAlarmBase for the code that sets the alarm end, viewBounds: {left: 0, top: 34, right: 100, bottom: 54}, viewJustify: 8388630, debug: "alarmButton", _proto: @226 }; AddStepForm(FalseAlarmBase, alarmButton); StepDeclare(FalseAlarmBase, alarmButton, 'alarmButton); timeArea := {viewFlags: 0, viewFormat: nil, viewBounds: {left: 6, top: 64, right: 198, bottom: 184}, debug: "timeArea", viewClass: 74 }; AddStepForm(FalseAlarmBase, timeArea); StepDeclare(FalseAlarmBase, timeArea, 'timeArea); _view000 := {text: "current time", viewBounds: {left: 8, top: 16, right: 88, bottom: 32}, _proto: @218 }; AddStepForm(timeArea, _view000); _view001 := {text: "alarm time", viewBounds: {left: 8, top: 40, right: 88, bottom: 56}, _proto: @218 }; AddStepForm(timeArea, _view001); curTime := {text: "cur time", viewBounds: {left: 100, top: 16, right: 180, bottom: 32}, debug: "curTime", _proto: @218 }; AddStepForm(timeArea, curTime); StepDeclare(FalseAlarmBase, curTime, 'curTime); alarmTime := {text: "alarm time", viewBounds: {left: 100, top: 40, right: 180, bottom: 56}, debug: "alarmTime", _proto: @218 }; AddStepForm(timeArea, alarmTime); StepDeclare(FalseAlarmBase, alarmTime, 'alarmTime); _view002 := {text: "Kill Alarm", buttonClickScript: func() begin call kRemoveAlarmFunc with (kAppString); GetRoot().(kAppSymbol):DoAlarm(); end, viewBounds: {left: 50, top: 74, right: 134, bottom: 94}, _proto: @226 }; AddStepForm(timeArea, _view002); constant |layout_FalseAlarm.t| := FalseAlarmBase; // End of file FalseAlarm.t