// Text of project NewTextFuncs written on 5/14/95 at 12:31 PM // Beginning of text file Project Data // Copyright, ©1994 Apple Computer. All rights reserved. // app constants constant kAppMaxWidth := 240 ; constant kAppMaxHeight := 336 ; // error strings DefConst('kAppErrors, ["There is no Source Text to display", ]); // End of text file Project Data // Beginning of file NewTextFuncs.t myBase := {viewBounds: {left: 0, top: 2, right: 236, bottom: 310}, viewFormat: 83951953, viewSetupFormScript: func() begin a := GetAppParams(); viewBounds := RelBounds(a.AppAreaLeft, a.AppAreaTop, MIN(a.AppAreaWidth, kAppMaxWidth), MIN(a.AppAreaHeight, kAppMaxHeight)); end, DoError: func(errorID, params) begin local errorString := Clone(kAppErrors[errorID]) ; if params then errorString := ParamStr(errorString, params) ; :Notify(kNotifyAlert, EnsureInternal(kAppName), errorString); end, declareSelf: 'base, DrawFunkyText: func(myText, funkyFontFrame) begin local b := :LocalBox(); local bounds := SetBounds(0, 0, 0, 0) ; // temporary use only // get the bounding box required for the text TextBounds(myText, funkyFontFrame, bounds); // just to make things look nice, clear our view :DrawShape(MakeRect(b.left, b.top, b.right, b.bottom), {fillpattern:vfWhite}); // now have some fun blasting the text around local height := bounds.bottom - bounds.top; local width := bounds.right - bounds.left; // make the text fit completely horizontally within us local horizontalMax := (b.right - b.left) - width; // make the text fit completely vertically within us local verticalMax := (b.bottom - b.top) - height; for i := 1 to 25 do TextBox(myText, funkyFontFrame, RelBounds(Random(0, horizontalMax), Random(0, verticalMax), width, height)); :Dirty(); // redraw our entire application RefreshViews(); // refresh immediately so the textbutton 'unhilite' will look pretty end, debug: "myBase", _proto: @157 }; theText := {viewFlags: 33553921, viewFormat: 209233, viewLineSpacing: 20, viewBounds: {left: 6, top: 25, right: 234, bottom: 95} , text: "Some text with\nline breaks in places\nthat are breaks", viewFont: nil, viewSetupFormScript: func() begin viewFont := userconfiguration.userFont ; end, debug: "theText", viewClass: 81 }; AddStepForm(myBase, theText); StepDeclare(myBase, theText, 'theText); _view000 := {text: "Display Text", buttonClickScript: func() begin local bounds := SetBounds(0, 0, 0, 0) ; local funkyFontFrame := {font: FontStyle:GetFontFrame(), justification: Justification:GetJustification()}; if StrLen(theText.text) < 1 then return :DoError(kNoTextError, nil) ; local myText := theText.text ; // do not need to display the new viewbounds newViewBounds:Close(); targetText:Close(); if functionType.clusterValue = 'TextBox then begin base:DoDrawing('DrawFunkyText, [myText, funkyFontFrame]); end; else begin // if we are using the function called TextBounds local newBounds := Clone(bounds); TextBounds(myText, funkyFontFrame, newBounds); newViewBounds:SetText(bounds, newBounds); targetText.text := myText ; targetText.funkyFont := funkyFontFrame ; targetText.textBounds := newBounds ; targetText:Open(); newViewbounds:Open(); end; end, viewBounds: {left: 10, top: 194, right: 130, bottom: 210}, _proto: @226 }; AddStepForm(myBase, _view000); targetText := {viewBounds: {left: 9, top: 117, right: 231, bottom: 187}, viewFormat: 336, viewEffect: 8625185, viewFlags: 0, text: "", viewDrawScript: func() begin TextBox(text, funkyFont, textBounds); end, funkyFont: nil, TextBounds: nil, debug: "targetText", viewClass: 74 }; AddStepForm(myBase, targetText); StepDeclare(myBase, targetText, 'targetText); functionType := {viewBounds: {left: 141, top: 261, right: 227, bottom: 299}, clusterValue: 'TextBox, viewFormat: 336, debug: "functionType", _proto: @203 }; AddStepForm(myBase, functionType); StepDeclare(myBase, functionType, 'functionType); _view001 := {buttonValue: 'TextBox, viewBounds: {left: 9, top: 5, right: 75, bottom: 21}, text: "TextBox", _proto: @202 }; AddStepForm(functionType, _view001); _view002 := {buttonValue: 'TextBounds, viewBounds: {left: 9, top: 21, right: 75, bottom: 37}, text: "TextBounds", _proto: @202 }; AddStepForm(functionType, _view002); _view003 := {text: "Use Function:", viewBounds: {left: 145, top: 254, right: 207, bottom: 270}, viewFormat: 1, viewFont: simpleFont9, _proto: @218 }; AddStepForm(myBase, _view003); _view004 := {text: "Source Text", viewBounds: {left: 8, top: 8, right: 72, bottom: 24}, _proto: @218 }; AddStepForm(myBase, _view004); _view005 := {text: "Target View", viewBounds: {left: 8, top: 100, right: 72, bottom: 116}, _proto: @218 }; AddStepForm(myBase, _view005); FontStyle := {viewFlags: 1, viewFormat: 336, viewBounds: {left: 9, top: 241, right: 119, bottom: 303}, GetFontFrame: func() begin {family: FontFamily:GetFamily(), face: FontFace:GetFace(), size: FontSize:GetSize()} end, debug: "FontStyle", viewClass: 74 }; AddStepForm(myBase, FontStyle); StepDeclare(myBase, FontStyle, 'FontStyle); FontFamily := {viewBounds: {left: 5, top: 7, right: 107, bottom: 21}, viewSetupFormScript: func() begin self.labelCommands := foreach slot, val deeply in fonts collect Capitalize(SprintObject(slot)); inherited:?viewSetupFormScript() end, text: "Family", GetFamily: func() begin Intern(entryLine.text); end, debug: "FontFamily", _proto: @190 }; AddStepForm(FontStyle, FontFamily); StepDeclare(FontStyle, FontFamily, 'FontFamily); FontFace := {viewBounds: {left: 5, top: 27, right: 107, bottom: 41}, text: "Face", labelCommands: ["Normal", "Bold", "Italic", "Underline"], labelActionScript: func(cmd) begin currIndex := cmd; end, currIndex: 0, GetFace: func() begin if currIndex = 0 then kFaceNormal; else if currIndex = 1 then kFaceBold; else if currIndex = 2 then kFaceItalic; else kFaceUnderline; end, debug: "FontFace", _proto: @190 }; AddStepForm(FontStyle, FontFace); StepDeclare(FontStyle, FontFace, 'FontFace); FontSize := {viewBounds: {left: 5, top: 47, right: 107, bottom: 61}, text: "Size", labelCommands: ["9", "10", "12", "14", "18"], currIndex: 0, labelActionScript: func(cmd) begin currIndex := cmd; end, GetSize: func() begin if currIndex = 0 then 9; else if currIndex = 1 then 10; else if currIndex = 2 then 12; else if currIndex = 3 then 14; else 18; end, debug: "FontSize", _proto: @190 }; AddStepForm(FontStyle, FontSize); StepDeclare(FontStyle, FontSize, 'FontSize); _view006 := {text: "Use Font:", viewBounds: {left: 12, top: 234, right: 56, bottom: 250}, viewFont: simpleFont9, viewFormat: 1, _proto: @218 }; AddStepForm(myBase, _view006); Justification := {viewBounds: {left: 9, top: 217, right: 131, bottom: 235}, labelCommands: ["Left", "Center", "Right"], GetJustification: func() begin Intern(entryLine.text); end, text: "Justification", debug: "Justification", _proto: @190 }; AddStepForm(myBase, Justification); StepDeclare(myBase, Justification, 'Justification); newViewbounds := {viewFlags: 0, viewFormat: 336, viewBounds: {left: 137, top: 193, right: 231, bottom: 251} , viewFont: {family: 'espy, face: kFaceNormal, size: 9}, viewDrawScript: func() begin TextBox(displayText, {font: viewFont, justification: 'center}, :LocalBox()); end, viewEffect: 8625185, sourceText: "Source Viewbounds:\n^0\nNew Viewbounds:\n^1", displaytext: nil , SetText: func(sourceBounds, newBounds) begin local s := "(", n := "(" ; foreach x in sourceBounds do s := s & NumberStr(x) & ", "; StrMunger(s, StrLen(s) - 2, 2, ")", 0, 1); foreach x in newBounds do n := n & NumberStr(x) & ", "; StrMunger(n, StrLen(n) - 2, 2, ")", 0, 1); displayText := ParamStr(sourceText, [s, n]); end, debug: "newViewbounds", viewClass: 74 }; AddStepForm(myBase, newViewbounds); StepDeclare(myBase, newViewbounds, 'newViewbounds); // After Script for "myBase" thisView := myBase; // Copyright, ©1994 Apple Computer. All rights reserved. thisView.title := kAppName; constant |layout_NewTextFuncs.t| := myBase; // End of file NewTextFuncs.t