keycode.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:7k
- /*
- * keycode.h
- *
- * Windows keyboard input code.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: keycode.h,v $
- * Revision 1.15 1999/03/10 03:49:52 robertj
- * More documentation adjustments.
- *
- * Revision 1.14 1999/03/09 08:01:48 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.13 1999/02/16 08:08:45 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.12 1998/09/23 06:24:03 robertj
- * Added open source copyright license.
- *
- * Revision 1.11 1995/11/20 11:03:10 robertj
- * Fixed compatibility the resource compiler and editor.
- *
- * Revision 1.10 1995/03/14 12:41:39 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.9 1994/12/15 12:47:15 robertj
- * Documentation.
- *
- * Revision 1.8 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.7 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.6 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.5 1994/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * Revision 1.4 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.3 1993/12/16 03:30:24 robertj
- * Removed usage of enum as bitmask, GCC doesn't like it.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #ifdef __GNUC__
- #pragma interface
- #endif
- /**A class representing a key from the keyboard. This virtualises the key into
- a platform independent form that removes as far as possible the variations
- in keyboards and layouts.
- Note that not all key values and modifiers may be generated by all target
- platforms.
- */
- class PKeyCode : public PObject
- {
- PCLASSINFO(PKeyCode, PObject);
- public:
- /**All possible keyboard values (codes representing each key on a
- "normalised" keyboard).
- */
- enum Value {
- NullValue, // No value
- LeftButton, // Left mouse button
- RightButton, // Right mouse button
- MiddleButton, // Middle mouse button
- A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,
- // Standard keyboard keys for alphabetic characters.
- KB0, KB1, KB2, KB3, KB4, KB5, KB6, KB7, KB8, KB9,
- // Standard number keys in main part of the keyboard.
- KP0, KP1, KP2, KP3, KP4, KP5, KP6, KP7, KP8, KP9,
- // Keypad number keys.
- Add, // Add key on the keypad.
- Subtract, // Subtract key on the keypad.
- Multiply, // Multiply key on the keypad.
- Divide, // Divide key on the keypad.
- Separator, // Separator key on the keypad, typically a comma.
- Decimal, // Decimal point key on the keypad, typically a dot.
- F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
- F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
- // Function keys.
- Up, Down, Left, Right, // Arrow keys.
- PageUp, PageDown, Home, End, // Standard movement keys.
- Insert, Delete, Undo, Cut, Copy, Paste, Clear, Cancel, Help, Quit,
- // Special function keys.
- BackSpace, Tab, Return, Escape, Space,
- // Miscellaneous keys.
- CapsLockKey, ShiftKey, ControlKey, Altkey,
- CommandKey, OptionKey, MetaKey,
- // Modifier keys.
- Oem1, Oem2, Oem3, Oem4, Oem5, Oem6, Oem7, Oem8, Oem9, Oem10,
- Oem11, Oem12, Oem13, Oem14, Oem15, Oem16, Oem17, Oem18, Oem19, Oem20,
- Oem21, Oem22, Oem23, Oem24, Oem25, Oem26, Oem27, Oem28, Oem29, Oem30,
- Oem31, Oem32, Oem33, Oem34, Oem35, Oem36, Oem37, Oem38, Oem39,
- // Arbitrary keys, not normalised.
- LastCode
- };
- /**All the possible modifiers to the key values specified above. The
- modifiers Accelerator1 and Accelerator2 are normalised menu bar
- accelerators for the different platforms, e.g. for the Macintosh
- Accelerator1 if the Command key, which does not exist on the IBM-PC so
- it has Accelerator1 set to Control. An application can thus use
- Accelerator1 for its menu accelerator code and get the "correct" code
- for the platform used.
- */
- enum Modifiers {
- /// No modifers present.
- NoModifier = 0x0000,
- /// Either shift key.
- Shift = 0x0001,
- /// The control key.
- Control = 0x0002,
- /// The Alt or Extend key.
- Alt = 0x0004,
- /// The quadraphogly key on the Macintosh.
- Command = 0x0008,
- /// The option key on the Macintosh.
- Option = 0x0010,
- /// The CAPS LOCK key.
- CapsLock = 0x0020,
- /// The primary accelerator key.
- Accelerator1 = 0x0040,
- /// The secondary accelerator key.
- Accelerator2 = 0x0080,
- /// The left mouse button.
- LeftMouseButton = 0x1000,
- /// The right mouse button.
- RightMouseButton = 0x2000,
- /// The middle mouse button.
- MiddleMouseButton = 0x4000
- };
- /** Create a new key code representation. */
- PKeyCode(
- Value theValue = NullValue, /// Value of key code.
- int theMods = NoModifier /// Modifiers present for key code.
- );
- /**@name Overrides from class PObject */
- /** Create a copy of the key code. */
- virtual PObject * Clone() const;
- /**Determine the relative rank of the key codes.
- @return
- #EqualTo# if the key value and modifiers are the same,
- #LessThan# if the key codes are the same but the modifier is
- different and #GreaterThan# if they are both different.
- */
- virtual Comparison Compare(
- const PObject & obj /// Other key code to compare against.
- ) const;
- /**Get the value part of the key code.
- @return
- value of key code.
- */
- Value GetValue() const;
- /**Get the modifiers part of the key code.
- @return
- modifiers of key code.
- */
- int GetModifiers() const;
- /**Determine if any of the the specified modifier(s) are set. This would
- usually be used with a single modifier, but is not limited to it.
- @return
- TRUE if any of the modifiers in the #modmask# are set.
- */
- BOOL IsModifier(
- int modmask /// Mask of modifiers to check for.
- ) const;
- protected:
- Value value;
- int modifiers;
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////