2005-06-27 03:47:22 -04:00
|
|
|
! Copyright (C) 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2005-03-06 20:03:22 -05:00
|
|
|
IN: gadgets
|
2005-04-19 20:28:01 -04:00
|
|
|
USING: alien hashtables kernel lists namespaces sdl sequences
|
2005-06-27 03:47:22 -04:00
|
|
|
strings styles io ;
|
2005-03-06 20:03:22 -05:00
|
|
|
|
|
|
|
: draw-surface ( x y surface -- )
|
|
|
|
surface get SDL_UnlockSurface
|
|
|
|
[
|
2005-08-24 00:30:07 -04:00
|
|
|
[ sdl-surface-rect ] keep swap surface get 0 0
|
|
|
|
] keep sdl-surface-rect swap rot SDL_UpperBlit drop
|
2005-03-06 20:03:22 -05:00
|
|
|
surface get dup must-lock-surface? [
|
|
|
|
SDL_LockSurface
|
|
|
|
] when drop ;
|
|
|
|
|
2005-03-07 00:39:57 -05:00
|
|
|
: filter-nulls ( str -- str )
|
2005-07-04 17:35:22 -04:00
|
|
|
[ dup 0 = [ drop CHAR: \s ] when ] map ;
|
2005-03-07 00:39:57 -05:00
|
|
|
|
2005-03-06 20:03:22 -05:00
|
|
|
: size-string ( font text -- w h )
|
2005-06-27 03:47:22 -04:00
|
|
|
filter-nulls dup empty? [
|
|
|
|
drop 0 swap TTF_FontHeight
|
2005-03-06 20:03:22 -05:00
|
|
|
] [
|
2005-05-05 03:12:37 -04:00
|
|
|
0 <int> 0 <int> [ TTF_SizeUNICODE drop ] 2keep
|
|
|
|
swap *int swap *int
|
2005-03-06 20:03:22 -05:00
|
|
|
] ifte ;
|
|
|
|
|
2005-07-13 21:03:34 -04:00
|
|
|
: draw-string ( gadget text -- )
|
2005-06-27 03:47:22 -04:00
|
|
|
filter-nulls dup empty? [
|
|
|
|
2drop
|
2005-03-06 20:03:22 -05:00
|
|
|
] [
|
2005-07-13 21:03:34 -04:00
|
|
|
>r [ gadget-font ] keep r> swap
|
2005-07-27 20:13:11 -04:00
|
|
|
fg 3unseq make-color
|
2005-07-17 03:47:14 -04:00
|
|
|
TTF_RenderUNICODE_Blended
|
2005-07-19 17:40:32 -04:00
|
|
|
[ >r origin get 2unseq r> draw-surface ] keep
|
2005-03-06 20:03:22 -05:00
|
|
|
SDL_FreeSurface
|
|
|
|
] ifte ;
|