[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / focus-manager / keyinput-focus-manager-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H__
2 #define __DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 // EXTERNAL INCLUDES
21 #include <string>
22 #include <deque>
23
24 // INTERNAL INCLUDES
25 #include <dali/dali.h>
26 #include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
27 #include <dali-toolkit/public-api/controls/control.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Internal
36 {
37
38 class KeyInputFocusManager;
39
40 /**
41  * @copydoc Toolkit::KeyInputFocusManager
42  */
43 class KeyInputFocusManager : public Dali::BaseObject
44 {
45 public:
46
47   typedef std::deque< unsigned int > ActorQueue;
48   typedef std::deque< unsigned int >::iterator ActorQueueIterator;
49   typedef std::deque< unsigned int >::const_iterator ActorQueueConstIterator;
50
51   /**
52    * Construct a new KeyInputFocusManager.
53    */
54   KeyInputFocusManager();
55
56   /**
57    * @copydoc Toolkit::SetFocus
58    */
59   void SetFocus(Toolkit::Control control);
60
61   /**
62    * @copydoc Toolkit::GetCurrentFocusControl
63    */
64   Toolkit::Control GetCurrentFocusControl() const;
65
66   /**
67    * @copydoc Toolkit::RemoveFocus
68    */
69   void RemoveFocus(Toolkit::Control control);
70
71   /**
72    * @copydoc Toolkit::IsKeyboardListener
73    */
74   bool IsKeyboardListener(Toolkit::Control control) const;
75
76 public:
77
78   /**
79    * @copydoc Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignal()
80    */
81   Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalV2& KeyInputFocusChangedSignal();
82
83   /**
84    * @copydoc Toolkit::KeyInputFocusManager::UnhandledKeyEventSignal()
85    */
86   Toolkit::KeyInputFocusManager::UnhandledKeyEventSignalV2& UnhandledKeyEventSignal();
87
88   /**
89    * Connects a callback function with the object's signals.
90    * @param[in] object The object providing the signal.
91    * @param[in] tracker Used to disconnect the signal.
92    * @param[in] signalName The signal to connect to.
93    * @param[in] functor A newly allocated FunctorDelegate.
94    * @return True if the signal was connected.
95    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
96    */
97   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
98
99 protected:
100
101   /**
102    * Destructor
103    */
104   virtual ~KeyInputFocusManager();
105
106 private:
107
108   /**
109    * Callback for the key event when no actor in the stage has gained the key input focus
110    * @param[in] event The KeyEvent event.
111    */
112   void OnKeyEvent(const KeyEvent& event);
113
114   /**
115    * Signal handler called when a focused Actor is removed from Stage.
116    * @param[in]  actor  The actor removed from stage.
117    */
118   void OnFocusActorStageDisconnection( Dali::Actor actor );
119
120 private:
121
122   // Undefined
123   KeyInputFocusManager(const KeyInputFocusManager&);
124
125   KeyInputFocusManager& operator=(const KeyInputFocusManager& rhs);
126
127 private:
128
129   // The key input focus change signal
130   Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalV2 mKeyInputFocusChangedSignalV2;
131
132   // The un-handled key event signal
133   Toolkit::KeyInputFocusManager::UnhandledKeyEventSignalV2 mUnhandledKeyEventSignalV2;
134
135   // Keyboard events are sent to the current focus actor, which will be the actor on the top of the focus actors stack.
136   ActorQueue mFocusActorsQueue;
137
138   SlotDelegate< KeyInputFocusManager > mSlotDelegate;
139 };
140
141 } // namespace Internal
142
143 inline Internal::KeyInputFocusManager& GetImpl(Dali::Toolkit::KeyInputFocusManager& obj)
144 {
145   DALI_ASSERT_ALWAYS(obj);
146
147   Dali::BaseObject& handle = obj.GetBaseObject();
148
149   return static_cast<Internal::KeyInputFocusManager&>(handle);
150 }
151
152 inline const Internal::KeyInputFocusManager& GetImpl(const Dali::Toolkit::KeyInputFocusManager& obj)
153 {
154   DALI_ASSERT_ALWAYS(obj);
155
156   const Dali::BaseObject& handle = obj.GetBaseObject();
157
158   return static_cast<const Internal::KeyInputFocusManager&>(handle);
159 }
160
161 } // namespace Toolkit
162
163 } // namespace Dali
164
165 #endif // __DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H__