factor/library/ui/tools/help.factor

47 lines
1.3 KiB
Factor
Raw Normal View History

! Copyright (C) 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: gadgets-help
2006-06-29 03:54:30 -04:00
USING: gadgets gadgets-buttons gadgets-frames gadgets-panes
2006-07-01 16:07:10 -04:00
gadgets-presentations gadgets-scrolling help kernel models
namespaces sequences ;
2006-07-01 16:07:10 -04:00
TUPLE: help-gadget history ;
2006-06-29 03:54:30 -04:00
: find-help-gadget [ help-gadget? ] find-parent ;
: show-help ( link help -- )
2006-07-01 16:07:10 -04:00
dup help-gadget-history add-history
[ help-gadget-history set-model ] keep
2006-06-29 03:54:30 -04:00
dup update-title ;
: go-home ( help -- ) "handbook" swap show-help ;
2006-07-01 16:07:10 -04:00
: history-action find-help-gadget help-gadget-history ;
2006-06-29 03:54:30 -04:00
: <help-toolbar> ( -- gadget )
[
2006-07-01 16:07:10 -04:00
"Back" [ history-action go-back ] <bevel-button> ,
"Forward" [ history-action go-forward ] <bevel-button> ,
"Home" [ history-action go-home ] <bevel-button> ,
2006-06-29 03:54:30 -04:00
] make-toolbar ;
: <help-pane> ( -- gadget )
2006-07-01 16:07:10 -04:00
gadget get help-gadget-history [ help ] <pane-control> ;
2006-06-29 03:54:30 -04:00
C: help-gadget ( -- gadget )
2006-07-01 16:07:10 -04:00
<history> over set-help-gadget-history {
2006-06-29 03:54:30 -04:00
{ [ <help-toolbar> ] f f @top }
{ [ <help-pane> <scroller> ] f f @center }
} make-frame* ;
M: help-gadget gadget-title
2006-07-01 16:07:10 -04:00
"Help - " swap help-gadget-history model-value
2006-06-29 03:54:30 -04:00
article-title append ;
: help-tool
[ help-gadget? ]
[ <help-gadget> ]
[ show-help ] ;
M: link show ( link -- ) help-tool call-tool ;