00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Edward Lam 00008 * Side Effects Software Inc 00009 * 123 Front Street West, Suite 1401 00010 * Toronto, Ontario 00011 * Canada M5J 2M2 00012 * 416-504-9876 00013 * 00014 * NAME: UI_HotkeyHelper.h (UI Library, C++) 00015 * 00016 * COMMENTS: Helper class for hotkey handling 00017 */ 00018 00019 #ifndef __UI_HOTKEYHELPER_H__ 00020 #define __UI_HOTKEYHELPER_H__ 00021 00022 #include "UI_API.h" 00023 #include <UT/UT_PtrProxy.h> 00024 #include <UT/UT_SymbolTable.h> 00025 #include "UI_Object.h" 00026 00027 class UI_Event; 00028 00029 /// Hotkey handler method. Returns true if successfully consumed. 00030 typedef bool (UI_Object::*UI_HotkeyMethod)(UI_Event *); 00031 00032 00033 /// The UI_HotkeyHelper class allows one to maintain a table of hotkeys and 00034 /// their associated handler functions (of type UI_HotkeyMethod) so that we 00035 /// can easily perform functions like dispatching hotkey handlers as well as 00036 /// testing to see if a hotkey is going to be handled without invoking the 00037 /// handler. 00038 class UI_API UI_HotkeyHelper 00039 { 00040 public: 00041 struct Entry 00042 { 00043 const char * mySymbol; 00044 UI_HotkeyMethod myMethod; 00045 }; 00046 00047 /// Default constructor 00048 UI_HotkeyHelper(UI_Object *client); 00049 /// Construct using an array of hotkey entries terminated by NULL mySymbol. 00050 UI_HotkeyHelper(UI_Object *client, const Entry *hotkey_entries); 00051 /// Destructor 00052 virtual ~UI_HotkeyHelper(); 00053 00054 /// Adds an array of hotkey entries terminated by NULL mySymbol. 00055 void addHotkeys(const Entry *hotkey_entries); 00056 /// Add a single hotkey entry 00057 void addHotkey(const Entry &entry); 00058 /// Remove a hotkey entry 00059 void removeHotkey(const char *symbol); 00060 00061 /// Invoke the handler for the given UI hotkey event. 00062 /// Returns true if consumed, false otherwise. 00063 bool processHotkey(UI_Event *event); 00064 00065 /// Will we handle the given UI hotkey symbol? 00066 bool willProcessHotkey(UI_Event *event); 00067 00068 private: // methods 00069 00070 UI_HotkeyHelper(const UI_HotkeyHelper ©); // not yet done 00071 UI_HotkeyHelper & operator=(const UI_HotkeyHelper ©); // not yet done 00072 00073 private: // data 00074 00075 UT_RefProxy<UI_Object> myClient; 00076 UT_SymbolTable myTable; 00077 00078 }; 00079 00080 #endif // __UI_HOTKEYHELPER_H__
1.5.9