DIRECTORY Icons USING [IconFlavor], IO USING[STREAM], Rope USING [ROPE] ; DBIcons: CEDAR DEFINITIONS = BEGIN EstablishIconDB: PROC [file: Rope.ROPE]; IconDB: READONLY Rope.ROPE; readOnly: READONLY BOOLEAN; RegisterIcon: PROC [iconName: Rope.ROPE, fileName: Rope.ROPE, index: CARDINAL]; IsRegistered: PROC[iconName: Rope.ROPE _ NIL, fileName: Rope.ROPE _ NIL, index: CARDINAL _ LAST[CARDINAL]] RETURNS[name: Rope.ROPE, file: Rope.ROPE, i: CARDINAL]; GetIcon: PROC [iconName: Rope.ROPE, default: Icons.IconFlavor _ unInit] RETURNS [Icons.IconFlavor]; InvalidateCache: PROC [iconName: Rope.ROPE _ NIL]; WriteCatalogue: PROC[ file: Rope.ROPE ]; ReadCatalogue: PROC[ file: Rope.ROPE, errlog: IO.STREAM _ NIL ]; Failed: ERROR [why: Failure, reason: Rope.ROPE]; Failure: TYPE = {badSegment, noSuchIcon, fileNotFound, invalidIndex}; END. DBIcons.mesa; Last Edited by: Teitelman, April 12, 1983 4:47 pm Last Edited by: Donahue, August 2, 1983 8:28 am General comments The purpose of this interface is to enable associating a name with an icon and allow client programs to obtain an IconFlavor for the corresponding icon without having to worry about which file the actual definition of the icon is stored in (and which icon index in that file). Furthermore, a cache is kept of the iconflavors that have already been created, so that the client can simply call DBIcons.GetIcon each place that the corresponding icon flavor is desired without having to distinguish the first call from subsequent calls. Icons can be registered from programs via the procedure RegisterIcon; these changes are permanently stored in the current icon database. Additionally, the ReadCatalogue procedure can be called to load a collection of icon definitions into the database; the stream that is read is assumed to be a vanilla text file with lines of the form iconName: fileName index where fileName can be a full path name. WriteCatalogue appends entries to the given stream that can be read back in with ReadCatalogue. Procedures Establishes the file named in the argument as the current icon database The name of the current icon database Whether the current database can be written on or not Registers the indicated icon. The new registration replaces an earlier registration, if any. Note that the icon Flavor itself is not actually created until the icon is used, i.e. until GetIcon is called. RegisterIcon does not check for existence of fileName, or validity of index. If saveInCatalogue is TRUE, and this registration constitutes a change, i.e. new iconName, or different fileName or index, rewrites RegisteredIcons.Catalogue to reflect the indicated association. Can be called with either iconName, or fileName and index. name = NIL if not registered. Obtain an icon flavor for the icon associated with iconName. Create a new icon flavor if one has not previously been created. If for some reason it could not obtain the icon, and default # unInit, returns the default. Otherwise, raises Error (defined below) with appropriate parameters. If an iconFlavor was previous created for this icon, discard the flavor, i.e. the next call to GetIcon will create a new flavor. If iconName = NIL, invalidate the cache for all registered icons. Nop if iconName not registered. For all registered icons, appends their registration to the supplied file. Add all catalogued information to the current icon database. Signals badSegment => segment name supplied to EstablishDB not legal or not $Icons segment NoSuchIcon => corresponding name was not found in database FileNotFound => the icon file could not be found, InvalidIndex => index too large, i.e. not that many icons in the file. ΚU– "cedar" style˜JšΟc™Jšœ1™1Jš/™/šΟk ˜ Jšœžœ˜Jšžœžœžœ˜Jšœžœžœ˜Jšœ˜J˜—JšΠblœžœž œž˜"headšœ™IbodyšΟrrΠor  Œ‘ }™”Lš œ8Οo œX’œι’œB’ œ™ς—™ šΟnœžœ žœ˜)JšœH™H—šœžœžœ˜Jšœ&™&—šœ žœžœ˜J™5J™—š £ œžœžœžœ žœ˜PJ™˜J™ΔJ™—š£ œžœžœžœžœžœ žœžœžœžœ žœ žœžœ˜’J™YJ™—š£œžœžœ&žœ˜cJš}™}J™ —J˜š£œžœžœžœ˜2J™γJ™—š£œžœ žœ˜(J™JJ™—š £ œžœ žœ žœžœžœ˜@J™<——™Jšœžœžœ˜0J˜šœ žœ8˜EJšΟeR™RJšœ:™:J™1J™FJ˜——J™Jšžœ˜J˜J˜J˜J˜J˜J˜—…—NΏ