event_.pp 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. (******************************************************************************
  2. *
  3. * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
  4. * All rights reserved.
  5. *
  6. * File: Event.h
  7. *
  8. * Release: Palm OS SDK 4.0 (63220)
  9. *
  10. * Description:
  11. * This file defines UI event structures and routines.
  12. *
  13. * History:
  14. * September 26, 1994 Created by Art Lamb
  15. * 07/14/99 jesse Separated from Event.h
  16. * 09/12/99 gap Add for new multi-tap implementation
  17. * 09/14/99 gap Removed EvtGetTrapState.
  18. * 10/28/99 kwk Added EvtKeydownIsVirtual macro.
  19. *
  20. *****************************************************************************)
  21. unit event_;
  22. interface
  23. uses palmos, coretraps, sysevent, control, day, field, list, scrollbar, table;
  24. type
  25. eventsEnum = WordEnum;
  26. const
  27. nilEvent = 0; // system level
  28. penDownEvent = Succ(nilEvent); // system level
  29. penUpEvent = Succ(penDownEvent); // system level
  30. penMoveEvent = Succ(penUpEvent); // system level
  31. keyDownEvent = Succ(penMoveEvent); // system level
  32. winEnterEvent = Succ(keyDownEvent); // system level
  33. winExitEvent = Succ(winEnterEvent); // system level
  34. ctlEnterEvent = Succ(winExitEvent);
  35. ctlExitEvent = Succ(ctlEnterEvent);
  36. ctlSelectEvent = Succ(ctlExitEvent);
  37. ctlRepeatEvent = Succ(ctlSelectEvent);
  38. lstEnterEvent = Succ(ctlRepeatEvent);
  39. lstSelectEvent = Succ(lstEnterEvent);
  40. lstExitEvent = Succ(lstSelectEvent);
  41. popSelectEvent = Succ(lstExitEvent);
  42. fldEnterEvent = Succ(popSelectEvent);
  43. fldHeightChangedEvent = Succ(fldEnterEvent);
  44. fldChangedEvent = Succ(fldHeightChangedEvent);
  45. tblEnterEvent = Succ(fldChangedEvent);
  46. tblSelectEvent = Succ(tblEnterEvent);
  47. daySelectEvent = Succ(tblSelectEvent);
  48. menuEvent = Succ(daySelectEvent);
  49. appStopEvent = 22; // system level
  50. frmLoadEvent = Succ(appStopEvent);
  51. frmOpenEvent = Succ(frmLoadEvent);
  52. frmGotoEvent = Succ(frmOpenEvent);
  53. frmUpdateEvent = Succ(frmGotoEvent);
  54. frmSaveEvent = Succ(frmUpdateEvent);
  55. frmCloseEvent = Succ(frmSaveEvent);
  56. frmTitleEnterEvent = Succ(frmCloseEvent);
  57. frmTitleSelectEvent = Succ(frmTitleEnterEvent);
  58. tblExitEvent = Succ(frmTitleSelectEvent);
  59. sclEnterEvent = Succ(tblExitEvent);
  60. sclExitEvent = Succ(sclEnterEvent);
  61. sclRepeatEvent = Succ(sclExitEvent);
  62. tsmConfirmEvent = 35; // system level
  63. tsmFepButtonEvent = Succ(tsmConfirmEvent); // system level
  64. tsmFepModeEvent = Succ(tsmFepButtonEvent); // system level
  65. //DOLATER - peter: remove this: frmTitleChangedEvent, // system level
  66. attnIndicatorEnterEvent = Succ(tsmFepModeEvent); // for attention manager's indicator
  67. attnIndicatorSelectEvent = Succ(attnIndicatorEnterEvent); // for attention manager's indicator
  68. // add future UI level events in this numeric space
  69. // to save room for new system level events
  70. menuCmdBarOpenEvent = $0800;
  71. menuOpenEvent = Succ(menuCmdBarOpenEvent);
  72. menuCloseEvent = Succ(menuOpenEvent);
  73. frmGadgetEnterEvent = Succ(menuCloseEvent);
  74. frmGadgetMiscEvent = Succ(frmGadgetEnterEvent);
  75. // <chg 2-25-98 RM> Equates added for library events
  76. firstINetLibEvent = $1000;
  77. firstWebLibEvent = $1100;
  78. // <chg 10/9/98 SCL> Changed firstUserEvent from 32767 (0x7FFF) to 0x6000
  79. // Enums are signed ints, so 32767 technically only allowed for ONE event.
  80. firstUserEvent = $6000;
  81. lastUserEvent = $7FFF;
  82. type
  83. ctlEnter = record
  84. controlID: UInt16;
  85. pControl: ControlPtr;
  86. end;
  87. ctlExit = record
  88. controlID: UInt16;
  89. pControl: ControlPtr;
  90. end;
  91. ctlSelect = record
  92. controlID: UInt16;
  93. pControl: ControlPtr;
  94. on: Boolean;
  95. reserved1: UInt8;
  96. value: UInt16; // used for slider controls only
  97. end;
  98. ctlRepeat = record
  99. controlID: UInt16;
  100. pControl: ControlPtr;
  101. time: UInt32;
  102. value: UInt16; // used for slider controls only
  103. end;
  104. fldEnter = record
  105. fieldID: UInt16;
  106. pField: FieldPtr;
  107. end;
  108. fldHeightChanged = record
  109. fieldID: UInt16;
  110. pField: FieldPtr;
  111. newHeight: Int16;
  112. currentPos: UInt16;
  113. end;
  114. fldChanged = record
  115. fieldID: UInt16;
  116. pField: ^FieldType;
  117. end;
  118. fldExit = record
  119. fieldID: UInt16;
  120. pField: ^FieldType;
  121. end;
  122. lstEnter = record
  123. listID: UInt16;
  124. pList: ^ListType;
  125. selection: Int16;
  126. end;
  127. lstExit = record
  128. listID: UInt16;
  129. pList: ListPtr;
  130. end;
  131. lstSelect = record
  132. listID: UInt16;
  133. pList: ^ListType;
  134. selection: Int16;
  135. end;
  136. tblEnter = record
  137. tableID: UInt16;
  138. pTable: TablePtr;
  139. row: Int16;
  140. column: Int16;
  141. end;
  142. tblExit = record
  143. tableID: UInt16;
  144. pTable: TablePtr;
  145. row: Int16;
  146. column: Int16;
  147. end;
  148. tblSelect = record
  149. tableID: UInt16;
  150. pTable: TablePtr;
  151. row: Int16;
  152. column: Int16;
  153. end;
  154. frmLoad = record
  155. formID: UInt16;
  156. end;
  157. frmOpen = record
  158. formID: UInt16;
  159. end;
  160. frmGoto = record
  161. formID: UInt16;
  162. recordNum: UInt16; // index of record that contain a match
  163. matchPos: UInt16; // postion in record of the match.
  164. matchLen: UInt16; // length of match.
  165. matchFieldNum: UInt16; // field number string was found int
  166. matchCustom: UInt32; // application specific info
  167. end;
  168. frmClose = record
  169. formID: UInt16;
  170. end;
  171. frmUpdate = record
  172. formID: UInt16;
  173. updateCode: UInt16; // Application specific
  174. end;
  175. frmTitleEnter = record
  176. formID: UInt16;
  177. end;
  178. frmTitleSelect = record
  179. formID: UInt16;
  180. end;
  181. attnIndicatorEnter = record
  182. formID: UInt16;
  183. end;
  184. attnIndicatorSelect = record
  185. formID: UInt16;
  186. end;
  187. daySelect = record
  188. pSelector: ^DaySelectorType;
  189. selection: Int16;
  190. useThisDate: Boolean;
  191. reserved1: UInt8;
  192. end;
  193. menu = record
  194. itemID: UInt16;
  195. end;
  196. popSelect = record
  197. controlID: UInt16;
  198. controlP: ^ControlType;
  199. listID: UInt16;
  200. listP: ^ListType;
  201. selection: Int16;
  202. priorSelection: Int16;
  203. end;
  204. sclEnter = record
  205. scrollBarID: UInt16;
  206. pScrollBar: ^ScrollBarType;
  207. end;
  208. sclExit = record
  209. scrollBarID: UInt16;
  210. pScrollBar: ^ScrollBarType;
  211. value: Int16;
  212. newValue: Int16;
  213. end;
  214. sclRepeat = record
  215. scrollBarID: UInt16;
  216. pScrollBar: ^ScrollBarType;
  217. value: Int16;
  218. newValue: Int16;
  219. time: Int32;
  220. end;
  221. menuCmdBarOpen = record
  222. preventFieldButtons: Boolean; // set to stop the field from automatically adding cut/copy/paste
  223. reserved: UInt8; // alignment padding
  224. end;
  225. menuOpen = record
  226. menuRscID: UInt16;
  227. //struct MenuBarType *pMenu;
  228. cause: Int16;
  229. end;
  230. gadgetEnter = record
  231. gadgetID: UInt16; // must be same as gadgetMisc
  232. gadgetP: Pointer{^FormGadgetType}; // must be same as gadgetMisc
  233. end;
  234. gadgetMisc = record
  235. gadgetID: UInt16; // must be same as gadgetEnter
  236. gadgetP: Pointer{^FormGadgetType}; // must be same as gadgetEnter
  237. selector: UInt16;
  238. dataP: Pointer;
  239. end;
  240. // The event record.
  241. type
  242. EventType = record
  243. eType: eventsEnum;
  244. penDown: Boolean;
  245. tapCount: UInt8;
  246. screenX: Int16;
  247. screenY: Int16;
  248. case Integer of
  249. 1: (generic: _GenericEventType);
  250. 2: (penUp: _PenUpEventType);
  251. 3: (keyDown: _KeyDownEventType);
  252. 4: (winEnter: _WinEnterEventType);
  253. 5: (winExit: _WinExitEventType);
  254. 6: (tsmConfirm: _TSMConfirmType);
  255. 7: (tsmFepButton: _TSMFepButtonType);
  256. 8: (tsmFepMode: _TSMFepModeEventType);
  257. 9: (ctlEnter: ctlEnter);
  258. 10: (ctlSelect: ctlSelect);
  259. 11: (ctlRepeat: ctlRepeat);
  260. 12: (ctlExit: ctlExit);
  261. 13: (fldEnter: fldEnter);
  262. 14: (fldHeightChanged: fldHeightChanged);
  263. 15: (fldChanged: fldChanged);
  264. 16: (fldExit: fldExit);
  265. 17: (lstEnter: lstEnter);
  266. 18: (lstExit: lstExit);
  267. 19: (lstSelect: lstSelect);
  268. 20: (tblEnter: tblEnter);
  269. 21: (tblExit: tblExit);
  270. 22: (tblSelect: tblSelect);
  271. 23: (frmLoad: frmLoad);
  272. 24: (frmOpen: frmOpen);
  273. 25: (frmGoto: frmGoto);
  274. 26: (frmClose: frmClose);
  275. 27: (frmUpdate: frmUpdate);
  276. 28: (frmTitleEnter: frmTitleEnter);
  277. 29: (frmTitleSelect: frmTitleSelect);
  278. 30: (attnIndicatorEnter: attnIndicatorEnter);
  279. 31: (attnIndicatorSelect: attnIndicatorSelect);
  280. 32: (daySelect: daySelect);
  281. 33: (menu: menu);
  282. 34: (popSelect: popSelect);
  283. 35: (sclEnter: sclEnter);
  284. 36: (sclExit: sclExit);
  285. 37: (sclRepeat: sclRepeat);
  286. 38: (menuCmdBarOpen: menuCmdBarOpen);
  287. 39: (menuOpen: menuOpen);
  288. 40: (gadgetEnter: gadgetEnter);
  289. 41: (gadgetMisc: gadgetMisc);
  290. end;
  291. TEvent = EventType;
  292. EventPtr = ^EventType;
  293. // Evaluate to true if <eventP> is a pointer to a virtual character key-
  294. // down event. We assume that the caller has already determined the event
  295. // is a keydown. WARNING!!! This macro is only safe to use on Palm OS 3.5
  296. // or later. With earlier versions of the OS, use TxtGlueCharIsVirtual()
  297. // in PalmOSGlue.lib
  298. function EvtKeydownIsVirtual(eventP: EventPtr): Boolean;
  299. //---------------------------------------------------------------------
  300. // Event Functions
  301. //---------------------------------------------------------------------
  302. procedure EvtAddEventToQueue(const event: EventPtr); syscall sysTrapEvtAddEventToQueue;
  303. procedure EvtAddUniqueEventToQueue(const eventP: EventPtr; id: UInt32; inPlace: Boolean); syscall sysTrapEvtAddUniqueEventToQueue;
  304. procedure EvtCopyEvent(const source: EventPtr; dest: EventPtr); syscall sysTrapEvtCopyEvent;
  305. procedure EvtGetEvent(var event: EventType; timeout: Int32); syscall sysTrapEvtGetEvent;
  306. function EvtEventAvail: Boolean; syscall sysTrapEvtEventAvail;
  307. procedure EvtGetPen(var pScreenX, pScreenY: Int16; var pPenDown: Boolean); syscall sysTrapEvtGetPen;
  308. implementation
  309. function EvtKeydownIsVirtual(eventP: EventPtr): Boolean;
  310. begin
  311. EvtKeydownIsVirtual := (eventP^.keyDown.modifiers and virtualKeyMask) <> 0
  312. end;
  313. end.