DIRECTORY Imager, ImagerSample, IO, SF, Xl, XlColorMapAccess, XlBitmap, XlBitmapWindow, XTk, XTkFriends, XTkBitmapWidgets, XTkShellWidgets; XTkBitmapWidgetsImpl: CEDAR MONITOR LOCKS bmRef USING bmRef: REF BMRec IMPORTS ImagerSample, SF, XlBitmapWindow, XlColorMapAccess, Xl, XlBitmap, XTk, XTkFriends, XTkShellWidgets EXPORTS XTkBitmapWidgets = BEGIN OPEN Xl, XTk, XTkBitmapWidgets; bmClass: ImplementorClass ¬ XTkFriends.CreateClass[[ key: $bitmapWidget, wDataNum: 1, configureLR: BMConfigureLR, destroyWindowLR: BMDestroyWindowLR, preStopFastAccess: BMPreStopFastAccess, fullStopFastAccessLR: BMFullStopFastAccessLR, destroyWidget: BMDestroyWidget, initInstPart: InitInstPart, eventMask: [exposure: TRUE, structureNotify: TRUE], backgroundKey: $white ]]; BMRec: TYPE = MONITORED RECORD [ handle: XlBitmapWindow.Handle ¬ NIL, bm: XlBitmap.Bitmap ¬ NIL, origin: Xl.Point ¬ [0, 0], restrict: SF.Box ¬ SF.maxBox, notify: BitmapEventProc, data: REF ¬ NIL, ownedBitmap: XlBitmap.Bitmap ¬ NIL ]; GetInstData: PROC [w: Widget] RETURNS [REF BMRec] = INLINE { RETURN [NARROW[XTkFriends.InstPart[w, bmClass]]]; }; mapEvents: Xl.EventFilter = Xl.CreateEventFilter[unmapNotify, mapNotify]; NotifyMapChange: Xl.EventProcType = { widget: Widget = NARROW[clientData]; bmRef: REF BMRec ~ GetInstData[widget]; IF bmRef.notify#NIL THEN { SELECT event.type FROM mapNotify => bmRef.notify[widget, map, bmRef.data]; unmapNotify => bmRef.notify[widget, unmap, bmRef.data]; ENDCASE => {}; }; }; BMDestroyWindowLR: TerminateProc = { bmRef: REF BMRec ~ GetInstData[widget]; IF bmRef.notify#NIL THEN bmRef.notify[widget, destroyWindow, bmRef.data]; XTkFriends.SimpleDestroyWindowLR[widget, reason]; }; dummyBitmap: XlBitmap.Bitmap ¬ XlBitmap.Create[[s: 1, f: 32], 1, FALSE]; -- Used to uinstall other bitmaps BMConfigureLR: ConfigureProc = { bmRef: REF BMRec ~ GetInstData[widget]; existW, createW: BOOL; reason: BitmapEventReason ¬ resize; existW ¬ widget.actualMapping1 THEN { IF widget.screenDepth=NIL OR XlColorMapAccess.Find8BitPseudoColorVisualType[widget.screenDepth.screen]=NIL THEN { XlBitmapWindow.SetBitmap[handle: bmRef.handle, bitmap: dummyBitmap, immediateRefresh: FALSE]; RETURN; }; }; XlBitmapWindow.SetBitmap[handle: bmRef.handle, bitmap: bmRef.bm, restrict: restrict, origin: origin, immediateRefresh: immediateRefresh, retainRefreshs: retainRefreshs]; }; }; GetImplData: PUBLIC PROC [widget: BitmapWidget] RETURNS [REF] = { bmRef: REF BMRec ~ GetInstData[widget]; RETURN [bmRef.handle]; }; Wait: PUBLIC PROC [widget: BitmapWidget, server: BOOL ¬ FALSE] = { bmRef: REF BMRec ~ GetInstData[widget]; XlBitmapWindow.Wait[bmRef.handle, server]; }; CreateContext: PUBLIC PROC [widget: BitmapWidget, surfaceUnitsPerPixel: NAT ¬ 1] RETURNS [context: Imager.Context] = { bmRef: REF BMRec ~ GetInstData[widget]; context ¬ XlBitmap.CreateContext[bmRef.bm, surfaceUnitsPerPixel]; }; CreateAndSetBitmap: PUBLIC PROC [widget: BitmapWidget, size: SF.Vec, bpp: NAT ¬ 1, origin: Xl.Point ¬ [0, 0]] = { bmRef: REF BMRec ~ GetInstData[widget]; bm: XlBitmap.Bitmap; IF bpp=0 THEN { IF widget.screenDepth#NIL AND XlColorMapAccess.Find8BitPseudoColorVisualType[widget.screenDepth.screen]#NIL THEN bpp ¬ 8 ELSE bpp ¬ 1; }; bm ¬ XlBitmap.Create[size, bpp]; SetBitmap[widget: widget, bitmap: bm, origin: origin]; IF widget.screenDepth#NIL THEN InitColormap[widget, bm] ELSE bmRef.ownedBitmap ¬ bm }; InitColormap: PROC [widget: XTk.Widget, bitmap: XlBitmap.Bitmap] = { IF bitmap#NIL THEN { cd: XlColorMapAccess.ColorData ¬ XlColorMapAccess.Access[widget.screenDepth.screen]; IF cd#NIL AND cd.hasColors THEN { XlBitmap.SetColormap[bitmap, cd.entries]; IF cd.hasPrivateColormap AND widget.attributes.colorMap#cd.colormap THEN { attributes: Xl.Attributes ¬ []; widget.attributes.colorMap ¬ attributes.colorMap ¬ cd.colormap; XlBitmap.SetColormap[bitmap, cd.entries]; XTkShellWidgets.TrackColorMap[shell: NIL, w: widget]; Xl.ChangeWindowAttributes[widget.connection, widget.window, attributes]; }; }; }; }; END. 2XTkBitmapWidgetsImpl.mesa Copyright Σ 1988, 1989, 1990, 1991, 1992 by Xerox Corporation. All rights reserved. Christian Jacobi, October 21, 1988 1:13:59 pm PDT Christian Jacobi, April 28, 1992 5:02 pm PDT --make sure we never use an old bitmap with incopatible bits per pixel producing match errors Κΐ–(cedarcode) style•NewlineDelimiter ˜code™Kšœ ΟeœI™TK™1K™,—K˜šΟk œ˜ K˜Kšœ ž˜ Kšžœ˜Kšžœ˜K˜K˜K˜ K˜K˜K˜ K˜Kšœ˜K˜—šΟnœžœžœ˜$Kšžœžœžœ˜"Kšžœ žœR˜jKšžœ˜—Kšžœžœ˜%K˜šœ4˜4Kšœ!˜!Kšœ˜Kšœ$˜$Kšœ(˜(Kšœ.˜.Kšœ ˜ Kšœ˜Kšœžœžœ˜4Kšœ˜Kšœ˜—K˜šœžœž œžœ˜ Kšœ žœ˜$Kšœžœ˜Kšœ˜Kšœ žœžœ˜K˜Kšœžœžœ˜Kšœž˜"K˜—K˜š Ÿ œžœ žœžœ žœ˜