Coin Logo http://www.sim.no/
http://www.coin3d.org/

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) by Kongsberg Oil & Gas Technologies.
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 Kongsberg Oil & Gas Technologies
00018  *  about acquiring a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
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   SO_EVENT_HEADER();
00047 
00048 public:
00049   static void initClass(void);
00050 
00051   SoKeyboardEvent(void);
00052   virtual ~SoKeyboardEvent();
00053 
00054   enum Key {
00055     ANY = 0,
00056     UNDEFINED = 1,
00057 
00058     LEFT_SHIFT = 0xffe1, RIGHT_SHIFT, LEFT_CONTROL, RIGHT_CONTROL,
00059     LEFT_ALT = 0xffe9, RIGHT_ALT,
00060 
00061     NUMBER_0 = 0x0030, NUMBER_1, NUMBER_2, NUMBER_3, NUMBER_4, NUMBER_5,
00062     NUMBER_6, NUMBER_7, NUMBER_8, NUMBER_9,
00063 
00064     A = 0x0061, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T,
00065     U, V, W, X, Y, Z,
00066 
00067     HOME = 0xff50, LEFT_ARROW, UP_ARROW, RIGHT_ARROW, DOWN_ARROW,
00068     PAGE_UP, PAGE_DOWN, END,
00069     PRIOR = 0xff55, NEXT,
00070 
00071     PAD_ENTER = 0xff8d,
00072     PAD_F1 = 0xff91, PAD_F2, PAD_F3, PAD_F4,
00073     PAD_0 = 0xff9e, PAD_1 = 0xff9c, PAD_2 = 0xff99, PAD_3 = 0xff9b,
00074     PAD_4 = 0xff96, PAD_5 = 0xff9d, PAD_6 = 0xff98, PAD_7 = 0xff95,
00075     PAD_8 = 0xff97, PAD_9 = 0xff9a,
00076     PAD_ADD = 0xffab, PAD_SUBTRACT = 0xffad,
00077     PAD_MULTIPLY = 0xffaa, PAD_DIVIDE = 0xffaf,
00078     PAD_SPACE = 0xff8d, PAD_TAB = 0xff89,
00079     PAD_INSERT = 0xff9e, PAD_DELETE = 0xff9f, PAD_PERIOD = 0xff9f,
00080 
00081     F1 = 0xffbe, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
00082 
00083     BACKSPACE = 0xff08, TAB = 0xff09,
00084     RETURN = 0xff0d, ENTER = 0xff0d,
00085     PAUSE = 0xff13, SCROLL_LOCK = 0xff14,
00086     ESCAPE = 0xff1b, DELETE = 0xffff, KEY_DELETE = DELETE,
00087     PRINT = 0xff61, INSERT = 0xff63,
00088     NUM_LOCK = 0xff7f, CAPS_LOCK = 0xffe5, SHIFT_LOCK = 0xffe6,
00089 
00090     SPACE = 0x0020, APOSTROPHE = 0x0027,
00091     COMMA = 0x002c, MINUS = 0x002d, PERIOD = 0x002e, SLASH = 0x002f,
00092     SEMICOLON = 0x003b, EQUAL = 0x003d,
00093     BRACKETLEFT = 0x005b, BACKSLASH = 0x005c,
00094     BRACKETRIGHT = 0x005d, GRAVE = 0x0060
00095   };
00096 
00097   void setKey(Key key);
00098   Key getKey(void) const;
00099 
00100   void setPrintableCharacter(const char c);
00101   char getPrintableCharacter(void) const;
00102 
00103   static SbBool isKeyPressEvent(const SoEvent * e, Key whichKey);
00104   static SbBool isKeyReleaseEvent(const SoEvent * e, Key whichKey);
00105 
00106   static SbBool enumToString(Key enumval, SbString & stringrep);
00107 
00108 private:
00109   Key key;
00110   char printable;
00111   char isprintableset;
00112 
00113 }; // SoKeyboardEvent
00114 
00115 // Avoid problem with Microsoft Win32 API headers (see above). Define
00116 // DELETE back to its value in the MSVC header file.
00117 //
00118 // FIXME: we shouldn't uncritically trust this value to come from the
00119 // MSVC headers, but rather check in the block at the top to see that
00120 // it matches the value we believe it does. Alternatively, we could
00121 // just don't bother to set it back -- it seems quite unlikely that
00122 // this would break any client code, but if so, it would be a simple
00123 // fix on the client side to get around it -- just rearrange
00124 // headers. 20040629 mortene.
00125 #ifdef SOKEYBOARDEVENT_UNDEF_DELETE
00126 #define DELETE (0x00010000L)
00127 #undef SOKEYBOARDEVENT_UNDEF_DELETE
00128 #endif // SOKEYBOARDEVENT_UNDEF_DELETE
00129 
00130 #endif // !COIN_SOKEYBOARDEVENT_H

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated for Coin by Doxygen 1.7.5.1.