6 X11BaseWindow subclass: X11Button [
7 | bOnClick text hovered wasPress |
9 ^new: parent at: xy size: sz text: aText [
11 wid := parent ifNotNil: [ parent wid ].
12 wid := X11Singleton XCreateSimpleWindow: wid
14 width: sz x height: sz y
15 bgcolor: X11Singleton blackPixel.
16 obj := self newWithId: wid.
17 self in: obj var: #text put: aText.
18 parent ifNotNil: [ parent add: obj ].
19 obj fontColor: 1.0 g: 1.0 b: 1.0.
23 ^new: parent at: xy text: aText [
25 gw := self textWidth: aText font: nil.
26 gh := self textHeight: aText font: nil.
27 ^self new: parent at: xy size: (gw + 12) @ (gh + 8) text: aText.
40 self fgColor: 0.0 g: 0.0 b: 0.7.
42 self fgColor: 0.0 g: 0.0 b: 0.9.
44 self fillRect: -1 @ -1 to: (self dimensions moveX: 1 y: 1).
46 wasPress ifNotNil: [ tpt := tpt moveX: 1 y: 1 ].
47 self putText: tpt text: text.
54 onX11EnterNotify: evt [
59 onX11LeaveNotify: evt [
60 hovered := wasPress := nil.
64 onX11ButtonPress: evt [
65 (evt at: 8) = 1 ifTrue: [ wasPress := true. self draw. ].
68 onX11ButtonRelease: evt [
69 ((wasPress notNil) and: [ (evt at: 8) = 1 ]) ifTrue: [
70 wasPress := nil. self draw.
71 bOnClick ifNotNil: [ bOnClick value: self ]