[NUI]Refactor Components (#1152)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / ImageControl.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System;
18 using System.Collections.Generic;
19 using System.ComponentModel;
20 using Tizen.NUI.BaseComponents;
21
22 namespace Tizen.NUI.Components
23 {
24     /// <summary>
25     /// The control component is class of image. Temporarily for SelectButton.
26     /// </summary>
27     /// <since_tizen> 6 </since_tizen>
28     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
29     [EditorBrowsable(EditorBrowsableState.Never)]
30     public class ImageControl : Control
31     {
32         /// <summary>
33         /// Control style.
34         /// </summary>
35         /// <since_tizen> 6 </since_tizen>
36         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
37         [EditorBrowsable(EditorBrowsableState.Never)]
38         private ImageControlStyle imageControlStyle;
39
40         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
41         [EditorBrowsable(EditorBrowsableState.Never)]
42         public new ImageControlStyle Style => imageControlStyle;
43
44         internal ImageView imageView;
45
46         /// <summary>
47         /// Construct an empty Control.
48         /// </summary>
49         /// <since_tizen> 6 </since_tizen>
50         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public ImageControl() : base()
53         {
54         }
55
56         /// <summary>
57         /// Construct with style.
58         /// </summary>
59         /// <param name="style">Create style customized by user</param>
60         /// <since_tizen> 6 </since_tizen>
61         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
62         [EditorBrowsable(EditorBrowsableState.Never)]
63         public ImageControl(ImageControlStyle style) : base(style)
64         {
65         }
66
67         /// <summary>
68         /// Construct with style
69         /// </summary>
70         /// <param name="style">Style to be applied</param>
71         /// <since_tizen> 6 </since_tizen>
72         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public ImageControl(string style) : base(style)
75         {
76         }
77
78         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public override void ApplyStyle(ViewStyle viewStyle)
81         {
82             base.ApplyStyle(viewStyle);
83
84             ImageControlStyle imageControlStyle = viewStyle as ImageControlStyle;
85             if (null != imageControlStyle)
86             {
87                 if (null == imageView)
88                 {
89                     imageView = new ImageView();
90                     this.Add(imageView);
91                 }
92             }
93
94             imageView.ApplyStyle(imageControlStyle.Image);
95         }
96
97         /// <summary>
98         /// Dispose Control and all children on it.
99         /// </summary>
100         /// <param name="type">Dispose type.</param>
101         /// <since_tizen> 6 </since_tizen>
102         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
103         [EditorBrowsable(EditorBrowsableState.Never)]
104         protected override void Dispose(DisposeTypes type)
105         {
106             if (disposed)
107             {
108                 return;
109             }
110
111             if (imageView != null)
112             {
113                 Utility.Dispose(imageView);
114             }
115
116             base.Dispose(type);
117         }
118
119         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
120         [EditorBrowsable(EditorBrowsableState.Never)]
121         protected override ViewStyle GetViewStyle()
122         {
123             imageControlStyle = new ImageControlStyle();
124             return imageControlStyle;
125         }
126     }
127 }