2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/adaptor-framework/application.h>
22 #include <dali/integration-api/debug.h>
25 #include <dali/internal/adaptor/common/application-impl.h>
30 Application Application::New()
32 return New( NULL, NULL );
35 Application Application::New( int* argc, char **argv[] )
37 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
40 // pre-initialized application
41 internal->SetCommandLineOptions( argc, argv );
42 if( argc && ( *argc > 0 ) )
44 internal->GetWindow().SetClass( (*argv)[0], "" );
47 return Application( internal.Get() );
51 internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE, PositionSize(),
52 Internal::Adaptor::Framework::NORMAL);
53 return Application(internal.Get());
57 Application Application::New( int* argc, char **argv[], const std::string& stylesheet )
59 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
62 // pre-initialized application
63 internal->SetCommandLineOptions( argc, argv );
64 if( argc && ( *argc > 0 ) )
66 internal->GetWindow().SetClass( (*argv)[0], "" );
68 internal->SetStyleSheet( stylesheet );
70 return Application( internal.Get() );
74 internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE, PositionSize(),
75 Internal::Adaptor::Framework::NORMAL);
76 return Application(internal.Get());
80 Application Application::New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode )
82 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
85 // pre-initialized application
86 internal->SetCommandLineOptions( argc, argv );
87 if( argc && ( *argc > 0 ) )
89 internal->GetWindow().SetClass( (*argv)[0], "" );
91 internal->SetStyleSheet( stylesheet );
93 internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
95 return Application( internal.Get() );
99 internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, PositionSize(),
100 Internal::Adaptor::Framework::NORMAL);
101 return Application(internal.Get());
105 Application Application::New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize )
107 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
110 // pre-initialized application
111 internal->SetCommandLineOptions( argc, argv );
112 if( argc && ( *argc > 0 ) )
114 internal->GetWindow().SetClass( (*argv)[0], "" );
116 internal->SetStyleSheet( stylesheet );
118 internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
119 internal->GetWindow().SetSize( Window::WindowSize( positionSize.width, positionSize.height ) );
120 internal->GetWindow().SetPosition( Window::WindowPosition( positionSize.x, positionSize.y ) );
122 return Application( internal.Get() );
126 internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL );
127 return Application( internal.Get() );
131 Application::~Application()
135 Application::Application()
139 Application::Application(const Application& application)
140 : BaseHandle(application)
144 Application& Application::operator=(const Application& application)
146 if( *this != application )
148 BaseHandle::operator=( application );
153 void Application::MainLoop()
155 Internal::Adaptor::GetImplementation(*this).MainLoop(Configuration::APPLICATION_HANDLES_CONTEXT_LOSS);
158 void Application::MainLoop(Configuration::ContextLoss configuration)
160 Internal::Adaptor::GetImplementation(*this).MainLoop(configuration);
163 void Application::Lower()
165 Internal::Adaptor::GetImplementation(*this).Lower();
168 void Application::Quit()
170 Internal::Adaptor::GetImplementation(*this).Quit();
173 bool Application::AddIdle( CallbackBase* callback )
175 return Internal::Adaptor::GetImplementation(*this).AddIdle( callback, false );
178 Window Application::GetWindow()
180 return Internal::Adaptor::GetImplementation(*this).GetWindow();
183 void Application::ReplaceWindow(PositionSize windowPosition, const std::string& name)
185 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: ReplaceWindow is deprecated and will be removed from next release.\n" );
187 Internal::Adaptor::GetImplementation(*this).ReplaceWindow(windowPosition, name);
190 std::string Application::GetResourcePath()
192 return Internal::Adaptor::Application::GetResourcePath();
195 std::string Application::GetRegion() const
197 return Internal::Adaptor::GetImplementation(*this).GetRegion();
200 std::string Application::GetLanguage() const
202 return Internal::Adaptor::GetImplementation(*this).GetLanguage();
205 void Application::SetViewMode( ViewMode viewMode )
207 Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
210 ViewMode Application::GetViewMode() const
212 return Internal::Adaptor::GetImplementation(*this).GetViewMode();
215 void Application::SetStereoBase( float stereoBase )
217 Internal::Adaptor::GetImplementation(*this).SetStereoBase( stereoBase );
220 float Application::GetStereoBase() const
222 return Internal::Adaptor::GetImplementation(*this).GetStereoBase();
225 Application::AppSignalType& Application::InitSignal()
227 return Internal::Adaptor::GetImplementation(*this).InitSignal();
230 Application::AppSignalType& Application::TerminateSignal()
232 return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
235 Application::AppSignalType& Application::PauseSignal()
237 return Internal::Adaptor::GetImplementation(*this).PauseSignal();
240 Application::AppSignalType& Application::ResumeSignal()
242 return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
245 Application::AppSignalType& Application::ResetSignal()
247 return Internal::Adaptor::GetImplementation(*this).ResetSignal();
250 Application::AppSignalType& Application::ResizeSignal()
252 DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: ResizeSignal() is deprecated and will be removed from next release. Use Window::ResizedSignal() instead.\n" );
254 return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
257 Application::AppControlSignalType & Application::AppControlSignal()
259 return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
262 Application::AppSignalType& Application::LanguageChangedSignal()
264 return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
267 Application::AppSignalType& Application::RegionChangedSignal()
269 return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
272 Application::AppSignalType& Application::BatteryLowSignal()
274 DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: BatteryLowSignal() is deprecated and will be removed from next release. Use Application::LowBatterySignal() instead.\n" );
275 return Internal::Adaptor::GetImplementation(*this).BatteryLowSignal();
278 Application::AppSignalType& Application::MemoryLowSignal()
280 DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: MemoryLowSignal() is deprecated and will be removed from next release. Use Application::LowMemorySignal() instead.\n" );
281 return Internal::Adaptor::GetImplementation(*this).MemoryLowSignal();
284 Application::LowBatterySignalType& Application::LowBatterySignal()
286 return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
289 Application::LowMemorySignalType& Application::LowMemorySignal()
291 return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
294 Application::Application(Internal::Adaptor::Application* application)
295 : BaseHandle(application)