/objects/ui2/qUI2Events.self

http://github.com/ticking/self · Unknown · 283 lines · 213 code · 70 blank · 0 comment · 0 complexity · cfdcb9bb044ce3f86cd955fad5c9409e MD5 · raw file

  1. '$Revision: 30.1 $'
  2. '
  3. Copyright 1992-2006 Sun Microsystems, Inc. and Stanford University.
  4. See the LICENSE file for license information.
  5. '
  6. '-- Module body'
  7. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'modules' -> () From: ( | {
  8. 'ModuleInfo: Module: qUI2Events InitialContents: FollowSlot'
  9. qUI2Events = bootstrap define: bootstrap stub -> 'globals' -> 'modules' -> 'qUI2Events' -> () ToBe: bootstrap addSlotsTo: (
  10. bootstrap remove: 'directory' From:
  11. bootstrap remove: 'fileInTimeString' From:
  12. bootstrap remove: 'myComment' From:
  13. bootstrap remove: 'postFileIn' From:
  14. bootstrap remove: 'revision' From:
  15. bootstrap remove: 'subpartNames' From:
  16. globals modules init copy ) From: bootstrap setObjectAnnotationOf: bootstrap stub -> 'globals' -> 'modules' -> 'qUI2Events' -> () From: ( |
  17. {} = 'ModuleInfo: Creator: globals modules qUI2Events.
  18. CopyDowns:
  19. globals modules init. copy
  20. SlotsToOmit: directory fileInTimeString myComment postFileIn revision subpartNames.
  21. \x7fIsComplete: '.
  22. | ) .
  23. } | )
  24. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'modules' -> 'qUI2Events' -> () From: ( | {
  25. 'ModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  26. directory <- 'ui2'.
  27. } | )
  28. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'modules' -> 'qUI2Events' -> () From: ( | {
  29. 'ModuleInfo: Module: qUI2Events InitialContents: InitializeToExpression: (_CurrentTimeString)\x7fVisibility: public'
  30. fileInTimeString <- _CurrentTimeString.
  31. } | )
  32. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'modules' -> 'qUI2Events' -> () From: ( | {
  33. 'ModuleInfo: Module: qUI2Events InitialContents: FollowSlot'
  34. myComment <- ''.
  35. } | )
  36. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'modules' -> 'qUI2Events' -> () From: ( | {
  37. 'ModuleInfo: Module: qUI2Events InitialContents: FollowSlot'
  38. postFileIn = ( |
  39. | resend.postFileIn).
  40. } | )
  41. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'modules' -> 'qUI2Events' -> () From: ( | {
  42. 'ModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  43. revision <- '$Revision: 30.1 $'.
  44. } | )
  45. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'modules' -> 'qUI2Events' -> () From: ( | {
  46. 'ModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: private'
  47. subpartNames <- ''.
  48. } | )
  49. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'quartzGlobals' -> () From: ( | {
  50. 'Comment: Supports platform independent usage of events
  51. combined with platform specific initialization:
  52. Native MacOS events are used for initialization,
  53. but the resulting ui2Event is used in a platform
  54. independent manner (as a \"Self/ui2\" event).\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  55. ui2Event = bootstrap define: bootstrap stub -> 'globals' -> 'quartzGlobals' -> 'ui2Event' -> () ToBe: bootstrap addSlotsTo: (
  56. bootstrap remove: 'parent' From:
  57. globals abstractUI2Event copy ) From: bootstrap setObjectAnnotationOf: bootstrap stub -> 'globals' -> 'quartzGlobals' -> 'ui2Event' -> () From: ( |
  58. {} = 'ModuleInfo: Creator: globals quartzGlobals ui2Event.
  59. CopyDowns:
  60. globals abstractUI2Event. copy
  61. SlotsToOmit: parent.
  62. \x7fIsComplete: '.
  63. | ) .
  64. } | )
  65. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> () From: ( | {
  66. 'Category: ui2\x7fCategory: System\x7fCategory: Events\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  67. ui2QuartzEvent = bootstrap setObjectAnnotationOf: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( |
  68. {} = 'Comment: A ui2MacEvent is a general input event. Variations include mouse button
  69. transitions, mouse movements, and keyboard key transitions. It
  70. is initialized in a MacOS specific way but used in a portable way.
  71. Note that \"portable\" in this case means that all platforms have
  72. been coerced to look like X Windows..\x7fModuleInfo: Creator: traits ui2QuartzEvent.
  73. '.
  74. | ) .
  75. } | )
  76. bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'quartzGlobals' -> 'ui2Event' -> () From: ( | {
  77. 'ModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  78. parent* = bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> ().
  79. } | )
  80. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  81. 'Category: event location\x7fComment: (see isKeyEvent)\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  82. adjustForCanvas: aWindowCanvas = ( |
  83. |
  84. "for windowResize, window was already resized by platformWindow code"
  85. "Just need to run it through Self to resize other things"
  86. "Someday, should cache the offset, update when window moves"
  87. "Mac closes window first"
  88. aWindowCanvas isOpen ifFalse: [^ self].
  89. cursorPoint: aWindowCanvas platformWindow globalToLocal: cursorPoint.
  90. resend.adjustForCanvas: aWindowCanvas.
  91. type: case if: [windowExpose not] Then: [type]
  92. If: [aWindowCanvas hasSizeChanged] Then: [
  93. bounds: aWindowCanvas innerPosition ## aWindowCanvas size.
  94. 'windowResize']
  95. Else: [ "expose event without size change"
  96. bounds: (0@0) ## aWindowCanvas size.
  97. type]).
  98. } | )
  99. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  100. 'Category: stateMaskCompatibility\x7fComment: This mask selects for a bit whose underlying
  101. concept is foreign to MacOS; it is mapped to
  102. a Mac relevant mask for portability.\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  103. altGraphicMask = ( |
  104. |
  105. altMask).
  106. } | )
  107. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  108. 'Category: stateMasks\x7fComment: This mask selects for a bit whose underlying
  109. concept is foreign to MacOS; it is mapped to
  110. a Mac relevant mask for portability.\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  111. anyMouseMask = ( |
  112. |
  113. quartz event modifierMasks anyButton).
  114. } | )
  115. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  116. 'Category: stateMasks\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  117. capsLockMask = ( |
  118. |
  119. quartz event modifierMasks capsLock).
  120. } | )
  121. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  122. 'Category: stateMasks\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  123. commandMask = ( |
  124. |
  125. quartz event modifierMasks command).
  126. } | )
  127. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  128. 'Category: stateMasks\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  129. controlMask = ( |
  130. |
  131. quartz event modifierMasks control).
  132. } | )
  133. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  134. 'Category: conversion\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  135. doesPlatformReportDoubleClicks = bootstrap stub -> 'globals' -> 'true' -> ().
  136. } | )
  137. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  138. 'Category: time stamps\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  139. isOKToUseMyTimeStampForMenus = ( |
  140. |
  141. "single machine, so event time compares to popUpTime"
  142. "And slow implementation, so need to use event time"
  143. true).
  144. } | )
  145. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  146. 'Category: keyboard Event Handling\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: private'
  147. keyCapForCharacter: c = ( |
  148. |
  149. "The arrow keys (on a Mac, anyway):"
  150. c asByte = 28 ifTrue: [ ^ keyCaps arrows left ].
  151. c asByte = 29 ifTrue: [ ^ keyCaps arrows right].
  152. c asByte = 30 ifTrue: [ ^ keyCaps arrows up ].
  153. c asByte = 31 ifTrue: [ ^ keyCaps arrows down ].
  154. ^ resend.keyCapForCharacter: c).
  155. } | )
  156. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  157. 'Category: stateMasks\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  158. leftMouseMask = ( |
  159. |
  160. quartz event modifierMasks leftButton).
  161. } | )
  162. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  163. 'Category: stateMasks\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  164. middleMouseMask = ( |
  165. |
  166. quartz event modifierMasks middleButton).
  167. } | )
  168. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  169. 'Category: stateMasks\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  170. numLockMask = ( |
  171. |
  172. quartz event modifierMasks numLock).
  173. } | )
  174. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  175. 'Category: stateMasks\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  176. optionMask = ( |
  177. |
  178. quartz event modifierMasks option).
  179. } | )
  180. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  181. 'ModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  182. parent* = bootstrap stub -> 'traits' -> 'abstractUI2Event' -> ().
  183. } | )
  184. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  185. 'Category: stateMasks\x7fComment: This mask selects for a bit whose underlying
  186. concept is foreign to MacOS; it is mapped to
  187. a Mac relevant mask for portability.\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  188. rightMouseMask = ( |
  189. |
  190. quartz event modifierMasks rightButton).
  191. } | )
  192. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  193. 'Category: stateMaskCompatibility\x7fComment: This mask selects for a bit whose underlying
  194. concept is foreign to MacOS; it is mapped to
  195. a Mac relevant mask for portability.\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  196. shiftLockMask = ( |
  197. | capsLockMask).
  198. } | )
  199. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  200. 'Category: stateMasks\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot\x7fVisibility: public'
  201. shiftMask = ( |
  202. |
  203. quartz event modifierMasks shift).
  204. } | )
  205. bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'ui2QuartzEvent' -> () From: ( | {
  206. 'Category: stateMaskCompatibility\x7fComment: These masks correspond to
  207. concepts which are foreign
  208. to the Mac; the implementation
  209. maps them to native Mac methods.\x7fModuleInfo: Module: qUI2Events InitialContents: FollowSlot'
  210. stateMaskCompatibilityComment = bootstrap stub -> 'globals' -> 'nil' -> ().
  211. } | )
  212. '-- Side effects'
  213. globals modules qUI2Events postFileIn