[NUI.Components] Fix Background Image not works issue (#1246) (#1248)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / InputFieldStyle.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.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI.Components
22 {
23     /// <summary>
24     /// InputFieldAttributes is a class which saves InputField's ux data.
25     /// </summary>
26     /// <since_tizen> 6 </since_tizen>
27     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class InputFieldStyle : ControlStyle
30     {
31         static InputFieldStyle() { }
32
33         /// <summary>
34         /// Creates a new instance of a InputFieldAttributes.
35         /// </summary>
36         /// <since_tizen> 6 </since_tizen>
37         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         public InputFieldStyle() : base()
40         {
41             BackgroundImageAttributes = new ImageViewStyle();
42             InputBoxAttributes = new TextFieldStyle();
43         }
44
45         /// <summary>
46         /// Creates a new instance of a InputFieldStyle with Style.
47         /// </summary>
48         /// <param name="attrs">Create InputFieldStyle by Style customized by user.</param>
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 InputFieldStyle(InputFieldStyle attrs) : base(attrs)
53         {
54             if (null == attrs)
55             {
56                 return;
57             }
58
59             BackgroundImageAttributes = new ImageViewStyle();
60             InputBoxAttributes = new TextFieldStyle();
61
62             if (null != attrs.BackgroundImageAttributes)
63             {
64                 BackgroundImageAttributes.CopyFrom(attrs.BackgroundImageAttributes);
65             }
66             if (null != attrs.InputBoxAttributes)
67             {
68                 InputBoxAttributes.CopyFrom(attrs.InputBoxAttributes);
69             }
70             if (null != attrs.Space)
71             {
72                 Space = attrs.Space;
73             }
74         }
75
76         /// <summary>
77         /// Gets or sets background image attributes of input field.
78         /// </summary>
79         /// <since_tizen> 6 </since_tizen>
80         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
81         [EditorBrowsable(EditorBrowsableState.Never)]
82         public ImageViewStyle BackgroundImageAttributes { get; set; }
83
84         /// <summary>
85         /// Gets or sets input box attributes of input field.
86         /// </summary>
87         /// <since_tizen> 6 </since_tizen>
88         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
89         [EditorBrowsable(EditorBrowsableState.Never)]
90         public TextFieldStyle InputBoxAttributes { get; set; }
91
92         /// <summary>
93         /// Gets or sets space.
94         /// </summary>
95         /// <since_tizen> 6 </since_tizen>
96         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
97         [EditorBrowsable(EditorBrowsableState.Never)]
98         public int? Space { get; set; } 
99
100         /// <summary>
101         /// Attributes's clone function.
102         /// </summary>
103         /// <since_tizen> 6 </since_tizen>
104         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
105         [EditorBrowsable(EditorBrowsableState.Never)]
106         public override void CopyFrom(BindableObject bindableObject)
107         {
108             InputFieldStyle inputFieldAttributes = bindableObject as InputFieldStyle;
109
110             if (null != inputFieldAttributes)
111             {
112                 Space = inputFieldAttributes.Space;
113
114                 if (null != inputFieldAttributes.BackgroundImageAttributes)
115                 {
116                     BackgroundImageAttributes.CopyFrom(inputFieldAttributes.BackgroundImageAttributes);
117                 }
118
119                 if (null != inputFieldAttributes.InputBoxAttributes)
120                 {
121                     InputBoxAttributes.CopyFrom(inputFieldAttributes.InputBoxAttributes);
122                 }
123             }
124         }
125     }
126 }