sync with tizen branch to finalize API
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / VisualFactory.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI
18 {
19
20     /// <summary>
21     /// VisualFactory is a singleton object that provides and shares visuals between views
22     /// </summary>
23     public class VisualFactory : BaseHandle
24     {
25         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26
27         internal VisualFactory(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.VisualFactory_SWIGUpcast(cPtr), cMemoryOwn)
28         {
29             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
30         }
31
32         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VisualFactory obj)
33         {
34             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
35         }
36
37         protected override void Dispose(DisposeTypes type)
38         {
39             if(disposed)
40             {
41                 return;
42             }
43
44             if(type == DisposeTypes.Explicit)
45             {
46                 //Called by User
47                 //Release your own managed resources here.
48                 //You should release all of your own disposable objects here.
49             }
50
51             //Release your own unmanaged resources here.
52             //You should not access any managed member here except static instance.
53             //because the execution order of Finalizes is non-deterministic.
54
55             if (swigCPtr.Handle != global::System.IntPtr.Zero)
56             {
57                 if (swigCMemOwn)
58                 {
59                     swigCMemOwn = false;
60                     NDalicPINVOKE.delete_VisualFactory(swigCPtr);
61                 }
62                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
63             }
64
65             base.Dispose(type);
66         }
67
68
69         /// <summary>
70         /// Create or retrieve VisualFactory singleton.
71         /// </summary>
72         /// <returns>A handle to the VisualFactory control.</returns>
73         public static VisualFactory Get()
74         {
75             VisualFactory ret = new VisualFactory(NDalicPINVOKE.VisualFactory_Get(), true);
76             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77             return ret;
78         }
79
80         internal VisualFactory() : this(NDalicPINVOKE.new_VisualFactory__SWIG_0(), true)
81         {
82             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83         }
84
85
86         /// <summary>
87         /// Request the visual
88         /// </summary>
89         /// <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>
90         /// <returns>The handle to the created visual</returns>
91         public VisualBase CreateVisual(PropertyMap propertyMap)
92         {
93             VisualBase ret = new VisualBase(NDalicPINVOKE.VisualFactory_CreateVisual__SWIG_0(swigCPtr, PropertyMap.getCPtr(propertyMap)), true);
94             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95             return ret;
96         }
97
98         internal VisualBase CreateVisual(Image image)
99         {
100             VisualBase ret = new VisualBase(NDalicPINVOKE.VisualFactory_CreateVisual__SWIG_1(swigCPtr, Image.getCPtr(image)), true);
101             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102             return ret;
103         }
104
105         private static readonly VisualFactory instance = VisualFactory.Get();
106
107         /// <summary>
108         /// retrieve VisualFactory singleton.
109         /// </summary>
110         public static VisualFactory Instance
111         {
112             get
113             {
114                 return instance;
115             }
116         }
117
118     }
119
120 }