TextInput uses style properties for PopUp and Highlight
[platform/core/uifw/dali-toolkit.git] / base / 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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
21 // EXTERNAL INCLUDES
22 #include <string>
23 #include <deque>
24
25 // INTERNAL INCLUDES
26 #include <dali/dali.h>
27 #include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
28 #include <dali-toolkit/public-api/controls/control.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 class KeyInputFocusManager;
40
41 /**
42  * @copydoc Toolkit::KeyInputFocusManager
43  */
44 class KeyInputFocusManager : public Dali::BaseObject
45 {
46 public:
47
48   typedef std::deque< unsigned int > ActorQueue;
49   typedef std::deque< unsigned int >::iterator ActorQueueIterator;
50   typedef std::deque< unsigned int >::const_iterator ActorQueueConstIterator;
51
52   /**
53    * Construct a new KeyInputFocusManager.
54    */
55   KeyInputFocusManager();
56
57   /**
58    * @copydoc Toolkit::SetFocus
59    */
60   void SetFocus(Toolkit::Control control);
61
62   /**
63    * @copydoc Toolkit::GetCurrentFocusControl
64    */
65   Toolkit::Control GetCurrentFocusControl() const;
66
67   /**
68    * @copydoc Toolkit::RemoveFocus
69    */
70   void RemoveFocus(Toolkit::Control control);
71
72   /**
73    * @copydoc Toolkit::IsKeyboardListener
74    */
75   bool IsKeyboardListener(Toolkit::Control control) const;
76
77 public:
78
79   /**
80    * @copydoc Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignal()
81    */
82   Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalV2& KeyInputFocusChangedSignal();
83
84   /**
85    * @copydoc Toolkit::KeyInputFocusManager::UnhandledKeyEventSignal()
86    */
87   Toolkit::KeyInputFocusManager::UnhandledKeyEventSignalV2& UnhandledKeyEventSignal();
88
89   /**
90    * Connects a callback function with the object's signals.
91    * @param[in] object The object providing the signal.
92    * @param[in] tracker Used to disconnect the signal.
93    * @param[in] signalName The signal to connect to.
94    * @param[in] functor A newly allocated FunctorDelegate.
95    * @return True if the signal was connected.
96    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
97    */
98   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
99
100 protected:
101
102   /**
103    * Destructor
104    */
105   virtual ~KeyInputFocusManager();
106
107 private:
108
109   /**
110    * Callback for the key event when no actor in the stage has gained the key input focus
111    * @param[in] event The KeyEvent event.
112    */
113   void OnKeyEvent(const KeyEvent& event);
114
115   /**
116    * Signal handler called when a focused Actor is removed from Stage.
117    * @param[in]  actor  The actor removed from stage.
118    */
119   void OnFocusActorStageDisconnection( Dali::Actor actor );
120
121 private:
122
123   // Undefined
124   KeyInputFocusManager(const KeyInputFocusManager&);
125
126   KeyInputFocusManager& operator=(const KeyInputFocusManager& rhs);
127
128 private:
129
130   // The key input focus change signal
131   Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalV2 mKeyInputFocusChangedSignalV2;
132
133   // The un-handled key event signal
134   Toolkit::KeyInputFocusManager::UnhandledKeyEventSignalV2 mUnhandledKeyEventSignalV2;
135
136   // Keyboard events are sent to the current focus actor, which will be the actor on the top of the focus actors stack.
137   ActorQueue mFocusActorsQueue;
138
139   SlotDelegate< KeyInputFocusManager > mSlotDelegate;
140 };
141
142 } // namespace Internal
143
144 inline Internal::KeyInputFocusManager& GetImpl(Dali::Toolkit::KeyInputFocusManager& obj)
145 {
146   DALI_ASSERT_ALWAYS(obj);
147
148   Dali::BaseObject& handle = obj.GetBaseObject();
149
150   return static_cast<Internal::KeyInputFocusManager&>(handle);
151 }
152
153 inline const Internal::KeyInputFocusManager& GetImpl(const Dali::Toolkit::KeyInputFocusManager& obj)
154 {
155   DALI_ASSERT_ALWAYS(obj);
156
157   const Dali::BaseObject& handle = obj.GetBaseObject();
158
159   return static_cast<const Internal::KeyInputFocusManager&>(handle);
160 }
161
162 } // namespace Toolkit
163
164 } // namespace Dali
165
166 #endif // __DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H__