7 | wid gc font fcolor fdraw ablock visible bgcolor title parent dead |
10 ^self error: 'X11BaseWindow instances must be created with special methods'.
16 self in: obj at: 1 put: wid.
17 self in: obj var: #dead put: false.
22 ^new: aParent at: xy size: sz bgColor: clr [
24 wid := X11Singleton XCreateSimpleWindow: (aParent ifNotNil: [ aParent wid ])
26 width: sz x height: sz y
28 obj := self newWithId: wid.
29 obj; bgColor: clr; backgroundColor: clr.
30 self in: obj var: #bgcolor put: clr.
31 self in: obj var: #parent put: aParent.
32 aParent ifNotNil: [ aParent isGroup ifTrue: [ aParent add: obj ]].
51 fcolor := X11FontColor new: 1.0 g: 1.0 b: 1.0.
52 fdraw := X11FontDraw new: wid.
53 X11Singleton XSelectInput: wid interestFlag: 1.
56 self addToBeFinalized.
67 fdraw ifNotNil: [ fdraw free ].
68 fcolor ifNotNil: [ fcolor free ].
69 font ifNotNil: [ font free ].
70 bgcolor ifNotNil: [ bgcolor free ].
71 gc ifNotNil: [ gc free ].
72 title := parent := nil.
74 X11Singleton XDestroyWindow: wid.
80 fdraw := fcolor := font := gc := wid := bgcolor := title := parent := nil.
88 dead ifFalse: [ self deinit ].
104 dead ifTrue: [ ^self ].
105 title := aTitle ifNil: [ '' ].
106 X11Singleton XSetTitle: wid title: title.
115 aVis ifTrue: [ ^self show ].
121 dead ifFalse: [ X11Singleton XMapWindow: wid ].
127 dead ifFalse: [ X11Singleton XUnmapWindow: wid ].
132 ^dead not and: [ visible ].
136 backgroundColor: clr [
137 "window background; not GC"
138 dead ifTrue: [ ^self ].
140 X11Singleton XSetWindowBackground: wid color: clr color
144 dead ifTrue: [ ^self ].
149 dead ifTrue: [ ^self ].
153 fgColor: r g: g b: b [
154 self fgColor: (X11Color new: r g: g b: b)
157 bgColor: r g: g b: b [
158 self bgColor: (X11Color new: r g: g b: b)
163 aWid ifNil: [ ^false ].
164 (aWid isKindOf: X11BaseWindow) ifTrue: [ aWid := aWid wid ].
165 ^(X11Singleton sameWids: wid and: aWid)
172 passEvent: aWid event: evt [
173 "return true if event handler found"
174 (X11Singleton sameWids: wid and: aWid) ifTrue: [
175 (evt at: 1) == #KeyPress ifTrue: [ ^self keyPressEvent: evt ].
184 (mt := self class findMethodInAll: ('onX11' + (evt at: 1) asString + ':') asSymbol ifAbsent: [nil]) ifNotNil: [
185 "'perform: ' print. mt name printNl."
186 ^self perform: mt withArgument: evt
191 self isActive ifTrue: [
192 self focused ifFalse: [ X11Singleton XSetInputFocus: wid ].
197 dead ifTrue: [ ^false ].
198 visible ifFalse: [ ^false ].
199 ^self sameWid: (X11Singleton XGetInputFocus)
215 ablock ifNotNil: [ ablock value: self ]
220 dead ifTrue: [ ^self ].
221 X11Singleton XMoveWindow: wid x: aPoint x y: aPoint y
225 dead ifTrue: [ ^self ].
226 X11Singleton XResizeWindow: wid width: aPoint x height: aPoint y
229 move: aPoint resize: aSize [
230 dead ifTrue: [ ^self ].
231 X11Singleton XMoveResizeWindow: wid x: aPoint x y: aPoint y width: aSize x height: aSize y
236 dead ifTrue: [ ^0 @ 0 ].
237 x := X11Singleton XGetGeometry: wid item: 1.
238 y := X11Singleton XGetGeometry: wid item: 2.
244 dead ifTrue: [ ^0 @ 0 ].
245 w := X11Singleton XGetGeometry: wid item: 3.
246 h := X11Singleton XGetGeometry: wid item: 4.
252 dead ifTrue: [ ^0 @ 0 ].
253 w := X11Singleton XGetGeometry: wid item: 3.
254 h := X11Singleton XGetGeometry: wid item: 4.
260 ^X11Singleton XGetGeometry: wid item: 3.
265 ^X11Singleton XGetGeometry: wid item: 4.
269 ^Rectangle newFrom: 0 @ 0 size: self dimensions
273 ^Rectangle newFrom: 0 @ 0 size: self maxXY
278 dead ifTrue: [ ^self ].
279 X11Singleton XClearWindow: wid
283 dead ifTrue: [ ^self ].
284 X11Singleton XDrawPoint: wid gc: gc gc x: p0 x y: p0 y.
287 drawLine: p0 to: p1 [
288 dead ifTrue: [ ^self ].
289 X11Singleton XDrawLine: wid gc: gc gc x0: p0 x y0: p0 y x1: p1 x y1: p1 y.
293 dead ifTrue: [ ^self ].
294 X11Singleton XDrawRect: wid gc: gc gc x: aRect x y: aRect y width: aRect width height: aRect height.
298 dead ifTrue: [ ^self ].
299 X11Singleton XFillRect: wid gc: gc gc x: aRect x y: aRect y width: aRect width height: aRect height.
308 dead ifTrue: [ ^self ].
309 font := X11Font new: aName
313 dead ifTrue: [ ^self ].
317 fontColor: r g: g b: b [
318 dead ifTrue: [ ^self ].
319 fcolor := X11FontColor new: r g: g b: b.
322 putTextAt: p0 text: text [
323 dead ifTrue: [ ^self ].
324 X11Singleton XftFontDraw: fdraw draw
331 drawTextAt: p0 text: text [
333 dead ifTrue: [ ^self ].
334 gx := font textX: text. gy := font textY: text.
335 X11Singleton XftFontDraw: fdraw draw
338 x: p0 x + gx y: p0 y + gy
343 "'-' print. self print. ' ' print. dead printNl.
344 dead ifFalse: [ 'died: ' print. (X11Singleton wid2str: wid) printNl ]."
345 dead ifFalse: [ self deinit. dead := true ]
348 childVisibility: aChild vis: aVisFlag [
351 childFocusing: aChild focused: aFFlag [
362 aFull ifTrue: [ self redraw ].
373 onX11MotionNotify: evt [
376 onX11ButtonPress: evt [
379 onX11ButtonRelease: evt [
382 onX11EnterNotify: evt [
385 onX11LeaveNotify: evt [
390 self draw: (evt at: 7) = 0
394 parent ifNil: [ ^self selected: true ].
395 parent childFocusing: self focused: true.
399 parent ifNil: [ ^self selected: false ].
400 parent childFocusing: self focused: false.
403 onX11KeymapNotify: evt [
409 onX11KeyRelease: evt [
412 onX11MapNotify: evt [
415 parent childVisibility: self vis: true.
420 onX11UnmapNotify: evt [
423 parent childVisibility: self vis: true.
428 onX11DestroyNotify: evt [
429 "'dying: ' print. (X11Singleton wid2str: wid) printNl."
433 onX11WMCloseRequest: evt [