summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/palmunits/src/event_.pp
blob: 9cef52abcdbd42472cc3434b37537035cb67027d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
(******************************************************************************
 *
 * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
 * All rights reserved.
 *
 * File: Event.h
 *
 * Release: Palm OS SDK 4.0 (63220)
 *
 * Description:
 *        This file defines UI event structures and routines.
 *
 * History:
 *    September 26, 1994   Created by Art Lamb
 *    07/14/99 jesse Separated from Event.h
 *    09/12/99 gap   Add for new multi-tap implementation
 *    09/14/99 gap   Removed EvtGetTrapState.
 *    10/28/99 kwk   Added EvtKeydownIsVirtual macro.
 *
 *****************************************************************************)
unit event_;

interface

uses palmos, coretraps, sysevent, control, day, field, list, scrollbar, table;

type
  eventsEnum = WordEnum;

const
  nilEvent = 0;                          // system level
  penDownEvent = Succ(nilEvent);         // system level
  penUpEvent = Succ(penDownEvent);       // system level
  penMoveEvent = Succ(penUpEvent);       // system level
  keyDownEvent = Succ(penMoveEvent);     // system level
  winEnterEvent = Succ(keyDownEvent);    // system level
  winExitEvent = Succ(winEnterEvent);    // system level
  ctlEnterEvent = Succ(winExitEvent);
  ctlExitEvent = Succ(ctlEnterEvent);
  ctlSelectEvent = Succ(ctlExitEvent);
  ctlRepeatEvent = Succ(ctlSelectEvent);
  lstEnterEvent = Succ(ctlRepeatEvent);
  lstSelectEvent = Succ(lstEnterEvent);
  lstExitEvent = Succ(lstSelectEvent);
  popSelectEvent = Succ(lstExitEvent);
  fldEnterEvent = Succ(popSelectEvent);
  fldHeightChangedEvent = Succ(fldEnterEvent);
  fldChangedEvent = Succ(fldHeightChangedEvent);
  tblEnterEvent = Succ(fldChangedEvent);
  tblSelectEvent = Succ(tblEnterEvent);
  daySelectEvent = Succ(tblSelectEvent);
  menuEvent = Succ(daySelectEvent);
  appStopEvent = 22;                     // system level
  frmLoadEvent = Succ(appStopEvent);
  frmOpenEvent = Succ(frmLoadEvent);
  frmGotoEvent = Succ(frmOpenEvent);
  frmUpdateEvent = Succ(frmGotoEvent);
  frmSaveEvent = Succ(frmUpdateEvent);
  frmCloseEvent = Succ(frmSaveEvent);
  frmTitleEnterEvent = Succ(frmCloseEvent);
  frmTitleSelectEvent = Succ(frmTitleEnterEvent);
  tblExitEvent = Succ(frmTitleSelectEvent);
  sclEnterEvent = Succ(tblExitEvent);
  sclExitEvent = Succ(sclEnterEvent);
  sclRepeatEvent = Succ(sclExitEvent);
  tsmConfirmEvent = 35;                      // system level
  tsmFepButtonEvent = Succ(tsmConfirmEvent); // system level
  tsmFepModeEvent = Succ(tsmFepButtonEvent); // system level

//DOLATER - peter: remove this:  frmTitleChangedEvent,      // system level
  attnIndicatorEnterEvent = Succ(tsmFepModeEvent);          // for attention manager's indicator
  attnIndicatorSelectEvent = Succ(attnIndicatorEnterEvent); // for attention manager's indicator

  // add future UI level events in this numeric space
  // to save room for new system level events
  menuCmdBarOpenEvent = $0800;
  menuOpenEvent = Succ(menuCmdBarOpenEvent);
  menuCloseEvent = Succ(menuOpenEvent);
  frmGadgetEnterEvent = Succ(menuCloseEvent);
  frmGadgetMiscEvent = Succ(frmGadgetEnterEvent);

  // <chg 2-25-98 RM> Equates added for library events
  firstINetLibEvent = $1000;
  firstWebLibEvent = $1100;

  // <chg 10/9/98 SCL> Changed firstUserEvent from 32767 (0x7FFF) to 0x6000
  // Enums are signed ints, so 32767 technically only allowed for ONE event.
  firstUserEvent = $6000;
  lastUserEvent  = $7FFF;

