Add Text Preedit Style
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-window.cpp
1 /*
2  * Copyright (c) 2019 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 "toolkit-window-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/common/stage.h>
25 #include <dali/public-api/object/base-object.h>
26
27 #define DALI_WINDOW_H
28 #include <dali/integration-api/adaptors/adaptor.h>
29 #include <toolkit-adaptor-impl.h>
30
31 // INTERNAL INCLUDES
32 #include "test-render-surface.h"
33
34 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
35
36 namespace Dali
37 {
38
39 class Window;
40
41 /********************************************************************************
42  * Stub for Dali::Internal::Adaptor::Window
43  ********************************************************************************/
44
45 namespace Internal
46 {
47 namespace Adaptor
48 {
49
50 Window::Window( const PositionSize& positionSize )
51 : SceneHolder( positionSize )
52 {
53 }
54
55 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
56 {
57   return new Window( positionSize );
58 }
59
60 } // Adaptor
61 } // Internal
62
63 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
64 {
65   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
66   BaseObject& object = window.GetBaseObject();
67   return static_cast<Internal::Adaptor::Window&>(object);
68 }
69
70 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
71 {
72   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
73   const BaseObject& object = window.GetBaseObject();
74   return static_cast<const Internal::Adaptor::Window&>(object);
75 }
76
77 Window::Window()
78 {
79 }
80
81 Window::~Window()
82 {
83 }
84
85 Window::Window(const Window& handle)
86 : BaseHandle( handle )
87 {
88 }
89
90 Window& Window::operator=(const Window& rhs)
91 {
92   BaseHandle::operator=(rhs);
93   return *this;
94 }
95
96 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
97 {
98   return New( windowPosition, name, "", isTransparent );
99 }
100
101 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
102 {
103   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
104
105   Dali::Window result( window );
106
107   // This will also emit the window created signals
108   AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window );
109
110   return result;
111 }
112
113 Window::Window( Internal::Adaptor::Window* window )
114 : BaseHandle( window )
115 {
116 }
117
118 Integration::Scene Window::GetScene()
119 {
120   return GetImplementation( *this ).GetScene();
121 }
122
123 Integration::RenderSurface& Window::GetRenderSurface()
124 {
125   return GetImplementation( *this ).GetRenderSurface();
126 }
127
128 void Window::Add( Actor actor )
129 {
130   GetImplementation( *this ).Add( actor );
131 }
132
133 void Window::Remove( Actor actor )
134 {
135   GetImplementation( *this ).Remove( actor );
136 }
137
138 Dali::Layer Window::GetRootLayer() const
139 {
140   return GetImplementation( *this ).GetRootLayer();
141 }
142
143 void Window::SetBackgroundColor( const Vector4& color )
144 {
145   GetImplementation( *this ).SetBackgroundColor( color );
146 }
147
148 Vector4 Window::GetBackgroundColor() const
149 {
150   return GetImplementation( *this ).GetBackgroundColor();
151 }
152
153 void Window::Raise()
154 {
155   GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true);
156 }
157
158 FocusChangeSignalType& Window::FocusChangeSignal()
159 {
160   return GetImplementation( *this ).mFocusChangeSignal;
161 }
162
163 namespace DevelWindow
164 {
165
166 Window Get( Actor actor )
167 {
168   Internal::Adaptor::Window* windowImpl = nullptr;
169
170   if ( Dali::Adaptor::IsAvailable() )
171   {
172     windowImpl = static_cast<Internal::Adaptor::Window*>( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) );
173   }
174
175   return Dali::Window( windowImpl );
176 }
177
178 Window DownCast( BaseHandle handle )
179 {
180   Internal::Adaptor::Window* windowImpl = nullptr;
181   if ( Dali::Adaptor::IsAvailable() )
182   {
183     windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr());
184   }
185   return Dali::Window( windowImpl );
186 }
187
188 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
189 {
190   return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
191 }
192
193 KeyEventSignalType& KeyEventSignal( Window window )
194 {
195   return GetImplementation( window ).KeyEventSignal();
196 }
197
198 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
199 {
200   return GetImplementation( window ).KeyEventGeneratedSignal();
201 }
202
203 TouchSignalType& TouchSignal( Window window )
204 {
205   return GetImplementation( window ).TouchSignal();
206 }
207
208 WheelEventSignalType& WheelEventSignal( Window window )
209 {
210   return GetImplementation( window ).WheelEventSignal();
211 }
212
213 } // namespace DevelWindow
214
215 } // Dali