access font via message send to gc
authorStefan Vogel <sv@exept.de>
Thu, 20 Mar 2014 10:37:30 +0100
changeset 14148 5e6a841c980f
parent 14147 f42a7d6d6b52
child 14149 e248bf1390a0
access font via message send to gc
EventMonitor.st
--- a/EventMonitor.st	Wed Mar 19 15:49:33 2014 +0100
+++ b/EventMonitor.st	Thu Mar 20 10:37:30 2014 +0100
@@ -47,8 +47,8 @@
     like xev - show events.
 
     You can use this to check your keyboard mappings, for example.
-    start with: 
-        EventMonitor open
+    start with:
+	EventMonitor open
     and watch the output on the xterm/console.
 "
 ! !
@@ -80,28 +80,28 @@
 
     <resource: #canvas>
 
-    ^ 
+    ^
      #(FullSpec
-        name: windowSpec
-        window: 
+	name: windowSpec
+	window:
        (WindowSpec
-          label: 'EventMonitor'
-          name: 'EventMonitor'
-          min: (Point 100 100)
-          bounds: (Rectangle 0 0 300 300)
-          menu: mainMenu
-        )
-        component: 
+	  label: 'EventMonitor'
+	  name: 'EventMonitor'
+	  min: (Point 100 100)
+	  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
-            )
-           )
-         
-        )
+	  collection: (
+	   (NonScrollableArbitraryComponentSpec
+	      name: 'eventMonitorView'
+	      layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+	      component: EventMonitorView
+	    )
+	   )
+
+	)
       )
 ! !
 
@@ -121,113 +121,113 @@
 
     <resource: #menu>
 
-    ^ 
+    ^
      #(Menu
-        (
-         (MenuItem
-            label: 'File'
-            translateLabel: true
-            submenu: 
-           (Menu
-              (
-               (MenuItem
-                  label: 'Open Modal Box'
-                  itemValue: openModalBox
-                  translateLabel: true
-                )
-               (MenuItem
-                  label: 'Exit'
-                  itemValue: closeRequest
-                  translateLabel: true
-                )
-               )
-              nil
-              nil
-            )
-          )
-         (MenuItem
-            label: 'Filter'
-            translateLabel: true
-            submenu: 
-           (Menu
-              (
-               (MenuItem
-                  label: 'Show ButtonMotion Events'
-                  itemValue: showButtonMotion:
-                  translateLabel: true
-                  indication: showButtonMotion
-                )
-               (MenuItem
-                  label: 'Show Focus Events'
-                  itemValue: showFocusEvents:
-                  translateLabel: true
-                  indication: showFocusEvents
-                )
-               )
-              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
-                )
-               (MenuItem
-                  label: '-'
-                )
-               (MenuItem
-                  label: 'Show Timestamp'
-                  itemValue: showTimestamp:
-                  translateLabel: true
-                  indication: showTimestamp
-                )
-               )
-              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
+	(
+	 (MenuItem
+	    label: 'File'
+	    translateLabel: true
+	    submenu:
+	   (Menu
+	      (
+	       (MenuItem
+		  label: 'Open Modal Box'
+		  itemValue: openModalBox
+		  translateLabel: true
+		)
+	       (MenuItem
+		  label: 'Exit'
+		  itemValue: closeRequest
+		  translateLabel: true
+		)
+	       )
+	      nil
+	      nil
+	    )
+	  )
+	 (MenuItem
+	    label: 'Filter'
+	    translateLabel: true
+	    submenu:
+	   (Menu
+	      (
+	       (MenuItem
+		  label: 'Show ButtonMotion Events'
+		  itemValue: showButtonMotion:
+		  translateLabel: true
+		  indication: showButtonMotion
+		)
+	       (MenuItem
+		  label: 'Show Focus Events'
+		  itemValue: showFocusEvents:
+		  translateLabel: true
+		  indication: showFocusEvents
+		)
+	       )
+	      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
+		)
+	       (MenuItem
+		  label: '-'
+		)
+	       (MenuItem
+		  label: 'Show Timestamp'
+		  itemValue: showTimestamp:
+		  translateLabel: true
+		  indication: showTimestamp
+		)
+	       )
+	      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
       )
 ! !
 
@@ -239,8 +239,8 @@
 
 outputSelector
     outputSelector isNil ifTrue:[
-        outputSelector := #transcript asValue.
-        outputSelector onChangeEvaluate:[ self outputSelectorChanged ].
+	outputSelector := #transcript asValue.
+	outputSelector onChangeEvaluate:[ self outputSelectorChanged ].
     ].
     ^ outputSelector
 !
@@ -323,8 +323,8 @@
 "
     like xev - show events.
     You can use this to check your keyboard mappings, for example.
-    start with: 
-        EventMonitorView open
+    start with:
+	EventMonitorView open
     and watch the output on xterm.
 "
 ! !
@@ -344,10 +344,10 @@
 
     labelHolder value:nil.
     outputStream == Stdout ifTrue:[
-        labelHolder value: 'See event trace\on the standard output' withCRs.
+	labelHolder value: 'See event trace\on the standard output' withCRs.
     ].
     outputStream == Transcript ifTrue:[
-        labelHolder value: 'See event trace\on the Transcript' withCRs.
+	labelHolder value: 'See event trace\on the Transcript' withCRs.
     ].
     self invalidate.
 
@@ -393,22 +393,23 @@
 !EventMonitor::EventMonitorView methodsFor:'drawing'!
 
 redraw
-    |y p lines|
+    |y p lines font|
 
     self clear.
     lines := labelHolder value asCollectionOfLines.
+    font := gc font.
 
     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).
+	p := (self center x - ((font widthOf:eachLine) // 2)) @ y.
+	self displayString:eachLine value x:(p x) y:(p y).
+	y := y + (font heightOf:eachLine).
     ]
 !
 
 showEventTime
     self showTimestamp ifTrue:[
-        Transcript show:(Timestamp now); show:' '.
+	Transcript show:(Timestamp now); show:' '.
     ]
 
     "Created: / 04-10-2006 / 13:08:27 / cg"
@@ -507,7 +508,7 @@
 
 dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate
     event isButtonMotionEvent ifTrue:[
-        self showButtonMotion ifFalse:[^ self].
+	self showButtonMotion ifFalse:[^ self].
     ].
 
 "/    Timestamp now printOn:outputStream.
@@ -573,14 +574,14 @@
     s printOn:outputStream.
 
     (key isMemberOf:Character) ifTrue:[
-        s := ' character key:' , key storeString
-             , ' (' , key asciiValue printString , ')'.
+	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
-        ].
+	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.
@@ -588,9 +589,9 @@
     s printOn:outputStream.
 
     key isCharacter ifTrue:[
-        outputStream nextPutAll:' '''.
-        key asString printOn:outputStream.
-        outputStream nextPutAll:''''.
+	outputStream nextPutAll:' '''.
+	key asString printOn:outputStream.
+	outputStream nextPutAll:''''.
     ].
     outputStream cr.
 
@@ -608,20 +609,20 @@
     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
+	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
-        ]
+	' 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
@@ -653,7 +654,7 @@
     "Modified: / 04-10-2006 / 13:09:34 / cg"
 !
 
-pointerLeave:state 
+pointerLeave:state
     self showEventTime.
 
     outputStream nextPutAll:'pointerLeave state:'.
@@ -722,5 +723,5 @@
 !EventMonitor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/EventMonitor.st,v 1.30 2009-03-20 17:44:15 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/EventMonitor.st,v 1.31 2014-03-20 09:37:30 stefan Exp $'
 ! !