HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UI_HotkeyHelper.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: UI_HotkeyHelper.h (UI Library, C++)
7  *
8  * COMMENTS: Helper class for hotkey handling
9  */
10 
11 #ifndef __UI_HOTKEYHELPER_H__
12 #define __UI_HOTKEYHELPER_H__
13 
14 #include "UI_API.h"
15 #include <UT/UT_PtrProxy.h>
16 #include <UT/UT_StringMap.h>
17 #include "UI_Object.h"
18 
19 class UI_Event;
20 
21 /// Hotkey handler method. Returns true if successfully consumed.
22 typedef bool (UI_Object::*UI_HotkeyMethod)(UI_Event *);
23 
24 
25 /// The UI_HotkeyHelper class allows one to maintain a table of hotkeys and
26 /// their associated handler functions (of type UI_HotkeyMethod) so that we
27 /// can easily perform functions like dispatching hotkey handlers as well as
28 /// testing to see if a hotkey is going to be handled without invoking the
29 /// handler.
31 {
32 public:
33  struct Entry
34  {
35  const char * mySymbol;
37  };
38 
39  /// Default constructor
40  UI_HotkeyHelper(UI_Object *client);
41  /// Construct using an array of hotkey entries terminated by NULL mySymbol.
42  UI_HotkeyHelper(UI_Object *client, const Entry *hotkey_entries);
43  /// Destructor
44  virtual ~UI_HotkeyHelper();
45 
46  /// Adds an array of hotkey entries terminated by NULL mySymbol.
47  void addHotkeys(const Entry *hotkey_entries);
48  /// Add a single hotkey entry
49  void addHotkey(const Entry &entry);
50  /// Remove a hotkey entry
51  void removeHotkey(const char *symbol);
52 
53  /// Invoke the handler for the given UI hotkey event.
54  /// Returns true if consumed, false otherwise.
55  bool processHotkey(UI_Event *event);
56 
57  /// Will we handle the given UI hotkey symbol?
58  bool willProcessHotkey(UI_Event *event);
59 
60 private: // methods
61 
62  UI_HotkeyHelper(const UI_HotkeyHelper &copy); // not yet done
63  UI_HotkeyHelper & operator=(const UI_HotkeyHelper &copy); // not yet done
64 
65 private: // data
66 
67  UT_RefProxy<UI_Object> myClient;
69 
70 };
71 
72 #endif // __UI_HOTKEYHELPER_H__
bool(UI_Object::* UI_HotkeyMethod)(UI_Event *)
Hotkey handler method. Returns true if successfully consumed.
UI_HotkeyMethod myMethod
struct _cl_event * event
Definition: glcorearb.h:2960
const char * mySymbol
#define UI_API
Definition: UI_API.h:10