Revert "[4.0] Implement WebEngineLite interface and plugin for Minimized Web Engine"
[platform/core/uifw/dali-adaptor.git] / adaptors / widget / internal / widget-application-impl.h
1 #ifndef __DALI_INTERNAL_WIDGET_APPLICATION_H__
2 #define __DALI_INTERNAL_WIDGET_APPLICATION_H__
3
4 /*
5  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/math/rect.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <widget-application.h>
27 #include <singleton-service.h>
28
29 #include <framework.h>
30 #include <window.h>
31 #include <base/environment-options.h>
32
33 namespace Dali
34 {
35 class Adaptor;
36
37 namespace Internal
38 {
39
40 namespace Adaptor
41 {
42 class CommandLineOptions;
43 class EventLoop;
44
45 class WidgetApplication;
46 typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
47
48 /**
49  * Implementation of the WidgetApplication class.
50  */
51 class WidgetApplication : public BaseObject, public Framework::Observer
52 {
53 public:
54   typedef Dali::WidgetApplication::AppSignalType AppSignalType;
55
56   /**
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
61    */
62   static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
63
64 public:
65
66   /**
67    * @copydoc Dali::WidgetApplication::MainLoop()
68    */
69   void MainLoop();
70
71   /**
72    * @copydoc Dali::WidgetApplication::Quit()
73    */
74   void Quit();
75
76   /**
77    * @copydoc Dali::WidgetApplication::GetWindow();
78    */
79   Dali::Window GetWindow();
80
81   /**
82    * @copydoc Dali::WidgetApplication::GetAdaptor();
83    */
84   Dali::Adaptor& GetAdaptor();
85
86   /**
87    * @copydoc Dali::WidgetApplication::GetResourcePath();
88    */
89   static std::string GetResourcePath();
90
91 public: // Lifecycle functionality
92
93   /**
94    * Called when OnInit is called or the framework is initialised.
95    */
96   void DoInit();
97
98   /**
99    * Called after OnInit is called or the framework is started.
100    */
101   void DoStart();
102
103   /**
104    * Called when OnTerminate is called or the framework is terminated.
105    */
106   void DoTerminate();
107
108   /**
109    * Called when OnLanguageChanged is called or the framework informs the application that the language of the device has changed.
110    */
111   void DoLanguageChange();
112
113 public: // From Framework::Observer
114
115   /**
116    * Called when the framework is initialised.
117    */
118   virtual void OnInit();
119
120   /**
121    * Called when the framework is terminated.
122    */
123   virtual void OnTerminate();
124
125   /**
126    * Called when the framework informs the application that the language of the device has changed.
127    */
128   virtual void OnLanguageChanged();
129
130   /**
131   * Called when the framework informs the application that the region of the device has changed.
132   */
133   virtual void OnRegionChanged();
134
135   /**
136   * Called when the framework informs the application that the battery level of the device is low.
137   */
138   virtual void OnBatteryLow();
139
140   /**
141   * Called when the framework informs the application that the memory level of the device is low.
142   */
143   virtual void OnMemoryLow();
144
145 public:  // Signals
146
147   /**
148    * @copydoc Dali::WidgetApplication::InitSignal()
149    */
150    Dali::WidgetApplication::AppSignalType& InitSignal() { return mInitSignal; }
151
152   /**
153    * @copydoc Dali::WidgetApplication::TerminateSignal()
154    */
155   Dali::WidgetApplication::AppSignalType& TerminateSignal() { return mTerminateSignal; }
156
157   /**
158    * @copydoc Dali::WidgetApplication::LanguageChangedSignal()
159    */
160   Dali::WidgetApplication::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
161
162   /**
163   * @copydoc Dali::WidgetApplication::RegionChangedSignal()
164   */
165   Dali::WidgetApplication::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
166
167   /**
168   * @copydoc Dali::WidgetApplication::BatteryLowSignal()
169   */
170   Dali::WidgetApplication::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
171
172   /**
173   * @copydoc Dali::WidgetApplication::MemoryLowSignal()
174   */
175   Dali::WidgetApplication::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
176
177 protected:
178
179   /**
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
184    */
185   WidgetApplication( int* argc, char **argv[], const std::string& stylesheet );
186
187   /**
188    * Destructor
189    */
190   virtual ~WidgetApplication();
191
192   // Undefined
193   WidgetApplication(const Application&);
194   WidgetApplication& operator=(Application&);
195
196   /**
197    * Creates the adaptor
198    */
199   void CreateAdaptor();
200
201   /**
202    * Quits from the main loop
203    */
204   void QuitFromMainLoop();
205
206   /**
207    * Add idle
208    */
209   bool AddIdle( CallbackBase* callback );
210
211 private:
212
213   AppSignalType                         mInitSignal;
214   AppSignalType                         mTerminateSignal;
215   AppSignalType                         mLanguageChangedSignal;
216   AppSignalType                         mRegionChangedSignal;
217   AppSignalType                         mBatteryLowSignal;
218   AppSignalType                         mMemoryLowSignal;
219
220   Framework*                            mFramework;
221
222   Dali::Configuration::ContextLoss      mContextLossConfiguration;
223   CommandLineOptions*                   mCommandLineOptions;
224
225   Dali::SingletonService                mSingletonService;
226   Dali::Adaptor*                        mAdaptor;
227   Dali::Window                          mWindow;
228   std::string                           mName;
229   std::string                           mStylesheet;
230   EnvironmentOptions                    mEnvironmentOptions;
231
232   SlotDelegate< WidgetApplication >     mSlotDelegate;
233 };
234
235 inline WidgetApplication& GetImplementation(Dali::WidgetApplication& widgetApplication)
236 {
237   DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
238
239   BaseObject& handle = widgetApplication.GetBaseObject();
240
241   return static_cast<Internal::Adaptor::WidgetApplication&>(handle);
242 }
243
244 inline const WidgetApplication& GetImplementation(const Dali::WidgetApplication& widgetApplication)
245 {
246   DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
247
248   const BaseObject& handle = widgetApplication.GetBaseObject();
249
250   return static_cast<const Internal::Adaptor::WidgetApplication&>(handle);
251 }
252
253 } // namespace Adaptor
254
255 } // namespace Internal
256
257 } // namespace Dali
258
259 #endif // __DALI_INTERNAL_WIDGET_APPLICATION_H__