factor/core/ui/gadgets/controls.factor

36 lines
888 B
Factor
Raw Normal View History

! Copyright (C) 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2006-10-03 18:17:21 -04:00
USING: kernel models ;
IN: gadgets
2006-09-16 17:11:55 -04:00
TUPLE: control self model quot ;
C: control ( model gadget quot -- gadget )
dup dup set-control-self
[ set-control-quot ] keep
[ set-gadget-delegate ] keep
[ set-control-model ] keep ;
2006-11-26 20:36:44 -05:00
: control-value ( control -- value )
control-model model-value ;
: set-control-value ( value control -- )
2006-11-26 21:19:40 -05:00
control-model set-model ;
2006-10-03 18:17:21 -04:00
M: control graft*
2006-10-03 18:17:21 -04:00
control-self dup dup control-model add-connection
model-changed ;
M: control ungraft*
2006-10-03 18:17:21 -04:00
control-self dup control-model remove-connection ;
M: control model-changed
2006-10-03 18:17:21 -04:00
control-self
[ control-value ] keep
[ dup control-quot call ] keep
relayout ;
2006-10-03 18:17:21 -04:00
: delegate>control ( gadget model underlying -- )
[ 2drop ] <control> over set-gadget-delegate
dup set-control-self ;