// Text of project InkForm written on 11/20/95 at 5:33 PM // Beginning of file InkForm Layout // Before Script for "InkForm" // Newton Developer Technical Support Sample Code // InkForm, Ink/Text/RichText example // by Bob Ebert & J. Christopher Bell // Copyright © 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. InkForm := {title: "InkForm", viewBounds: {top: 0, left: 0, right: 240, bottom: 320}, viewFormat: 83951953, viewFlags: 549, viewSetupFormScript: func() begin local b := GetAppParams(); constant kMaxWidth := 240; constant kMaxHeight := 336; viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop, Min(b.appAreaWidth, kMaxWidth), Min(b.appAreaHeight, kMaxHeight) ); end, RecalcSummary: func() begin local a := one:GetRichString(); local b := two:GetRichString(); local c := three:GetRichString(); // since it is text only, we could just get the text slot local theSum; if StrLen(a&b&c) > 0 then theSum := a && b && c; else theSum := "Write something in the input areas above."; // This will handle actually change the text AND styles slots // based on the data in the rich string. SetValue(sum, 'text, theSum); // this one does the same thing, but forces a single style SetValue(plainSum, 'text, theSum); end, viewSetupDoneScript: func() begin :RecalcSummary(); end, RecognizeAll: func() begin // this seems to expect an integer for the hilite setting instead of true/nil if one.text then RecognizePara(one, 0, StrLen(one.text), 1, nil); if two.text then RecognizePara(two, 0, StrLen(two.text), 1, nil); if three.text then RecognizePara(three, 0, StrLen(three.text), 1, nil); end, declareSelf: 'base, debug: "InkForm", viewClass: 74 }; _view000 := {_proto: @229}; AddStepForm(InkForm, _view000); InkOnlyLabel := {text: "Ink words only", viewBounds: {left: 8, top: 24, right: 224, bottom: 40}, debug: "InkOnlyLabel", _proto: @218 }; AddStepForm(InkForm, InkOnlyLabel); one := {viewBounds: {left: 9, top: 41, right: 215, bottom: 79}, viewFlags: 14881, viewFormat: 12625, viewLineSpacing: 35, recConfig: // Ink Only { doInkWordRecognition: true, // accept ink words doRawInkRecognition: nil, // disallow raw ink };, viewChangedScript: func(slot, view) begin if slot = 'text or slot = 'styles then :RecalcSummary(); nil; end, debug: "one", viewClass: 81 }; AddStepForm(InkForm, one); StepDeclare(InkForm, one, 'one); TextOnlyLabel := {text: "Text only", viewBounds: {left: 8, top: 88, right: 200, bottom: 104}, debug: "TextOnlyLabel", _proto: @218 }; AddStepForm(InkForm, TextOnlyLabel); two := {viewBounds: {left: 9, top: 105, right: 215, bottom: 143}, viewFlags: 14881, viewFormat: 12625, viewLineSpacing: 35, viewChangedScript: func(slot, view) begin if slot = 'text or slot = 'styles then :RecalcSummary(); nil; end, recConfig: // Text Only { inputMask: vClickable+vGesturesAllowed+vCharsAllowed, doInkWordRecognition: nil, // disallow ink words doRawInkRecognition: nil, // disallow raw ink }, debug: "two", viewClass: 81 }; AddStepForm(InkForm, two); StepDeclare(InkForm, two, 'two); inkOrTextLabel := {text: "Ink or Text (use the recToggle button!)", viewBounds: {left: 8, top: 152, right: 210, bottom: 168}, debug: "inkOrTextLabel", _proto: @218 }; AddStepForm(InkForm, inkOrTextLabel); three := {viewBounds: {left: 9, top: 169, right: 215, bottom: 207}, viewFlags: 14881, viewFormat: 12625, viewLineSpacing: 35, recConfig: ROM_RCInkOrText /* RCInkOrText corresponds to this: { inputMask: nil, buildInputMask: true, // force it to use prefs doShapeRecognition: nil, // disallow shapes doFormulaRecognition: nil, // disallow formulas doInkWordRecognition: true, // accept ink words doRawInkRecognition: nil, // disallow raw ink }; */, viewChangedScript: func(slot, view) begin if slot = 'text or slot = 'styles then :RecalcSummary(); nil; end, debug: "three", viewClass: 81 }; AddStepForm(InkForm, three); StepDeclare(InkForm, three, 'three); sum := {viewBounds: {left: 10, top: 218, right: 218, bottom: 258}, viewFormat: 1, viewFlags: 33, recConfig: // this will prevent automatic recognition of ink // when SetValue is called. (Experiment with different values!) // You can also prevent it by setting vReadOnly, see plainSum for an example. ROM_RCInkOrText, viewLineSpacing: 20, debug: "sum", viewClass: 81 }; AddStepForm(InkForm, sum); StepDeclare(InkForm, sum, 'sum); plainSum := {viewBounds: {left: 10, top: 258, right: 218, bottom: 298}, viewFont: simpleFont10, viewFormat: 1, viewFlags: 35, textFlags: // force the text to be of a single style vFixedTextStyle + vFixedInkTextStyle;, viewLineSpacing: 13, debug: "plainSum", viewClass: 81 }; AddStepForm(InkForm, plainSum); StepDeclare(InkForm, plainSum, 'plainSum); _view001 := {_proto: @219}; AddStepForm(InkForm, _view001); _view002 := { _recogPopup: // customize the Recognition Popup menu to only include relavant options. [ 'recogText, 'recogInkText, 'pickseparator, 'recToggleSettings, ], _proto: @234 }; AddStepForm(_view001, _view002); Recognize := { buttonClickScript: func() begin :RecognizeAll(); end, text: "Recognize", viewBounds: {left: 7, top: 0, right: 64, bottom: 13}, viewJustify: 8406054, debug: "Recognize", _proto: @226 }; AddStepForm(_view001, Recognize); constant |layout_InkForm Layout| := InkForm; // End of file InkForm Layout