Package Name: events
with Interfaces.C.Extensions; use Interfaces.C.Extensions;
with Types; use Types;
with OSUtils; use OSUtils;
with Quickdraw; use Quickdraw;
package Events is
--
-- File: Events.h
--
-- Contains: Event Manager Interfaces.
--
-- Version: Technology: System 7.5
-- Package: Universal Interfaces 2.1 in ÒMPW LatestÓ on ETO #18
--
-- Copyright: © 1984-1995 by Apple Computer, Inc.
-- All rights reserved.
--
subtype EventKind is UInt16;
nullEvent : constant EventKind := 0;
mouseDown : constant EventKind := 1;
mouseUp : constant EventKind := 2;
keyDown : constant EventKind := 3;
keyUp : constant EventKind := 4;
autoKey : constant EventKind := 5;
updateEvt : constant EventKind := 6;
diskEvt : constant EventKind := 7;
activateEvt: constant EventKind := 8;
osEvt : constant EventKind := 15;
subtype EventMask is UInt16;
mDownMask : constant EventMask:= 16#0002#; --mouse button pressed
mUpMask : constant EventMask:= 16#0004#; -- mouse button released
keyDownMask : constant EventMask:= 16#0008#; -- key pressed
keyUpMask : constant EventMask:= 16#0010#; -- key released
autoKeyMask : constant EventMask:= 16#0020#; -- key repeatedly held down
updateMask : constant EventMask:= 16#0040#; -- window needs updating
diskMask : constant EventMask:= 16#0080#; -- disk inserted
activMask : constant EventMask:= 16#0100#; -- activate/deactivate window
highLevelEventMask : constant EventMask:= 16#0400#; -- high-level events (includes AppleEvents)
osMask : constant EventMask:= 16#8000#; -- operating system events (suspend, resume)
everyEvent : constant EventMask:= 16#FFFF#; -- all of the above
-- event message equates
charCodeMask : constant UInt32:= 16#000000FF#;
keyCodeMask : constant UInt32:= 16#0000FF00#;
adbAddrMask : constant UInt32:= 16#00FF0000#;
osEvtMessageMask : constant UInt32:= 16#FF000000#;
-- OS event messages. Event (sub)code is in the high byte of the message field.
mouseMovedMessage : constant UInt16:= 16#00FA#;
suspendResumeMessage : constant UInt16:= 16#0001#;
resumeFlag : constant UInt16:= 16#0001#; -- Bit 0 of message indicates resume vs suspend
convertClipboardFlag : constant UInt16:= 16#0002#; -- Bit 1 in resume message indicates clipboard change
subtype EventModifiers is UInt16;
-- modifiers
activeFlag : constant EventModifiers:= 16#0001#; -- Bit 0 for activateEvt and mouseDown events
btnState : constant EventModifiers:= 16#0080#; -- Bit 7 of low byte is mouse button state
cmdKey : constant EventModifiers:= 16#0100#; -- Bit 0 of high byte
shiftKey : constant EventModifiers:= 16#0200#; -- Bit 1 of high byte
alphaLock : constant EventModifiers:= 16#0400#; -- Bit 2 of high byte
optionKey : constant EventModifiers:= 16#0800#; -- Bit 3 of high byte
controlKey : constant EventModifiers:= 16#1000#; -- Bit 4 of high byte
rightShiftKey : constant EventModifiers:= 16#2000#; -- Bit 5 of high byte
rightOptionKey : constant EventModifiers:= 16#4000#; -- Bit 6 of high byte
rightControlKey : constant EventModifiers:= 16#8000#; -- Bit 7 of high byte
type EventRecord is
record
what : EventKind;
message : UInt32;
when_Id : UInt32;
where : Point;
modifiers : EventModifiers;
end record;
type EventRecord_Ptr is Access EventRecord;
subtype KeyMap is UInt32_Vec_4;
type EvQEl is
record
qLink : QElemPtr;
qType : Short_Integer;
evtQWhat : EventKind; -- this part is identical to the EventRecord as...
evtQMessage : UInt32; -- defined above
evtQWhen : UInt32;
evtQWhere : Point;
evtQModifiers : EventModifiers;
end record;
type EvQElPtr is Access EvQEl;
type GetNextEventFilterProcPtr is Access procedure
(theEvent : access EventRecord;
result : access Boolean);
subtype GetNextEventFilterUPP is UniversalProcPtr;
subtype GNEFilterUPP is GetNextEventFilterUPP;
type FKEYProcPtr is Access procedure ;
subtype FKEYUPP is UniversalProcPtr;
function GetCaretTime
return UInt32;
pragma Import (C, GetCaretTime, "GetCaretTime", "GetCaretTime");
procedure SetEventMask
(value : in EventMask);
pragma Import (C, SetEventMask, "SetEventMask", "SetEventMask");
function GetEventMask
return EventMask;
pragma Import (C, GetEventMask, "GetEventMask", "GetEventMask");
function GetEvQHdr
return QHdrPtr;
pragma Import (C, GetEvQHdr, "GetEvQHdr", "GetEvQHdr");
-- InterfaceLib exports GetEvQHdr, so make GetEventQueue map to that
function GetDblTime
return UInt32;
pragma Import (C, GetDblTime, "GetDblTime", "GetDblTime");
-- InterfaceLib exports GetDblTime, so make GetDoubleClickTime map to that
function GetNextEvent
(evtMask : in EventMask;
theEvent : access EventRecord)
return Boolean;
pragma Import (C, GetNextEvent, "GetNextEvent", "GetNextEvent");
function WaitNextEvent
(evtMask : in EventMask;
theEvent : access EventRecord;
sleep : in UInt32;
mouseRgn : in RgnHandle)
return Boolean;
pragma Import (C, WaitNextEvent, "WaitNextEvent", "WaitNextEvent");
function EventAvail
(evtMask : in EventMask;
theEvent : access EventRecord)
return Boolean;
pragma Import (C, EventAvail, "EventAvail", "EventAvail");
procedure GetMouse
(mouseLoc : access Point);
pragma Import (C, GetMouse, "GetMouse", "GetMouse");
function Button
return Boolean;
pragma Import (C, Button, "Button", "Button");
function StillDown
return Boolean;
pragma Import (C, StillDown, "StillDown", "StillDown");
function WaitMouseUp
return Boolean;
pragma Import (C, WaitMouseUp, "WaitMouseUp", "WaitMouseUp");
procedure GetKeys
(theKeys : in KeyMap);
pragma Import (C, GetKeys, "GetKeys", "GetKeys");
function KeyTranslate
(transData : in Void_Ptr;
keycode : in UInt16;
state : access UInt32)
return UInt32;
pragma Import (C, KeyTranslate, "KeyTranslate", "KeyTranslate");
function TickCount
return UInt32;
pragma Import (C, TickCount, "TickCount", "TickCount");
function PostEvent
(eventNum : in EventKind;
eventMsg : in UInt32)
return OSErr;
pragma Import (C, PostEvent, "PostEvent", "PostEvent");
function PPostEvent
(eventCode : in EventKind;
eventMsg : in UInt32;
qEl : access EvQElPtr)
return OSErr;
pragma Import (C, PPostEvent, "PPostEvent", "PPostEvent");
function OSEventAvail
(mask : in EventMask;
theEvent : access EventRecord)
return Boolean;
pragma Import (C, OSEventAvail, "OSEventAvail", "OSEventAvail");
function GetOSEvent
(mask : in EventMask;
theEvent : access EventRecord)
return Boolean;
pragma Import (C, GetOSEvent, "GetOSEvent", "GetOSEvent");
procedure FlushEvents
(whichMask : in EventMask;
stopMask : in EventMask);
pragma Import (C, FlushEvents, "FlushEvents", "FlushEvents");
procedure SystemClick
(theEvent : access EventRecord;
theWindow : in WindowPtr);
pragma Import (C, SystemClick, "SystemClick", "SystemClick");
procedure SystemTask;
pragma Import (C, SystemTask, "SystemTask", "SystemTask");
function SystemEvent
(theEvent : access EventRecord)
return Boolean;
pragma Import (C, SystemEvent, "SystemEvent", "SystemEvent");
end Events;