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

SoKeyboardEvent.h
1 #ifndef COIN_SOKEYBOARDEVENT_H
2 #define COIN_SOKEYBOARDEVENT_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) by Kongsberg Oil & Gas Technologies.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Kongsberg Oil & Gas Technologies
18  * about acquiring a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/events/SoButtonEvent.h>
28 
29 // Avoid problem with Microsoft Visual C++ Win32 API headers (yes,
30 // they actually #define DELETE in their WINNT.H header file).
31 #ifdef DELETE
32 #define SOKEYBOARDEVENT_UNDEF_DELETE
33 #undef DELETE
34 #endif // DELETE
35 
36 
37 #define SO_KEY_PRESS_EVENT(EVENT, KEY) \
38  (SoKeyboardEvent::isKeyPressEvent(EVENT, SoKeyboardEvent::KEY))
39 
40 #define SO_KEY_RELEASE_EVENT(EVENT, KEY) \
41  (SoKeyboardEvent::isKeyReleaseEvent(EVENT, SoKeyboardEvent::KEY))
42 
43 
44 class COIN_DLL_API SoKeyboardEvent : public SoButtonEvent {
45  typedef SoButtonEvent inherited;
46  SO_EVENT_HEADER();
47 
48 public:
49  static void initClass(void);
50 
51  SoKeyboardEvent(void);
52  virtual ~SoKeyboardEvent();
53 
54  enum Key {
55  ANY = 0,
56  UNDEFINED = 1,
57 
58  LEFT_SHIFT = 0xffe1, RIGHT_SHIFT, LEFT_CONTROL, RIGHT_CONTROL,
59  LEFT_ALT = 0xffe9, RIGHT_ALT,
60 
61  NUMBER_0 = 0x0030, NUMBER_1, NUMBER_2, NUMBER_3, NUMBER_4, NUMBER_5,
62  NUMBER_6, NUMBER_7, NUMBER_8, NUMBER_9,
63 
64  A = 0x0061, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T,
65  U, V, W, X, Y, Z,
66 
67  HOME = 0xff50, LEFT_ARROW, UP_ARROW, RIGHT_ARROW, DOWN_ARROW,
68  PAGE_UP, PAGE_DOWN, END,
69  PRIOR = 0xff55, NEXT,
70 
71  PAD_ENTER = 0xff8d,
72  PAD_F1 = 0xff91, PAD_F2, PAD_F3, PAD_F4,
73  PAD_0 = 0xff9e, PAD_1 = 0xff9c, PAD_2 = 0xff99, PAD_3 = 0xff9b,
74  PAD_4 = 0xff96, PAD_5 = 0xff9d, PAD_6 = 0xff98, PAD_7 = 0xff95,
75  PAD_8 = 0xff97, PAD_9 = 0xff9a,
76  PAD_ADD = 0xffab, PAD_SUBTRACT = 0xffad,
77  PAD_MULTIPLY = 0xffaa, PAD_DIVIDE = 0xffaf,
78  PAD_SPACE = 0xff8d, PAD_TAB = 0xff89,
79  PAD_INSERT = 0xff9e, PAD_DELETE = 0xff9f, PAD_PERIOD = 0xff9f,
80 
81  F1 = 0xffbe, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
82 
83  BACKSPACE = 0xff08, TAB = 0xff09,
84  RETURN = 0xff0d, ENTER = 0xff0d,
85  PAUSE = 0xff13, SCROLL_LOCK = 0xff14,
86  ESCAPE = 0xff1b, DELETE = 0xffff, KEY_DELETE = DELETE,
87  PRINT = 0xff61, INSERT = 0xff63,
88  NUM_LOCK = 0xff7f, CAPS_LOCK = 0xffe5, SHIFT_LOCK = 0xffe6,
89 
90  SPACE = 0x0020, APOSTROPHE = 0x0027,
91  COMMA = 0x002c, MINUS = 0x002d, PERIOD = 0x002e, SLASH = 0x002f,
92  SEMICOLON = 0x003b, EQUAL = 0x003d,
93  BRACKETLEFT = 0x005b, BACKSLASH = 0x005c,
94  BRACKETRIGHT = 0x005d, GRAVE = 0x0060
95  };
96 
97  void setKey(Key key);
98  Key getKey(void) const;
99 
100  void setPrintableCharacter(const char c);
101  char getPrintableCharacter(void) const;
102 
103  static SbBool isKeyPressEvent(const SoEvent * e, Key whichKey);
104  static SbBool isKeyReleaseEvent(const SoEvent * e, Key whichKey);
105 
106  static SbBool enumToString(Key enumval, SbString & stringrep);
107 
108 private:
109  Key key;
110  char printable;
111  char isprintableset;
112 
113 }; // SoKeyboardEvent
114 
115 // Avoid problem with Microsoft Win32 API headers (see above). Define
116 // DELETE back to its value in the MSVC header file.
117 //
118 // FIXME: we shouldn't uncritically trust this value to come from the
119 // MSVC headers, but rather check in the block at the top to see that
120 // it matches the value we believe it does. Alternatively, we could
121 // just don't bother to set it back -- it seems quite unlikely that
122 // this would break any client code, but if so, it would be a simple
123 // fix on the client side to get around it -- just rearrange
124 // headers. 20040629 mortene.
125 #ifdef SOKEYBOARDEVENT_UNDEF_DELETE
126 #define DELETE (0x00010000L)
127 #undef SOKEYBOARDEVENT_UNDEF_DELETE
128 #endif // SOKEYBOARDEVENT_UNDEF_DELETE
129 
130 #endif // !COIN_SOKEYBOARDEVENT_H
The SoButtonEvent class is the base class for all button events.The event classes which results from ...
Definition: SoButtonEvent.h:31
static SbBool enumToString(State enumval, SbString &stringrep)
Definition: SoButtonEvent.cpp:120
Key
Definition: SoKeyboardEvent.h:54
static void initClass(void)
Definition: SoButtonEvent.cpp:65
The SoKeyboardEvent class contains information about keyboard interaction.When the user presses any k...
Definition: SoKeyboardEvent.h:44
The SoEvent class is the base class for all Coin events.Coin contains its own set of event classes...
Definition: SoEvent.h:34
The SbString class is a string class with convenience functions for string operations.This is the class used for storing and working with character strings. It automatically takes care of supporting all the "bookkeeping" tasks usually associated with working with character strings, like memory allocation and deallocation etc.
Definition: SbString.h:42

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

Generated for Coin by Doxygen 1.8.14.