"
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libtool' }"
ApplicationModel subclass:#EventMonitor
instanceVariableNames:'outputSelector'
classVariableNames:''
poolDictionaries:''
category:'Monitors-ST/X'
!
View subclass:#EventMonitorView
instanceVariableNames:'outputStream labelHolder showButtonMotion'
classVariableNames:''
poolDictionaries:''
privateIn:EventMonitor
!
!EventMonitor class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
like xev - show events.
You can use this to check your keyboard mappings, for example.
start with:
EventMonitor open
and watch the output on the xterm/console.
"
! !
!EventMonitor class methodsFor:'defaults'!
defaultExtent
^ 200 @ 200
!
defaultLabel
^ 'Event Monitor'
! !
!EventMonitor class methodsFor:'interface specs'!
windowSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:EventMonitor andSelector:#windowSpec
EventMonitor new openInterface:#windowSpec
EventMonitor open
"
<resource: #canvas>
^
#(FullSpec
name: windowSpec
window:
(WindowSpec
label: 'EventMonitor'
name: 'EventMonitor'
min: (Point 10 10)
max: (Point 1024 768)
bounds: (Rectangle 0 0 300 300)
menu: mainMenu
)
component:
(SpecCollection
collection: (
(NonScrollableArbitraryComponentSpec
name: 'eventMonitorView'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
component: EventMonitorView
)
)
)
)
! !
!EventMonitor class methodsFor:'menu specs'!
mainMenu
"This resource specification was automatically generated
by the MenuEditor of ST/X."
"Do not manually edit this!! If it is corrupted,
the MenuEditor may not be able to read the specification."
"
MenuEditor new openOnClass:EventMonitor andSelector:#mainMenu
(Menu new fromLiteralArrayEncoding:(EventMonitor mainMenu)) startUp
"
<resource: #menu>
^
#(Menu
(
(MenuItem
label: 'File'
translateLabel: true
submenu:
(Menu
(
(MenuItem
label: 'Exit'
itemValue: closeRequest
translateLabel: true
)
)
nil
nil
)
)
(MenuItem
label: 'Filter'
translateLabel: true
submenu:
(Menu
(
(MenuItem
label: 'Show ButtonMotion'
itemValue: showButtonMotion:
translateLabel: true
indication: showButtonMotion
)
)
nil
nil
)
)
(MenuItem
label: 'Output'
translateLabel: true
submenu:
(Menu
(
(MenuItem
label: 'Stdout'
translateLabel: true
choice: outputSelector
choiceValue: stdout
)
(MenuItem
label: 'Transcript'
translateLabel: true
choice: outputSelector
choiceValue: transcript
)
)
nil
nil
)
)
(MenuItem
label: 'Help'
translateLabel: true
startGroup: right
submenu:
(Menu
(
(MenuItem
label: 'Documentation'
itemValue: openDocumentation
translateLabel: true
)
(MenuItem
label: '-'
)
(MenuItem
label: 'About this Application'
itemValue: openAboutThisApplication
translateLabel: true
)
)
nil
nil
)
)
)
nil
nil
)
! !
!EventMonitor methodsFor:'aspects'!
eventMonitorView
^ (self builder componentAt:#eventMonitorView)
!
outputSelector
outputSelector isNil ifTrue:[
outputSelector := #stdout asValue.
outputSelector onChangeEvaluate:[ self outputSelectorChanged ].
].
^ outputSelector
!
outputSelectorChanged
|stream|
stream := self outputSelector value == #transcript ifTrue:[Transcript] ifFalse:[Stdout].
self eventMonitorView outputStream:stream.
!
showButtonMotion
^ self eventMonitorView showButtonMotion
!
showButtonMotion:aBoolean
^ self eventMonitorView showButtonMotion:aBoolean
! !
!EventMonitor methodsFor:'menu actions'!
openAboutThisApplication
"This method was generated by the Browser.
It will be invoked when the menu-item 'help-about' is selected."
"/ could open a customized aboutBox here ...
super openAboutThisApplication
!
openDocumentation
HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#EVENTMONITOR'.
! !
!EventMonitor::EventMonitorView class methodsFor:'defaults'!
defaultExtent
^ 200 @ 200
!
defaultLabel
^ 'Event Monitor'
! !
!EventMonitor::EventMonitorView class methodsFor:'documentation'!
documentation
"
like xev - show events.
You can use this to check your keyboard mappings, for example.
start with:
EventMonitorView open
and watch the output on xterm.
"
! !
!EventMonitor::EventMonitorView class methodsFor:'startup'!
isVisualStartable
^ true
"Created: / 10.8.1998 / 16:03:13 / cg"
! !
!EventMonitor::EventMonitorView methodsFor:'accessing'!
outputStream:something
outputStream := something.
labelHolder value:nil.
outputStream == Stdout ifTrue:[
labelHolder value: 'See event trace\on the standard output' withCRs.
].
outputStream == Transcript ifTrue:[
labelHolder value: 'See event trace\on the Transcript' withCRs.
].
self invalidate.
!
showButtonMotion
^ showButtonMotion ? true
!
showButtonMotion:something
showButtonMotion := something.
! !
!EventMonitor::EventMonitorView methodsFor:'drawing'!
redraw
|y p lines|
self clear.
lines := labelHolder value asCollectionOfLines.
y := (self height - ((font heightOf:'A') * lines size)) // 2.
lines do:[:eachLine |
p := (self center x - ((font widthOf:eachLine) // 2)) @ y.
self displayString:eachLine value x:(p x) y:(p y).
y := y + (font heightOf:eachLine).
]
! !
!EventMonitor::EventMonitorView methodsFor:'events'!
buttonMotion:state x:x y:y
self showButtonMotion ifFalse:[^ self].
outputStream nextPutAll:'buttonMotion x:'.
x printOn:outputStream.
outputStream nextPutAll:' y:'.
y printOn:outputStream.
outputStream nextPutAll:' state:'.
state printOn:outputStream.
outputStream cr.
"Modified: 5.4.1997 / 01:23:39 / cg"
!
buttonMultiPress:button x:x y:y
outputStream nextPutAll:'buttonMultiPress x:'.
x printOn:outputStream.
outputStream nextPutAll:' y:'.
y printOn:outputStream.
outputStream nextPutAll:' button:'.
button printOn:outputStream.
outputStream cr.
"Modified: / 5.4.1997 / 01:23:42 / cg"
"Created: / 19.5.1999 / 09:40:40 / cg"
!
buttonPress:button x:x y:y
outputStream nextPutAll:'buttonPress x:'.
x printOn:outputStream.
outputStream nextPutAll:' y:'.
y printOn:outputStream.
outputStream nextPutAll:' button:'.
button printOn:outputStream.
outputStream cr.
outputStream flush.
"Modified: 5.4.1997 / 01:23:42 / cg"
!
buttonRelease:button x:x y:y
outputStream nextPutAll:'buttonRelease x:'.
x printOn:outputStream.
outputStream nextPutAll:' y:'.
y printOn:outputStream.
outputStream nextPutAll:' button:'.
button printOn:outputStream.
outputStream cr.
"Modified: 5.4.1997 / 01:23:43 / cg"
!
configureX:x y:y width:newWidth height:newHeight
outputStream nextPutAll:'configure x:'.
x printOn:outputStream.
outputStream nextPutAll:' y:'.
y printOn:outputStream.
outputStream nextPutAll:' width:'.
newWidth printOn:outputStream.
outputStream nextPutAll:' height:'.
newHeight printOn:outputStream.
outputStream nextPutAll:' button:'.
outputStream cr.
super configureX:x y:y width:newWidth height:newHeight.
self invalidate.
"Modified: 5.4.1997 / 01:23:45 / cg"
!
dropMessage:dropType data:dropData
outputStream nextPutAll:'drop '.
dropType printOn:outputStream.
outputStream nextPutAll:' data:'.
dropData printOn:outputStream.
outputStream cr.
"Modified: 5.4.1997 / 01:23:28 / cg"
!
focusIn
outputStream nextPutLine:'focusIn '.
"Created: 7.3.1996 / 15:06:18 / cg"
"Modified: 5.4.1997 / 01:23:48 / cg"
!
focusOut
outputStream nextPutLine:'focusOut '.
"Created: 7.3.1996 / 15:06:21 / cg"
"Modified: 5.4.1997 / 01:23:49 / cg"
!
hasKeyboardFocus:aBoolen
outputStream nextPutAll:'hasKeyboardFocus:'.
aBoolen printOn:outputStream.
outputStream cr.
"Modified: / 19.5.1999 / 09:42:59 / cg"
!
keyPress:key x:x y:y
|s rawKey untranslatedKey|
s := 'KeyPress x:' , x printString , ' y:' , y printString.
s printOn:outputStream.
(key isMemberOf:Character) ifTrue:[
s := ' character key:' , key storeString
, ' (' , key asciiValue printString , ')'.
] ifFalse:[
s := ' symbolic key:' , key storeString.
untranslatedKey := device keyboardMap keyAtValue:key ifAbsent:key.
untranslatedKey ~~ key ifTrue:[
s := s , ' untranslated key:' , untranslatedKey storeString
].
].
rawKey := (WindowGroup lastEventQuerySignal query) rawKey.
s := s , ' rawKey:' , rawKey storeString.
s printOn:outputStream.
outputStream cr.
!
keyRelease:key x:x y:y
|untranslatedKey|
'KeyRelease x:' printOn:outputStream.
x printOn:outputStream.
' y:' printOn:outputStream.
y printOn:outputStream.
(key isMemberOf:Character) ifTrue:[
key codePoint <= 16rFF ifTrue:[
' character key:' printOn:outputStream.
key storeString printOn:outputStream.
] ifFalse:[
' unicode character utf8:' printOn:outputStream.
key asString utf8Encoded asByteArray hexPrintOn:outputStream.
].
' (' printOn:outputStream. key asciiValue printOn:outputStream. ')' printOn:outputStream
] ifFalse:[
' symbolic key:' print. key storeString printOn:outputStream.
untranslatedKey := device keyboardMap keyAtValue:key ifAbsent:key.
untranslatedKey ~~ key ifTrue:[
' untranslated key:' printOn:outputStream. untranslatedKey storeString printOn:outputStream
]
].
outputStream cr
!
mapped
outputStream nextPutLine:'mapped '.
super mapped.
"Modified: / 6.1.1999 / 11:04:32 / cg"
!
pointerEnter:state x:x y:y
outputStream nextPutAll:'pointerEnter x:'.
x printOn:outputStream.
outputStream nextPutAll:' y:'.
y printOn:outputStream.
outputStream nextPutAll:' state:'.
state printOn:outputStream.
outputStream cr.
"Modified: 5.4.1997 / 01:24:02 / cg"
!
pointerLeave:state
outputStream nextPutAll:'pointerLeave state:'.
state storeString printOn:outputStream.
outputStream cr.
"Modified: 5.4.1997 / 01:24:05 / cg"
!
sizeChanged:how
super sizeChanged:how.
self invalidate
!
unmapped
outputStream nextPutLine:'unmapped '.
super unmapped.
"Modified: / 6.1.1999 / 11:04:22 / cg"
!
visibilityChange:how
outputStream nextPutAll:'visibilityChange:'.
how storeString printOn:outputStream.
outputStream cr.
super visibilityChange:how
"Modified: / 6.1.1999 / 11:04:12 / cg"
! !
!EventMonitor::EventMonitorView methodsFor:'initialization'!
initialize
super initialize.
labelHolder := '' asValue.
self outputStream:Stdout.
! !
!EventMonitor::EventMonitorView methodsFor:'realization'!
initEvents
self enableMotionEvents.
self enableKeyReleaseEvents.
self enableEnterLeaveEvents.
self enableFocusEvents.
self enableEvent:#visibilityChange
"Modified: 7.3.1996 / 15:06:42 / cg"
! !
!EventMonitor class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libtool/EventMonitor.st,v 1.24 2006-02-20 09:51:03 cg Exp $'
! !