f2a221c0193f2b7fd2402bb321fd40a364cfcb2c
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / image-view / image-view.h
1 #ifndef __DALI_TOOLKIT_IMAGE_VIEW_H__
2 #define __DALI_TOOLKIT_IMAGE_VIEW_H__
3
4 /*
5  * Copyright (c) 2015 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 <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class ImageView;
33 }
34 /**
35  * @addtogroup dali-toolkit-controls-image-view
36  * @{
37  */
38
39 /**
40  *
41  * @brief ImageView is a class for displaying an Image.
42  */
43 class DALI_IMPORT_API ImageView : public Control
44 {
45 public:
46   /**
47    * @brief The start and end property ranges for this control.
48    */
49   enum PropertyRange
50   {
51     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
52     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
53   };
54
55   /**
56    * @brief An enumeration of properties belonging to the ImageView class.
57    */
58   struct Property
59   {
60     enum
61     {
62       IMAGE = PROPERTY_START_INDEX, ///< name "image", @see SetImage(), type string if it is a url, map otherwise
63     };
64   };
65
66 public:
67
68   /**
69    * @brief Create an uninitialized ImageView.
70    */
71   ImageView();
72
73   /**
74    * @brief Create an initialized ImageView.
75    *
76    * @return A handle to a newly allocated Dali ImageView.
77    */
78   static ImageView New();
79
80   /**
81    * @brief Create an initialized ImageView from an Image.
82    *
83    * If the handle is empty, ImageView will display nothing
84    * @param[in] image The Image to display.
85    * @return A handle to a newly allocated ImageView.
86    */
87   static ImageView New( Image image );
88
89   /**
90    * @brief Create an initialized ImageView from an Image resource url
91    *
92    * If the string is empty, ImageView will display nothing
93    * @param[in] url The url of the image resource to display.
94    * @return A handle to a newly allocated ImageView.
95    */
96   static ImageView New( const std::string& url );
97
98   /**
99    * @brief Destructor
100    *
101    * This is non-virtual since derived Handle types must not contain data or virtual methods.
102    */
103   ~ImageView();
104
105   /**
106    * @brief Copy constructor.
107    *
108    * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
109    */
110   ImageView( const ImageView& imageView );
111
112   /**
113    * @brief Assignment operator.
114    *
115    * @param[in] imageView The ImageView to assign from.
116    * @return The updated ImageView.
117    */
118   ImageView& operator=( const ImageView& imageView );
119
120   /**
121    * @brief Downcast an Object handle to ImageView.
122    *
123    * If handle points to a ImageView the downcast produces valid
124    * handle. If not the returned handle is left uninitialized.
125    *
126    * @param[in] handle Handle to an object
127    * @return handle to a ImageView or an uninitialized handle
128    */
129   static ImageView DownCast( BaseHandle handle );
130
131   /**
132    * @brief Sets this ImageView from an Image
133    *
134    * If the handle is empty, ImageView will display nothing
135    * @param[in] image The Image to display.
136    */
137   void SetImage( Image image );
138
139   /**
140    * @brief Sets this ImageView from an Image url
141    *
142    * If the handle is empty, ImageView will display nothing
143    * @param[in] url The Image resource to display.
144    */
145   void SetImage( const std::string& url );
146
147   /**
148    * @deprecated Gets the Image
149    *
150    * @return The Image currently set to this ImageView
151    */
152   Image GetImage() const;
153
154 public: // Not intended for application developers
155
156   /**
157    * @brief Creates a handle using the Toolkit::Internal implementation.
158    *
159    * @param[in]  implementation  The ImageView implementation.
160    */
161   DALI_INTERNAL ImageView( Internal::ImageView& implementation );
162
163   /**
164    * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
165    *
166    * @param[in]  internal  A pointer to the internal CustomActor.
167    */
168   DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
169
170 };
171
172 /**
173  * @}
174  */
175 } // namespace Toolkit
176
177 } // namespace Dali
178
179 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__