forsyth20121205-174063a80cc13 years agoHistory
262 lines · 6.0 KB · Text
RawDownload
.TH PREFAB-COMPOUND 2.SH NAMEprefab: Compound \- windows for ITV toolkit.SH SYNOPSIS.EXinclude "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);};.EE.SH DESCRIPTION.B Compoundis the data type defining boxes drawn on the screen.Each appears in a new window,.BR Compound.image ,and holds a (possibly.BR nil )title.B Elementand contents.BR Element .It occupies the space onthe screen defined by.BR Compound.r .Allocating a.B Compoundcreatesa window but does not draw it;after the.B Compoundis built,.B Compound.drawmust be called to make it visible.Compounds have a border around them, drawn in.B Style.edgecolorand contain from top to bottom the title (if any),a horizontal line (if there is a title), and the contents..PP.TP.B "Compound.iconbox(\f2env\fP, \f2p\fP, \f2title\fP, \f2icon\fP, \f2mask\fP)Creates a.B Compoundwhose contents are made by calling.B Element.icon(see.IR prefab-element (2))using the.I iconand.IR mask .The.BR Compound 'supper left corner is at.IR p ;its size is determined by the size of the.I iconand.IR mask ..TP.B "Compound.textbox(\f2env\fP, \f2r\fP, \f2title\fP, \f2text\fP)Creates a.B Compoundwhose contents are made by calling.B Element.textusing the supplied.IR text .As with.BR Element.text ,the resulting contents.B Elementwill be actually a list of text.B Elementsif the text occupies multiple lines on the screen.The rectangle behaves as in.BR Element.text ..TP.B "Compound.layoutbox(\f2env\fP, \f2r\fP, \f2title\fP, \f2layoutlist\fP)Like.BR Compound.textbox ,but based on.B Element.layoutrather than.BR Element.text ..TP.B "Compound.box(\f2env\fP, \f2p\fP, \f2title\fP, \f2element\fP)Creates a.B Compoundwhose contents are made from an existing.BR Element .To build complex structures, use the.BR Element -buildingfunctions,size the.B Elementappropriately,and use.BR Compound.box .The result is positioned with its upper left corner at.IR p ,and with size determined by that of the.BR Element ..PPHowever a.B Compoundis built,its size computation makes allowance for the border and title.Moreover, if the requested size and placement makes partappear offscreen, the result may be moved to display it better..TP.B Compound.draw()This functionuses the description of the title and contents to paint theon-screen image.It takes no arguments;all the information is included in the description..TP.BI Compound.redraw( r )Like.BR Compound.draw ,but restricts the drawing to the specified.B Rect.IR r ..PP.TP.ft 5Compound.select( \f2element\fP, \f2index\fP, \f2c\fP ): (int, int, Element).ft 1The channel.I cis a.B chanof.B intconnected to an IR remote control interface, typically acquired through the program's.B Context(see.IR draw-context (2)).The.I elementis contained in the.BR Compound ,and may be at any level of its structure.Itis most usefully a list,but may be a singleton, in which case it behaves like a list of one element.The arrow keys on the remote control scroll through the members of the list,using the.B Style.highlightcolorassociated with each member element to indicate selection.A.B Selectkey on the remote control triggers.B selectto return a tuple.BI ( key ,.IB index ,.IB elem )\f1;.I keyis the key code of the action (here.BR Select ),.I indexis the number of the element in the list (ignoring separators),and.I elemis the list member highlighted when the key was hit.Any other key returns the same tuple with.I index\-1 and the value of the key.The.I elemreturned is always the most recently highlighted,even if the result was not a selection.When.B selectreturns, it always restores the default appearance of the list..PP.TP.ft 5Compound.tagselect( \f2element\fP, \f2index\fP, \f2c\fP): (int, int, Element).ft 1Like.BR Compound.select ,but rather than selecting among all the elementsof a list, it selects among only those elements withdefinedtags in thestructure contained within the specified.IR element ..TP\f5Compound.highlight(\fP\f2element\fP\f5,\  \fP\f2on\fP\f5)\fPSet the highlighting to be ``on'' or ``off''for the.I elementwithin the compound..TP\f5Compound.scroll(\fP\f2element\fP\f5,\  \fP\f2d\fP\f5)\fPLike.BR Element.scroll :scroll the.I elementwithin the compound.The updated image is redrawn after the scrolling..TP.ft 5\f5Compound.show(\fP\f2element\fP\f5,\  \fP\f2d\fP\f5)\fP.ft 1Like.BR Element.show :make sure the.I elementis visiblewithin the rectangle of the top-level.B Elementof the.BR Compound ,that is, in effect call.ft 5Element.show(Compound.contents, \f2element\fP);.ft 1.SH SOURCE.B /libinterp/prefab.c.br.B /libprefab/*.c.SH SEE ALSO.IR prefab-element (2),.IR prefab-environ (2),.IR prefab-style (2)