Merge branch 'devel/master (1.2.49)' into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / 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 "application.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23
24 // INTERNAL INCLUDES
25 #include <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     DevelWindow::SetTransparency( internal->GetWindow(), ( 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()
100 {
101 }
102
103 Application::Application()
104 {
105 }
106
107 Application::Application(const Application& application)
108 : BaseHandle(application)
109 {
110 }
111
112 Application& Application::operator=(const Application& application)
113 {
114   if( *this != application )
115   {
116     BaseHandle::operator=( application );
117   }
118   return *this;
119 }
120
121 void Application::MainLoop()
122 {
123   Internal::Adaptor::GetImplementation(*this).MainLoop(Configuration::APPLICATION_HANDLES_CONTEXT_LOSS);
124 }
125
126 void Application::MainLoop(Configuration::ContextLoss configuration)
127 {
128   Internal::Adaptor::GetImplementation(*this).MainLoop(configuration);
129 }
130
131 void Application::Lower()
132 {
133   Internal::Adaptor::GetImplementation(*this).Lower();
134 }
135
136 void Application::Quit()
137 {
138   Internal::Adaptor::GetImplementation(*this).Quit();
139 }
140
141 bool Application::AddIdle( CallbackBase* callback )
142 {
143   return Internal::Adaptor::GetImplementation(*this).AddIdle( callback );
144 }
145
146 Window Application::GetWindow()
147 {
148   return Internal::Adaptor::GetImplementation(*this).GetWindow();
149 }
150
151 void Application::ReplaceWindow(PositionSize windowPosition, const std::string& name)
152 {
153   Internal::Adaptor::GetImplementation(*this).ReplaceWindow(windowPosition, name);
154 }
155
156 std::string Application::GetResourcePath()
157 {
158   return Internal::Adaptor::Application::GetResourcePath();
159 }
160
161 void Application::SetViewMode( ViewMode viewMode )
162 {
163   Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
164 }
165
166 ViewMode Application::GetViewMode() const
167 {
168   return Internal::Adaptor::GetImplementation(*this).GetViewMode();
169 }
170
171 void Application::SetStereoBase( float stereoBase )
172 {
173   Internal::Adaptor::GetImplementation(*this).SetStereoBase( stereoBase );
174 }
175
176 float Application::GetStereoBase() const
177 {
178   return Internal::Adaptor::GetImplementation(*this).GetStereoBase();
179 }
180
181 Application::AppSignalType& Application::InitSignal()
182 {
183   return Internal::Adaptor::GetImplementation(*this).InitSignal();
184 }
185
186 Application::AppSignalType& Application::TerminateSignal()
187 {
188   return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
189 }
190
191 Application::AppSignalType& Application::PauseSignal()
192 {
193   return Internal::Adaptor::GetImplementation(*this).PauseSignal();
194 }
195
196 Application::AppSignalType& Application::ResumeSignal()
197 {
198   return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
199 }
200
201 Application::AppSignalType& Application::ResetSignal()
202 {
203   return Internal::Adaptor::GetImplementation(*this).ResetSignal();
204 }
205
206 Application::AppSignalType& Application::ResizeSignal()
207 {
208   DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: ResizeSignal() is deprecated and will be removed from next release. Use Window::ResizedSignal() instead.\n" );
209
210   return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
211 }
212
213 Application::AppControlSignalType & Application::AppControlSignal()
214 {
215   return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
216 }
217
218 Application::AppSignalType& Application::LanguageChangedSignal()
219 {
220   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
221 }
222
223 Application::AppSignalType& Application::RegionChangedSignal()
224 {
225   return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
226 }
227
228 Application::AppSignalType& Application::BatteryLowSignal()
229 {
230   return Internal::Adaptor::GetImplementation(*this).BatteryLowSignal();
231 }
232
233 Application::AppSignalType& Application::MemoryLowSignal()
234 {
235   return Internal::Adaptor::GetImplementation(*this).MemoryLowSignal();
236 }
237
238 Application::Application(Internal::Adaptor::Application* application)
239 : BaseHandle(application)
240 {
241 }
242
243
244 } // namespace Dali