<* PRAGMA LL *> <* PRAGMA SUBTYPE *>An
ZChildVBT.T
is a VBT that is typically used as a subwindow.
A ZChildVBT
is a subclass of a HighlightVBT
that insulates any
highlighting done in the ZChildVBT
from highlighting done in
other subwindows. Clients should use a ZBackgroundVBT
around the
background child in order to insulate highlighting in the
background child from highlighting in the subwindows.
There are two alternate ways to initialize a ZChildVBT
. Each
allows the client to specify whether the subwindow should be
initially visible (``mapped'') and how the subwindow should
be reshaped when the parent ZSplit
is reshaped.
The method call v.init(...)
allows the client to specify where
the center or a corner of v
should be placed, relative to the
parent, either in absolute distance (in millimeters) from the
parent's northwest corner (CoordType.Absolute
), or as percentages
of the parent's width and height (CoordType.Scaled
). The default
is to align the center of v
with the center of the parent. The size
of v
is its preferred sizes in both the horizontal and vertical
dimensions.
The method call v.initFromEdges(...)
allows the client to specify
the edges of v
, either in absolute distance (in millimeters) from
the parent's northwest corner (this is the only case in which the
client specifies the absolute size of v
), or as percentages of
the parent's width and height.
The implementation will not pop up a subwindow with its northwest
corner north or west of the visible portion of the ZSplit
parent;
it will override the specified position as necessary to bring it
into view. It is a checked runtime error to specify scaled
coordinates (percentages) that are outside the range 0.0--1.0.
If the specified position is overriden, or if the subwindow is
not entirely visible when the subwindow is first made visible,
the implementation will also override the reshape method so that
the subwindow will be repositioned using the information specified
when it was initialized.
Finally, in order for the reformatting to meet specifications
above, the client must call Inserted
after the subwindow is
inserted as a child of a ZSplit
; the client must call Moved
after the subwindow is repositioned by the user; and the client
must call Grew
after the size of the subwindow is changed by the
user.
INTERFACEZChildVBT ; IMPORT HighlightVBT, VBT, ZSplit; TYPE Location = {NW, NE, SW, SE, Center}; CoordType = {Absolute, Scaled}; T <: Public; Public = HighlightVBT.T OBJECT METHODS <* LL <= VBT.mu *> init (ch : VBT.T; h, v := 0.5; loc := Location.Center; type := CoordType.Scaled; shaper: ZSplit.ReshapeControl := NIL; open: BOOLEAN := TRUE): T; initFromEdges (ch: VBT.T; w, e, n, s: REAL; type := CoordType.Absolute; shaper: ZSplit.ReshapeControl := NIL; open := TRUE): T; END; PROCEDURE InitiallyMapped (v: VBT.T): BOOLEAN;
Ifv
is aZChild
, return the value ofopen
when it was initialized. Otherwise, returnTRUE
.
PROCEDURE Pop (v: VBT.T; forcePlace := FALSE);
Mapv
and lift it to the top of its parent's children. IfforcePlace
is set, positionv
at its initial location.
PROCEDURE Inserted (v: VBT.T);
The client must call this procedure afterv
has been inserted into aZSplit
. This procedure sets aReshapeControl
object onv
. Ifv
isn't aZChildVBT
, theReshapeControl
tries to centerv
, subject to the contraint that its northwest corner is just visible. Ifv
is aZChild
, theReshapeControl
will followvbt
's initial position untilv
is moved by the user (usually becauseMoved
is called). At that point, the northwest corner ofv
will remain at that position relative to its parent, until the user moves it again.
PROCEDURE Moved (v: VBT.T);
The client must call this procedure afterv
has been moved by a user. Ifv
is aZChildVBT
, this procedure notes thatv
has been moved by the user, so that the next time it is reshaped,v
will retain its current position relative to its parent. Ifv
isn't aZChildVBT
, this procedure is a no-op.
PROCEDURE Grew (v: VBT.T; w, h: INTEGER);
The client must call this procedure after the size ofv
has been changed tow
-by-h
(in pixels) by a user. Ifv
is aZChildVBT
, this procedure notes thatv
has a new shape and callsVBT.NewShape
to tell the parentZSplit
. Subsequently,v
will report its shape asw
-by-h
. Ifv
is not aZChildVBT
, this procedure is a no-op.
Finally, here are a few
ZSplit
reshape controllers
that are sometimes useful:
VAR (*CONST*) Scaled: ZSplit.ReshapeControl; ScaledHFixed: ZSplit.ReshapeControl; ScaledVFixed: ZSplit.ReshapeControl; ScaledHVFixed: ZSplit.ReshapeControl;
Scaled
reshapes the child by
scaling the old child domain to occupy the same relative position
of the changing parent domain. ScaledHFixed
does the same, and then
insets the west and east edges so that the child's width is not
changed. Similarly, ScaledVFixed
scales the child's domain and then
insets the north and south edges. ScaledHVFixed
insets both the
north and south edges and the west and east edges so the size of
the child's domain stays fixed. In other words, ScaledHVFixed
can
be used to reposition the center point of the child without changing
its size.
END ZChildVBT.