include "draw.m"; include "prefab.m"; prefab:= load Prefab Prefab->PATH; Compound: adt { image: ref Draw->Image; environ: ref Environ; r: Draw->Rect; title: ref Element; contents:ref Element; iconbox: fn(env: ref Environ, p: Draw->Point, title: string, icon, mask: ref Draw->Image) :ref Compound; textbox: fn(env: ref Environ, r: Draw->Rect, title, text: string): ref Compound; layoutbox: fn(env: ref Environ, r: Draw->Rect, title: string, lay: list of Layout) :ref Compound; box: fn(env: ref Environ, p: Draw->Point, title, elist: ref Element):ref Compound; draw: fn(comp: self ref Compound); redraw: fn(comp: self ref Compound, r: Draw->Rect); scroll: fn(comp: self ref Compound, elem: ref Element, d: Draw->Point); show: fn(comp: self ref Compound, elem: ref Element): int; select: fn(comp: self ref Compound, elem: ref Element, i: int, c: chan of int): (int, int, ref Element); tagselect: fn(comp: self ref Compound, elem: ref Element, i: int, c: chan of int): (int, int, ref Element); highlight: fn(comp: self ref Compound, elem: ref Element, on: int); };
Compound.textbox (env, r, title, text)
Creates a Compound whose contents are made by calling Element.text using the supplied text. As with Element.text, the resulting contents Element will be actually a list of text Elements if the text occupies multiple lines on the screen. The rectangle behaves as in Element.text. Compound.layoutbox (env, r, title, layoutlist)
Like Compound.textbox, but based on Element.layout rather than Element.text. Compound.box (env, p, title, element)
Creates a Compound whose contents are made from an existing Element. To build complex structures, use the Element -building functions, size the Element appropriately, and use Compound.box. The result is positioned with its upper left corner at p, and with size determined by that of the Element. However a Compound is built, its size computation makes allowance for the border and title. Moreover, if the requested size and placement makes part appear offscreen, the result may be moved to display it better. Compound.draw ( )
This function uses the description of the title and contents to paint the on-screen image. It takes no arguments. All the information is included in the description. Compound.redraw (r)
Like Compound.draw, but restricts the drawing to the specified Rect r. Compound.select (element, index, c): (int, int, Element)
The parameters to the select function are:
Any other key returns the same tuple with index -1 and the value of the key. The elem returned is always the most recently highlighted, even if the result was not a selection. When select returns, it always restores the default appearance of the list.
Compound.tagselect (element, index, c): (int, int, Element)
Like Compound.select, but rather than selecting among all the elements of a list, it selects among only those elements with defined tags in the structure contained within the specified element. Compound.highlight (element, on)
Set the highlighting to be 'on' or 'off' for the element within the compound. Compound.scroll (element, d)
Scroll the element within the compound. The updated image is redrawn after the scrolling. Compound.show (elementtag, d)
Make sure the element is visible within the rectangle of the top-level Element of the Compound by calling Element.show (Compound.contents, element).