1 USING: kernel math arrays namespaces sequences x11 x rectangle ;
5 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7 : text-width ( string -- width ) font get swap dup length XTextWidth ;
9 : string-size ( string -- size ) text-width font get font-height 2array ;
11 : string-rect ( string -- rect ) string-size { 0 0 } swap <rect> ;
13 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 : base-point ( rect -- )
16 top-left font get XFontStruct-ascent 0 swap 2array v+ ;
18 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20 : draw-string-top-left ( point string -- )
21 dup string-rect swapd move-top-left base-point swap draw-string ;
23 : draw-string-top-right ( point string -- )
24 dup string-rect swapd move-top-right base-point swap draw-string ;
26 : draw-string-bottom-left ( point string -- )
27 dup string-rect swapd move-bottom-left base-point swap draw-string ;
29 : draw-string-bottom-right ( point string -- )
30 dup string-rect swapd move-bottom-right base-point swap draw-string ;
32 : draw-string-middle-center ( point string -- )
33 dup string-rect swapd move-middle-center base-point swap draw-string ;
35 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37 : draw-string-centered ( string -- )
38 window-size { 1/2 1/2 } v* swap draw-string-middle-center ;