<*PRAGMA LL*>The
Palette
interface allows you to implement your own
screen-independent resources by registering a closure to
produce an appropriate screen-dependent resource for any given
screentype.
INTERFACETranslating a screen-independent resource into its screen-dependent form is called {\it resolving} the resource. Here are the closure types for resolving resources:Palette ; IMPORT VBT, PaintOp, Cursor, Pixmap, Font, ScrnPaintOp, ScrnCursor, ScrnPixmap, ScrnFont;
TYPE OpClosure = OBJECT METHODS <* LL.sup <= VBT.mu *> apply(st: VBT.ScreenType): ScrnPaintOp.T; END; CursorClosure = OBJECT METHODS <* LL.sup <= VBT.mu *> apply(st: VBT.ScreenType): ScrnCursor.T; END; PixmapClosure = OBJECT METHODS <* LL.sup <= VBT.mu *> apply(st: VBT.ScreenType): ScrnPixmap.T; END; FontClosure = OBJECT METHODS <* LL.sup <= VBT.mu *> apply(st: VBT.ScreenType): ScrnFont.T; END;When an
apply
method is called, st # NIL
.
If the method returns NIL
, then some default screen-dependent
resource will be used; for example, the built-in font or the
transparent painting operation.
The following procedures produce screen-independent resources from closures:
PROCEDURE FromOpClosure(cl: OpClosure): PaintOp.T; <* LL.sup <= VBT.mu *>
Return aPaintOp.T
that behaves likecl.apply(st)
onst
.
PROCEDURE FromCursorClosure (cl: CursorClosure): Cursor.T; <* LL.sup <= VBT.mu *>
Return aCursor.T
that behaves likecl.apply(st)
onst
.
PROCEDURE FromPixmapClosure (cl: PixmapClosure): Pixmap.T; <* LL.sup <= VBT.mu *>
Return aPixmap.T
that behaves likecl.apply(st)
onst
.
PROCEDURE FromFontClosure(cl: FontClosure): Font.T; <* LL.sup <= VBT.mu *>
Return aFont.T
that behaves likecl.apply(st)
onst
.
If your apply method that resolves a resource needs to resolve some other resource, you should use one of the following procedures to do so. In all cases,
st
must be non-NIL
.
PROCEDURE ResolveOp(st: VBT.ScreenType; op: PaintOp.T) : ScrnPaintOp.T;
Resolveop
forst
.
PROCEDURE ResolveCursor(st: VBT.ScreenType; cursor: Cursor.T): ScrnCursor.T;
Resolvecursor
forst
.
PROCEDURE ResolvePixmap(st: VBT.ScreenType; pixmap: Pixmap.T): ScrnPixmap.T;
Resolvepixmap
forst
.
PROCEDURE ResolveFont(st: VBT.ScreenType; font: Font.T) : ScrnFont.T;
Resolvefont
forst
.
If you create a cycle of screen-independent resources each of which tries to resolve the next resource in the cycle, then the program will deadlock.
To implement screen-independent resources, every screentype includes
a {\it palette}, which is a table of screen-dependent resources
appropriate for that screentype. Most clients don't need to worry
about the palette, but if you are implementing a VBT
class that
translates to some other window system---like X or Microsoft
Windows---here is the procedure for building the palette in the
screentype for a top-level window: \index{palette}
PROCEDURE Init(st: VBT.ScreenType); <* LL.sup = VBT.mu.v *>
Initializest
's palette, if it is not already initialized, by resolving all screen-independent resources forst
and storing the results.
END Palette.