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