home *** CD-ROM | disk | FTP | other *** search
- #ifndef _EVENT_HPP
- #define _EVENT_HPP
-
- // ------------------------------------------------------------------
- // File: EVENT.HPP
- // Path: ...\REHACK\EVENT\EVENT.HPP
- // Version: 0.01
- // Author: Pat Reilly
- // CIS Id: 71333,2764
- // Created On: 6/18/93
- // Modified On: 6/25/93
- // Description: Event class for REHACK. See EVENT.TXT for
- // more details.
- // Tabs: 4
- // ------------------------------------------------------------------
-
- #ifndef _MISC_HPP
- #include "..\GENERAL\MISC.HPP"
- #endif
-
- // Constance used by PosDeviceEvent class for designating buttons.
-
- const byte
- LeftBtn = 1,
- RightBtn = 2,
- CenterBtn = 4;
-
- // Class PosDeviceEvent
-
- struct PosDeviceEvent
- {
- byte buttons; // Bits: LeftBtn, RightBtn, CenterBtn.
- bool dblClicked; // True if a button event and a double click.
- Point location; // XY position at the time of the event.
- };
-
- // Class KeyCode
-
- struct KeyCode
- {
- byte code; // character code of the key.
- byte scan; // scan code of the key.
- };
-
- // Class KeyEvent
-
- struct KeyEvent
- {
- union
- {
- word value; // 16-bit key value.
- KeyCode charScanValue; // KeyCode value.
- };
- };
-
- // Class MsgEvent
-
- struct MsgEvent
- {
- word id; // message identifier.
- union
- {
- void* pointerValue; // Extra info as a generic pointer.
- long longValue; // Extra info as a long value.
- short shortValue; // Extra info as a short value.
- Point pointValue; // Extra info as a point value.
- };
- };
-
- // Some standard message id's.
- const word
- IdNull = 0,
- IdCancel = 1,
- IdQuit = 2;
-
-
- const word
- PosDeviceBtnDown = 0x0001,
- PosDeviceBtnUp = 0x0002,
- PosDeviceMove = 0x0004,
- PosDevice = 0x000F,
-
- KeyDown = 0x0010,
- KeyUp = 0x0020,
- Key = 0x0030,
-
- Broadcast = 0x8000,
- Message = 0xFF00;
-
- // Class Event
-
- struct Event
- {
- word type;
- dword ticks;
- union
- {
- PosDeviceEvent posDevice;
- KeyEvent key;
- MsgEvent msg;
- };
-
- bool isNull() const;
- bool isPositional() const;
- bool isFocused() const;
- bool isBroadcast() const;
- bool isMessage() const;
- void clear();
- void setSystemTicks();
- };
-
- inline bool Event::isNull() const
- {
- return bool(type == 0);
- }
-
- inline bool Event::isPositional() const
- {
- return bool((type & PosDevice) != 0);
- }
-
- inline bool Event::isFocused() const
- {
- return bool((type & (Key|Message) & ~Broadcast) != 0);
- }
-
- inline bool Event::isBroadcast() const
- {
- return bool((type & Broadcast) != 0);
- }
-
- inline bool Event::isMessage() const
- {
- return bool((type & Message) != 0);
- }
-
- inline void Event::clear()
- {
- type = 0;
- }
-
- inline void Event::setSystemTicks()
- {
- // Does this work with MSC++? It is certainly PC-only code...
- ticks = *( (dword FAR *)(0x046CUL) );
- }
-
- #endif // _EVENT_HPP
-