<> <> <> DIRECTORY Buttons, MBQueue, ViewerClasses, Rope; MBWindows: CEDAR DEFINITIONS = BEGIN Viewer: TYPE = ViewerClasses.Viewer; EnumProc: TYPE = PROC[enum: REF ANY] RETURNS [label: Rope.ROPE, thing: REF ANY]; <> CountProc: TYPE = PROC[v: Viewer, enum: REF ANY] RETURNS [INT]; <> ThumbProc: TYPE = PROC[v: Viewer, enum: REF ANY, where: NAT] RETURNS [newEnum: REF ANY]; <> <> CreateMBWindow: PROC[ next, prev: EnumProc, -- to go forward and backward in the enumeration thumb: ThumbProc, -- to create an enumeration set to a particular position count: CountProc, -- to give total size of enumeration buttonProc: Buttons.ButtonProc, -- called with the thing associated with button info: ViewerClasses.ViewerRec_ [], -- allows client to fill in ViewerRec fields initialScroll: INT_ 0, -- what percentage of scroll to have for initial display q: MBQueue.Queue_ NIL] -- MBQueue under which to synchronize (doesn't yet work) RETURNS [viewer: Viewer]; <> <> <> END. An example of the use of MBWindows (from Squirrel, DomainNutImpl): To create the MBWindow: parent.scrollable_ FALSE; -- Scrollbar will be provided by MBWindow mbw_ MBWindows.CreateMBWindow[ count: GetThingCount, thumb: DomainThumb, next: DomainNextProc, prev: DomainPrevProc, buttonProc: ProcessEntitySelection, info: [parent: parent, wx: 0, wy: 0, ww: parent.ww, wh: 800, border: FALSE], q: NIL ]; Containers.ChildYBound[container: parent, child: mbw]; GetThingCount: MBWindows.CountProc = { parent: Viewer_ GetTopLevel[v]; dInfo: DomainInfo_ NARROW[ ViewerOps.FetchProp[parent, $DomainInfo] ]; RETURN[EntitySetSize[DomainSubset[dInfo.domain, "", "\177"], FALSE]]; }; DomainNextProc: MBWindows.EnumProc = TRUSTED BEGIN es: EntitySet_ LOOPHOLE[enum]; e: Entity_ NextEntity[es]; RETURN[IF e=NIL THEN NIL ELSE NameOf[e], e]; END; DomainPrevProc: MBWindows.EnumProc = TRUSTED BEGIN es: EntitySet_ LOOPHOLE[enum]; e: Entity_ PrevEntity[es]; RETURN[IF e=NIL THEN NIL ELSE NameOf[e], e]; END; DomainThumb: MBWindows.ThumbProc = TRUSTED BEGIN es: EntitySet_ LOOPHOLE[enum]; dInfo: DomainInfo = NARROW[ViewerOps.FetchProp[GetTopLevel[v], $DomainInfo]]; DB.ReleaseEntitySet[es]; IF where<10 THEN es_ DB.DomainSubset[dInfo.domain, "", "\177", First] ELSE IF where>90 THEN { es_ DB.DomainSubset[dInfo.domain, "", "\177", Last]; []_ PrevEntity[es]; []_ PrevEntity[es]; []_ PrevEntity[es]} ELSE { <> es_ DB.DomainSubset[dInfo.domain, "", "\177", First]; THROUGH [0..where*GetThingCount[v, es]/100) DO []_ NextEntity[es] ENDLOOP; }; RETURN[es] END; GetTopLevel: PROCEDURE [v: Viewer] RETURNS [ancestor: Viewer] = { FOR ancestor _ v, ancestor.parent UNTIL ancestor.parent=NIL DO ENDLOOP; };