2006-06-27 03:26:52 -04:00
|
|
|
! Copyright (C) 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
IN: gadgets-controls
|
|
|
|
USING: gadgets kernel models ;
|
|
|
|
|
2006-07-21 18:07:26 -04:00
|
|
|
TUPLE: control self model quot ;
|
2006-06-27 03:26:52 -04:00
|
|
|
|
|
|
|
C: control ( model gadget quot -- gadget )
|
2006-07-21 18:07:26 -04:00
|
|
|
dup dup set-control-self
|
2006-06-27 03:26:52 -04:00
|
|
|
[ set-control-quot ] keep
|
|
|
|
[ set-gadget-delegate ] keep
|
2006-07-21 18:07:26 -04:00
|
|
|
[ set-control-model ] keep ;
|
2006-06-27 03:26:52 -04:00
|
|
|
|
2006-06-29 04:07:10 -04:00
|
|
|
M: control graft*
|
2006-07-21 18:07:26 -04:00
|
|
|
dup control-self over control-model add-connection
|
|
|
|
model-changed ;
|
2006-06-27 03:26:52 -04:00
|
|
|
|
2006-06-29 04:07:10 -04:00
|
|
|
M: control ungraft*
|
2006-07-21 18:07:26 -04:00
|
|
|
dup control-self swap control-model remove-connection ;
|
2006-06-27 03:26:52 -04:00
|
|
|
|
|
|
|
M: control model-changed ( gadget -- )
|
|
|
|
[ control-model model-value ] keep
|
2006-07-21 18:07:26 -04:00
|
|
|
[ dup control-self swap control-quot call ] keep
|
|
|
|
control-self relayout ;
|
|
|
|
|
|
|
|
: delegate>control ( gadget model -- )
|
|
|
|
<gadget> [ drop ] <control> swap set-gadget-delegate ;
|