type
  ctlEnter = record
    controlID: UInt16;
    pControl: ControlPtr;
  end;

  ctlExit = record
    controlID: UInt16;
    pControl: ControlPtr;
  end;

  ctlSelect = record
    controlID: UInt16;
    pControl: ControlPtr;
    on: Boolean;
    reserved1: UInt8;
    value: UInt16; // used for slider controls only
  end;

  ctlRepeat = record
    controlID: UInt16;
    pControl: ControlPtr;
    time: UInt32;
    value: UInt16; // used for slider controls only
  end;

  fldEnter = record
    fieldID: UInt16;
    pField: FieldPtr;
  end;

  fldHeightChanged = record
    fieldID: UInt16;
    pField: FieldPtr;
    newHeight: Int16;
    currentPos: UInt16;
  end;

  fldChanged = record
    fieldID: UInt16;
    pField: ^FieldType;
  end;

  fldExit = record
    fieldID: UInt16;
    pField: ^FieldType;
  end;

  lstEnter = record
    listID: UInt16;
    pList: ^ListType;
    selection: Int16;
  end;

  lstExit = record
    listID: UInt16;
    pList: ListPtr;
  end;

  lstSelect = record
    listID: UInt16;
    pList: ^ListType;
    selection: Int16;
  end;

  tblEnter = record
    tableID: UInt16;
    pTable: TablePtr;
    row: Int16;
    column: Int16;
  end;

  tblExit = record
    tableID: UInt16;
    pTable: TablePtr;
    row: Int16;
    column: Int16;
  end;

  tblSelect = record
    tableID: UInt16;
    pTable: TablePtr;
    row: Int16;
    column: Int16;
  end;

  frmLoad = record
    formID: UInt16;
  end;

  frmOpen = record
    formID: UInt16;
  end;

  frmGoto = record
    formID: UInt16;
    recordNum: UInt16;     // index of record that contain a match
    matchPos: UInt16;      // postion in record of the match.
    matchLen: UInt16;      // length of match.
    matchFieldNum: UInt16; // field number string was found int
    matchCustom: UInt32;   // application specific info
  end;

  frmClose = record
    formID: UInt16;
  end;

  frmUpdate = record
    formID: UInt16;
    updateCode: UInt16;    // Application specific
  end;

  frmTitleEnter = record
    formID: UInt16;
  end;

  frmTitleSelect = record
    formID: UInt16;
  end;

  attnIndicatorEnter = record
    formID: UInt16;
  end;

  attnIndicatorSelect = record
    formID: UInt16;
  end;

  daySelect = record
    pSelector: ^DaySelectorType;
    selection: Int16;
    useThisDate: Boolean;
    reserved1: UInt8;
  end;

  menu = record
    itemID: UInt16;
  end;

  popSelect = record
    controlID: UInt16;
    controlP: ^ControlType;
    listID: UInt16;
    listP: ^ListType;
    selection: Int16;
    priorSelection: Int16;
  end;

  sclEnter = record
    scrollBarID: UInt16;
    pScrollBar: ^ScrollBarType;
  end;

  sclExit = record
    scrollBarID: UInt16;
    pScrollBar: ^ScrollBarType;
    value: Int16;
    newValue: Int16;
  end;

  sclRepeat = record
    scrollBarID: UInt16;
    pScrollBar: ^ScrollBarType;
    value: Int16;
    newValue: Int16;
    time: Int32;
  end;

  menuCmdBarOpen = record
   preventFieldButtons: Boolean; // set to stop the field from automatically adding cut/copy/paste
   reserved: UInt8;              // alignment padding
  end;

  menuOpen = record
   menuRscID: UInt16;
   //struct MenuBarType *pMenu;
   cause: Int16;
  end;

  gadgetEnter = record
    gadgetID: UInt16;         // must be same as gadgetMisc
    gadgetP: Pointer{^FormGadgetType}; // must be same as gadgetMisc
  end;

  gadgetMisc = record
    gadgetID: UInt16;         // must be same as gadgetEnter
    gadgetP: Pointer{^FormGadgetType}; // must be same as gadgetEnter
    selector: UInt16;
    dataP: Pointer;
  end;

