factor/library/ui/gadgets/controls.factor

32 lines
812 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
IN: gadgets
USING: kernel models ;
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-10-03 18:17:21 -04:00
: control-value ( control -- value ) control-model model-value ;
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 ;