home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IKEYEVT.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  11KB  |  191 lines

  1. #ifndef _IKEYEVT_
  2.   #define _IKEYEVT_
  3. /*******************************************************************************
  4. * FILE NAME: ikeyevt.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IKeyboardEvent - represents a keyboard-related event                     *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   All Rights Reserved                                                        *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #ifndef _IEVENT_
  19.   #include <ievent.hpp>
  20. #endif
  21.  
  22. /*----------------------------------------------------------------------------*/
  23. /* Align classes on four byte boundary.                                       */
  24. /*----------------------------------------------------------------------------*/
  25. #pragma pack(4)
  26.  
  27. // Forward declarations for other classes:
  28. class IString;
  29.  
  30.  
  31. class IKeyboardEvent : public IEvent {
  32. typedef IEvent
  33.   Inherited;
  34. /*******************************************************************************
  35. * The IKeyboardEvent class represents a keyboard-related event.  An            *
  36. * IKeyboardEvent object is created by a keyboard handler when a user presses   *
  37. * or releases a key.                                                           *
  38. *                                                                              *
  39. * Keyboard events are first dispatched to the window with the input focus,     *
  40. * such as an entry field with the input cursor.  If that window does not       *
  41. * process the keyboard event, the event is dispatched to the owner window of   *
  42. * the focus window.  The event continues to be dispatched to the next owner    *
  43. * window until a handler stops the processing or a window processes the        *
  44. * keystroke itself.  For example, an entry field processes character keys,     *
  45. * but it will not process a Tab key, so the Tab key is passed on to its owner  *
  46. * window.                                                                      *
  47. *******************************************************************************/
  48. public:
  49. /*------------------------ Constructor/Destructor ------------------------------
  50. | The only way to construct instances of this class is from an instance of     |
  51. | the IEvent class.                                                            |
  52. ------------------------------------------------------------------------------*/
  53.   IKeyboardEvent     ( IEvent& event );
  54. virtual
  55.  ~IKeyboardEvent     ( );
  56.  
  57. /*--------------------------------- Testing ------------------------------------
  58. | These functions should be called to determine the type of data stored in     |
  59. | the event:                                                                   |
  60. |   isCharacter        - Returns whether the event represents use of a data    |
  61. |                        key.                                                  |
  62. |   isScanCode         - Returns whether a hardware scan code is available.    |
  63. |   isVirtual          - Returns whether the event represents use of a         |
  64. |                        virtual key.                                          |
  65. |   isUpTransition     - Returns whether a previously pressed key is being     |
  66. |                        released.                                             |
  67. |   isRepeat           - Returns whether a key has been previously pressed     |
  68. |                        and is being held down.                               |
  69. |   isUncombined       - Returns whether this key is being pressed without     |
  70. |                        any other keys being pressed.                         |
  71. |   isShiftDown        - Returns whether the Shift key is being held down.     |
  72. |   isCtrlDown         - Returns whether the Ctrl key is being held down.      |
  73. |   isAltDown          - Returns whether the Alt key is being held down.       |
  74. |   isForComposite     - Returns whether the character is a dead key, such as  |
  75. |                        an accent, which is to be combined with the next      |
  76. |                        character.                                            |
  77. |   isComposite        - Returns whether the character is formed by combining  |
  78. |                        this key with the previous dead key.                  |
  79. |   isInvalidComposite - Returns whether the character is not valid to be      |
  80. |                        combined with the previous dead key.                  |
  81. ------------------------------------------------------------------------------*/
  82. Boolean
  83.   isCharacter        ( ) const,
  84.   isScanCode         ( ) const,
  85.   isVirtual          ( ) const,
  86.   isUpTransition     ( ) const,
  87.   isRepeat           ( ) const,
  88.   isUncombined       ( ) const,
  89.   isShiftDown        ( ) const,
  90.   isCtrlDown         ( ) const,
  91.   isAltDown          ( ) const,
  92.   isForComposite     ( ) const,
  93.   isComposite        ( ) const,
  94.   isInvalidComposite ( ) const;
  95.  
  96. /*-------------------------------- Accessors -----------------------------------
  97. | These functions provide means of querying values from instances of this      |
  98. | class:                                                                       |
  99. |   character      - Returns the character data of the key if it is a          |
  100. |                    single-byte character.  Before calling this function,     |
  101. |                    you should first verify that the event contains           |
  102. |                    character data by calling the isCharacter function.  The  |
  103. |                    mixedCharacter function should be used if double-byte     |
  104. |                    data is expected.                                         |
  105. |   mixedCharacter - Returns the character data of the key, whether it is      |
  106. |                    single- or double-byte character.  Before calling this    |
  107. |                    function, you should first verify that the event          |
  108. |                    contains character data by calling the isCharacter        |
  109. |                    function.                                                 |
  110. |   scanCode       - Returns the hardware scan code of the key.  Before        |
  111. |                    calling this function, you should first verify that the   |
  112. |                    event contains a scan code by calling the isScanCode      |
  113. |                    function.                                                 |
  114. |   VirtualKey     - Enumeration that lists the possible virtual keys that     |
  115. |                    can be returned from the virtualKey function.             |
  116. |   virtualKey     - Returns the virtual key code of the key.  Before calling  |
  117. |                    this function, you should first verify that the event     |
  118. |                    contains a virtual key code by calling the isVirtual      |
  119. |                    function.                                                 |
  120. |   repeatCount    - Returns the number of repeated keys combined into this    |
  121. |                    event.                                                    |
  122. ------------------------------------------------------------------------------*/
  123. char
  124.   character          ( ) const;
  125. IString
  126.   mixedCharacter     ( ) const;
  127. unsigned long
  128.   scanCode           ( ) const;
  129.  
  130. enum VirtualKey
  131. {
  132.   esc, tab, backTab, space, backSpace, enter, newLine,
  133.   shift, ctrl, altGraf, insert, deleteKey, home, end,
  134.   pageUp, pageDown, left, right, up, down,
  135.   capsLock, numLock, scrollLock, pause, sysRq, breakKey,
  136.   f2, f3, f4, f5, f6, f7, f8, f9, f11, f12,
  137.   f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24,
  138.   button1, button2, button3, endDrag,
  139.   firstDBCS, lastDBCS, firstUser, lastUser,
  140.   other
  141. };
  142.  
  143. VirtualKey
  144.   virtualKey         ( ) const;
  145.  
  146. unsigned long
  147.   repeatCount        ( ) const;
  148.  
  149. protected:
  150. /*------------------------------ Implementation --------------------------------
  151. | These static flags are used to test corresponding flags in the key event.    |
  152. |   ulCharacterFlag        - Used to implement the isCharacter check.          |
  153. |   ulScanCodeFlag         - Used to implement the isScanCode check.           |
  154. |   ulVirtualFlag          - Used to implement the isVirtual check.            |
  155. |   ulUpTransitionFlag     - Used to implement the isUpTransition check.       |
  156. |   ulRepeatFlag           - Used to implement the isRepeat check.             |
  157. |   ulUncombinedFlag       - Used to implement the isUncombined check.         |
  158. |   ulShiftFlag            - Used to implement the isShiftDown check.          |
  159. |   ulCtrlFlag             - Used to implement the isCtrlDown check.           |
  160. |   ulAltFlag              - Used to implement the isAltDown check.            |
  161. |   ulForCompositeFlag     - Used to implement the isForComposite check.       |
  162. |   ulCompositeFlag        - Used to implement the isComposite check.          |
  163. |   ulInvalidCompositeFlag - Used to implement the isInvalidComposite check.   |
  164. ------------------------------------------------------------------------------*/
  165. static const unsigned long
  166.   ulCharacterFlag,
  167.   ulScanCodeFlag,
  168.   ulVirtualFlag,
  169.   ulUpTransitionFlag,
  170.   ulRepeatFlag,
  171.   ulUncombinedFlag,
  172.   ulShiftFlag,
  173.   ulCtrlFlag,
  174.   ulAltFlag,
  175.   ulForCompositeFlag,
  176.   ulCompositeFlag,
  177.   ulInvalidCompositeFlag;
  178. }; // IKeyboardEvent
  179.  
  180. /*----------------------------------------------------------------------------*/
  181. /* Resume compiler default packing.                                           */
  182. /*----------------------------------------------------------------------------*/
  183. #pragma pack()
  184.  
  185. /*----------------------------- Inline Functions -----------------------------*/
  186. #ifndef I_NO_INLINES
  187.   #include <ikeyevt.inl>
  188. #endif
  189.  
  190. #endif /* _IKEYEVT_ */
  191.