Tizen 2.1 base
[framework/osp/uifw.git] / src / app / inc / FApp_UiAppImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FApp_UiAppImpl.h
20  * @brief       This is the header file for the %_UiAppImpl class.
21  */
22
23 #ifndef _FAPP_INTERNAL_UI_APP_IMPL_H_
24 #define _FAPP_INTERNAL_UI_APP_IMPL_H_
25
26 #include <app.h>
27
28 #include <FAppUiApp.h>
29 #include <FBaseRtIEventListener.h>
30
31 #include <FUi_IKeyEventListener.h>
32 #include <FUi_IUiEventListener.h>
33
34 #include "FApp_IAppImpl.h"
35
36 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
37 namespace Tizen { namespace Ui {namespace Controls { class Frame; } } }
38
39 namespace Tizen { namespace App
40 {
41
42 class IAppFrame;
43 class _AppFrame;
44
45 /**
46  * @class       _UiAppImpl
47  * @brief       This class is the Impl class of a UiApp class.
48  * @since 2.0
49  *
50  * This class is the Impl class of a UiApp class.
51  */
52 class _OSP_EXPORT_ _UiAppImpl
53         : public Tizen::Base::Object
54         , public Tizen::App::_IAppImpl
55         , public Tizen::Ui::_IKeyEventListener
56         , virtual public Tizen::Ui::_IUiEventListener
57         , virtual public Tizen::Base::Runtime::IEventListener
58 {
59 public:
60         /**
61         * Returns the _UiAppImpl's instance pointer.
62         *
63         * @since 2.0
64         * @return       A pointer to the %_UiAppImpl instance, @n
65         *                       else @c null if it fails
66         */
67         static _UiAppImpl* GetInstance(void);
68
69         /**
70         * Returns the UiApp's instance pointer.
71         *
72         * @since 2.0
73         * @return       A pointer to the %UiApp instance, @n
74         *                       else @c null if it fails
75         */
76         UiApp* GetUiAppInstance(void);
77
78         /**
79          * Called when the application is started
80          *
81          * @since 2.0
82          * @return      @c true if the method is successful, @n
83          *              else @c false
84          * @param[in]   user_data       The user data passed from the callback registration function
85          * @remarks     This is a system dependent callback function
86          */
87         virtual bool OnCreate(void);
88
89         /**
90          * Called when other application send the launch request to the application
91          *
92          * @since 2.0
93          * @param[in]   service The handle to the service
94          * @param[in]   user_data       The user data passed from the callback registration function
95          * @remarks     This is a system dependent callback function
96          */
97         virtual void OnService(service_s* service, bool initial);
98
99         /**
100          * Called when the application is completely obscured by another application and becomes invisible
101          *
102          * @since 2.0
103          * @param[in]   user_data       The user data passed from the callback registration function
104          * @remarks     This is a system dependent callback function
105          */
106         virtual void OnPause(void);
107
108         /**
109          * Called when the application becomes visible
110          *
111          * @since 2.0
112          * @param[in]   user_data       The user data passed from the callback registration function
113          * @remarks     This is a system dependent callback function
114          */
115         virtual void OnResume(void);
116
117         /**
118          * Called once after the main loop of application exits
119          *
120          * @since 2.0
121          * @param[in]   user_data       The user data passed from the callback registration function
122          * @remarks     This is a system dependent callback function
123          */
124         virtual void OnTerminate(void);
125
126         /**
127          * Called when an orintation event occurs.
128          *
129          * @since 2.0
130          * @param[in]   orientation     The information about the orientation event
131          */
132         virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation);
133
134         /**
135          * Called when the application's state changes to Tizen::App::AppState::INITIALIZING. @n
136          *
137          * @since 2.0
138          * @return      @c true if the method is successful, @n
139          *              else @c false
140          */
141         virtual bool OnAppInitializing(void);
142
143         /**
144          * Called when the application's INITIALIZING state is finished
145          *
146          * @since 2.0
147          * @return      @c true if the method is successful, @n
148          *                      else @c false
149          */
150         virtual bool OnAppInitialized(void);
151
152
153         /**
154          * Called when the internal window handle is required.
155          *
156          * @since 2.0
157          */
158         virtual long OnWindowHandleRequest(void);
159
160         /**
161          * Called when the application's state change to Tizen::App::AppState::TERMINATING. @n
162          *
163          * @since 2.0
164          * @param[in]   forcedTermination       @c true if the application terminate by system or other application, else @c false.
165          * @return      @c true if the method is successful, @n
166          *              else @c false
167          */
168         bool OnUiAppImplTerminating(void);
169
170         /**
171          * Gets the first frame in the frame list of the UI application. @n
172          *
173          * @since 2.0
174          *
175          * @return      A pointer to the IAppFrame interface of the frame, @n
176          *                      else @c null if it fails
177          */
178         IAppFrame* GetAppFrame(void);
179
180         /**
181          * Notifies when a key is pressed.
182          *
183          * @since 2.0
184          * @param[in]   source          The source of the event
185          * @param[in]   keyCode         The key code
186          */
187         virtual bool OnKeyPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_KeyInfo& keyInfo);
188
189         /**
190          * Notifies when a key is released.
191          *
192          * @since 2.0
193          * @param[in]   source          The source of the event
194          * @param[in]   keyCode         The key code
195          */
196         virtual bool OnKeyReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_KeyInfo& keyInfo);
197
198 private:
199         /**
200          * This is the default constructor for this class.
201          *
202          * @since 2.0
203          */
204         _UiAppImpl(void);
205
206         /**
207          * This is the constructor for this class.
208          *
209          * @since 2.0
210          */
211         _UiAppImpl(UiApp* pUiApp);
212
213         /**
214          * This is the copy constructor for the this class.
215          */
216         _UiAppImpl(const _UiAppImpl& source);
217
218         /**
219          * This is the assignment operator for this class.
220          */
221         _UiAppImpl& operator =(const _UiAppImpl& source);
222
223         /**
224          * This is the destructor for this class.
225          *
226          * @since 2.0
227          */
228         virtual ~_UiAppImpl(void);
229
230         /**
231          * Delete all frames of Ui application. @n
232          *
233          * @since 2.0
234          *
235          * @return      An error code
236          */
237         result RemoveAllFrames(void);
238
239         /**
240          * Adds the frame at the end of the list maintained by the UI application. @n
241          *
242          * @since 2.0
243          *
244          * @return      An error code
245          * @param[in]   frame               The frame to be added to the UI application
246          * @exception   E_SUCCESS           The method was successful.
247          * @exception   E_INVALID_ARG       The specified input parameter is invalid.
248          * @exception   E_INVALID_STATE     The application state is invalid.
249          * @exception   E_OBJ_ALREADY_EXIST The frame to be added is already registered to the UI application.
250          * @exception   E_OUT_OF_MEMORY     Insufficient memory.
251          * @exception   E_MAX_EXCEEDED      The number of frame has exceeded the maximum limit.
252          * @exception   E_SYSTEM            A system error occurred.
253          */
254         result AddFrame(const Tizen::Ui::Controls::Frame& frame);
255
256         /**
257          * Removes the specified frame from the UI application. @n
258          *
259          * @since 2.0
260          *
261          * @return      An error code
262          * @param[in]   frame           The frame to be removed
263          * @exception   E_SUCCESS       The method was successful.
264          * @exception   E_OBJ_NOT_FOUND The specified frame is not found.
265          * @exception   E_SYSTEM        A system error occurred.
266          * @remarks     The removed frame is deleted from the memory.
267          */
268         result RemoveFrame(const Tizen::Ui::Controls::Frame& frame);
269
270         /**
271          * Gets the list of the frames of the UI application. @n
272          *
273          * @since 2.0
274          *
275          * @return      A pointer to IList that contains the registered frames @n
276          *                      else @c null if it fails
277          * @exception   E_SUCCESS           The method is successful.
278          * @exception   E_INVALID_STATE     The application state is invalid.
279          * @remarks     The specific error code can be accessed using the GetLastResult() method.
280          */
281         Tizen::Base::Collection::IList* GetFrameList(void);
282
283         /**
284          * Gets the frame with the specified name. @n
285          *
286          * @since 2.0
287          *
288          * @return      A pointer to the frame having the specified name@n
289          *                      else @c null if it fails
290          * @param[in]   name                The name of the frame
291          * @exception   E_SUCCESS           The method is successful.
292          * @exception   E_OBJ_NOT_FOUND     The frame which has specified name is not fount.
293          * @remarks     The specific error code can be accessed using the GetLastResult() method.
294          */
295         Tizen::Ui::Controls::Frame* GetFrame(const Tizen::Base::String& name);
296
297         Tizen::Ui::Controls::Frame* GetFrameAt(int index);
298
299         /**
300          * Gets the UI state of the UI application.
301          *
302          * @since 2.0
303          * @return      The UI state of the UI application
304          */
305         AppUiState GetAppUiState(void) const;
306
307         void OnForeground(void);
308
309         void OnBackground(void);
310
311 private:
312         static _UiAppImpl* __pUiAppImpl;
313
314         _AppFrame* __pAppFrame;
315
316         _AppImpl* __pAppImpl;
317
318         AppUiState __appUiState;
319
320         Tizen::Base::Collection::ArrayList* __pFrameList;
321
322         UiApp* __pUiApp;
323
324         friend class UiApp;
325
326         friend class _ImeAppImpl;
327 }; //_UiAppImpl
328
329 } } //Tizen::App
330
331 #endif // _FAPP_INTERNAL_UI_APP_IMPL_H_