Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUi_KeyEventManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17 /**
18  * @file                FUi_KeyEventManager.h
19  * @brief               This is the header file for the _KeyEventManager class.
20  *
21  * This header file contains the declarations of the _KeyEventManager class. @n.
22  */
23 #ifndef _FUI_KEY_EVENT_MANAGER_H_
24 #define _FUI_KEY_EVENT_MANAGER_H_
25
26 // Includes
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"
34
35 // Forward declarations
36 namespace Tizen { namespace Ui
37 {
38 class Control;
39 } }
40
41 namespace Tizen {namespace Ui
42 {
43 /**
44  * @class       _KeyEventManager
45  * @brief       This class manages the key events that are fired within this application's context.
46  * @since       2.0
47  *
48  * The _KeyEventManager listens to all key events that are generated within this application's context.
49  */
50 class _KeyEventManager
51         : public Tizen::Base::Object
52 {
53 public:
54         static void Initialize(void);
55
56         /**
57          * Returns the pointer to the current key event manager.
58          *
59          * @since        2.0
60          * @return The current _KeyEventManager instance
61          */
62         static _KeyEventManager* GetInstance(void);
63
64         /**
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.
68          *
69          * @since                               2.0
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 ()
79          */
80         void AddKeyEventListener(const _IKeyEventListener& listener);
81
82
83         /**
84          * Removes the _IKeyEventListener instance. @n
85          * The removed listener is not notified even when the key events are fired.
86          *
87          * @since                       2.0
88          * @return    listener          The current application-wide key event listener to remove
89          * @see       AddKeyEventListener()
90          */
91         void RemoveKeyEventListener(const _IKeyEventListener& listener);
92
93         /**
94          * Returns the list of key event listeners. @n
95          *
96          * @since 2.0
97          * @return    _IKeyEventListener
98          */
99         Tizen::Base::Collection::LinkedListT<Tizen::Ui::_IKeyEventListener*>*  GetKeyEventListener(void) const;
100
101         _Control* GetCapturingControl(_KeyCode keyCode) const;
102
103         void SetCapturingControl(const _Control& control, _KeyCode keyCode, bool captureAllowed);
104
105         static void InitializeInstance(void);
106         static void ReleaseInstance(void);
107
108 private:
109         /**
110         * This is the default constructor for this class.
111         *
112         * @since        2.0
113         */
114         _KeyEventManager(void);
115
116         /**
117          * This is the destructor for this class.
118          *
119          * @since       2.0
120          */
121         virtual ~_KeyEventManager(void);
122
123         /*
124          * This is the copy constructor for this class.
125          */
126         _KeyEventManager(const _KeyEventManager&);
127
128         /**
129          * This is the assignment operator for this class.
130          */
131         _KeyEventManager& operator =(const _KeyEventManager&);
132
133 private:
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
139
140 } } // Tizen::Ui
141
142 #endif // _FUI_KEY_EVENT_MANAGER_H_