Merge "Move tts-player.h from devel-api to public-api" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / focus-manager / keyinput-focus-manager.cpp
1 /*
2  * Copyright (c) 2015 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/devel-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 KeyInputFocusManager::KeyInputFocusManager()
34 {
35 }
36
37 KeyInputFocusManager::~KeyInputFocusManager()
38 {
39 }
40
41 KeyInputFocusManager KeyInputFocusManager::Get()
42 {
43   KeyInputFocusManager manager;
44
45   // Check whether the focus manager is already created
46   SingletonService singletonService( SingletonService::Get() );
47   if ( singletonService )
48   {
49     Dali::BaseHandle handle = singletonService.GetSingleton(typeid(KeyInputFocusManager));
50     if(handle)
51     {
52       // If so, downcast the handle of singleton to focus manager
53       manager = KeyInputFocusManager(dynamic_cast<Internal::KeyInputFocusManager*>(handle.GetObjectPtr()));
54     }
55
56     if(!manager)
57     {
58       // If not, create the focus manager and register it as a singleton
59       manager = KeyInputFocusManager(new Internal::KeyInputFocusManager());
60       singletonService.Register(typeid(manager), manager);
61     }
62   }
63
64   return manager;
65 }
66
67 KeyInputFocusManager::KeyInputFocusManager(Internal::KeyInputFocusManager *impl)
68   : BaseHandle(impl)
69 {
70 }
71
72 void KeyInputFocusManager::SetFocus(Control control)
73 {
74   GetImpl(*this).SetFocus(control);
75 }
76
77 Control KeyInputFocusManager::GetCurrentFocusControl() const
78 {
79   return GetImpl(*this).GetCurrentFocusControl();
80 }
81
82 void KeyInputFocusManager::RemoveFocus(Control control)
83 {
84   GetImpl(*this).RemoveFocus(control);
85 }
86
87 bool KeyInputFocusManager::IsKeyboardListener(Control control)
88 {
89   return GetImpl(*this).IsKeyboardListener(control);
90 }
91
92 KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusManager::KeyInputFocusChangedSignal()
93 {
94   return GetImpl(*this).KeyInputFocusChangedSignal();
95 }
96
97 KeyInputFocusManager::UnhandledKeyEventSignalType& KeyInputFocusManager::UnhandledKeyEventSignal()
98 {
99   return GetImpl(*this).UnhandledKeyEventSignal();
100 }
101
102 } // namespace Toolkit
103
104 } // namespace Dali
105