Merge "Set Lock key event in event-handler" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / widget-impl.h
1 #ifndef DALI_INTERNAL_WIDGET_H
2 #define DALI_INTERNAL_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-object.h>
23 #include <dali/public-api/signals/connection-tracker-interface.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/adaptor-framework/widget.h>
27
28 namespace Dali
29 {
30 class Window;
31
32 /**
33  * @addtogroup dali_adaptor_framework
34  * @{
35  */
36
37 namespace Internal
38 {
39
40 namespace Adaptor
41 {
42
43 class Widget;
44 typedef IntrusivePtr<Widget> WidgetPtr;
45
46 /**
47  * @brief This is the internal base class of custom widget.
48  *
49  * It will provides several widget instance lifecycle virtual functions
50  * which the user can override.
51  *
52  * User should override OnCreate function and create scene for custom widget.
53  *
54  * Plus, Implements ConnectionTrackerInterface so that signals (typically connected to member functions) will
55  * be disconnected automatically when the control is destroyed.
56  *
57  * @SINCE_1_3_5
58  */
59 class DALI_IMPORT_API Widget : public BaseObject, public ConnectionTrackerInterface
60 {
61 public:
62
63   /**
64    * @brief Creates a new WidgetImpl instance.
65    *
66    * @SINCE_1_3_5
67    * @return A handle to the WidgetImpl instance
68    */
69   static WidgetPtr New();
70
71   /**
72    * @brief The user should override this function to determine when they create widget.
73    *
74    * @SINCE_1_3_5
75    * @param[in] contentInfo Information from WidgetView for creating. It contains previous status of widget which is sent by SetContentInfo before.
76    * @param[in] window Window handle for widget
77    */
78   virtual void OnCreate( const std::string& contentInfo, Dali::Window window );
79
80   /**
81    * @brief The user should override this function to determine when they terminate widget.
82    *
83    * @SINCE_1_3_5
84    * @param[in] contentInfo Data from WidgetView for deleting
85    * @param[in] type Termination type. When user delete widget view, termination type is PERMANENT.
86    */
87   virtual void OnTerminate( const std::string& contentInfo, Dali::Widget::Termination type );
88
89   /**
90    * @brief The user should override this function to determine when they pause widget.
91    * @SINCE_1_3_5
92    */
93   virtual void OnPause();
94
95   /**
96    * @brief The user should override this function to determine when they resume widget.
97    * @SINCE_1_3_5
98    */
99   virtual void OnResume();
100
101   /**
102    * @brief The user should override this function to determine when they resize widget.
103    *
104    * @SINCE_1_3_5
105    * @param[in] window Window handle for widget
106    */
107   virtual void OnResize( Dali::Window window );
108
109   /**
110    * @brief The user should override this function to determine when they update widget.
111    *
112    * @SINCE_1_3_5
113    * @param[in] contentInfo Data from WidgetView for updating
114    * @param[in] force Although the widget is paused, if it is true, the widget can be updated
115    */
116   virtual void OnUpdate( const std::string& contentInfo, int force );
117
118   // From ConnectionTrackerInterface
119
120   /**
121    * @copydoc ConnectionTrackerInterface::SignalConnected
122    */
123   virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback );
124
125   /**
126    * @copydoc ConnectionTrackerInterface::SignalDisconnected
127    */
128   virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
129
130   /**
131    * @brief Set content info to WidgetView.
132    *
133    * @SINCE_1_3_5
134    * @param[in] contentInfo Content info is kind of context information which contains current status of widget.
135    */
136   void SetContentInfo( const std::string& contentInfo );
137
138 protected:
139
140   /**
141    * @brief WidgetImpl constructor
142    */
143   Widget();
144
145   /**
146    * @brief Virtual destructor
147    */
148   virtual ~Widget();
149
150   /// @cond internal
151 public:
152   class Impl; // Class declaration is public so we can internally add devel API's to the WidgetImpl
153
154   /**
155    * Set pointer of WidgetImpl Internal.
156    * @SINCE_1_3_5
157    */
158   void SetImpl( Impl* impl );
159
160 private:
161   Impl* mImpl;
162
163   // Undefined
164   DALI_INTERNAL Widget(const Widget&);
165   DALI_INTERNAL Widget& operator=(Widget&);
166   /// @endcond
167
168 };
169
170 /**
171  * @brief Gets implementation from the handle.
172  *
173  * @SINCE_1_3_5
174  * @param handle
175  * @return Implementation
176  * @pre handle is initialized and points to a widget
177  */
178 DALI_IMPORT_API Internal::Adaptor::Widget& GetImplementation( Dali::Widget& widget );
179
180 /**
181  * @brief Gets implementation from the handle.
182  *
183  * @SINCE_1_3_5
184  * @param handle
185  * @return Implementation
186  * @pre Handle is initialized and points to a widget.
187  */
188 DALI_IMPORT_API const Internal::Adaptor::Widget& GetImplementation( const Dali::Widget& widget );
189
190 } // namespace Adaptor
191
192 } // namespace Internal
193
194 /**
195  * @}
196  */
197
198 } // namespace Dali
199 #endif // DALI_INTERNAL_WIDGET_H