Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / application.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 <dali/public-api/adaptor-framework/application.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/adaptor/common/application-impl.h>
26
27 namespace Dali
28 {
29
30 Application Application::New()
31 {
32   return New( NULL, NULL );
33 }
34
35 Application Application::New( int* argc, char **argv[] )
36 {
37   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
38   if( internal )
39   {
40     if( argc && ( *argc > 0 ) )
41     {
42       internal->GetWindow().SetClass( (*argv)[0], "" );
43     }
44
45     return Application( internal.Get() );
46   }
47   else
48   {
49     internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE, PositionSize(),
50       Internal::Adaptor::Framework::NORMAL);
51     return Application(internal.Get());
52   }
53 }
54
55 Application Application::New( int* argc, char **argv[], const std::string& stylesheet )
56 {
57   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
58   if( internal )
59   {
60     if( argc && ( *argc > 0 ) )
61     {
62       internal->GetWindow().SetClass( (*argv)[0], "" );
63     }
64     internal->SetStyleSheet( stylesheet );
65
66     return Application( internal.Get() );
67   }
68   else
69   {
70     internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE, PositionSize(),
71       Internal::Adaptor::Framework::NORMAL);
72     return Application(internal.Get());
73   }
74 }
75
76 Application Application::New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode )
77 {
78   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
79   if( internal )
80   {
81     if( argc && ( *argc > 0 ) )
82     {
83       internal->GetWindow().SetClass( (*argv)[0], "" );
84     }
85     internal->SetStyleSheet( stylesheet );
86
87     internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
88
89     return Application( internal.Get() );
90   }
91   else
92   {
93     internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, PositionSize(),
94       Internal::Adaptor::Framework::NORMAL);
95     return Application(internal.Get());
96   }
97 }
98
99 Application Application::New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize )
100 {
101   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
102   if( internal )
103   {
104     if( argc && ( *argc > 0 ) )
105     {
106       internal->GetWindow().SetClass( (*argv)[0], "" );
107     }
108     internal->SetStyleSheet( stylesheet );
109
110     internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
111     internal->GetWindow().SetSize( Window::WindowSize( positionSize.width, positionSize.height ) );
112     internal->GetWindow().SetPosition( Window::WindowPosition( positionSize.x, positionSize.y ) );
113
114     return Application( internal.Get() );
115   }
116   else
117   {
118     internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL );
119     return Application( internal.Get() );
120   }
121 }
122
123 Application::~Application()
124 {
125 }
126
127 Application::Application()
128 {
129 }
130
131 Application::Application(const Application& application)
132 : BaseHandle(application)
133 {
134 }
135
136 Application& Application::operator=(const Application& application)
137 {
138   if( *this != application )
139   {
140     BaseHandle::operator=( application );
141   }
142   return *this;
143 }
144
145 void Application::MainLoop()
146 {
147   Internal::Adaptor::GetImplementation(*this).MainLoop(Configuration::APPLICATION_HANDLES_CONTEXT_LOSS);
148 }
149
150 void Application::MainLoop(Configuration::ContextLoss configuration)
151 {
152   Internal::Adaptor::GetImplementation(*this).MainLoop(configuration);
153 }
154
155 void Application::Lower()
156 {
157   Internal::Adaptor::GetImplementation(*this).Lower();
158 }
159
160 void Application::Quit()
161 {
162   Internal::Adaptor::GetImplementation(*this).Quit();
163 }
164
165 bool Application::AddIdle( CallbackBase* callback )
166 {
167   return Internal::Adaptor::GetImplementation(*this).AddIdle( callback, false );
168 }
169
170 Window Application::GetWindow()
171 {
172   return Internal::Adaptor::GetImplementation(*this).GetWindow();
173 }
174
175 void Application::ReplaceWindow(PositionSize windowPosition, const std::string& name)
176 {
177   Internal::Adaptor::GetImplementation(*this).ReplaceWindow(windowPosition, name);
178 }
179
180 std::string Application::GetResourcePath()
181 {
182   return Internal::Adaptor::Application::GetResourcePath();
183 }
184
185 std::string Application::GetRegion() const
186 {
187   return Internal::Adaptor::GetImplementation(*this).GetRegion();
188 }
189
190 std::string Application::GetLanguage() const
191 {
192   return Internal::Adaptor::GetImplementation(*this).GetLanguage();
193 }
194
195 void Application::SetViewMode( ViewMode viewMode )
196 {
197   Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
198 }
199
200 ViewMode Application::GetViewMode() const
201 {
202   return Internal::Adaptor::GetImplementation(*this).GetViewMode();
203 }
204
205 void Application::SetStereoBase( float stereoBase )
206 {
207   Internal::Adaptor::GetImplementation(*this).SetStereoBase( stereoBase );
208 }
209
210 float Application::GetStereoBase() const
211 {
212   return Internal::Adaptor::GetImplementation(*this).GetStereoBase();
213 }
214
215 Application::AppSignalType& Application::InitSignal()
216 {
217   return Internal::Adaptor::GetImplementation(*this).InitSignal();
218 }
219
220 Application::AppSignalType& Application::TerminateSignal()
221 {
222   return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
223 }
224
225 Application::AppSignalType& Application::PauseSignal()
226 {
227   return Internal::Adaptor::GetImplementation(*this).PauseSignal();
228 }
229
230 Application::AppSignalType& Application::ResumeSignal()
231 {
232   return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
233 }
234
235 Application::AppSignalType& Application::ResetSignal()
236 {
237   return Internal::Adaptor::GetImplementation(*this).ResetSignal();
238 }
239
240 Application::AppSignalType& Application::ResizeSignal()
241 {
242   DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: ResizeSignal() is deprecated and will be removed from next release. Use Window::ResizedSignal() instead.\n" );
243
244   return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
245 }
246
247 Application::AppControlSignalType & Application::AppControlSignal()
248 {
249   return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
250 }
251
252 Application::AppSignalType& Application::LanguageChangedSignal()
253 {
254   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
255 }
256
257 Application::AppSignalType& Application::RegionChangedSignal()
258 {
259   return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
260 }
261
262 Application::AppSignalType& Application::BatteryLowSignal()
263 {
264   DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: BatteryLowSignal() is deprecated and will be removed from next release. Use Application::LowBatterySignal() instead.\n" );
265   return Internal::Adaptor::GetImplementation(*this).BatteryLowSignal();
266 }
267
268 Application::AppSignalType& Application::MemoryLowSignal()
269 {
270   DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: MemoryLowSignal() is deprecated and will be removed from next release. Use Application::LowMemorySignal() instead.\n" );
271   return Internal::Adaptor::GetImplementation(*this).MemoryLowSignal();
272 }
273
274 Application::LowBatterySignalType& Application::LowBatterySignal()
275 {
276   return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
277 }
278
279 Application::LowMemorySignalType& Application::LowMemorySignal()
280 {
281   return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
282 }
283
284 Application::Application(Internal::Adaptor::Application* application)
285 : BaseHandle(application)
286 {
287 }
288
289
290 } // namespace Dali