This structure provides the gate of selectors.
List of Import References :
See BOOL
See Char
See Com
See DENOTATION
See Nat
See Option
See Pair
See Real
See Seq
See Set
See String
See Void
See WinInternal
See WinRegulator
See WinTclTk
SIGNATURE WinSelector[data]
$Date: 2010-09-30 18:24:17 +0200 (Do, 30. Sep 2010) $ ($Revision: 616 $)
SORT data IMPORT Com[selector] ONLY com Com[void] ONLY com Com[data] ONLY com Void ONLY void IMPORT WinInternal ONLY config:SORT WinRegulator ONLY regulator:SORT
A selector is a gate which represents a data value. Agents may set or get the value or may synchronize with value changes.
SORT selector FUN selector : data -> com[selector] FUN set : selector ** data -> com[void] FUN get : selector -> com[data] FUN await : selector ** (data -> bool) -> com[data]
An agent may set or get the selectors values with the commands set
and get
. An agent may synchronize with value changes via the
command await(Sel, Pred)
: this command is enabled whenever the given
predicate on the value of the selector is true. It yields the
current value of the selector.
A selector may be attached to a view or item such that each time
a given predicate on the selectors value becomes true, one configuration
is send to the view or item (the first argument of sync
), and each time
it becomes false another configuration is send.
FUN sync : selector ** (data -> bool) ** config ** config -> config
A specialzed version of sync
,
enable(Sel, Pred)
, enables the given view or item whenever the given
predicate is true and disables it otherwise. It is simply defined as
sync(Sel, Pred, state(normal), state(disabled))
.
FUN enable : selector ** (data -> bool) -> config
Views and menu-items such as check-buttons and radio-buttons support a special selection mechanism, which is controlled by the configuration below:
FUN select : selector ** (data -> bool) ** (data -> data) ** (data -> data) -> config
The configured view or menu-item will select and deselect itself (and display the selection state) according to whether the given predicate is true on the selectors value. Moreover, if the view is selected or deselected by the user, the transformer functions are applied to the selectors value (the first one if it is selected, the second one if it is deselected).
A typical use of select
for check-buttons
is with selectors which are instantiated with sets, such as in:
TYPE opt == opt1 opt2 ... checkButton with select(Sel : selector[set[opt, <]], opt1 in _, opt1 incl _, opt1 excl _)
Here, opt1
is automatically added or removed from the selectors
set value according to the selection state of the check-button.
To implement a radio-button like behaviour, one would write:
TYPE mode == mode1 mode2 ... radioButton with select(Sel : selector[mode], mode1?, \\ _ . mode1, \\ X. X)
A shortcut is provided which supports this usage:
FUN select : selector ** (data -> bool) ** data -> config
select(Sel, Pred, Val)
is defined as
select(Sel, Pred, \\ _ . Val, \\ X. X)
next node: WinCanvasEditor,
prev node: WinEmitter,
up to node: Subsystem Opal Windows