Add SyncKeyEvent for Widget
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / widget-impl.cpp
1 /*
2  * Copyright (c) 2020 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 "widget-impl.h"
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/system/common/widget-controller.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace Adaptor
29 {
30 WidgetPtr Widget::New()
31 {
32   return new Widget();
33 }
34
35 Widget::Widget()
36 : mImpl(nullptr)
37 {
38 }
39
40 Widget::~Widget()
41 {
42   if(mImpl != nullptr)
43   {
44     delete mImpl;
45   }
46 }
47
48 void Widget::OnCreate(const std::string& contentInfo, Dali::Window window)
49 {
50 }
51
52 void Widget::OnTerminate(const std::string& contentInfo, Dali::Widget::Termination type)
53 {
54 }
55
56 void Widget::OnPause()
57 {
58 }
59
60 void Widget::OnResume()
61 {
62 }
63
64 void Widget::OnResize(Dali::Window window)
65 {
66 }
67
68 void Widget::OnUpdate(const std::string& contentInfo, int force)
69 {
70 }
71
72 void Widget::SignalConnected(SlotObserver* slotObserver, CallbackBase* callback)
73 {
74   mImpl->SignalConnected(slotObserver, callback);
75 }
76
77 void Widget::SignalDisconnected(SlotObserver* slotObserver, CallbackBase* callback)
78 {
79   mImpl->SignalDisconnected(slotObserver, callback);
80 }
81
82 void Widget::SetContentInfo(const std::string& contentInfo)
83 {
84   if(mImpl != nullptr)
85   {
86     mImpl->SetContentInfo(contentInfo);
87   }
88 }
89
90 bool Widget::IsKeyEventUsing() const
91 {
92   if(mImpl != nullptr)
93   {
94     return mImpl->IsKeyEventUsing();
95   }
96
97   //if mImpl is null, return default value
98   return false;
99 }
100
101 void Widget::SetUsingKeyEvent(bool flag)
102 {
103   if(mImpl != nullptr)
104   {
105     mImpl->SetUsingKeyEvent(flag);
106   }
107 }
108
109 void Widget::SetImpl(Impl* impl)
110 {
111   mImpl = impl;
112 }
113
114
115 void Widget::SetInformation(Dali::Window window, const std::string& widgetId)
116 {
117   if(mImpl != nullptr)
118   {
119     mImpl->SetInformation(window, widgetId);
120   }
121 }
122
123 Dali::Window Widget::GetWindow() const
124 {
125   if(mImpl != nullptr)
126   {
127     return mImpl->GetWindow();
128   }
129
130   return Dali::Window();
131 }
132
133 std::string Widget::GetWidgetId() const
134 {
135   if(mImpl != nullptr)
136   {
137     return mImpl->GetWidgetId();
138   }
139
140   return std::string();
141 }
142
143 Internal::Adaptor::Widget& GetImplementation(Dali::Widget& widget)
144 {
145   DALI_ASSERT_ALWAYS(widget && "widget handle is empty");
146
147   BaseObject& handle = widget.GetBaseObject();
148
149   return static_cast<Internal::Adaptor::Widget&>(handle);
150 }
151
152 const Internal::Adaptor::Widget& GetImplementation(const Dali::Widget& widget)
153 {
154   const BaseObject& handle = widget.GetBaseObject();
155
156   return static_cast<const Internal::Adaptor::Widget&>(handle);
157 }
158
159 } // namespace Adaptor
160
161 } // namespace Internal
162
163 } // namespace Dali