3017b5656a2626fbb6769a1eb769483c0a798703
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Item.cs
1 /*
2  * Copyright(c) 2017 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.ComponentModel;
19
20 namespace Tizen.NUI
21 {
22     using Tizen.NUI.BaseComponents;
23
24     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public class Item : global::System.IDisposable
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29
30         /// <summary>swigCMemOwn.</summary>
31         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
32         protected bool swigCMemOwn;
33
34         internal Item(global::System.IntPtr cPtr, bool cMemoryOwn)
35         {
36             swigCMemOwn = cMemoryOwn;
37             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38         }
39
40         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Item obj)
41         {
42             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43         }
44
45         /// <summary>A Flag to check who called Dispose(). (By User or DisposeQueue)</summary>
46         private bool isDisposeQueued = false;
47
48         /// <summary>A Flag to check if it is already disposed.</summary>
49         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
50         protected bool disposed = false;
51
52
53         /// <summary>Destructor.</summary>
54         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
55         ~Item()
56         {
57             if (!isDisposeQueued)
58             {
59                 isDisposeQueued = true;
60                 DisposeQueue.Instance.Add(this);
61             }
62         }
63
64         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
65         [EditorBrowsable(EditorBrowsableState.Never)]
66         public void Dispose()
67         {
68             //Throw excpetion if Dispose() is called in separate thread.
69             if (!Window.IsInstalled())
70             {
71                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
72             }
73
74             if (isDisposeQueued)
75             {
76                 Dispose(DisposeTypes.Implicit);
77             }
78             else
79             {
80                 Dispose(DisposeTypes.Explicit);
81                 System.GC.SuppressFinalize(this);
82             }
83         }
84
85         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         protected virtual void Dispose(DisposeTypes type)
88         {
89             if (disposed)
90             {
91                 return;
92             }
93
94             if (type == DisposeTypes.Explicit)
95             {
96                 //Called by User
97                 //Release your own managed resources here.
98                 //You should release all of your own disposable objects here.
99
100             }
101
102             //Release your own unmanaged resources here.
103             //You should not access any managed member here except static instance.
104             //because the execution order of Finalizes is non-deterministic.
105
106             if (swigCPtr.Handle != global::System.IntPtr.Zero)
107             {
108                 if (swigCMemOwn)
109                 {
110                     swigCMemOwn = false;
111                     Interop.Item.delete_Item(swigCPtr);
112                 }
113                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
114             }
115
116             disposed = true;
117         }
118
119         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
120         [EditorBrowsable(EditorBrowsableState.Never)]
121         public Item() : this(Interop.Item.new_Item__SWIG_0(), true)
122         {
123             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124         }
125
126         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
127         [EditorBrowsable(EditorBrowsableState.Never)]
128         public Item(uint t, View u) : this(Interop.Item.new_Item__SWIG_1(t, View.getCPtr(u)), true)
129         {
130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131         }
132
133         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
134         [EditorBrowsable(EditorBrowsableState.Never)]
135         public Item(Item p) : this(Interop.Item.new_Item__SWIG_2(Item.getCPtr(p)), true)
136         {
137             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138         }
139
140         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
141         [EditorBrowsable(EditorBrowsableState.Never)]
142         public uint first
143         {
144             set
145             {
146                 Interop.Item.Item_first_set(swigCPtr, value);
147                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148             }
149             get
150             {
151                 uint ret = Interop.Item.Item_first_get(swigCPtr);
152                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153                 return ret;
154             }
155         }
156
157         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
158         [EditorBrowsable(EditorBrowsableState.Never)]
159         public View second
160         {
161             set
162             {
163                 Interop.Item.Item_second_set(swigCPtr, View.getCPtr(value));
164                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165             }
166             get
167             {
168                 global::System.IntPtr cPtr = Interop.Item.Item_second_get(swigCPtr);
169                 View ret = (cPtr == global::System.IntPtr.Zero) ? null : new View(cPtr, false);
170                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171                 return ret;
172             }
173         }
174
175     }
176
177 }