[Tizen] Create Widget Application
[platform/core/uifw/dali-adaptor.git] / adaptors / widget / widget.h
1 #ifndef __DALI_WIDGET_H__
2 #define __DALI_WIDGET_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/object/base-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
24 #include <bundle.h>
25 #include <dali/public-api/math/vector2.h>
26 #include <dali/public-api/math/uint-16-pair.h>
27
28 // INTERNAL INCLUDES
29 #include "widget-data.h"
30
31 namespace Dali
32 {
33
34 namespace Internal DALI_INTERNAL
35 {
36
37 namespace Adaptor
38 {
39 class Widget;
40 }
41
42 }
43
44 class WidgetData;
45
46 /**
47  * @brief Widget object should be created by WidgetApplication.
48  */
49
50 class DALI_IMPORT_API Widget : public BaseHandle
51 {
52 public:
53
54   /**
55    * @brief Enumeration for terminate type of widget instance.
56    */
57   typedef enum
58   {
59     PERMANENT, /**< User deleted this widget from the viewer */
60     TEMPORARY, /**< Widget is deleted because of other reasons (e.g. widget process is terminated temporarily by the system) */
61   } WidgetTerminateType;
62
63   typedef enum
64   {
65     APP_DEAD = 0,
66     CREATE  = 1,    /**< The widget is created */
67     DESTROY = 2,    /**< The widget is destroyed */
68     PAUSE   = 3,    /**< The widget is paused */
69     RESUME  = 4,    /**< The widget is resumed */
70   } WidgetLifecycleEventType;
71
72   typedef Uint16Pair WindowSize;
73
74   typedef Signal< void (WidgetData, bundle*, WindowSize) > WidgetInstanceCreateSignalType;  ///< Widget instance lifecycle signal and system signal callback type
75   typedef Signal< void (WidgetData, bundle*, WidgetTerminateType) > WidgetInstanceTerminateSignalType;  ///< Widget instance lifecycle signal and system signal callback type
76   typedef Signal< void (WidgetData) > WidgetInstancePauseSignalType;  ///< Widget instance lifecycle signal and system signal callback type
77   typedef Signal< void (WidgetData) > WidgetInstanceResumeSignalType;  ///< Widget instance lifecycle signal and system signal callback type
78   typedef Signal< void (WidgetData, WindowSize) > WidgetInstanceResizeSignalType;  ///< Widget instance lifecycle signal and system signal callback type
79   typedef Signal< void (WidgetData, bundle*, int) > WidgetInstanceUpdateSignalType;  ///< Widget instance lifecycle signal and system signal callback type
80
81 public:
82
83   /**
84    * @brief This is the constructor for Widget.
85    * @param[in]      id for widget instance
86    * @return A handle to the Widget
87    */
88   static Widget New( const std::string& id );
89
90   /**
91    * @brief The default constructor.
92    *
93    */
94   Widget();
95
96   /**
97    * @brief Copy Constructor.
98    * @param[in] Widget Handle to an object
99    */
100   Widget( const Widget& widget );
101
102   /**
103    * @brief Assignment operator.
104    * @param[in] Widget Handle to an object
105    * @return A reference to this
106    */
107   Widget& operator=( const Widget& widget );
108
109   /**
110    * @brief Destructor
111    *
112    */
113   ~Widget();
114
115 public:  // Signals
116
117   /**
118    * @brief The user should connect to this signal to determine when they create widget instance.
119    * @return The signal to connect to
120    */
121   WidgetInstanceCreateSignalType& CreateSignal();
122
123   /**
124    * @brief The user should connect to this signal to determine when they terminate widget instance.
125    * @return The signal to connect to
126    */
127   WidgetInstanceTerminateSignalType& TerminateSignal();
128
129   /**
130    * @brief This signal is emitted when the language is changed on the device.
131    * @return The signal to connect to
132    */
133   WidgetInstancePauseSignalType& PauseSignal();
134
135   /**
136   * @brief This signal is emitted when the region of the device is changed.
137   * @return The signal to connect to
138   */
139   WidgetInstanceResumeSignalType& ResumeSignal();
140
141   /**
142   * @brief This signal is emitted when the battery level of the device is low.
143   * @return The signal to connect to
144   */
145   WidgetInstanceResizeSignalType& ResizeSignal();
146
147   /**
148   * @brief This signal is emitted when the memory level of the device is low.
149   * @return The signal to connect to
150   */
151   WidgetInstanceUpdateSignalType& UpdateSignal();
152
153 public: // Not intended for application developers
154   /// @cond internal
155   /**
156    * @brief Internal constructor.
157    */
158   explicit DALI_INTERNAL Widget(Internal::Adaptor::Widget* widget);
159   /// @endcond
160 };
161
162 } // namespace Dali
163
164 #endif // ___DALI_WIDGET_H__