Revert "ScrollView - Store properties in local values for GetCurrentScrollPosition"
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / focus-manager / keyinput-focus-manager.h
1 #ifndef __DALI_TOOLKIT_KEYINPUT_FOCUS_MANAGER_H__
2 #define __DALI_TOOLKIT_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 // INTERNAL INCLUDES
22 #include <dali/dali.h>
23 #include <dali-toolkit/public-api/controls/control.h>
24
25 namespace Dali DALI_IMPORT_API
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33 class KeyInputFocusManager;
34 }
35
36 /**
37  * KeyInputFocusManager
38  * This class provides the functionality of registering for keyboard events for controls.
39  * The keyinput focus manager maintains a stack of controls, With the last added control receiving
40  * all the keyboard events first. And if the conrol doesn't consume the event it is passed to
41  * the next control in the stack. If none of the controls in the stack consume the key event then
42  * UnhandledKeyEventSignal() is emitted.
43  */
44
45  class KeyInputFocusManager : public BaseHandle
46  {
47  public:
48   //Signal Names
49   static const char* const SIGNAL_KEY_INPUT_FOCUS_CHANGED;
50   static const char* const SIGNAL_UNHANDLED_KEY_EVENT;
51
52   // KeyInputFocusChanged
53   typedef SignalV2< void (Control, Control) > KeyInputFocusChangedSignalV2;
54
55   // Unhandled Key Event
56   typedef SignalV2< void (const KeyEvent&) > UnhandledKeyEventSignalV2;
57
58  public:
59
60   /**
61    * Create a KeyInputFocusManager handle; this can be initialised with KeyInputFocusManager::Get()
62    * Calling member functions with an uninitialised handle is not allowed.
63    */
64   KeyInputFocusManager();
65
66   /**
67    * Virtual destructor.
68    */
69   virtual ~KeyInputFocusManager();
70
71   /**
72    * Get the singleton of KeyInputFocusManager object.
73    * @return A handle to the KeyInputFocusManager control.
74    */
75   static KeyInputFocusManager Get();
76
77   /**
78    * Sets keyboard focus for a control.
79    * Note: A control can be set to be in focus and still not receive all the key events if another control has over ridden it.
80    * As the key input focus mechanism works like a stack, the top most control receives all the key events, and passes on the
81    * unhandled events to the controls below in the stack. A control in the stack will regain key input focus when there are no more
82    * controls above it in the focus stack.
83    *
84    * @pre The Control is not in the focus stack. If it is allready present in the top of the stack it results in a no-op, If it is
85    * present in the stack but not on the top of the stack, then the control is moved to the top of the focus stack.
86    * @param[in] control The Control to receive keyboard input
87    */
88   void SetFocus(Control control);
89
90   /**
91    * Query for the control that is currently set to be on top of the fcous stack and receives all
92    * keyboard input events first.
93    * @return Pointer to the control set to receive keyboard inputs.
94    */
95   Control GetCurrentFocusControl() const;
96
97   /**
98    * Removes focus for the given control, The control will no longer receive events from keyboard.
99    * @param [in] control which should be removed from focus.
100    */
101   void RemoveFocus(Control control);
102
103   /**
104    * Queries whether a control is currently part of the focus stack.
105    * @param [in] control which should be queried.
106    * @return True if it is part of the foucus stack False otherwise.
107    */
108   bool IsKeyboardListener(Control control);
109
110  public: // Signals
111
112   /**
113    * This signal is emitted when the key input focus control changes.
114    * Two control parameters are sent as part of this signal, the first being the signal that now has the focus, the second
115    * being the one that has lost focus.
116    * A callback of the following type may be connected:
117    * @code
118    *   void YourCallback(Control focusGainedControl, Control focusLostActor);
119    * @endcode
120    * @return The signal to connect to.
121    */
122   KeyInputFocusChangedSignalV2& KeyInputFocusChangedSignal();
123
124   /**
125    * This signal is emitted when a key event was received, and none of the focused controls on the stage have consumed it.
126    * A callback of the following type may be connected:
127    * @code
128    *   void YourCallbackName(const KeyEvent& event);
129    * @endcode
130    * @return The signal to connect to.
131    */
132   UnhandledKeyEventSignalV2& UnhandledKeyEventSignal();
133
134 private:
135
136   KeyInputFocusManager(Internal::KeyInputFocusManager *impl);
137
138 }; // class KeyInputFocusManager
139
140 } // namespace Toolkit
141
142 } // namespace Dali
143
144 #endif // __DALI_TOOLKIT_KEYINPUT_FOCUS_MANAGER_H__