2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FUi_KeyEventManager.h
19 * @brief This is the header file for the _KeyEventManager class.
21 * This header file contains the declarations of the _KeyEventManager class. @n.
23 #ifndef _FUI_KEY_EVENT_MANAGER_H_
24 #define _FUI_KEY_EVENT_MANAGER_H_
27 #include <FBaseObject.h>
28 #include <FBaseErrors.h>
29 #include <FOspConfig.h>
30 #include <FBaseColLinkedListT.h>
31 #include <FBaseColHashMapT.h>
32 #include "FUi_Types.h"
33 #include "FUi_IKeyEventListener.h"
35 // Forward declarations
36 namespace Tizen { namespace Ui
41 namespace Tizen {namespace Ui
44 * @class _KeyEventManager
45 * @brief This class manages the key events that are fired within this application's context.
48 * The _KeyEventManager listens to all key events that are generated within this application's context.
50 class _KeyEventManager
51 : public Tizen::Base::Object
54 static void Initialize(void);
57 * Returns the pointer to the current key event manager.
60 * @return The current _KeyEventManager instance
62 static _KeyEventManager* GetInstance(void);
65 * Adds an application-wide _IKeyEventListener instance. @n
66 * The added listeners gets notified when a key is pressed, released, or long
67 * pressed within this application's context.
70 * @param[in] listener The event listener to add
71 * @remarks The listener is called after the key event is delivered
72 * to the focused Control's key event listeners, but before the
73 * key event is passed onto the focused Control itself. @n
74 * Moreover, if the key needs to be consumed by Control itself,
75 * the added listeners will not be notified.
76 * @see Tizen::Ui::_IKeyEventListener::OnKeyPressed()
77 * @see Tizen::Ui::_IKeyEventListener::OnKeyReleased()
78 * @see RemoveKeyEventListener ()
80 void AddKeyEventListener(const _IKeyEventListener& listener);
84 * Removes the _IKeyEventListener instance. @n
85 * The removed listener is not notified even when the key events are fired.
88 * @return listener The current application-wide key event listener to remove
89 * @see AddKeyEventListener()
91 void RemoveKeyEventListener(const _IKeyEventListener& listener);
94 * Returns the list of key event listeners. @n
97 * @return _IKeyEventListener
99 Tizen::Base::Collection::LinkedListT<Tizen::Ui::_IKeyEventListener*>* GetKeyEventListener(void) const;
101 _Control* GetCapturingControl(_KeyCode keyCode) const;
103 void SetCapturingControl(const _Control& control, _KeyCode keyCode, bool captureAllowed);
105 static void InitializeInstance(void);
106 static void ReleaseInstance(void);
110 * This is the default constructor for this class.
114 _KeyEventManager(void);
117 * This is the destructor for this class.
121 virtual ~_KeyEventManager(void);
124 * This is the copy constructor for this class.
126 _KeyEventManager(const _KeyEventManager&);
129 * This is the assignment operator for this class.
131 _KeyEventManager& operator =(const _KeyEventManager&);
134 static _KeyEventManager* __pInstance;
135 Tizen::Base::Collection::LinkedListT<Tizen::Ui::_IKeyEventListener*>* __pKeyEventListeners;
136 _IKeyEventListener* __pKeyEventListener;
137 Tizen::Base::Collection::HashMapT<_KeyCode, _ControlHandle>* __pKeyCapturingMap;
138 }; // _KeyEventManager
142 #endif // _FUI_KEY_EVENT_MANAGER_H_