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