// The event record.
type
  EventType = record
   eType: eventsEnum;
   penDown: Boolean;
   tapCount: UInt8;
   screenX: Int16;
   screenY: Int16;
   case Integer of
     1: (generic: _GenericEventType);
     2: (penUp: _PenUpEventType);
     3: (keyDown: _KeyDownEventType);
     4: (winEnter: _WinEnterEventType);
     5: (winExit: _WinExitEventType);
     6: (tsmConfirm: _TSMConfirmType);
     7: (tsmFepButton: _TSMFepButtonType);
     8: (tsmFepMode: _TSMFepModeEventType);
     9: (ctlEnter: ctlEnter);
     10: (ctlSelect: ctlSelect);
     11: (ctlRepeat: ctlRepeat);
     12: (ctlExit: ctlExit);
     13: (fldEnter: fldEnter);
     14: (fldHeightChanged: fldHeightChanged);
     15: (fldChanged: fldChanged);
     16: (fldExit: fldExit);
     17: (lstEnter: lstEnter);
     18: (lstExit: lstExit);
     19: (lstSelect: lstSelect);
     20: (tblEnter: tblEnter);
     21: (tblExit: tblExit);
     22: (tblSelect: tblSelect);
     23: (frmLoad: frmLoad);
     24: (frmOpen: frmOpen);
     25: (frmGoto: frmGoto);
     26: (frmClose: frmClose);
     27: (frmUpdate: frmUpdate);
     28: (frmTitleEnter: frmTitleEnter);
     29: (frmTitleSelect: frmTitleSelect);
     30: (attnIndicatorEnter: attnIndicatorEnter);
     31: (attnIndicatorSelect: attnIndicatorSelect);
     32: (daySelect: daySelect);
     33: (menu: menu);
     34: (popSelect: popSelect);
     35: (sclEnter: sclEnter);
     36: (sclExit: sclExit);
     37: (sclRepeat: sclRepeat);
     38: (menuCmdBarOpen: menuCmdBarOpen);
     39: (menuOpen: menuOpen);
     40: (gadgetEnter: gadgetEnter);
     41: (gadgetMisc: gadgetMisc);
  end;

  TEvent = EventType;
  EventPtr = ^EventType;

// Evaluate to true if <eventP> is a pointer to a virtual character key-
// down event. We assume that the caller has already determined the event
// is a keydown. WARNING!!! This macro is only safe to use on Palm OS 3.5
// or later. With earlier versions of the OS, use TxtGlueCharIsVirtual()
// in PalmOSGlue.lib

function EvtKeydownIsVirtual(eventP: EventPtr): Boolean;

//---------------------------------------------------------------------
// Event Functions
//---------------------------------------------------------------------

procedure EvtAddEventToQueue(const event: EventPtr); syscall sysTrapEvtAddEventToQueue;

procedure EvtAddUniqueEventToQueue(const eventP: EventPtr; id: UInt32; inPlace: Boolean); syscall sysTrapEvtAddUniqueEventToQueue;

procedure EvtCopyEvent(const source: EventPtr; dest: EventPtr); syscall sysTrapEvtCopyEvent;

procedure EvtGetEvent(var event: EventType; timeout: Int32); syscall sysTrapEvtGetEvent;

function EvtEventAvail: Boolean; syscall sysTrapEvtEventAvail;

procedure EvtGetPen(var pScreenX, pScreenY: Int16; var pPenDown: Boolean); syscall sysTrapEvtGetPen;

implementation

function EvtKeydownIsVirtual(eventP: EventPtr): Boolean;
begin
  EvtKeydownIsVirtual := (eventP^.keyDown.modifiers and virtualKeyMask) <> 0
end;

end.