1 #ifndef __DALI_INTERNAL_WIDGET_APPLICATION_H__
2 #define __DALI_INTERNAL_WIDGET_APPLICATION_H__
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/math/rect.h>
23 #include <dali/public-api/object/base-object.h>
26 #include <widget-application.h>
27 #include <singleton-service.h>
29 #include <framework.h>
31 #include <base/environment-options.h>
42 class CommandLineOptions;
45 class WidgetApplication;
46 typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
49 * Implementation of the WidgetApplication class.
51 class WidgetApplication : public BaseObject, public Framework::Observer
54 typedef Dali::WidgetApplication::AppSignalType AppSignalType;
57 * Create a new widget application
58 * @param[in] argc A pointer to the number of arguments
59 * @param[in] argv A pointer to the argument list
60 * @param[in] stylesheet The path to user defined theme file
62 static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
67 * @copydoc Dali::WidgetApplication::MainLoop()
72 * @copydoc Dali::WidgetApplication::Quit()
77 * @copydoc Dali::WidgetApplication::GetWindow();
79 Dali::Window GetWindow();
82 * @copydoc Dali::WidgetApplication::GetAdaptor();
84 Dali::Adaptor& GetAdaptor();
87 * @copydoc Dali::WidgetApplication::GetResourcePath();
89 static std::string GetResourcePath();
91 public: // Lifecycle functionality
94 * Called when OnInit is called or the framework is initialised.
99 * Called after OnInit is called or the framework is started.
104 * Called when OnTerminate is called or the framework is terminated.
109 * Called when OnLanguageChanged is called or the framework informs the application that the language of the device has changed.
111 void DoLanguageChange();
113 public: // From Framework::Observer
116 * Called when the framework is initialised.
118 virtual void OnInit();
121 * Called when the framework is terminated.
123 virtual void OnTerminate();
126 * Called when the framework informs the application that the language of the device has changed.
128 virtual void OnLanguageChanged();
131 * Called when the framework informs the application that the region of the device has changed.
133 virtual void OnRegionChanged();
136 * Called when the framework informs the application that the battery level of the device is low.
138 virtual void OnBatteryLow();
141 * Called when the framework informs the application that the memory level of the device is low.
143 virtual void OnMemoryLow();
148 * @copydoc Dali::WidgetApplication::InitSignal()
150 Dali::WidgetApplication::AppSignalType& InitSignal() { return mInitSignal; }
153 * @copydoc Dali::WidgetApplication::TerminateSignal()
155 Dali::WidgetApplication::AppSignalType& TerminateSignal() { return mTerminateSignal; }
158 * @copydoc Dali::WidgetApplication::LanguageChangedSignal()
160 Dali::WidgetApplication::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
163 * @copydoc Dali::WidgetApplication::RegionChangedSignal()
165 Dali::WidgetApplication::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
168 * @copydoc Dali::WidgetApplication::BatteryLowSignal()
170 Dali::WidgetApplication::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
173 * @copydoc Dali::WidgetApplication::MemoryLowSignal()
175 Dali::WidgetApplication::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
180 * Private Constructor
181 * @param[in] argc A pointer to the number of arguments
182 * @param[in] argv A pointer to the argument list
183 * @param[in] stylesheet The path to user defined theme file
185 WidgetApplication( int* argc, char **argv[], const std::string& stylesheet );
190 virtual ~WidgetApplication();
193 WidgetApplication(const Application&);
194 WidgetApplication& operator=(Application&);
197 * Creates the adaptor
199 void CreateAdaptor();
202 * Quits from the main loop
204 void QuitFromMainLoop();
209 bool AddIdle( CallbackBase* callback );
213 AppSignalType mInitSignal;
214 AppSignalType mTerminateSignal;
215 AppSignalType mLanguageChangedSignal;
216 AppSignalType mRegionChangedSignal;
217 AppSignalType mBatteryLowSignal;
218 AppSignalType mMemoryLowSignal;
220 Framework* mFramework;
222 Dali::Configuration::ContextLoss mContextLossConfiguration;
223 CommandLineOptions* mCommandLineOptions;
225 Dali::SingletonService mSingletonService;
226 Dali::Adaptor* mAdaptor;
227 Dali::Window mWindow;
229 std::string mStylesheet;
230 EnvironmentOptions mEnvironmentOptions;
232 SlotDelegate< WidgetApplication > mSlotDelegate;
235 inline WidgetApplication& GetImplementation(Dali::WidgetApplication& widgetApplication)
237 DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
239 BaseObject& handle = widgetApplication.GetBaseObject();
241 return static_cast<Internal::Adaptor::WidgetApplication&>(handle);
244 inline const WidgetApplication& GetImplementation(const Dali::WidgetApplication& widgetApplication)
246 DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
248 const BaseObject& handle = widgetApplication.GetBaseObject();
250 return static_cast<const Internal::Adaptor::WidgetApplication&>(handle);
253 } // namespace Adaptor
255 } // namespace Internal
259 #endif // __DALI_INTERNAL_WIDGET_APPLICATION_H__