Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

# SoKeyboardEvent.h

    00001 #ifndef COIN_SOKEYBOARDEVENT_H
    00002 #define COIN_SOKEYBOARDEVENT_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <Inventor/events/SoButtonEvent.h>
    00028
    00029 // Avoid problem with Microsoft Visual C++ Win32 API headers (yes,
    00030 // they actually #define DELETE in their WINNT.H header file).
    00031 #ifdef DELETE
    00032 #define SOKEYBOARDEVENT_UNDEF_DELETE
    00033 #undef DELETE
    00034 #endif // DELETE
    00035
    00036
    00037 #define SO_KEY_PRESS_EVENT(EVENT, KEY) \
    00038  (SoKeyboardEvent::isKeyPressEvent(EVENT, SoKeyboardEvent::KEY))
    00039
    00040 #define SO_KEY_RELEASE_EVENT(EVENT, KEY) \
    00041  (SoKeyboardEvent::isKeyReleaseEvent(EVENT, SoKeyboardEvent::KEY))
    00042
    00043
    00044 class COIN_DLL_API SoKeyboardEvent : public SoButtonEvent {
    00045   typedef SoButtonEvent inherited;
    00046
    00047   SO_EVENT_HEADER();
    00048
    00049 public:
    00050   enum Key {
    00051     ANY = 0,
    00052     UNDEFINED = 1,
    00053
    00054     LEFT_SHIFT = 0xffe1, RIGHT_SHIFT, LEFT_CONTROL, RIGHT_CONTROL,
    00055     LEFT_ALT = 0xffe9, RIGHT_ALT,
    00056
    00057     NUMBER_0 = 0x0030, NUMBER_1, NUMBER_2, NUMBER_3, NUMBER_4, NUMBER_5,
    00058     NUMBER_6, NUMBER_7, NUMBER_8, NUMBER_9,
    00059
    00060     A = 0x0061, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T,
    00061     U, V, W, X, Y, Z,
    00062
    00063     HOME = 0xff50, LEFT_ARROW, UP_ARROW, RIGHT_ARROW, DOWN_ARROW,
    00064     PAGE_UP, PAGE_DOWN, END,
    00065     PRIOR = 0xff55, NEXT,
    00066
    00067     PAD_ENTER = 0xff8d,
    00068     PAD_F1 = 0xff91, PAD_F2, PAD_F3, PAD_F4,
    00069     PAD_0 = 0xff9e, PAD_1 = 0xff9c, PAD_2 = 0xff99, PAD_3 = 0xff9b,
    00070     PAD_4 = 0xff96, PAD_5 = 0xff9d, PAD_6 = 0xff98, PAD_7 = 0xff95,
    00071     PAD_8 = 0xff97, PAD_9 = 0xff9a,
    00072     PAD_ADD = 0xffab, PAD_SUBTRACT = 0xffad,
    00073     PAD_MULTIPLY = 0xffaa, PAD_DIVIDE = 0xffaf,
    00074     PAD_SPACE = 0xff8d, PAD_TAB = 0xff89,
    00075     PAD_INSERT = 0xff9e, PAD_DELETE = 0xff9f, PAD_PERIOD = 0xff9f,
    00076
    00077     F1 = 0xffbe, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
    00078
    00079     BACKSPACE = 0xff08, TAB = 0xff09,
    00080     RETURN = 0xff0d, ENTER = 0xff0d,
    00081     PAUSE = 0xff13, SCROLL_LOCK = 0xff14,
    00082     ESCAPE = 0xff1b, DELETE = 0xffff, KEY_DELETE = DELETE,
    00083     PRINT = 0xff61, INSERT = 0xff63,
    00084     NUM_LOCK = 0xff7f, CAPS_LOCK = 0xffe5, SHIFT_LOCK = 0xffe6,
    00085
    00086     SPACE = 0x0020, APOSTROPHE = 0x0027,
    00087     COMMA = 0x002c, MINUS = 0x002d, PERIOD = 0x002e, SLASH = 0x002f,
    00088     SEMICOLON = 0x003b, EQUAL = 0x003d,
    00089     BRACKETLEFT = 0x005b, BACKSLASH = 0x005c,
    00090     BRACKETRIGHT = 0x005d, GRAVE = 0x0060
    00091   };
    00092
    00093   SoKeyboardEvent(void);
    00094   virtual ~SoKeyboardEvent();
    00095
    00096   void setKey(SoKeyboardEvent::Key key);
    00097   SoKeyboardEvent::Key getKey(void) const;
    00098
    00099   void setPrintableCharacter(const char c);
    00100   char getPrintableCharacter(void) const;
    00101
    00102   static SbBool isKeyPressEvent(const SoEvent * e,
    00103                                 SoKeyboardEvent::Key whichKey);
    00104   static SbBool isKeyReleaseEvent(const SoEvent * e,
    00105                                   SoKeyboardEvent::Key whichKey);
    00106
    00107   static void initClass(void);
    00108
    00109 private:
    00110   Key key;
    00111   char printable;
    00112   char isprintableset;
    00113 };
    00114
    00115
    00116 // Avoid problem with Microsoft Win32 API headers (see above). Define
    00117 // DELETE back to its value in the MSVC header file.
    00118 #ifdef SOKEYBOARDEVENT_UNDEF_DELETE
    00119 #define DELETE (0x00010000L)
    00120 #undef SOKEYBOARDEVENT_UNDEF_DELETE
    00121 #endif // SOKEYBOARDEVENT_UNDEF_DELETE
    00122
    00123 #endif // !COIN_SOKEYBOARDEVENT_H