[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / VisualFactory.cs
1 /*
2  * Copyright(c) 2018 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
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23
24     /// <summary>
25     /// The VisualFactory is a singleton object that provides and shares visuals between views.
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     public class VisualFactory : BaseHandle
29     {
30
31         /// <summary>
32         /// Instance of the VisualFactory singleton.
33         /// </summary>
34         private static VisualFactory instance;
35         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
36
37         internal VisualFactory(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.VisualFactory.VisualFactory_SWIGUpcast(cPtr), cMemoryOwn)
38         {
39             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
40         }
41
42         internal VisualFactory() : this(Interop.VisualFactory.new_VisualFactory__SWIG_0(), true)
43         {
44             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45         }
46
47         /// <summary>
48         /// Retrieves the VisualFactory singleton.
49         /// </summary>
50         /// <since_tizen> 3 </since_tizen>
51         public static VisualFactory Instance
52         {
53             get
54             {
55                 if (!instance)
56                 {
57                     instance = new VisualFactory(Interop.VisualFactory.VisualFactory_Get(), true);
58                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
59                 }
60
61                 return instance;
62             }
63         }
64
65         /// <summary>
66         /// Please do not use! this will be deprecated, please use VisualFactory.Instance instead.
67         /// </summary>
68         /// <since_tizen> 3 </since_tizen>
69         [Obsolete("Please do not use! This will be deprecated! Please use VisualFactory.Instance instead! " +
70             "Like: " +
71             "VisualFactory visualFactory = VisualFactory.Instance; " +
72             "visualFactory.CreateVisual(visualMap);")]
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public static VisualFactory Get()
75         {
76             return VisualFactory.Instance;
77         }
78
79         /// <summary>
80         /// Request the visual.
81         /// </summary>
82         /// <param name="propertyMap">The map contains the properties required by the visual. The content of the map determines the type of visual that will be returned.</param>
83         /// <returns>The handle to the created visual.</returns>
84         /// <since_tizen> 3 </since_tizen>
85         public VisualBase CreateVisual(PropertyMap propertyMap)
86         {
87             VisualBase ret = new VisualBase(Interop.VisualFactory.VisualFactory_CreateVisual__SWIG_0(swigCPtr, PropertyMap.getCPtr(propertyMap)), true);
88             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89             return ret;
90         }
91
92         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VisualFactory obj)
93         {
94             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
95         }
96
97         internal VisualBase CreateVisual(Image image)
98         {
99             VisualBase ret = new VisualBase(Interop.VisualFactory.VisualFactory_CreateVisual__SWIG_1(swigCPtr, Image.getCPtr(image)), true);
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101             return ret;
102         }
103
104     }
105
106 }