2005-06-27 16:50:21 -04:00
|
|
|
! Copyright (C) 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2005-08-31 21:06:13 -04:00
|
|
|
IN: gadgets-presentations
|
2005-12-16 22:28:29 -05:00
|
|
|
USING: arrays gadgets gadgets-borders gadgets-labels
|
|
|
|
gadgets-layouts gadgets-outliner gadgets-panes hashtables io
|
|
|
|
kernel sequences strings styles ;
|
2005-09-24 23:21:09 -04:00
|
|
|
|
2005-10-28 21:13:41 -04:00
|
|
|
: init-commands ( style gadget -- gadget )
|
2005-11-29 23:49:59 -05:00
|
|
|
presented rot hash [ <command-button> ] when* ;
|
2005-10-28 21:13:41 -04:00
|
|
|
|
|
|
|
: style-font ( style -- font )
|
2005-11-29 23:49:59 -05:00
|
|
|
[ font swap hash [ "Monospaced" ] unless* ] keep
|
|
|
|
[ font-style swap hash [ plain ] unless* ] keep
|
|
|
|
font-size swap hash [ 12 ] unless* 3array ;
|
2005-06-27 16:50:21 -04:00
|
|
|
|
|
|
|
: <styled-label> ( style text -- label )
|
2005-11-29 23:49:59 -05:00
|
|
|
<label> foreground pick hash [ over set-label-color ] when*
|
2005-10-28 21:13:41 -04:00
|
|
|
swap style-font over set-label-font ;
|
2005-06-29 00:33:07 -04:00
|
|
|
|
2005-07-13 22:51:43 -04:00
|
|
|
: <presentation> ( style text -- presentation )
|
2005-11-29 23:49:59 -05:00
|
|
|
gadget pick hash
|
2005-10-28 21:13:41 -04:00
|
|
|
[ ] [ >r dup dup r> <styled-label> init-commands ] ?if
|
2005-11-29 23:49:59 -05:00
|
|
|
outline rot hash [ <outliner> ] when* ;
|
2005-07-13 18:08:54 -04:00
|
|
|
|
2005-12-16 21:12:35 -05:00
|
|
|
UNION: gadget-stream pack paragraph ;
|
|
|
|
|
|
|
|
M: gadget-stream stream-write ( string stream -- )
|
|
|
|
over empty? [ 2drop ] [ >r <label> r> add-gadget ] if ;
|
|
|
|
|
|
|
|
M: gadget-stream stream-write1 ( char stream -- )
|
|
|
|
>r ch>string r> stream-write ;
|
|
|
|
|
|
|
|
M: gadget-stream stream-format ( string style stream -- )
|
|
|
|
pick empty? pick hash-empty? and [
|
|
|
|
3drop
|
|
|
|
] [
|
|
|
|
>r swap <presentation> r> add-gadget
|
|
|
|
] if ;
|
|
|
|
|
|
|
|
M: gadget-stream stream-break ( stream -- )
|
|
|
|
<break> swap add-gadget ;
|
|
|
|
|
|
|
|
M: gadget-stream stream-close ( stream -- ) drop ;
|
|
|
|
|
2005-12-16 22:24:39 -05:00
|
|
|
: paragraph-style ( pane style -- pane )
|
|
|
|
border-width over hash [ >r <border> r> ] when
|
|
|
|
border-color swap hash
|
|
|
|
[ <solid> over set-gadget-boundary ] when* ;
|
|
|
|
|
|
|
|
M: pane with-nested-stream ( quot style stream -- )
|
|
|
|
>r >r make-pane r> paragraph-style
|
|
|
|
r> pane-current add-gadget ;
|