// Text of project Letter.¹ written on 5/12/95 at 18:26 // Beginning of text file Project Data // Copyright © 1993-1995 by Apple Computer, Inc. All Rights Reserved //this constant may be defined in a future version of NTK //but we are including currently // End of text file Project Data // Beginning of file Letter.t // Before Script for "Single Letter Example" //Copyright 1993-1994 Apple Computer. All rights reserved. Single Letter Example := {title: "Single Letters", viewBounds: {left: 0, top: 18, right: 203, bottom: 309}, viewEffect: 986145 , debug: "Single Letter Example", _proto: @157 }; usesDictionary := {viewBounds: {left: 16, top: 40, right: 184, bottom: 88}, dictionaries: [kLettersDictionary]; // uses the built-in single letter dictionary , viewFlags: 25168385, textflags: vNoSpaces, debug: "usesDictionary", _proto: @185 }; AddStepForm(Single Letter Example, usesDictionary); _view000 := {text: "Uses custom dictionary", viewBounds: {left: 18, top: 82, right: 154, bottom: 98}, viewFont: simpleFont9, _proto: @218 }; AddStepForm(Single Letter Example, _view000); generic := {viewBounds: {left: 16, top: 184, right: 184, bottom: 232}, viewFlags: 8407809, textflags: vNoSpaces, debug: "generic", _proto: @185 }; AddStepForm(Single Letter Example, generic); _view001 := {text: "Uses \"vLettersAllowed\" flag", viewBounds: {left: 18, top: 226, right: 162, bottom: 242}, viewFont: simpleFont9, _proto: @218 }; AddStepForm(Single Letter Example, _view001); totallyCustom := {viewBounds: {left: 16, top: 112, right: 184, bottom: 160}, dictionaries: [kLettersDictionary];, viewFlags: 25168385, textflags: vNoSpaces, viewFormat: 337, viewWordScript: // This code very naively assumes that only A-Z characters are valid letters // Do not use code like this if you want to work on non-American Newton systems. DefConst('kOrdA, ord($A)); DefConst('kOrdZ, ord($Z)); DefConst('kDefLetter, "A"); func(unit) begin local candidate; local cOrd; local list := GetWordArray(unit); print(list); foreach word in list do begin print(isalphanumeric(word[0])); cOrd := ord(word[0]); if cOrd >= kOrdA and cOrd <= kOrdZ and word[0] <> letter then begin candidate := word; break; end; end; if not candidate then candidate := letter & ""; theShape := MakeText(candidate, 0, 0, width, baseline); letter := candidate[0]; :Dirty(); TRUE; //This should return TRUE if you handled the word end , viewSetupDoneScript: func() begin self.baseline := :LocalBox().bottom DIV 2 + 9; self.width := :LocalBox().right; end, baseline: nil, theShape: nil, viewDrawScript: DefConst('kCentered18ptStyle, {font: fancyFont18, justification: 'center}); func() begin if theShape then :DrawShape(theShape, kCentered18ptStyle); end, width: nil, letter: nil, viewClickScript: func(unit) begin theShape := nil; :Dirty(); RefreshViews(); NIL; end, debug: "totallyCustom", viewClass: 74 }; AddStepForm(Single Letter Example, totallyCustom); _view002 := {text: "Totally custom", viewBounds: {left: 16, top: 160, right: 160, bottom: 176}, viewFont: simpleFont9, _proto: @218 }; AddStepForm(Single Letter Example, _view002); constant |layout_Letter.t| := Single Letter Example; // End of file Letter.t