e14960dc1795ecf5150020dbeb1aa01d6ee67f51
[platform/core/uifw/widget-viewer-dali.git] / internal / widget_view / widget_view_impl.h
1 #ifndef __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__
2 #define __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__
3
4 /*
5  * Copyright (c) 2016 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 // INTERNAL INCLUDES
22 #include <public_api/widget_view/widget_view.h>
23
24 // EXTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
27 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
28 #include <pepper-dali/public-api/object-view/object-view.h>
29 #include <bundle.h>
30
31 namespace Dali
32 {
33
34 namespace WidgetView
35 {
36
37 namespace Internal
38 {
39
40 class WidgetView : public Toolkit::Internal::Control
41 {
42 public:
43
44   /**
45    * @copydoc Dali::WidgetView::WidgetView::New
46    */
47   static Dali::WidgetView::WidgetView New( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period );
48
49   /**
50    * @copydoc Dali::WidgetView::WidgetView::GetWidgetId
51    */
52   const std::string& GetWidgetId() const;
53
54   /**
55    * @copydoc Dali::WidgetView::WidgetView::GetInstanceId
56    */
57   const std::string& GetInstanceId() const;
58
59   /**
60    * @copydoc Dali::WidgetView::WidgetView::GetContentInfo
61    */
62   const std::string& GetContentInfo();
63
64   /**
65    * @copydoc Dali::WidgetView::WidgetView::GetTitle
66    */
67   const std::string& GetTitle();
68
69   /**
70    * @copydoc Dali::WidgetView::WidgetView::GetPeriod
71    */
72   double GetPeriod() const;
73
74   /**
75    * @copydoc Dali::WidgetView::WidgetView::Show
76    */
77   void Show();
78
79   /**
80    * @copydoc Dali::WidgetView::WidgetView::Hide
81    */
82   void Hide();
83
84   /**
85    * @copydoc Dali::WidgetView::WidgetView::CancelTouchEvent
86    */
87   bool CancelTouchEvent();
88
89   /**
90    * @copydoc Dali::WidgetView::WidgetView::SetPreviewEnabled
91    */
92   void SetPreviewEnabled( bool enabled );
93
94   /**
95    * @copydoc Dali::WidgetView::WidgetView::GetPreviewEnabled
96    */
97   bool GetPreviewEnabled() const;
98
99   /**
100    * @copydoc Dali::WidgetView::WidgetView::SetStateTextEnabled
101    */
102   void SetStateTextEnabled( bool enabled );
103
104   /**
105    * @copydoc Dali::WidgetView::WidgetView::GetStateTextEnabled
106    */
107   bool GetStateTextEnabled() const;
108
109   /**
110    * @copydoc Dali::WidgetView::WidgetView::ActivateFaultedWidget
111    */
112   void ActivateFaultedWidget();
113
114   /**
115    * @copydoc Dali::WidgetView::WidgetView::IsWidgetFaulted
116    */
117   bool IsWidgetFaulted();
118
119   /**
120    * @copydoc Dali::WidgetView::WidgetView::SetPermanentDelete
121    */
122   void SetPermanentDelete( bool permanentDelete );
123
124   void AddObjectView( Pepper::ObjectView objectView );
125   void RemoveObjectView();
126
127 public: //Signals
128
129   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAddedSignal();
130   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetDeletedSignal();
131
132 protected:
133
134   /**
135    * Construct a new WidgetView.
136    */
137   WidgetView();
138
139   /**
140    * Construct a new WidgetView.
141    */
142   WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period );
143
144   /**
145    * A reference counted object may only be deleted by calling Unreference()
146    */
147   virtual ~WidgetView();
148
149 private: // From Control
150
151   /**
152    * @copydoc Toolkit::Control::OnInitialize()
153    */
154   virtual void OnInitialize();
155
156 private:
157
158   // Undefined
159   WidgetView( const WidgetView& );
160
161   // Undefined
162   WidgetView& operator= ( const WidgetView& );
163
164 private:
165
166   Pepper::ObjectView mObjectView;     ///< Widget content
167   Toolkit::ImageView mPreviewImage;   ///< Preview image
168   Toolkit::TextLabel mStateText;      ///< State text
169
170   std::string mWidgetId;
171   std::string mInstanceId;
172   std::string mContentInfo;
173   std::string mTitle;
174
175   bundle* mBundle;
176
177   int mWidth;
178   int mHeight;
179   int mPid;
180   double mPeriod;
181
182   bool mPreviewEnabled;
183   bool mStateTextEnabled;
184   bool mPermanentDelete;
185
186   // Signals
187   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetAddedSignal;
188   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetDeletedSignal;
189 };
190
191 } // namespace Internal
192
193 // Helpers for public-api forwarding methods
194
195 inline Internal::WidgetView& GetImplementation( WidgetView& widgetView )
196 {
197   DALI_ASSERT_ALWAYS( widgetView );
198
199   Dali::RefObject& handle = widgetView.GetImplementation();
200
201   return static_cast<Internal::WidgetView&>( handle );
202 }
203
204 inline const Internal::WidgetView& GetImplementation( const WidgetView& widgetView )
205 {
206   DALI_ASSERT_ALWAYS( widgetView );
207
208   const Dali::RefObject& handle = widgetView.GetImplementation();
209
210   return static_cast<const Internal::WidgetView&>( handle );
211 }
212
213 } // namespace WidgetView
214
215 } // namespace Dali
216
217 #endif // __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__