8f6ad2bb3a4cfd1ae2b2c3967e432f03b3606723
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / RelayoutContainer.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 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 // Some have been manually changed
18
19
20 namespace Tizen.NUI
21 {
22     using Tizen.NUI.BaseComponents;
23     /// <summary>
24     /// An interface to encapsulate the information required for relayout.
25     /// </summary>
26     public class RelayoutContainer : global::System.IDisposable
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29         protected bool swigCMemOwn;
30
31         internal RelayoutContainer(global::System.IntPtr cPtr, bool cMemoryOwn)
32         {
33             swigCMemOwn = cMemoryOwn;
34             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35         }
36
37         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelayoutContainer obj)
38         {
39             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40         }
41
42         //A Flag to check who called Dispose(). (By User or DisposeQueue)
43         private bool isDisposeQueued = false;
44         //A Flat to check if it is already disposed.
45         protected bool disposed = false;
46
47         ~RelayoutContainer()
48         {
49             if(!isDisposeQueued)
50             {
51                 isDisposeQueued = true;
52                 DisposeQueue.Instance.Add(this);
53             }
54         }
55
56         /// <summary>
57         /// To make the RelayoutContainer instance be disposed.
58         /// </summary>
59         /// <since_tizen> 3 </since_tizen>
60         public void Dispose()
61         {
62             //Throw excpetion if Dispose() is called in separate thread.
63             if (!Window.IsInstalled())
64             {
65                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
66             }
67
68             if (isDisposeQueued)
69             {
70                 Dispose(DisposeTypes.Implicit);
71             }
72             else
73             {
74                 Dispose(DisposeTypes.Explicit);
75                 System.GC.SuppressFinalize(this);
76             }
77         }
78
79         protected virtual void Dispose(DisposeTypes type)
80         {
81             if (disposed)
82             {
83                 return;
84             }
85
86             if(type == DisposeTypes.Explicit)
87             {
88                 //Called by User
89                 //Release your own managed resources here.
90                 //You should release all of your own disposable objects here.
91             }
92
93             //Release your own unmanaged resources here.
94             //You should not access any managed member here except static instance.
95             //because the execution order of Finalizes is non-deterministic.
96
97             if (swigCPtr.Handle != global::System.IntPtr.Zero)
98             {
99                 if (swigCMemOwn)
100                 {
101                     swigCMemOwn = false;
102                     NDalicPINVOKE.delete_RelayoutContainer(swigCPtr);
103                 }
104                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
105             }
106             disposed = true;
107         }
108
109         /// <summary>
110         /// Adds relayout information to the container if it doesn't already exist.
111         /// </summary>
112         /// <param name="view">The view to relayout.</param>
113         /// <param name="size">The size to relayout.</param>
114         /// <since_tizen> 3 </since_tizen>
115         public virtual void Add(View view, Size2D size)
116         {
117             NDalicPINVOKE.RelayoutContainer_Add(swigCPtr, View.getCPtr(view), Size2D.getCPtr(size));
118             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119         }
120
121     }
122
123 }