1 #ifndef DALI_INTERNAL_WIDGET_H
2 #define DALI_INTERNAL_WIDGET_H
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/public-api/signals/connection-tracker-interface.h>
33 * @addtogroup dali_adaptor_framework
44 * @brief This is the internal base class of custom widget.
46 * It will provides several widget instance lifecycle virtual functions
47 * which the user can override.
49 * User should override OnCreate function and create scene for custom widget.
51 * Plus, Implements ConnectionTrackerInterface so that signals (typically connected to member functions) will
52 * be disconnected automatically when the control is destroyed.
54 class DALI_IMPORT_API Widget : public BaseObject, public ConnectionTrackerInterface
59 * @brief Creates a new WidgetImpl instance.
61 * @return A handle to the WidgetImpl instance
63 static Dali::Widget New();
66 * @brief The user should override this function to determine when they create widget.
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
71 virtual void OnCreate( const std::string& contentInfo, Dali::Window window );
74 * @brief The user should override this function to determine when they terminate widget.
76 * @param[in] contentInfo Data from WidgetView for deleting
77 * @param[in] type Termination type. When user delete widget view, termination type is PERMANENT.
79 virtual void OnTerminate( const std::string& contentInfo, Dali::Widget::Termination::Type type );
82 * @brief The user should override this function to determine when they pause widget.
84 virtual void OnPause();
87 * @brief The user should override this function to determine when they resume widget.
89 virtual void OnResume();
92 * @brief The user should override this function to determine when they resize widget.
94 * @param[in] window Window handle for widget
96 virtual void OnResize( Dali::Window window );
99 * @brief The user should override this function to determine when they update widget.
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
104 virtual void OnUpdate( const std::string& contentInfo, int force );
106 // From ConnectionTrackerInterface
109 * @copydoc ConnectionTrackerInterface::SignalConnected
111 virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback );
114 * @copydoc ConnectionTrackerInterface::SignalDisconnected
116 virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
119 * @brief Set content info to WidgetView.
121 * @param[in] contentInfo Content info is kind of context information which contains current status of widget.
123 void SetContentInfo( const std::string& contentInfo );
128 * @brief WidgetImpl constructor
133 * @brief Virtual destructor
139 class Impl; // Class declaration is public so we can internally add devel API's to the WidgetImpl
142 * Set pointer of WidgetImpl Internal.
144 void SetImpl( Widget::Impl* impl );
150 DALI_INTERNAL Widget(const Widget&);
151 DALI_INTERNAL Widget& operator=(Widget&);
157 * @brief Gets implementation from the handle.
160 * @return Implementation
161 * @pre handle is initialized and points to a widget
163 DALI_IMPORT_API Internal::Adaptor::Widget& GetImplementation( Dali::Widget& widget );
166 * @brief Gets implementation from the handle.
169 * @return Implementation
170 * @pre Handle is initialized and points to a widget.
172 DALI_IMPORT_API const Internal::Adaptor::Widget& GetImplementation( const Dali::Widget& widget );
174 } // namespace Adaptor
176 } // namespace Internal
183 #endif // DALI_INTERNAL_WIDGET_H