2 * Copyright (c) 2020 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/public-api/object/object-registry.h>
23 #include <dali/integration-api/debug.h>
26 #include <dali/internal/adaptor/common/application-impl.h>
31 Application Application::New()
33 return New( NULL, NULL );
36 Application Application::New( int* argc, char **argv[] )
38 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
41 // pre-initialized application
42 internal->SetCommandLineOptions( argc, argv );
43 if( argc && ( *argc > 0 ) )
45 internal->GetWindow().SetClass( (*argv)[0], "" );
48 return Application( internal.Get() );
52 internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE, PositionSize(),
53 Internal::Adaptor::Framework::NORMAL);
54 return Application(internal.Get());
58 Application Application::New( int* argc, char **argv[], const std::string& stylesheet )
60 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
63 // pre-initialized application
64 internal->SetCommandLineOptions( argc, argv );
65 if( argc && ( *argc > 0 ) )
67 internal->GetWindow().SetClass( (*argv)[0], "" );
69 internal->SetStyleSheet( stylesheet );
71 return Application( internal.Get() );
75 internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE, PositionSize(),
76 Internal::Adaptor::Framework::NORMAL);
77 return Application(internal.Get());
81 Application Application::New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode )
83 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
86 // pre-initialized application
87 internal->SetCommandLineOptions( argc, argv );
88 if( argc && ( *argc > 0 ) )
90 internal->GetWindow().SetClass( (*argv)[0], "" );
92 internal->SetStyleSheet( stylesheet );
94 internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
96 return Application( internal.Get() );
100 internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, PositionSize(),
101 Internal::Adaptor::Framework::NORMAL);
102 return Application(internal.Get());
106 Application Application::New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize )
108 Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
111 // pre-initialized application
112 internal->SetCommandLineOptions( argc, argv );
113 if( argc && ( *argc > 0 ) )
115 internal->GetWindow().SetClass( (*argv)[0], "" );
117 internal->SetStyleSheet( stylesheet );
119 internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
120 internal->GetWindow().SetSize( Window::WindowSize( positionSize.width, positionSize.height ) );
121 internal->GetWindow().SetPosition( Window::WindowPosition( positionSize.x, positionSize.y ) );
123 return Application( internal.Get() );
127 internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL );
128 return Application( internal.Get() );
132 Application::~Application()
136 Application::Application()
140 Application::Application(const Application& application)
141 : BaseHandle(application)
145 Application& Application::operator=(const Application& application)
147 if( *this != application )
149 BaseHandle::operator=( application );
154 void Application::MainLoop()
156 Internal::Adaptor::GetImplementation(*this).MainLoop(Configuration::APPLICATION_HANDLES_CONTEXT_LOSS);
159 void Application::MainLoop(Configuration::ContextLoss configuration)
161 Internal::Adaptor::GetImplementation(*this).MainLoop(configuration);
164 void Application::Lower()
166 Internal::Adaptor::GetImplementation(*this).Lower();
169 void Application::Quit()
171 Internal::Adaptor::GetImplementation(*this).Quit();
174 bool Application::AddIdle( CallbackBase* callback )
176 return Internal::Adaptor::GetImplementation(*this).AddIdle( callback, false );
179 Window Application::GetWindow()
181 return Internal::Adaptor::GetImplementation(*this).GetWindow();
184 std::string Application::GetResourcePath()
186 return Internal::Adaptor::Application::GetResourcePath();
189 std::string Application::GetRegion() const
191 return Internal::Adaptor::GetImplementation(*this).GetRegion();
194 std::string Application::GetLanguage() const
196 return Internal::Adaptor::GetImplementation(*this).GetLanguage();
199 ObjectRegistry Application::GetObjectRegistry() const
201 return Internal::Adaptor::GetImplementation(*this).GetObjectRegistry();
204 Application::AppSignalType& Application::InitSignal()
206 return Internal::Adaptor::GetImplementation(*this).InitSignal();
209 Application::AppSignalType& Application::TerminateSignal()
211 return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
214 Application::AppSignalType& Application::PauseSignal()
216 return Internal::Adaptor::GetImplementation(*this).PauseSignal();
219 Application::AppSignalType& Application::ResumeSignal()
221 return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
224 Application::AppSignalType& Application::ResetSignal()
226 return Internal::Adaptor::GetImplementation(*this).ResetSignal();
229 Application::AppControlSignalType & Application::AppControlSignal()
231 return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
234 Application::AppSignalType& Application::LanguageChangedSignal()
236 return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
239 Application::AppSignalType& Application::RegionChangedSignal()
241 return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
244 Application::LowBatterySignalType& Application::LowBatterySignal()
246 return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
249 Application::LowMemorySignalType& Application::LowMemorySignal()
251 return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
254 Application::Application(Internal::Adaptor::Application* application)
255 : BaseHandle(application)