]> gitweb.factorcode.org Git - factor.git/blob - libs/x11/draw-string.factor
more sql changes
[factor.git] / libs / x11 / draw-string.factor
1 USING: kernel math arrays namespaces sequences x11 x rectangle ;
2
3 IN: x
4
5 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6
7 : text-width ( string -- width ) font get swap dup length XTextWidth ;
8
9 : string-size ( string -- size ) text-width font get font-height 2array ;
10
11 : string-rect ( string -- rect ) string-size { 0 0 } swap <rect> ;
12
13 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14
15 : base-point ( rect -- )
16   top-left font get XFontStruct-ascent 0 swap 2array v+ ;
17
18 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19
20 : draw-string-top-left ( point string -- )
21   dup string-rect swapd move-top-left base-point swap draw-string ;
22
23 : draw-string-top-right ( point string -- )
24   dup string-rect swapd move-top-right base-point swap draw-string ;
25
26 : draw-string-bottom-left ( point string -- )
27   dup string-rect swapd move-bottom-left base-point swap draw-string ;
28
29 : draw-string-bottom-right ( point string -- )
30   dup string-rect swapd move-bottom-right base-point swap draw-string ;
31
32 : draw-string-middle-center ( point string -- )
33   dup string-rect swapd move-middle-center base-point swap draw-string ;
34
35 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36
37 : draw-string-centered ( string -- )
38 window-size { 1/2 1/2 } v* swap draw-string-middle-center ;