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& copy ) = default;
142 Application& Application::operator=( const Application& rhs ) = default;
144 Application::Application( Application&& rhs ) = default;
146 Application& Application::operator=( Application&& rhs ) = default;
148 void Application::MainLoop()
150 Internal::Adaptor::GetImplementation(*this).MainLoop();
153 void Application::Lower()
155 Internal::Adaptor::GetImplementation(*this).Lower();
158 void Application::Quit()
160 Internal::Adaptor::GetImplementation(*this).Quit();
163 bool Application::AddIdle( CallbackBase* callback )
165 return Internal::Adaptor::GetImplementation(*this).AddIdle( callback, false );
168 Window Application::GetWindow()
170 return Internal::Adaptor::GetImplementation(*this).GetWindow();
173 std::string Application::GetResourcePath()
175 return Internal::Adaptor::Application::GetResourcePath();
178 std::string Application::GetRegion() const
180 return Internal::Adaptor::GetImplementation(*this).GetRegion();
183 std::string Application::GetLanguage() const
185 return Internal::Adaptor::GetImplementation(*this).GetLanguage();
188 ObjectRegistry Application::GetObjectRegistry() const
190 return Internal::Adaptor::GetImplementation(*this).GetObjectRegistry();
193 Application::AppSignalType& Application::InitSignal()
195 return Internal::Adaptor::GetImplementation(*this).InitSignal();
198 Application::AppSignalType& Application::TerminateSignal()
200 return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
203 Application::AppSignalType& Application::PauseSignal()
205 return Internal::Adaptor::GetImplementation(*this).PauseSignal();
208 Application::AppSignalType& Application::ResumeSignal()
210 return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
213 Application::AppSignalType& Application::ResetSignal()
215 return Internal::Adaptor::GetImplementation(*this).ResetSignal();
218 Application::AppControlSignalType & Application::AppControlSignal()
220 return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
223 Application::AppSignalType& Application::LanguageChangedSignal()
225 return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
228 Application::AppSignalType& Application::RegionChangedSignal()
230 return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
233 Application::LowBatterySignalType& Application::LowBatterySignal()
235 return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
238 Application::LowMemorySignalType& Application::LowMemorySignal()
240 return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
243 Application::Application(Internal::Adaptor::Application* application)
244 : BaseHandle(application)