factor/library/ui/ui.factor

58 lines
1.3 KiB
Factor
Raw Normal View History

2005-05-03 19:10:20 -04:00
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: gadgets
USING: gadgets-layouts gadgets-listener generic help io kernel
listener lists math namespaces prettyprint sdl sequences shells
styles threads words ;
2005-08-26 00:55:56 -04:00
2005-09-01 01:20:43 -04:00
: world-theme
{{
[[ background @{ 255 255 255 }@ ]]
[[ rollover-bg @{ 236 230 232 }@ ]]
[[ bevel-1 { 160 160 160 }@ ]]
[[ bevel-2 @{ 232 232 232 }@ ]]
[[ foreground @{ 0 0 0 }@ ]]
2005-09-01 01:20:43 -04:00
[[ reverse-video f ]]
[[ font "Monospaced" ]]
[[ font-size 12 ]]
[[ font-style plain ]]
}} ;
: init-world
ttf-init
global [
<world> world set
@{ 600 700 0 }@ world get set-gadget-dim
2005-09-01 01:20:43 -04:00
world-theme world get set-gadget-paint
2005-08-26 00:55:56 -04:00
<plain-gadget> add-layer
2005-08-26 00:55:56 -04:00
listener-application
] bind ;
SYMBOL: first-time
global [ first-time on ] bind
2005-05-03 19:10:20 -04:00
: ?init-world
first-time get [ init-world first-time off ] when ;
2005-08-26 00:55:56 -04:00
: ui-title
2005-09-24 15:21:17 -04:00
[ "Factor " % version % " - " % image % ] "" make ;
2005-08-26 00:55:56 -04:00
2005-09-03 22:28:46 -04:00
IN: shells
2005-05-03 19:10:20 -04:00
: ui ( -- )
#! Start the Factor graphics subsystem with the given screen
#! dimensions.
2005-07-13 18:08:54 -04:00
ttf-init
?init-world
world get rect-dim first2 0 SDL_RESIZABLE [
[
2005-08-26 00:55:56 -04:00
ui-title dup SDL_WM_SetCaption
start-world
run-world
2005-05-03 19:10:20 -04:00
] with-screen
] with-scope ;