[NUI] Implement shadow in View (#1236)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PropertyMap.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
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// A map of property values, the key type could be string or Property::Index.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class PropertyMap : Disposable
26     {
27
28         /// <summary>
29         /// The constructor.
30         /// </summary>
31         /// <since_tizen> 3 </since_tizen>
32         public PropertyMap() : this(Interop.PropertyMap.new_Property_Map__SWIG_0(), true)
33         {
34             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
35         }
36
37         /// <summary>
38         /// The copy constructor.
39         /// </summary>
40         /// <param name="other">The map to copy from.</param>
41         /// <since_tizen> 3 </since_tizen>
42         public PropertyMap(PropertyMap other) : this(Interop.PropertyMap.new_Property_Map__SWIG_1(PropertyMap.getCPtr(other)), true)
43         {
44             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45         }
46
47         internal PropertyMap(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
48         {
49         }
50
51         /// <summary>
52         /// The operator to access the element with the specified string key.<br />
53         /// If an element with the key does not exist, then it is created.<br />
54         /// </summary>
55         /// <param name="key">The key whose value to access.</param>
56         /// <returns>A value for the element with the specified key.</returns>
57         /// <since_tizen> 3 </since_tizen>
58         public PropertyValue this[string key]
59         {
60             get
61             {
62                 return ValueOfIndex(key);
63             }
64             internal set
65             {
66                 SetValue(key, value);
67             }
68         }
69
70         /// <summary>
71         /// The operator to access the element with the specified index key.<br />
72         /// If an element with the key does not exist, then it is created.<br />
73         /// </summary>
74         /// <param name="key">The key whose value to access.</param>
75         /// <returns>A value for the element with the specified key.</returns>
76         /// <since_tizen> 3 </since_tizen>
77         public PropertyValue this[int key]
78         {
79             get
80             {
81                 return ValueOfIndex(key);
82             }
83             internal set
84             {
85                 SetValue(key, value);
86             }
87         }
88
89         /// <summary>
90         /// Retrieves the number of elements in the map.
91         /// </summary>
92         /// <returns>The number of elements in the map.</returns>
93         /// <since_tizen> 3 </since_tizen>
94         public uint Count()
95         {
96             uint ret = Interop.PropertyMap.Property_Map_Count(swigCPtr);
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98             return ret;
99         }
100
101         /// <summary>
102         /// Returns whether the map is empty.
103         /// </summary>
104         /// <returns>Returns true if empty, false otherwise.</returns>
105         /// <since_tizen> 3 </since_tizen>
106         public bool Empty()
107         {
108             bool ret = Interop.PropertyMap.Property_Map_Empty(swigCPtr);
109             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110             return ret;
111         }
112
113         /// <summary>
114         /// Inserts the key-value pair in the map, with the key type as string.<br />
115         /// Does not check for duplicates.<br />
116         /// </summary>
117         /// <param name="key">The key to insert.</param>
118         /// <param name="value">The value to insert.</param>
119         /// <since_tizen> 3 </since_tizen>
120         public void Insert(string key, PropertyValue value)
121         {
122             Interop.PropertyMap.Property_Map_Insert__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value));
123             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124         }
125
126         /// <summary>
127         /// Inserts the key-value pair in the map, with the key type as index.<br />
128         /// Does not check for duplicates.<br />
129         /// </summary>
130         /// <param name="key">The key to insert.</param>
131         /// <param name="value">The value to insert.</param>
132         /// <since_tizen> 3 </since_tizen>
133         public void Insert(int key, PropertyValue value)
134         {
135             Interop.PropertyMap.Property_Map_Insert__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value));
136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137         }
138
139         /// <summary>
140         /// Inserts the key-value pair in the map, with the key type as string.<br />
141         /// Does not check for duplicates.<br />
142         /// </summary>
143         /// <param name="key">The key to insert.</param>
144         /// <param name="value">The value to insert.</param>
145         /// <returns>Returns a reference to this object.</returns>
146         /// <since_tizen> 3 </since_tizen>
147         public PropertyMap Add(string key, PropertyValue value)
148         {
149             PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value)), false);
150             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
151             return ret;
152         }
153
154         /// <summary>
155         /// Inserts the key-value pair in the map, with the key type as string.<br />
156         /// Does not check for duplicates.<br />
157         /// </summary>
158         /// <param name="key">The key to insert.</param>
159         /// <param name="value">The value to insert.</param>
160         /// <returns>Returns a reference to this object.</returns>
161         /// <since_tizen> 3 </since_tizen>
162         public PropertyMap Add(int key, PropertyValue value)
163         {
164             PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value)), false);
165             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166             return ret;
167         }
168
169         /// <summary>
170         /// Inserts the keyvalue to the map.<br />
171         /// Does not check for duplicates.<br />
172         /// </summary>
173         /// <param name="keyValue">The keyvalue to insert.</param>
174         /// <returns>Returns a reference to this object.</returns>
175         public PropertyMap Add(KeyValue keyValue)
176         {
177             PropertyMap ret = new PropertyMap();
178             if ( keyValue.KeyInt != null )
179             {
180                 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, (int)keyValue.KeyInt, PropertyValue.getCPtr(keyValue.TrueValue)), false);
181             }
182             else if ( keyValue.KeyString != null )
183             {
184                 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, keyValue.KeyString, PropertyValue.getCPtr(keyValue.TrueValue)), false);
185             }
186             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187
188             return ret;
189         }
190
191         /// <summary>
192         /// Retrieves the value at the specified position.
193         /// </summary>
194         /// <param name="position">The specified position.</param>
195         /// <returns>A reference to the value at the specified position.</returns>
196         /// <since_tizen> 3 </since_tizen>
197         public PropertyValue GetValue(uint position)
198         {
199             PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_GetValue(swigCPtr, position), false);
200             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201             return ret;
202         }
203
204         /// <summary>
205         /// Retrieves the key at the specified position.
206         /// </summary>
207         /// <param name="position">The specified position.</param>
208         /// <returns>A copy of the key at the specified position.</returns>
209         /// <since_tizen> 3 </since_tizen>
210         public PropertyKey GetKeyAt(uint position)
211         {
212             PropertyKey ret = new PropertyKey(Interop.PropertyMap.Property_Map_GetKeyAt(swigCPtr, position), true);
213             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214             return ret;
215         }
216
217         /// <summary>
218         /// Finds the value for the specified key if it exists.
219         /// </summary>
220         /// <param name="key">The key to find.</param>
221         /// <returns>The value if it exists, an empty object otherwise.</returns>
222         /// <since_tizen> 3 </since_tizen>
223         public PropertyValue Find(int key)
224         {
225             global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_2(swigCPtr, key);
226             PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
227             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228             return ret;
229         }
230
231         /// <summary>
232         /// Finds the value for the specified keys if either exist.
233         /// </summary>
234         /// <param name="indexKey">The index key to find.</param>
235         /// <param name="stringKey">The string key to find.</param>
236         /// <returns>The value if it exists, an empty object otherwise.</returns>
237         /// <since_tizen> 3 </since_tizen>
238         public PropertyValue Find(int indexKey, string stringKey)
239         {
240             global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_3(swigCPtr, indexKey, stringKey);
241             PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
242             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243             return ret;
244         }
245
246         /// <summary>
247         /// Clears the map.
248         /// </summary>
249         /// <since_tizen> 3 </since_tizen>
250         public void Clear()
251         {
252             Interop.PropertyMap.Property_Map_Clear(swigCPtr);
253             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254         }
255
256         /// <summary>
257         /// Merges values from the map 'from' to the current.<br />
258         /// Any values in 'from' will overwrite the values in the current map.<br />
259         /// </summary>
260         /// <param name="from">The map to merge from.</param>
261         /// <since_tizen> 3 </since_tizen>
262         public void Merge(PropertyMap from)
263         {
264             Interop.PropertyMap.Property_Map_Merge(swigCPtr, PropertyMap.getCPtr(from));
265             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266         }
267
268         /// <summary>
269         /// Retrieves the element with the specified string key.
270         /// </summary>
271         /// <param name="key">The key whose value to retrieve.</param>
272         /// <returns>The value for the element with the specified key.</returns>
273         internal PropertyValue ValueOfIndex(string key)
274         {
275             PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_0(swigCPtr, key), false);
276             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277             return ret;
278         }
279
280         /// <summary>
281         /// Retrieves the element with the specified index key.
282         /// </summary>
283         /// <param name="key">The key whose value to retrieve.</param>
284         /// <returns>The value for the element with the specified key.</returns>
285         internal PropertyValue ValueOfIndex(int key)
286         {
287             PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_2(swigCPtr, key), false);
288             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289             return ret;
290         }
291
292         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyMap obj)
293         {
294             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
295         }
296
297         internal void SetValue(int key, PropertyValue value)
298         {
299             Interop.PropertyMap.Property_Map_SetValue_IntKey(swigCPtr, key, PropertyValue.getCPtr(value));
300             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301         }
302
303         internal void SetValue(string key, PropertyValue value)
304         {
305             Interop.PropertyMap.Property_Map_SetValue_StringKey(swigCPtr, key, PropertyValue.getCPtr(value));
306             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307         }
308
309         /// This will not be public opened.
310         [EditorBrowsable(EditorBrowsableState.Never)]
311         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
312         {
313             Interop.PropertyMap.delete_Property_Map(swigCPtr);
314         }
315     }
316 }