MeVisLab Toolbox Reference
ManagedKeyboardShortcut.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2014, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef MANAGED_KEYBOARD_SHORTCUT_H
14 #define MANAGED_KEYBOARD_SHORTCUT_H
15 
16 #include "SoInteraction.h"
17 
18 #include <ThirdPartyWarningsDisable.h>
19 #include <Inventor/events/SoKeyboardEvent.h>
20 
21 #include <map>
22 #include <ThirdPartyWarningsRestore.h>
23 
27 {
28 public:
30  ManagedKeyboardShortcut() : _modifiers(0), _key(SoKeyboardEvent::ANY) {}
31 
33  ManagedKeyboardShortcut(int modifiers, SoKeyboardEvent::Key key) : _modifiers(modifiers), _key(key) {}
34 
36  bool matches(int modifiers, SoKeyboardEvent::Key key) const;
37 
39  bool isValid() const;
40 
42  int getModifiers() const { return _modifiers; }
43 
45  SoKeyboardEvent::Key getKey() const { return _key; }
46 
48  std::string toString() const;
49 
54  static ManagedKeyboardShortcut fromString(const std::string& s);
55 
56 
57 private:
58 
60  int _modifiers;
61  SoKeyboardEvent::Key _key;
62 
63  static void _populateKeyMap();
64  static void _setKeyMapEntry(const char* cname, SoKeyboardEvent::Key key);
65 
66  static std::map<std::string, SoKeyboardEvent::Key> _keyCodeMap;
67  static std::map<SoKeyboardEvent::Key, std::string> _keyNameMap;
68 
70  static SoKeyboardEvent::Key _getKeyCodeForName (const std::string& keyName);
72  static std::string _getKeyNameForCode (SoKeyboardEvent::Key keyCode);
73 
77  static bool decodeKeyString (const std::string& keyCombo, int& modifiers, SoKeyboardEvent::Key& nKey);
78 };
79 
80 #endif // __ManagedKeyboardShortcut_H
@ ANY
Special constant for any key.
Definition: SoKeyGrabber.h:26
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
ManagedActionTrigger is a base class for all triggers of managed interactions.
Class ManagedKeyboardShortcut encapsulates the combination of modifier keys and another key that acti...
static ManagedKeyboardShortcut fromString(const std::string &s)
Creates a shortcut from a string.
std::string toString() const
ManagedKeyboardShortcut(int modifiers, SoKeyboardEvent::Key key)
Creates shortcut with given key and key modifiers; see SoInteraction for possible key modifiers.
bool matches(int modifiers, SoKeyboardEvent::Key key) const
ManagedKeyboardShortcut()
The default constructor creates an invalid shortcut.
SoKeyboardEvent::Key getKey() const