// Text of project pictButtons written on 5/13/95 at 11:10 PM // Beginning of text file Project Data // Copyright © 1993-94 Apple Computer, Inc. All rights reserved. // first open the resource file // NOTE: you have to change the path to match your environment r := OpenResFileX("pictures"); // how read in the pictures by assigning them to variables // each picture will have a mask generated for it. alarmPict := GetPictAsBits("alarm clock", true); lightPict := GetPictAsBits("light bulb", true); planePict := GetPictAsBits("plane", true); scalesPict := GetPictAsBits("scales", true); // make an array of all the pictures that a button // can use. fullPictArray := [alarmPict, lightPict, planePict, scalesPict]; // make sure we close the resource file // End of text file Project Data // Beginning of file pictButtons.t myBase := {title: "Application", viewBounds: {top: 8, left: 0, right: 224, bottom: 328}, debug: "myBase", _proto: @157 }; pictureButton := {viewBounds: {left: 76, top: 108, right: 136, bottom: 160}, buttonClickScript: func() begin end, currentPictIndex: 0, pictArray: fullPictArray, viewSetupFormScript: func() begin // set my icon to the one of the elements in the array // use the currentPictIndex to decide which element // that is. Use my changePicture script to set things up :changePicture(currentPictIndex) ; end, changePicture: func(pictIndex) begin // this function will set the icon of this button // to some picture from its array of pictures. // the pictIndex argument is either an index // to the array, or nil. If nil, set the picture // to the next picture in the array. if pictIndex then // should really error check this value currentPictIndex := pictIndex ; else // set my picture to the next one in the array // make sure index is valid by wrapping it around currentPictIndex := (currentPictIndex + 1) MOD length(pictArray) ; // now set my icon to the new one SetValue(self, 'icon, pictArray[currentPictIndex]) ; end, debug: "pictureButton", _proto: @198 }; AddStepForm(myBase, pictureButton); StepDeclare(myBase, pictureButton, 'pictureButton); _view000 := {text: "Change the Picture", buttonClickScript: func() begin pictureButton:changePicture(nil); end, viewBounds: {left: 42, top: 194, right: 154, bottom: 218}, _proto: @226 }; AddStepForm(myBase, _view000); constant |layout_pictButtons.t| := myBase; // End of file pictButtons.t