Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUi_KeyEventManagerImpl.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_KeyEventManagerImpl.h
19  * @brief               This is the header file for the _KeyEventManagerImpl class.
20  *
21  * This header file contains the declarations of the _KeyEventManagerImpl class. @n.
22  */
23 #ifndef _FUI_INTERNAL_KEY_EVENT_MANAGER_IMPL_H_
24 #define _FUI_INTERNAL_KEY_EVENT_MANAGER_IMPL_H_
25
26 // Includes
27 #include <FBaseObject.h>
28 #include <FBaseErrors.h>
29 #include <FOspConfig.h>
30 #include <FUiIKeyEventListener.h>
31 #include <FBaseColLinkedListT.h>
32
33 namespace Tizen {namespace Ui
34 {
35 class _ControlImpl;
36
37 /**
38  * @class       _KeyEventManagerImpl
39  * @brief       This class manages the key events that are fired within this application's context.
40  * @since       2.0
41  *
42  * The _KeyEventManagerImpl listens to all key events that are generated within this application's context.
43  */
44 class _KeyEventManagerImpl
45         : public Tizen::Base::Object
46 {
47 public:
48         /**
49          * Returns the pointer to the current key event manager.
50          *
51          * @since        2.0
52          * @return The current _KeyEventManagerImpl instance
53          */
54         static _KeyEventManagerImpl* GetInstance(void);
55
56
57         /**
58          * Adds an application-wide IKeyEventListener instance. @n
59          * The added listeners gets notified when a key is pressed, released, or long
60          * pressed within this application's context.
61          *
62          * @since                               2.0
63          * @param[in] listener    The event listener to add
64          * @remarks     The listener is called after the key event is delivered
65          *              to the focused Control's key event listeners, but before the
66          *              key event is passed onto the focused Control itself. @n
67          *              Moreover, if the key needs to be consumed by Control itself,
68          *              the added listeners will not be notified.
69          * @see         Tizen::Ui::IKeyEventListener::OnKeyPressed()
70          * @see         Tizen::Ui::IKeyEventListener::OnKeyReleased()
71          * @see         Tizen::Ui::IKeyEventListener::OnKeyLongPressed()
72          * @see         RemoveKeyEventListener ()
73          */
74         void AddKeyEventListener(IKeyEventListener& listener);
75
76
77         /**
78          * Removes the IKeyEventListener instance. @n
79          * The removed listener is not notified even when the key events are fired.
80          *
81          * @since                       2.0
82          * @return    listener          The current application-wide key event listener to remove
83          * @see       AddKeyEventListener()
84          */
85         void RemoveKeyEventListener(IKeyEventListener& listener);
86
87          _ControlImpl* GetKeyCapturingControl(KeyCode keyCode) const;
88
89         static void Initialize(void);
90
91         static void ReleaseInstance(void);
92
93 private:
94         /**
95         * This is the default constructor for this class.
96         *
97         * @since        2.0
98         */
99         _KeyEventManagerImpl(void);
100
101         /**
102          * This is the destructor for this class.
103          *
104          * @since       2.0
105          */
106         virtual ~_KeyEventManagerImpl(void);
107
108         /*
109          * This is the copy constructor for this class.
110          */
111         _KeyEventManagerImpl(const _KeyEventManagerImpl&);
112
113         /**
114          * This is the assignment operator for this class.
115          */
116         _KeyEventManagerImpl& operator =(const _KeyEventManagerImpl&);
117
118         static void InitializeInstance(void);
119
120 private:
121         static _KeyEventManagerImpl* __pInstance;
122
123         Tizen::Base::Collection::LinkedListT <Tizen::Ui::IKeyEventListener*>* __pPublicKeyEventListeners;
124
125         class PublicEventListener;
126         PublicEventListener* __pKeyEventListeners;
127 }; // _KeyEventManagerImpl
128
129 } } // Tizen::Ui
130
131 #endif // _FUI_INTERNAL_KEY_EVENT_MANAGER_IMPL_H_