DALi signals refactor to remove V2 naming
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / focus-manager / keyinput-focus-manager.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "keyinput-focus-manager.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/adaptor-framework/singleton-service.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 const char* const KeyInputFocusManager::SIGNAL_KEY_INPUT_FOCUS_CHANGED = "key-input-focus-changed";
34 const char* const KeyInputFocusManager::SIGNAL_UNHANDLED_KEY_EVENT = "unhandled-key-event";
35
36 KeyInputFocusManager::KeyInputFocusManager()
37 {
38 }
39
40 KeyInputFocusManager::~KeyInputFocusManager()
41 {
42 }
43
44 KeyInputFocusManager KeyInputFocusManager::Get()
45 {
46   KeyInputFocusManager manager;
47
48   // Check whether the focus manager is already created
49   SingletonService singletonService( SingletonService::Get() );
50   if ( singletonService )
51   {
52     Dali::BaseHandle handle = singletonService.GetSingleton(typeid(KeyInputFocusManager));
53     if(handle)
54     {
55       // If so, downcast the handle of singleton to focus manager
56       manager = KeyInputFocusManager(dynamic_cast<Internal::KeyInputFocusManager*>(handle.GetObjectPtr()));
57     }
58
59     if(!manager)
60     {
61       // If not, create the focus manager and register it as a singleton
62       manager = KeyInputFocusManager(new Internal::KeyInputFocusManager());
63       singletonService.Register(typeid(manager), manager);
64     }
65   }
66
67   return manager;
68 }
69
70 KeyInputFocusManager::KeyInputFocusManager(Internal::KeyInputFocusManager *impl)
71   : BaseHandle(impl)
72 {
73 }
74
75 void KeyInputFocusManager::SetFocus(Control control)
76 {
77   GetImpl(*this).SetFocus(control);
78 }
79
80 Control KeyInputFocusManager::GetCurrentFocusControl() const
81 {
82   return GetImpl(*this).GetCurrentFocusControl();
83 }
84
85 void KeyInputFocusManager::RemoveFocus(Control control)
86 {
87   GetImpl(*this).RemoveFocus(control);
88 }
89
90 bool KeyInputFocusManager::IsKeyboardListener(Control control)
91 {
92   return GetImpl(*this).IsKeyboardListener(control);
93 }
94
95 KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusManager::KeyInputFocusChangedSignal()
96 {
97   return GetImpl(*this).KeyInputFocusChangedSignal();
98 }
99
100 KeyInputFocusManager::UnhandledKeyEventSignalType& KeyInputFocusManager::UnhandledKeyEventSignal()
101 {
102   return GetImpl(*this).UnhandledKeyEventSignal();
103 }
104
105 } // namespace Toolkit
106
107 } // namespace Dali
108