DIRECTORY Atom, Buttons, CedarProcess, Imager, ImagerBackdoor, InputFocus, KeyMappingTypes, MessageWindow, Rope, TIPPrivate, UserInput, UserInputOps, ViewerOps, ViewerPrivate, ViewerScreenTypes, ViewersWorld, ViewersWorldClasses, ViewersWorldInitializations, ViewersWorldInstance, ViewersWorldRefType, ViewersWorldTypes; ViewersWorldImpl: CEDAR MONITOR IMPORTS Atom, CedarProcess, Imager, ImagerBackdoor, MessageWindow, TIPPrivate, UserInputOps, ViewerOps, ViewerPrivate EXPORTS ViewersWorld, ViewersWorldClasses, ViewersWorldInitializations, ViewersWorldInstance, ViewersWorldRefType = BEGIN Focus: TYPE = InputFocus.Focus; FocusRec: TYPE = InputFocus.FocusRec; Ref: TYPE = ViewersWorld.Ref; ViewersWorldObj: PUBLIC TYPE = ViewersWorldTypes.ViewersWorldObj; ViewersWorldClass: TYPE = ViewersWorldClasses.ViewersWorldClass; outOfColormapEntries: PUBLIC ERROR = CODE; setWorldNotifiers: LIST OF ViewersWorldInstance.SetNotifyProc ¬ NIL; theVWorld: ViewersWorld.Ref ¬ DummyViewersWorld[]; DummyViewersWorld: PROC RETURNS [ViewersWorld.Ref] = { w: ViewersWorld.Ref ¬ CreateViewersWorld[class: DummyViewersWorldClass[]]; RETURN [w] }; dummySetCursorPatternProc: ViewersWorldClasses.SetCursorPatternProc ~ {}; dummyGetCursorPatternProc: ViewersWorldClasses.GetCursorPatternProc ~ { RETURN [deltaX: 0, deltaY: 0, cursorPattern: ALL[0], patternName: $Unnamed] }; dummySetBigCursorPatternProc: ViewersWorldClasses.SetBigCursorPatternProc ~ {}; dummyGetBigCursorPatternProc: ViewersWorldClasses.GetBigCursorPatternProc ~ {ERROR}; dummyIsBigCursorPatternProc: ViewersWorldClasses.IsBigCursorPatternProc ~ {RETURN [FALSE]}; dummyBigCursorsSupportedProc: ViewersWorldClasses.BigCursorsSupportedProc ~ {RETURN[FALSE]}; dummySetCursorColorProc: ViewersWorldClasses.SetCursorColorProc ~ {}; dummyGetCursorColorProc: ViewersWorldClasses.GetCursorColorProc ~ {RETURN [Imager.black]}; dummySetMousePositionProc: ViewersWorldClasses.SetMousePositionProc ~ {}; dummyGetMousePositionProc: ViewersWorldClasses.GetMousePositionProc ~ { RETURN [x: 0, y: 0, display: NIL] }; dummySetCutBufferProc: ViewersWorldClasses.SetCutBufferProc ~ {}; dummyGetCutBufferProc: ViewersWorldClasses.GetCutBufferProc ~ {RETURN[NIL]}; dummyBlinkProc: ViewersWorldClasses.BlinkProc ~ {}; dummyGetDeviceSizeProc: ViewersWorldClasses.GetDeviceSizeProc ~ {RETURN[1024, 808]}; dummyContextCreatorProc: ViewerScreenTypes.ContextCreatorProc ~ { RETURN [ImagerBackdoor.BitmapContext[ImagerBackdoor.NewBitmap[1,1]]] }; dummyAllocateColorMapIndexProc: ViewersWorldClasses.AllocateColorMapIndexProc ~ {RETURN[0]}; dummyFreeColorMapIndexProc: ViewersWorldClasses.FreeColorMapIndexProc ~ {}; dummySetColorMapEntryProc: ViewersWorldClasses.SetColorMapEntryProc ~ {}; dummyGetColorMapEntryProc: ViewersWorldClasses.GetColorMapEntryProc ~ {RETURN[0,0,0]}; DummyViewersWorldClass: PROC RETURNS [ViewersWorldClass] = { c: ViewersWorldClass ¬ NEW[ViewersWorldClasses.ViewersWorldClassObj ¬ [ setCursorPattern: dummySetCursorPatternProc, getCursorPattern: dummyGetCursorPatternProc, setBigCursorPattern: dummySetBigCursorPatternProc, getBigCursorPattern: dummyGetBigCursorPatternProc, isBigCursorPattern: dummyIsBigCursorPatternProc, bigCursorsSupported: dummyBigCursorsSupportedProc, setCursorColor: dummySetCursorColorProc, getCursorColor: dummyGetCursorColorProc, setMousePosition: dummySetMousePositionProc, getMousePosition: dummyGetMousePositionProc, setCutBuffer: dummySetCutBufferProc, getCutBuffer: dummyGetCutBufferProc, blink: dummyBlinkProc, getDeviceSize: dummyGetDeviceSizeProc, creator: dummyContextCreatorProc, allocateColorMapIndex: dummyAllocateColorMapIndexProc, freeColorMapIndex: dummyFreeColorMapIndexProc, setColorMapEntry: dummySetColorMapEntryProc, getColorMapEntry: dummyGetColorMapEntryProc ]]; RETURN [c] }; SetWorld: PROC [viewersWorld: ViewersWorld.Ref] = { IF viewersWorld = NIL THEN viewersWorld ¬ DummyViewersWorld[]; theVWorld ¬ viewersWorld; ViewerPrivate.SetBWScreenSize[viewersWorld.width, viewersWorld.height]; FOR l: LIST OF ViewersWorldInstance.SetNotifyProc ¬ setWorldNotifiers, l.rest WHILE l#NIL DO l.first[viewersWorld]; ENDLOOP }; GetWorld: PUBLIC PROC [] RETURNS [viewersWorld: ViewersWorld.Ref] = { viewersWorld ¬ theVWorld; }; CallWhenSet: PUBLIC ENTRY PROC[ proc: ViewersWorldInstance.SetNotifyProc ] = { IF proc#NIL THEN setWorldNotifiers ¬ CONS[proc, setWorldNotifiers]; }; CreateViewersWorld: PUBLIC PROC [class: ViewersWorldClass, mapping: KeyMappingTypes.Mapping ¬ NIL, screenServerData: REF ¬ NIL] RETURNS [viewersWorld: Ref] = { handle: UserInput.Handle; viewersWorld ¬ NEW[ViewersWorldObj]; viewersWorld.mapping ¬ mapping; viewersWorld.class ¬ class; viewersWorld.screenServerData ¬ screenServerData; viewersWorld.currentFocus ¬ NEW[FocusRec]; viewersWorld.focusTIP ¬ TIPPrivate.CreateTIPClient[buttons: ViewerPrivate.MasterButtonProc, notify: ViewerPrivate.MasterNotifyProc, clientData: viewersWorld, name: "ViewersWorld"]; handle ¬ TIPPrivate.GetInputHandle[viewersWorld.focusTIP]; IF viewersWorld.mapping#NIL THEN UserInputOps.SetMapping[handle, viewersWorld.mapping]; }; StartInstallation: PUBLIC PROC [viewersWorld: Ref] = { SetWorld[viewersWorld]; ViewerPrivate.ProcessEndOpsRegistry[]; SetUpOutput[viewersWorld, viewersWorld.class.creator]; EnableInput[viewersWorld]; ViewerPrivate.GreyScreen[main, 0, 0, 9999, 9999]; MessageWindow.CreateMessageWindow[]; RETURN}; FinishInstallation: PUBLIC PROC [viewersWorld: Ref] = { }; GetInputHandle: PUBLIC PROC [viewersWorld: Ref] RETURNS [handle: UserInput.Handle] = { IF viewersWorld.focusTIP # NIL THEN { handle ¬ TIPPrivate.GetInputHandle[viewersWorld.focusTIP]; }; }; EnableInput: PROC [viewersWorld: Ref] = { inner: PROC = { TIPPrivate.DiscardTypeAhead[viewersWorld.focusTIP]; TIPPrivate.StartTIPClient[viewersWorld.focusTIP]; }; CedarProcess.DoWithPriority[LOOPHOLE[ViewerPrivate.VMgrPriority], inner]; viewersWorld.inputEnabled ¬ TRUE; }; RestartInput: PUBLIC PROC [viewersWorld: Ref] = { handle: UserInput.Handle; TIPPrivate.DestroyClient[viewersWorld.focusTIP]; -- destroy old notifier viewersWorld.focusTIP ¬ TIPPrivate.CreateTIPClient[name: "ViewersWorldRestart", buttons: ViewerPrivate.MasterButtonProc, notify: ViewerPrivate.MasterNotifyProc, clientData: viewersWorld]; handle ¬ TIPPrivate.GetInputHandle[viewersWorld.focusTIP]; IF viewersWorld.mapping#NIL THEN UserInputOps.SetMapping[handle, viewersWorld.mapping]; EnableInput[viewersWorld]; }; SetUpOutput: PROC [viewersWorld: Ref, creator: ViewerPrivate.ContextCreatorProc] = { [] ¬ ViewerPrivate.SetCreator[creator]; -- allocates a pool of contexts viewersWorld.outputEnabled ¬ TRUE; }; SetMousePosition: PUBLIC PROC [viewersWorld: Ref, x, y: INTEGER, display: REF ¬ NIL, device: REF ¬ NIL] = { viewersWorld.class.setMousePosition[viewersWorld.screenServerData, x, y, display, device]; }; GetMousePosition: PUBLIC PROC [viewersWorld: Ref, device: REF ¬ NIL] RETURNS [x, y: INTEGER, display: REF ¬ NIL] = { RETURN viewersWorld.class.getMousePosition[viewersWorld.screenServerData, device]; }; BlinkViewersWorld: PUBLIC PROC [viewersWorld: Ref, display: REF ¬ NIL, frequency: CARDINAL ¬ 750, duration: CARDINAL ¬ 500] = { viewersWorld.class.blink[viewersWorld.screenServerData, display, frequency, duration]; }; SetSize: PUBLIC PROC [viewersWorld: Ref, width: NAT, height: NAT, display: REF ¬ NIL] = { viewersWorld.width ¬ width; viewersWorld.height ¬ height; IF viewersWorld=theVWorld THEN { ViewerPrivate.SetBWScreenSize[width, height]; IF viewersWorld.outputEnabled THEN { [] ¬ ViewerPrivate.SetCreator[viewersWorld.class.creator]; -- update the cache of contexts ViewerOps.PaintEverything[]; }; }; RETURN}; GetSize: PUBLIC PROC [viewersWorld: Ref, display: REF ¬ NIL] RETURNS [width, height: NAT] = { width ¬ viewersWorld.width; height ¬ viewersWorld.height; }; GetDeviceSize: PUBLIC PROC [viewersWorld: Ref, display: REF ¬ NIL] RETURNS [w, h: NAT] = { [w, h] ¬ viewersWorld.class.getDeviceSize[viewersWorld.screenServerData, display]; }; SetCutBuffer: PUBLIC PROC [viewersWorld: Ref, buffer: ATOM, data: Rope.ROPE] = { IF viewersWorld=NIL THEN viewersWorld ¬ GetWorld[]; viewersWorld.class.setCutBuffer[viewersWorld.screenServerData, buffer, data]; }; GetCutBuffer: PUBLIC PROC [viewersWorld: Ref, buffer: ATOM] RETURNS [data: Rope.ROPE] = { IF viewersWorld=NIL THEN viewersWorld ¬ GetWorld[]; data ¬ viewersWorld.class.getCutBuffer[viewersWorld.screenServerData, buffer]; }; AllocateColorMapIndex: PUBLIC PROC [viewersWorld: Ref, display: REF ¬ NIL, revokeIndex: RevokeColorMapIndexProc, clientData: REF ¬ NIL] RETURNS [index: CARDINAL] = { index ¬ viewersWorld.class.allocateColorMapIndex[viewersWorld.screenServerData, display, revokeIndex, clientData]; }; RevokeColorMapIndexProc: TYPE = ViewersWorld.RevokeColorMapIndexProc; FreeColorMapIndex: PUBLIC PROC [viewersWorld: Ref, index: CARDINAL, display: REF ¬ NIL] = { viewersWorld.class.freeColorMapIndex[viewersWorld.screenServerData, index, display]; }; SetColorMapEntry: PUBLIC PROC [viewersWorld: Ref, index: CARDINAL, display: REF ¬ NIL, red, green, blue: INTEGER] = { viewersWorld.class.setColorMapEntry[viewersWorld.screenServerData, index, display, red, green, blue]; }; GetColorMapEntry: PUBLIC PROC [viewersWorld: Ref, index: CARDINAL, display: REF ¬ NIL] RETURNS [red, green, blue: INTEGER] = { [red, green, blue] ¬ viewersWorld.class.getColorMapEntry[viewersWorld.screenServerData, index, display]; }; GetWorldProp: PUBLIC PROC [viewersWorld: Ref, prop: REF] RETURNS [val: REF] = { RETURN [Atom.GetPropFromList[viewersWorld.properties, prop]] }; PutWorldProp: PUBLIC ENTRY PROC [viewersWorld: Ref, prop: REF, val: REF] = { IF viewersWorld#NIL THEN viewersWorld.properties ¬ Atom.PutPropOnList[viewersWorld.properties, prop, val] }; RemWorldProp: PUBLIC ENTRY PROC [viewersWorld: Ref, prop: REF] = { IF viewersWorld#NIL THEN viewersWorld.properties ¬ Atom.RemPropFromList[viewersWorld.properties, prop] }; GetClassProp: PUBLIC PROC [class: ViewersWorldClass, prop: REF] RETURNS [val: REF] = { RETURN [Atom.GetPropFromList[class.properties, prop]] }; PutClassProp: PUBLIC ENTRY PROC [class: ViewersWorldClass, prop: REF, val: REF] = { IF class#NIL THEN class.properties ¬ Atom.PutPropOnList[class.properties, prop, val] }; RemClassProp: PUBLIC ENTRY PROC [class: ViewersWorldClass, prop: REF] = { IF class#NIL THEN class.properties ¬ Atom.RemPropFromList[class.properties, prop] }; Atom.PutProp[$Viewers, $Viewers, $Viewers]; --hack which allows to detect viewer less worlds END. D ViewersWorldImpl.mesa Copyright Σ 1988, 1990, 1991, 1992 by Xerox Corporation. All rights reserved. Bier, August 13, 1990 4:18 pm PDT Christian Jacobi, July 1, 1992 12:08 pm PDT Kenneth A. Pier, April 19, 1991 3:50 pm PDT Willie-s, October 29, 1991 5:12 pm PST Michael Plass, March 15, 1992 4:39 pm PST A big switch which allows separate implementation of viewer worlds. Last tweaked by Mike Spreitzer March 26, 1992 4:15 pm PST Connecting with Viewers Setting up Input Allows viewers to begin taking actions off its input queue and processing them. The process that takes actions from the input queue as died. Create a new one. Setting up Output red, green, blue should be between 0 and 255. They should not be gamma-corrected. red, green, blue should be between 0 and 255. They should not be gamma-corrected. ΚΚ–(cedarcode) style•NewlineDelimiter ™codešœ™Kšœ ΟeœB™NKšœ!™!K™+K™+K™&K™)K™KšœC™CK™9K™—šΟk ˜ K˜Ά—K˜šΟnœžœž˜Kšžœn˜uKšžœj˜q—Kšœž˜˜Kšœžœ˜Kšœ žœ˜%Kšœžœ˜Kšœžœžœ%˜AKšœžœ)˜@K˜Kšœžœžœžœ˜*K˜Kšœžœžœ&žœ˜DK˜K˜3K˜K˜—šŸœžœžœ˜6K˜JKšžœ˜ K˜K˜—K˜I˜GKšžœ'žœ˜KK˜—K˜OKšœMžœ˜TKšœKžœžœ˜[KšœMžœžœ˜\K˜EKšœCžœ˜ZK˜I˜GKšžœžœ˜!K˜—K˜AKšœ?žœžœ˜LK˜3KšœAžœ ˜T˜AKšžœ>˜DK˜—KšœQžœ˜\K˜KK˜IšœGžœ ˜VK˜—šŸœžœžœ˜<šœžœ-˜GK˜,K˜,K˜2K˜2K˜0K˜2K˜(K˜(K˜,K˜,K˜$K˜$K˜K˜&K˜!K˜6K˜.K˜,K˜+K˜—Kšžœ˜ K˜K˜—šŸœžœ%˜3Kšžœžœžœ$˜>K˜KšœG˜Gš žœžœžœ@žœžœž˜\K˜Kšž˜—K˜K˜—šŸœžœžœžœ%˜EK˜K˜K˜—šŸ œžœžœžœ0˜NKšžœžœžœžœ˜DK˜K˜—šŸœžœžœ?žœžœžœžœ˜ŸKšœ˜Kšœžœ˜$Kšœ˜Kšœ˜Kšœ1˜1Kšœžœ ˜*Kšœ΄˜΄Kšœ:˜:Kšžœžœžœ7˜WK˜—K™K™K™šŸœžœžœ˜6Kšœ˜K˜&Kšœ6˜6Kšœ˜K˜1K˜$Kšžœ˜K˜—šŸœžœžœ˜7K˜K˜—K™K™šŸœžœžœžœ˜Všžœžœžœ˜%K˜:K˜—K˜K˜—šŸ œžœ˜)K™Ošœžœ˜Kšœ3˜3Kšœ1˜1K˜—Kšœžœ%˜IKšœžœ˜!K˜K˜—šŸ œžœžœ˜1K™OKšœ˜Kšœ1Οc˜HKšœ»˜»Kšœ:˜:Kšžœžœžœ7˜WKšœ˜K˜—K˜K™K˜šŸ œžœC˜TKšœ( ˜GKšœžœ˜"K˜—K˜K˜šŸœžœžœžœ žœžœ žœžœ˜kK˜ZK˜K˜—šŸœžœžœžœžœžœžœ žœžœ˜tKšžœL˜RK˜K™—šŸœžœžœžœžœ žœžœ ˜K˜VK˜—K™šŸœžœžœžœ žœ žœžœ˜YKšœ˜Kšœ˜šžœžœ˜ Kšœ-˜-šžœžœ˜$Kšœ; ˜ZKšœ˜K˜—K˜—Kšžœ˜K˜—šŸœžœžœžœžœžœžœ˜]Kšœ˜Kšœ˜K˜—K™šŸ œžœžœžœžœžœžœ˜ZK˜RK˜—K˜š Ÿ œžœžœžœ žœ˜PKšžœžœžœ˜3KšœM˜MK˜K˜—š Ÿ œžœžœžœžœ žœ˜YKšžœžœžœ˜3KšœN˜NK˜—K˜šŸœžœžœžœžœ4žœžœžœ žœ˜₯K˜rK˜J™—Kšœžœ(˜Eš Ÿœž œžœ žœžœ˜[K˜TK˜K™—š Ÿœž œžœ žœžœžœ˜uKšœS™SK˜eK˜K˜—šŸœž œžœ žœžœžœžœ˜~KšœS™SK˜hK˜—K™š Ÿ œžœžœžœžœžœ˜OKšžœ6˜