4 X11Window subclass: MyX11Window [
7 centerText: y text: aText [
9 e := font textExtents: aText.
11 x := (self width - (e at: 1) + (e at: 3)) / 2.
12 self drawTextAt: x @ y text: aText.
18 '***MyX11Window init' printNl.
20 btn := X11Button new: self at: 2 @ 80 text: 'quit'.
21 '***button created' printNl.
22 btn onClick: [:btn | 'quit clicked!' printNl. self close ].
24 btn := X11Button new: self at: (2 + btn width + 4) @ 80 text: 'button 1'.
25 '***button created' printNl.
26 btn onClick: [:btn | 'button clicked!' printNl ].
28 self fontColor: 1.0 g: 1.0 b: 1.0.
29 self onExpose: [:w :full :rc |
31 rc := (w clientSizeRect) growX: 1 y: 1.
33 fgColor: 0.0 g: 0.1 b: 0;
35 fgColor: 1.0 g: 0 b: 0;
36 drawLine: 1 @ 1 to: 80 @ 60;
37 fgColor: 0 g: 1.0 b: 0;
38 drawLine: 1 @ 10 to: 80 @ 60;
39 fgColor: 0 g: 0 b: 1.0;
40 drawLine: 1 @ 20 to: 80 @ 60;
41 fgColor: 0.5 g: 0 b: 0;
42 drawLine: 1 @ 50 to: 80 @ 60;
43 fgColor: 1.0 g: 1.0 b: 0.
44 lineList ifNotNil: [ lineList do: [:i | w drawLine: (i at: 1) to: (i at: 2) ]].
45 w centerText: 5 text: 'Xft works!'.
46 w drawTextAt: 2 @ 2 text: 'drawText'.
49 self onButtonDown: [:w :bt :evt :x :y |
52 bt = 3 ifTrue: [ ox := x. oy := y. lineList := List new. ].
55 lineList << (Array with: ox @ oy with: x @ y).
57 fgColor: 1.0 g: 1.0 b: 0;
58 drawLine: ox @ oy to: x @ y.
61 ox := x. oy := y. lineList := List new.
71 "X11Singleton dumpEvents: true."
72 X11Singleton initialize.
73 w := MyX11Window new: nil at: 0 @ 0 size: 200 @ 110 title: 'LST X11 test'.
75 X11Singleton eventLoop.
77 X11Singleton deinitialize.