[Tizen] Remove graphics-api relative codes in public-api/application.h
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / application.cpp
1 /*
2  * Copyright (c) 2022 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 #include <dali/public-api/object/object-registry.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/adaptor/common/application-impl.h>
27
28 namespace Dali
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     // pre-initialized application
41     internal->SetCommandLineOptions(argc, argv);
42     if(argc && (*argc > 0))
43     {
44       internal->GetWindow().SetClass((*argv)[0], "");
45     }
46   }
47   else
48   {
49     internal = Internal::Adaptor::Application::New(argc, argv, "", OPAQUE, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL);
50   }
51   return Application(internal.Get());
52 }
53
54 Application Application::New(int* argc, char** argv[], const std::string& stylesheet)
55 {
56   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
57   if(internal)
58   {
59     // pre-initialized application
60     internal->SetCommandLineOptions(argc, argv);
61     if(argc && (*argc > 0))
62     {
63       internal->GetWindow().SetClass((*argv)[0], "");
64     }
65     internal->SetStyleSheet(stylesheet);
66   }
67   else
68   {
69     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, OPAQUE, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL);
70   }
71   return Application(internal.Get());
72 }
73
74 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode)
75 {
76   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
77   if(internal)
78   {
79     // pre-initialized application
80     internal->SetCommandLineOptions(argc, argv);
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   else
90   {
91     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, windowMode, PositionSize(), Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL);
92   }
93   return Application(internal.Get());
94 }
95
96 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize)
97 {
98   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
99   if(internal)
100   {
101     // pre-initialized application
102     internal->SetCommandLineOptions(argc, argv);
103     if(argc && (*argc > 0))
104     {
105       internal->GetWindow().SetClass((*argv)[0], "");
106     }
107     internal->SetStyleSheet(stylesheet);
108
109     internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
110
111     //Store only the value before adaptor is created
112     internal->StoreWindowPositionSize(positionSize);
113   }
114   else
115   {
116     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL, WindowType::NORMAL);
117   }
118   return Application(internal.Get());
119 }
120
121 Application::~Application()
122 {
123 }
124
125 Application::Application()
126 {
127 }
128
129 Application::Application(const Application& copy) = default;
130
131 Application& Application::operator=(const Application& rhs) = default;
132
133 Application::Application(Application&& rhs) = default;
134
135 Application& Application::operator=(Application&& rhs) = default;
136
137 void Application::MainLoop()
138 {
139   Internal::Adaptor::GetImplementation(*this).MainLoop();
140 }
141
142 void Application::Lower()
143 {
144   Internal::Adaptor::GetImplementation(*this).Lower();
145 }
146
147 void Application::Quit()
148 {
149   Internal::Adaptor::GetImplementation(*this).Quit();
150 }
151
152 bool Application::AddIdle(CallbackBase* callback)
153 {
154   return Internal::Adaptor::GetImplementation(*this).AddIdle(callback, false);
155 }
156
157 Window Application::GetWindow()
158 {
159   return Internal::Adaptor::GetImplementation(*this).GetWindow();
160 }
161
162 std::string Application::GetResourcePath()
163 {
164   return Internal::Adaptor::Application::GetResourcePath();
165 }
166
167 std::string Application::GetRegion() const
168 {
169   return Internal::Adaptor::GetImplementation(*this).GetRegion();
170 }
171
172 std::string Application::GetLanguage() const
173 {
174   return Internal::Adaptor::GetImplementation(*this).GetLanguage();
175 }
176
177 ObjectRegistry Application::GetObjectRegistry() const
178 {
179   return Internal::Adaptor::GetImplementation(*this).GetObjectRegistry();
180 }
181
182 Application::AppSignalType& Application::InitSignal()
183 {
184   return Internal::Adaptor::GetImplementation(*this).InitSignal();
185 }
186
187 Application::AppSignalType& Application::TerminateSignal()
188 {
189   return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
190 }
191
192 Application::AppSignalType& Application::PauseSignal()
193 {
194   return Internal::Adaptor::GetImplementation(*this).PauseSignal();
195 }
196
197 Application::AppSignalType& Application::ResumeSignal()
198 {
199   return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
200 }
201
202 Application::AppSignalType& Application::ResetSignal()
203 {
204   return Internal::Adaptor::GetImplementation(*this).ResetSignal();
205 }
206
207 Application::AppControlSignalType& Application::AppControlSignal()
208 {
209   return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
210 }
211
212 Application::AppSignalType& Application::LanguageChangedSignal()
213 {
214   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
215 }
216
217 Application::AppSignalType& Application::RegionChangedSignal()
218 {
219   return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
220 }
221
222 Application::LowBatterySignalType& Application::LowBatterySignal()
223 {
224   return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
225 }
226
227 Application::LowMemorySignalType& Application::LowMemorySignal()
228 {
229   return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
230 }
231
232 Application::Application(Internal::Adaptor::Application* application)
233 : BaseHandle(application)
234 {
235 }
236
237 } // namespace Dali