ecc2e2e7ac91f551d26b2ca2c6e63d136c64cb73
[platform/framework/native/uifw.git] / src / ui / inc / FUi_FocusManagerImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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_FocusManagerImpl.h
19  * @brief               This is the header file for the _FocusManagerImpl class.
20  *
21  * This header file contains the declarations of the _FocusManagerImpl class. @n.
22  */
23 #ifndef _FUI_INTERNAL_FOCUS_MANAGER_IMPL_H_
24 #define _FUI_INTERNAL_FOCUS_MANAGER_IMPL_H_
25
26 #include <FUi_IKeyEventListener.h>
27 #include <FUi_ITouchEventListener.h>
28 #include <FUiAnim_VisualElement.h>
29 #include <FBaseColIListT.h>
30 #include <FBaseObject.h>
31
32 namespace Tizen { namespace Ui { namespace Animations
33 {
34 class VisualElement;
35 }}} //Tizen::Ui::Animations
36
37 namespace Tizen { namespace Ui
38 {
39
40 class _Control;
41 class _ControlImpl;
42 class _WindowImpl;
43
44
45 enum FocusDirection
46 {
47         FOCUS_DIRECTION_DOWNWARD,
48         FOCUS_DIRECTION_UPWARD
49 };
50
51
52 /**
53  * @class       FocusManager
54  * @brief       This class manages the application's current focus owned by the UI control
55  *        and its ancestor Window.
56  * @since       2.0
57  *
58  * Use this class to query the application's current focus owner.
59  */
60 class  _FocusManagerImpl
61         : public Tizen::Base::Object
62         , public Tizen::Ui::_IKeyEventListener
63         , public Tizen::Ui::_ITouchEventListener
64 {
65 public:
66         /**
67          * Returns the pointer to the current focus manager.
68          *
69          * @since        2.0
70          * @return The current focus manager instance
71          */
72         static _FocusManagerImpl* GetInstance(void);
73
74
75         /**
76          * Gets the current focus owner.
77          *
78          * @since               2.0
79          * @return  The current focus owner
80          * @remarks The method returns the current focus owner of this application.
81          */
82         _ControlImpl* GetCurrentFocusOwner(void) const;
83
84
85         /**
86          * Gets the current focused Window.
87          *
88          * @since               2.0
89          * @return  The current focused Window
90          * @remarks The method returns the application's current focus owner's ancestor
91          *          Window or Window that is currently focused.
92          */
93         _WindowImpl* GetCurrentFocusedWindow(void) const;
94
95         static void Initialize(void);
96
97         static void ReleaseInstance(void);
98         bool IsFocusModeStateEnabled(void) const;
99
100 private:
101         /**
102          * This is the default constructor for this class.
103          *
104          * @since       2.0
105          */
106         _FocusManagerImpl(void);
107
108
109         /**
110          * This is the destructor for this class.
111          *
112          * @since       2.0
113          */
114         virtual ~_FocusManagerImpl(void);
115
116         _FocusManagerImpl(_FocusManagerImpl& rhs);
117         _FocusManagerImpl& operator=(_FocusManagerImpl& rhs);
118
119         static void InitializeInstance(void);
120
121         virtual bool OnKeyPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_KeyInfo& keyInfo);
122         virtual bool OnKeyReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_KeyInfo& keyInfo);
123
124         virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) ;
125         virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) ;
126         virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) ;
127         virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
128
129
130         void StartFocusTraversal(_Control* pControl, FocusDirection focusDirection);
131         int GetNextIndex(int currentIndex, FocusDirection focusDirection, const Tizen::Base::Collection::IListT<_Control*>* pFocusControlList) const;
132         bool IsFocusable(_Control* pControl) const;
133         _Control* FindTraversalControlFromChild(_Control* pControl);
134         bool IsFocusControlListControl(_Control* pControl) const;
135         bool IsForwardDirection(void) const;
136
137 private:
138         static _FocusManagerImpl* __pInstance;
139         Tizen::Ui::_Control* __pCurrentFocusUiControl;
140         bool __isFocusMode;
141         FocusDirection __focusDirection;
142 }; // _FocusManagerImpl
143
144 }}//Tizen::Ui
145
146 #endif // _FUI_INTERNAL_FOCUS_MANAGER_IMPL_H_