HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DM_ModifierKeys.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: DM_ModifierKeys.h ( DM Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __DM_ModifierKeys__
12 #define __DM_ModifierKeys__
13 
14 #include "DM_API.h"
15 
16 #include <UT/UT_ValArray.h>
17 
18 class UI_Event;
19 class UT_WorkBuffer;
20 
21 /// @brief Definition of a modifier key context
22 ///
23 /// A modifier key context consists of a list of modifier key states, each
24 /// mapping to an integer identifier. A UI_Event can then be mapped to the
25 /// appropriate identifier by its myAltFlags member.
27 {
28 public:
29  /// Returns the identifier for the modifier matching the event, if any.
30  /// In the event of no matching modifier, a value of -1 is returned.
31  int findMatch(const UI_Event *event) const;
32 
33  /// Returns whether the event matches the specified modifier identifier.
34  /// An event with multiple modifier keys set can match multiple modifier
35  /// identifiers when the matched modifiers are proper subsets.
36  bool match(const UI_Event *event, int modifier_id) const;
37 
38  /// Append a modifier. The order these modifiers are appended is what
39  /// determines their relative priorities. When modifier_key_flags is
40  /// supplied, that value overrides any loaded from the configuration files.
41  ///
42  /// TODO: Specify whether the modifier can be combined with other modifiers
43  /// or must stand alone.
44  void append(int modifier_id);
45  void append(int modifier_id, short modifier_key_flags);
46  void append(const DM_ModifierKeys &src_context);
47 
48  /// Call after appending any modifier(s).
49  void update();
50 
51  void clear()
52  { myModifiers.clear(); }
53  exint entries() const
54  { return myModifiers.entries(); }
55 
56  /// Query the description string for the specified modifier. Returns
57  /// false if the modifier is not found or is in conflict with a higher
58  /// priority modifier.
59  bool resolveDescription(int modifier_id,
60  UT_WorkBuffer &buffer) const;
61 
62  /// Register a new modifier token and return the corresponding identifier
63  /// to use in instances of this class.
64  static int registerModifier(const char *modifier_token);
65 
66 private:
67  struct ModifierInfo
68  {
69  ModifierInfo(int id, int key_flags) : myId(id), myKeyFlags(key_flags)
70  {}
71 
72  int myId;
73  int myKeyFlags;
74  };
75 
76  UT_ValArray<ModifierInfo> myModifiers;
77 };
78 
79 #endif
exint entries() const
GLuint buffer
Definition: glcorearb.h:659
struct _cl_event * event
Definition: glcorearb.h:2960
#define DM_API
Definition: DM_API.h:10
int64 exint
Definition: SYS_Types.h:115
Definition of a modifier key context.