VirtualKeyboard API for Settings
[platform/core/uifw/dali-adaptor.git] / adaptors / common / application-impl.h
1 #ifndef __DALI_INTERNAL_APPLICATION_H__
2 #define __DALI_INTERNAL_APPLICATION_H__
3
4 /*
5  * Copyright (c) 2014 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 <application.h>
27 #include <singleton-service.h>
28
29 #include <framework.h>
30 #include <window-impl.h>
31
32 namespace Dali
33 {
34 class Adaptor;
35 class Window;
36
37 namespace Internal
38 {
39
40 namespace Adaptor
41 {
42 class CommandLineOptions;
43 class EventLoop;
44
45 typedef Dali::Rect<int> PositionSize;
46
47 class Application;
48 typedef IntrusivePtr<Application> ApplicationPtr;
49
50 /**
51  * Implementation of the Application class.
52  */
53 class Application : public BaseObject, public Framework::Observer
54 {
55 public:
56
57   typedef Dali::Application::AppSignalType AppSignalType;
58   typedef Dali::Application::AppControlSignalType AppControlSignalType;
59   typedef Dali::Application::WINDOW_MODE WINDOW_MODE;
60
61   /**
62    * Create a new application
63    * @param[in]  argc        A pointer to the number of arguments
64    * @param[in]  argv        A pointer to the argument list
65    * @param[in]  stylesheet  The path to user defined theme file
66    * @param[in]  windowMode  A member of Dali::Application::WINDOW_MODE
67    */
68   static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
69
70 public:
71
72   /**
73    * @copydoc Dali::Application::MainLoop()
74    */
75   void MainLoop(Dali::Configuration::ContextLoss configuration);
76
77   /**
78    * @copydoc Dali::Application::Lower()
79    */
80   void Lower();
81
82   /**
83    * @copydoc Dali::Application::Quit()
84    */
85   void Quit();
86
87   /**
88    * @copydoc Dali::Application::AddIdle()
89    */
90   bool AddIdle( CallbackBase* callback );
91
92   /**
93    * @copydoc Dali::Application::GetAdaptor();
94    */
95   Dali::Adaptor& GetAdaptor();
96
97   /**
98    * @copydoc Dali::Application::GetWindow();
99    */
100   Dali::Window GetWindow();
101
102   /**
103    * @copydoc Dali::Application::ReplaceWindow();
104    */
105   void ReplaceWindow(PositionSize windowPosition, const std::string& name);
106
107 public: // Stereoscopy
108
109   /**
110    * @copydoc Dali::Application::SetViewMode()
111    */
112   void SetViewMode( ViewMode viewMode );
113
114   /**
115    * @copydoc Dali::Application::GetViewMode()
116    */
117   ViewMode GetViewMode() const;
118
119   /**
120    * @copydoc Dali::Application::SetStereoBase()
121    */
122   void SetStereoBase( float stereoBase );
123
124   /**
125    * @copydoc Dali::Application::GetStereoBase()
126    */
127   float GetStereoBase() const;
128
129 public: // From Framework::Observer
130
131   /**
132    * Called when the framework is initialised.
133    */
134   virtual void OnInit();
135
136   /**
137    * Called when the framework is terminated.
138    */
139   virtual void OnTerminate();
140
141   /**
142    * Called when the framework is paused.
143    */
144   virtual void OnPause();
145
146   /**
147    * Called when the framework resumes from a paused state.
148    */
149   virtual void OnResume();
150
151   /**
152   * Called when the framework received AppControlSignal.
153   * @param[in] The bundle data of AppControl event.
154   */
155   virtual void OnAppControl(void *data);
156
157   /**
158    * Called when the framework informs the application that it should reset itself.
159    */
160   virtual void OnReset();
161
162   /**
163    * Called when the framework informs the application that the language of the device has changed.
164    */
165   virtual void OnLanguageChanged();
166
167   /**
168   * Called when the framework informs the application that the region of the device has changed.
169   */
170   virtual void OnRegionChanged();
171
172   /**
173   * Called when the framework informs the application that the battery level of the device is low.
174   */
175   virtual void OnBatteryLow();
176
177   /**
178   * Called when the framework informs the application that the memory level of the device is low.
179   */
180   virtual void OnMemoryLow();
181
182 public:
183
184   /**
185    * Signal handler when the adaptor's window resizes itself.
186    * @param[in]  adaptor  The adaptor
187    */
188   void OnResize(Dali::Adaptor& adaptor);
189
190 public:  // Signals
191
192   /**
193    * @copydoc Dali::Application::InitSignal()
194    */
195   Dali::Application::AppSignalType& InitSignal() { return mInitSignal; }
196
197   /**
198    * @copydoc Dali::Application::TerminateSignal()
199    */
200   Dali::Application::AppSignalType& TerminateSignal() { return mTerminateSignal; }
201
202   /**
203    * @copydoc Dali::Application::PauseSignal()
204    */
205   Dali::Application::AppSignalType& PauseSignal() { return mPauseSignal; }
206
207   /**
208    * @copydoc Dali::Application::ResumeSignal()
209    */
210   Dali::Application::AppSignalType& ResumeSignal() { return mResumeSignal; }
211
212   /**
213    * @copydoc Dali::Application::ResetSignal()
214    */
215   Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
216
217   /**
218   * @copydoc Dali::Application::AppControlSignal()
219   */
220   Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
221
222   /**
223    * @copydoc Dali::Application::ResizeSignal()
224    */
225   Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
226
227   /**
228    * @copydoc Dali::Application::LanguageChangedSignal()
229    */
230   Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
231
232   /**
233   * @copydoc Dali::Application::RegionChangedSignal()
234   */
235   Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
236
237   /**
238   * @copydoc Dali::Application::BatteryLowSignal()
239   */
240   Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
241
242   /**
243   * @copydoc Dali::Application::MemoryLowSignal()
244   */
245   Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
246
247 private:
248
249   /**
250    * Private Constructor
251    * @param[in]  argc        A pointer to the number of arguments
252    * @param[in]  argv        A pointer to the argument list
253    * @param[in]  stylesheet  The path to user defined theme file
254    * @param[in]  windowMode  A member of Dali::Application::WINDOW_MODE
255    */
256   Application( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
257
258   /**
259    * Destructor
260    */
261   virtual ~Application();
262
263   // Undefined
264   Application(const Application&);
265   Application& operator=(Application&);
266
267 private:
268   /**
269    * Creates the window
270    */
271   void CreateWindow();
272
273   /**
274    * Creates the adaptor
275    */
276   void CreateAdaptor();
277
278   /**
279    * Quits from the main loop
280    */
281   void QuitFromMainLoop();
282
283 private:
284
285   AppSignalType                           mInitSignal;
286   AppSignalType                           mTerminateSignal;
287   AppSignalType                           mPauseSignal;
288   AppSignalType                           mResumeSignal;
289   AppSignalType                           mResetSignal;
290   AppSignalType                           mResizeSignal;
291   AppControlSignalType                    mAppControlSignal;
292   AppSignalType                           mLanguageChangedSignal;
293   AppSignalType                           mRegionChangedSignal;
294   AppSignalType                           mBatteryLowSignal;
295   AppSignalType                           mMemoryLowSignal;
296
297   EventLoop*                            mEventLoop;
298   Framework*                            mFramework;
299
300   Dali::Configuration::ContextLoss      mContextLossConfiguration;
301   CommandLineOptions*                   mCommandLineOptions;
302
303   Dali::SingletonService                mSingletonService;
304   Dali::Adaptor*                        mAdaptor;
305   Dali::Window                          mWindow;
306   Dali::Application::WINDOW_MODE        mWindowMode;
307   std::string                           mName;
308   std::string                           mStylesheet;
309
310   bool                                  mInitialized;
311
312   SlotDelegate< Application >           mSlotDelegate;
313 };
314
315 inline Application& GetImplementation(Dali::Application& application)
316 {
317   DALI_ASSERT_ALWAYS(application && "application handle is empty");
318
319   BaseObject& handle = application.GetBaseObject();
320
321   return static_cast<Internal::Adaptor::Application&>(handle);
322 }
323
324 inline const Application& GetImplementation(const Dali::Application& application)
325 {
326   DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
327
328   const BaseObject& handle = application.GetBaseObject();
329
330   return static_cast<const Internal::Adaptor::Application&>(handle);
331 }
332
333
334 } // namespace Adaptor
335
336 } // namespace Internal
337
338 } // namespace Dali
339
340 #endif // __DALI_INTERNAL_APPLICATION_H__