0e4057827b856d2d714650902936e4e4f42b7913
[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::CancelTouchEvent
76    */
77   bool CancelTouchEvent();
78
79   /**
80    * @copydoc Dali::WidgetView::WidgetView::SetPreviewEnabled
81    */
82   void SetPreviewEnabled( bool enabled );
83
84   /**
85    * @copydoc Dali::WidgetView::WidgetView::GetPreviewEnabled
86    */
87   bool GetPreviewEnabled() const;
88
89   /**
90    * @copydoc Dali::WidgetView::WidgetView::SetStateTextEnabled
91    */
92   void SetStateTextEnabled( bool enabled );
93
94   /**
95    * @copydoc Dali::WidgetView::WidgetView::GetStateTextEnabled
96    */
97   bool GetStateTextEnabled() const;
98
99   /**
100    * @copydoc Dali::WidgetView::WidgetView::ActivateFaultedWidget
101    */
102   void ActivateFaultedWidget();
103
104   /**
105    * @copydoc Dali::WidgetView::WidgetView::IsWidgetFaulted
106    */
107   bool IsWidgetFaulted();
108
109   /**
110    * @copydoc Dali::WidgetView::WidgetView::SetPermanentDelete
111    */
112   void SetPermanentDelete( bool permanentDelete );
113
114   void AddObjectView( Pepper::ObjectView objectView );
115   void RemoveObjectView();
116
117 public: //Signals
118
119   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetAddedSignal();
120   Dali::WidgetView::WidgetView::WidgetViewSignalType& WidgetDeletedSignal();
121
122 protected:
123
124   /**
125    * Construct a new WidgetView.
126    */
127   WidgetView();
128
129   /**
130    * Construct a new WidgetView.
131    */
132   WidgetView( const std::string& widgetId, const std::string& contentInfo, int width, int height, double period );
133
134   /**
135    * A reference counted object may only be deleted by calling Unreference()
136    */
137   virtual ~WidgetView();
138
139 private: // From Control
140
141   /**
142    * @copydoc Toolkit::Control::OnInitialize()
143    */
144   virtual void OnInitialize();
145
146 private:
147
148   // Undefined
149   WidgetView( const WidgetView& );
150
151   // Undefined
152   WidgetView& operator= ( const WidgetView& );
153
154 private:
155
156   Pepper::ObjectView mObjectView;     ///< Widget content
157   Toolkit::ImageView mPreviewImage;   ///< Preview image
158   Toolkit::TextLabel mStateText;      ///< State text
159
160   std::string mWidgetId;
161   std::string mInstanceId;
162   std::string mContentInfo;
163   std::string mTitle;
164
165   bundle* mBundle;
166
167   int mWidth;
168   int mHeight;
169   int mPid;
170   double mPeriod;
171
172   bool mPreviewEnabled;
173   bool mStateTextEnabled;
174   bool mPermanentDelete;
175
176   // Signals
177   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetAddedSignal;
178   Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetDeletedSignal;
179 };
180
181 } // namespace Internal
182
183 // Helpers for public-api forwarding methods
184
185 inline Internal::WidgetView& GetImplementation( WidgetView& widgetView )
186 {
187   DALI_ASSERT_ALWAYS( widgetView );
188
189   Dali::RefObject& handle = widgetView.GetImplementation();
190
191   return static_cast<Internal::WidgetView&>( handle );
192 }
193
194 inline const Internal::WidgetView& GetImplementation( const WidgetView& widgetView )
195 {
196   DALI_ASSERT_ALWAYS( widgetView );
197
198   const Dali::RefObject& handle = widgetView.GetImplementation();
199
200   return static_cast<const Internal::WidgetView&>( handle );
201 }
202
203 } // namespace WidgetView
204
205 } // namespace Dali
206
207 #endif // __DALI_WIDGET_VIEW_INTERNAL_WIDGET_VIEW_H__