DIRECTORY CommanderOps, Imager, ImagerTransformation, IO, PropList, Rope, SlateControls, SlateIO, Slate, Xl, XlColorAccess, XTk, XTkWidgets; SlatePrintingImpl: CEDAR MONITOR IMPORTS CommanderOps, ImagerTransformation, IO, PropList, Rope, SlateControls, SlateIO, Slate, Xl, XlColorAccess, XTk, XTkWidgets ~ BEGIN Widget: TYPE = XTk.Widget; FullScaleTrans: PROC [] RETURNS [trans: Imager.Transformation] = { trans ¬ ImagerTransformation.Rotate[90]; trans ¬ ImagerTransformation.PostScale[trans, 72.0/300.0*5.0]; trans ¬ ImagerTransformation.PostTranslate[trans, [x: 0.0254*8.5-0.004, y: 0.004]]; }; FitNiceTrans: PROC [] RETURNS [trans: Imager.Transformation] = { trans ¬ ImagerTransformation.Rotate[90]; trans ¬ ImagerTransformation.PostScale[trans, 72.0/300.0*4.0]; trans ¬ ImagerTransformation.PostTranslate[trans, [x: 0.0254*8.5-0.0254, y: 0.0254]]; }; CallName: PROC [callData: REF] RETURNS [Rope.ROPE] = { nameWidget: Widget ~ NARROW[callData]; name: Rope.ROPE ~ XTkWidgets.GetText[nameWidget]; RETURN [name]; }; IPPrintAllButtonHit: XTkWidgets.ButtonHitProcType = { trans: Imager.Transformation ¬ NIL; instance: Slate.Instance ¬ NARROW[registerData]; printerName: Rope.ROPE ¬ CallName[callData]; trans ¬ FitNiceTrans[]; SlateIO.IPPrint[pages: Slate.CurrentListOfPages[instance.session], printerName: printerName, log: instance.log, server: widget.connection, trans: trans] }; IPPrintPageHit: XTkWidgets.ButtonHitProcType = { trans: Imager.Transformation ¬ NIL; instance: Slate.Instance ¬ NARROW[registerData]; printerName: Rope.ROPE ¬ CallName[callData]; trans ¬ FitNiceTrans[]; SlateIO.IPPrint[pages: LIST[Slate.ActivePage[instance.session]], printerName: printerName, log: instance.log, server: widget.connection, trans: trans] }; PSPrintAllButtonHit: XTkWidgets.ButtonHitProcType = { trans: Imager.Transformation ¬ NIL; instance: Slate.Instance ¬ NARROW[registerData]; printerName: Rope.ROPE ¬ CallName[callData]; trans ¬ FitNiceTrans[]; SlateIO.PSPrint[pages: Slate.CurrentListOfPages[instance.session], printerName: printerName, log: instance.log, server: widget.connection, trans: trans] }; CreatePrintingWidget: Slate.EventProc = { shell: Widget ¬ XTkWidgets.CreateShell[ className: $SlateControl, windowHeader: "Slate Printing", packageName: "SlateControl", shortName: "Slate Control" ]; pnField: Widget ¬ XTkWidgets.CreateLabeledField[label: "printer:", init: "Snoball"]; printPageWidget: Widget ~ XTkWidgets.CreateButton[ text: "PrintPage", hitProc: IPPrintPageHit, registerData: instance, callData: pnField ]; printAll: Widget ~ XTkWidgets.CreateButton[ text: "IP-PrintAll", hitProc: IPPrintAllButtonHit, registerData: instance, callData: pnField ]; printPSAll: Widget ~ XTkWidgets.CreateButton[ text: "PS-PrintAll", hitProc: PSPrintAllButtonHit, registerData: instance, callData: pnField ]; xCont: Widget ~ XTkWidgets.CreateXStack[[], LIST[printAll, printPSAll, printPageWidget]]; topYCont: Widget _ XTkWidgets.CreateYStack[[],LIST[pnField, xCont]]; XTkWidgets.SetShellChild[shell, topYCont]; XTkWidgets.BindScreenShell[shell, callData ! Xl.connectionNotCreated => { IO.PutRope[instance.log, Rope.Concat["Failed: ", why.reason]]; GOTO oops }]; SlateControls.LimitLifetime[shell, instance]; XTkWidgets.RealizeShell[shell]; EXITS oops => {} }; WritePageButtonHit: XTkWidgets.ButtonHitProcType = { instance: Slate.Instance ~ NARROW[registerData]; fileName: Rope.ROPE ¬ CallName[callData]; SlateIO.WriteSlateFile[pages: LIST[Slate.ActivePage[instance.session]], fileName: fileName, log: instance.log, server: widget.connection] }; WriteAllButtonHit: XTkWidgets.ButtonHitProcType = { instance: Slate.Instance ~ NARROW[registerData]; fileName: Rope.ROPE ¬ CallName[callData]; SlateIO.WriteSlateFile[pages: Slate.CurrentListOfPages[instance.session], fileName: fileName, log: instance.log, server: widget.connection] }; WriteIPPageButtonHit: XTkWidgets.ButtonHitProcType = { instance: Slate.Instance ~ NARROW[registerData]; fileName: Rope.ROPE ¬ CallName[callData]; SlateIO.WriteIPFile[pages: LIST[Slate.ActivePage[instance.session]], fileName: fileName, log: instance.log, server: widget.connection] }; WriteIPAllButtonHit: XTkWidgets.ButtonHitProcType = { instance: Slate.Instance ~ NARROW[registerData]; fileName: Rope.ROPE ¬ CallName[callData]; SlateIO.WriteIPFile[pages: Slate.CurrentListOfPages[instance.session], fileName: fileName, log: instance.log, server: widget.connection] }; WritePSPageButtonHit: XTkWidgets.ButtonHitProcType = { instance: Slate.Instance ~ NARROW[registerData]; fileName: Rope.ROPE ¬ CallName[callData]; SlateIO.WritePSFile[pages: LIST[Slate.ActivePage[instance.session]], fileName: fileName, log: instance.log, server: widget.connection] }; WritePSAllButtonHit: XTkWidgets.ButtonHitProcType = { instance: Slate.Instance ~ NARROW[registerData]; fileName: Rope.ROPE ¬ CallName[callData]; SlateIO.WritePSFile[pages: Slate.CurrentListOfPages[instance.session], fileName: fileName, log: instance.log, server: widget.connection] }; ReadButtonHit: XTkWidgets.ButtonHitProcType = { instance: Slate.Instance ~ NARROW[registerData]; mapEntries: REF; fileName: Rope.ROPE ¬ CallName[callData]; mapEntries ¬ GetColorInfo[instance].mapEntries; SlateIO.ReadSlateFile[instance.session, fileName, instance.log, mapEntries]; }; ReadIPFileButtonHit: XTkWidgets.ButtonHitProcType = { instance: Slate.Instance ~ NARROW[registerData]; bpp: NAT; mapEntries: REF; fileName: Rope.ROPE ¬ CallName[callData]; [bpp, mapEntries] ¬ GetColorInfo[instance]; SlateIO.ReadIPFile[instance.session, fileName, instance.log, [0, 0], bpp, mapEntries]; }; CountPages: PROC [pages: LIST OF Slate.Page] RETURNS [n: INT ¬ 0] = { FOR list: LIST OF Slate.Page ¬ pages, list.rest WHILE list#NIL DO n ¬ n+1 ENDLOOP; }; FancyRemovePages: PROC [pages: LIST OF Slate.Page] = { removeCount: INT ~ CountPages[pages]; session: Slate.Session ¬ NIL; FOR list: LIST OF Slate.Page ¬ pages, list.rest WHILE (list#NIL AND session=NIL) DO IF list.first#NIL THEN session ¬ list.first.session ENDLOOP; IF session#NIL THEN { currentCount: INT ~ CountPages[Slate.CurrentListOfPages[session]]; IF removeCount { IO.PutRope[instance.log, Rope.Concat["Failed: ", why.reason]]; GOTO oops }]; SlateControls.LimitLifetime[shell, instance]; XTkWidgets.RealizeShell[shell]; EXITS oops => {} }; CreateScanner: Slate.EventProc = { out: Rope.ROPE; result: REF; serverName: Rope.ROPE ~ Xl.ServerName[NARROW[callData]]; [out, result] ¬ CommanderOps.DoCommandRope[Rope.Cat["X11 -server ", serverName, " -- ScannerTool"], NIL, NIL]; IO.PutRope[instance.log, out]; }; CreateHandwritingRecognizer: Slate.EventProc = { out: Rope.ROPE; result: REF; serverName: Rope.ROPE ~ Xl.ServerName[NARROW[callData]]; [out, result] ¬ CommanderOps.DoCommandRope[Rope.Cat["X11 -server ", serverName, " -- X11Handwriting"], NIL, NIL]; IO.PutRope[instance.log, out]; }; RegisterMain: PROC [name: Rope.ROPE, proc: Slate.EventProc] = { key: REF INT ¬ NEW[INT]; SlateControls.RegisterButton[$Main, name, key]; Slate.RegisterGlobalEventProc[key, proc]; }; RegisterMain["Scanning", CreateScanner]; RegisterMain["Printing", CreatePrintingWidget]; RegisterMain["IO", CreateIOWidget]; RegisterMain["Handwriting", CreateHandwritingRecognizer]; END. @ SlatePrintingImpl.mesa Copyright Ó 1993 by Xerox Corporation. All rights reserved. Christian Jacobi, February 24, 1993 6:44 pm PST Christian Jacobi, August 16, 1993 12:38 pm PDT -- Scale so that pixels on screen are integer number of pixel on printer -- 72 = pixel/inch on screen -- 300 = pixel/inch on some printers e.g. snoball -- 5 = nice integral factor blowing picture up only a little -- Center on page -- 0.0254*8.5-0.004 translate 8+1/2 inch to match page width, left 4 mm -- 0.004 up 4 mm from page border -- Scale so that pixels on screen are integer number of pixel on printer -- 72 = pixel/inch on screen -- 300 = pixel/inch on some printers e.g. snoball -- 4 = nice integral factor blowing picture up only a little -- Center on page -- 0.0254*8.5 translate 8+1/2 inch to match page width, left 1 inch -- 0.0254 up 1 inch from page border --Remove these pages from their session, except: noop if these are all pages --This fancy exception recognizes when a read operation failed Note that mapEntries is returned when available, even on bpp=1 Êš•NewlineDelimiter ™™J™—˜SK™K™HK™'—K˜K˜—šž œœœ#˜@K˜(˜@K™IKšŸœ™KšŸœ*™1KšŸœ7™>—˜UK™K™DK™*—K˜K˜—š žœœ œœœ˜6Kšœœ ˜&Kšœ œ"˜1Kšœ˜K˜—K˜šžœ"˜5Kšœœ˜#Kšœœ˜0Kšœœ˜,K˜K˜˜K˜K˜—šžœ"˜0Kšœœ˜#Kšœœ˜0Kšœœ˜,K˜Kšœœ{˜–K˜K˜—šžœ"˜5Kšœœ˜#Kšœœ˜0Kšœœ˜,K˜K˜˜K˜K˜—šžœ˜)˜'K˜K˜K˜K˜Kšœ˜—K˜T˜2K˜UK˜—˜+K˜\K˜—˜-K˜\K˜—Kšœ,œ)˜YKšœ.œ˜DK˜*˜IKšœ<˜>Kšœ˜ K˜—K˜-K˜Kšœ ˜K˜K˜—šžœ"˜4Jšœœ˜0Kšœœ˜)Kšœœg˜‰K˜K˜—šžœ"˜3Jšœœ˜0Kšœœ˜)K˜‹K˜K˜—šžœ"˜6Jšœœ˜0Kšœœ˜)Kšœœg˜†Kšœ˜K˜—šžœ"˜5Jšœœ˜0Kšœœ˜)K˜ˆK˜K˜—šžœ"˜6Jšœœ˜0Kšœœ˜)Kšœœg˜†Kšœ˜K˜—šžœ"˜5Jšœœ˜0Kšœœ˜)K˜ˆKšœ˜K˜—šž œ"˜/Jšœœ˜0Kšœ œ˜Kšœœ˜)K˜/K˜LKšœ˜K˜—šžœ"˜5Jšœœ˜0Kšœœœ˜Kšœœ˜)K˜+K˜VKšœ˜K˜—š ž œœ œœ œœ ˜Eš œœœœœ˜AK˜Kšœ˜—K˜—K˜šžœœ œœ˜6Kšœ)Ïbœ™LK™>Kšœ œ˜%Kšœœ˜šœœœœœœ œ˜SJšœ œœ˜3Kšœ˜—šœ œœ˜Jšœœ1˜Bšœœ˜"š œœœœœ˜AJ˜Kšœ˜—K˜—J˜—K˜—K˜š ž œœœœœœ˜_K™>šž œœ œœ˜2K˜"Kšœ#œ˜-K˜—J˜K˜lKšœœœœ˜,Kšœœœœ˜8K˜—K˜šžœ"˜5Jšœœ˜0Kšœœœ˜Kšœœ˜)Kšœœœ9˜GK˜+K˜VJ˜Kšœ˜K˜—šžœ"˜3Jšœœ˜0Kšœœ˜)Kšœœœ9˜GKšœ œ%˜4K˜LJ˜Kšœ˜K˜—šžœ"˜3Jšœœ˜0Kšœœ˜)K˜@Kšœ8œ˜MK˜K˜—šžœ˜#˜'K˜K˜K˜K˜Kšœ˜—K˜YK˜˜,K˜YK˜—˜*K˜WK˜—˜'K˜OK˜—˜+K˜WK˜—˜1K˜ZK˜—K˜˜.K˜]K˜—˜-K˜[K˜—˜)K˜WK˜—˜-K˜[K˜—K˜˜.K˜]K˜—˜-K˜[K˜—Kšœ3œ6˜mKšœ2œ/˜eKšœ2œ˜Q˜3Kšœ1˜5K˜—K˜/˜IKšœ<˜>Kšœ˜ K˜—K˜-K˜Kšœ ˜K˜—K˜šž œ˜"Kšœ œ œ˜Kšœœœ ˜8Kšœdœœ˜nKšœ˜K˜K˜—šžœ˜0Kšœ œ œ˜Kšœœœ ˜8Kšœgœœ˜qKšœ˜K˜K˜—šž œœ œ˜?Kš œœœœœ˜K˜/K˜)K˜K˜—K˜(K˜/K˜#K˜9Kšœ˜K˜—…—+Ò8¬