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/object/base-object.h>
23 #include <widget_base.h>
27 #include <widget-application.h>
28 #include <singleton-service.h>
30 #include <framework.h>
32 #include <base/environment-options.h>
43 class CommandLineOptions;
46 class WidgetApplication;
47 typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
50 * Implementation of the WidgetApplication class.
52 class WidgetApplication : public BaseObject, public Framework::Observer
55 typedef Dali::WidgetApplication::AppSignalType AppSignalType;
56 typedef Dali::WidgetApplication::LowBatterySignalType LowBatterySignalType;
57 typedef Dali::WidgetApplication::LowMemorySignalType LowMemorySignalType;
60 * Create a new widget application
61 * @param[in] argc A pointer to the number of arguments
62 * @param[in] argv A pointer to the argument list
63 * @param[in] stylesheet The path to user defined theme file
65 static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
70 * @copydoc Dali::WidgetApplication::MainLoop()
75 * @copydoc Dali::WidgetApplication::Quit()
80 * @copydoc Dali::WidgetApplication::GetAdaptor();
82 Dali::Adaptor& GetAdaptor();
85 * @copydoc Dali::WidgetApplication::GetResourcePath();
87 static std::string GetResourcePath();
90 * @copydoc Dali::WidgetApplication::GetRegion();
92 std::string GetRegion();
95 * @copydoc Dali::WidgetApplication::GetLanguage();
97 std::string GetLanguage();
99 public: // Lifecycle functionality
102 * Called when OnInit is called or the framework is initialised.
107 * Called after OnInit is called or the framework is started.
112 * Called when OnTerminate is called or the framework is terminated.
117 * Called when OnLanguageChanged is called or the framework informs the application that the language of the device has changed.
119 void DoLanguageChange();
121 public: // From Framework::Observer
124 * Called when the framework is initialised.
126 virtual void OnInit();
129 * Called when the framework is terminated.
131 virtual void OnTerminate();
134 * Called when the framework informs the application that the language of the device has changed.
136 virtual void OnLanguageChanged();
139 * Called when the framework informs the application that the region of the device has changed.
141 virtual void OnRegionChanged();
144 * Called when the framework informs the application that the battery level of the device is low.
146 virtual void OnBatteryLow( Dali::DeviceStatus::Battery::Status status );
149 * Called when the framework informs the application that the memory level of the device is low.
151 virtual void OnMemoryLow( Dali::DeviceStatus::Memory::Status status );
156 * @copydoc Dali::WidgetApplication::InitSignal()
158 Dali::WidgetApplication::AppSignalType& InitSignal() { return mInitSignal; }
161 * @copydoc Dali::WidgetApplication::TerminateSignal()
163 Dali::WidgetApplication::AppSignalType& TerminateSignal() { return mTerminateSignal; }
166 * @copydoc Dali::WidgetApplication::LanguageChangedSignal()
168 Dali::WidgetApplication::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
171 * @copydoc Dali::WidgetApplication::RegionChangedSignal()
173 Dali::WidgetApplication::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
176 * @copydoc Dali::WidgetApplication::LowBatterySignal()
178 Dali::WidgetApplication::LowBatterySignalType& LowBatterySignal() { return mLowBatterySignal; }
181 * @copydoc Dali::WidgetApplication::LowMemorySignal()
183 Dali::WidgetApplication::LowMemorySignalType& LowMemorySignal() { return mLowMemorySignal; }
188 * Private Constructor
189 * @param[in] argc A pointer to the number of arguments
190 * @param[in] argv A pointer to the argument list
191 * @param[in] stylesheet The path to user defined theme file
193 WidgetApplication( int* argc, char **argv[], const std::string& stylesheet );
198 virtual ~WidgetApplication();
201 WidgetApplication(const Application&);
202 WidgetApplication& operator=(Application&);
205 * Creates the adaptor
207 void CreateAdaptor();
210 * Quits from the main loop
212 void QuitFromMainLoop();
217 bool AddIdle( CallbackBase* callback );
221 AppSignalType mInitSignal;
222 AppSignalType mTerminateSignal;
223 AppSignalType mLanguageChangedSignal;
224 AppSignalType mRegionChangedSignal;
225 LowBatterySignalType mLowBatterySignal;
226 LowMemorySignalType mLowMemorySignal;
228 Framework* mFramework;
230 Dali::Configuration::ContextLoss mContextLossConfiguration;
231 CommandLineOptions* mCommandLineOptions;
233 Dali::SingletonService mSingletonService;
234 Dali::Adaptor* mAdaptor;
235 Dali::Window mWindow;
237 std::string mStylesheet;
238 EnvironmentOptions mEnvironmentOptions;
240 SlotDelegate< WidgetApplication > mSlotDelegate;
243 inline WidgetApplication& GetImplementation(Dali::WidgetApplication& widgetApplication)
245 DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
247 BaseObject& handle = widgetApplication.GetBaseObject();
249 return static_cast<Internal::Adaptor::WidgetApplication&>(handle);
252 inline const WidgetApplication& GetImplementation(const Dali::WidgetApplication& widgetApplication)
254 DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
256 const BaseObject& handle = widgetApplication.GetBaseObject();
258 return static_cast<const Internal::Adaptor::WidgetApplication&>(handle);
261 } // namespace Adaptor
263 } // namespace Internal
267 #endif // __DALI_INTERNAL_WIDGET_APPLICATION_H__