2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 using Tizen.NUI.BaseComponents;
23 /// An interface to encapsulate the information required for relayout.
25 public class RelayoutContainer : global::System.IDisposable
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
31 /// <since_tizen> 3 </since_tizen>
32 protected bool swigCMemOwn;
34 internal RelayoutContainer(global::System.IntPtr cPtr, bool cMemoryOwn)
36 swigCMemOwn = cMemoryOwn;
37 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
40 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelayoutContainer obj)
42 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45 //A Flag to check who called Dispose(). (By User or DisposeQueue)
46 private bool isDisposeQueued = false;
48 /// A Flat to check if it is already disposed.
50 /// <since_tizen> 3 </since_tizen>
51 protected bool disposed = false;
56 /// <since_tizen> 3 </since_tizen>
61 isDisposeQueued = true;
62 DisposeQueue.Instance.Add(this);
67 /// To make the RelayoutContainer instance be disposed.
69 /// <since_tizen> 3 </since_tizen>
72 //Throw excpetion if Dispose() is called in separate thread.
73 if (!Window.IsInstalled())
75 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
80 Dispose(DisposeTypes.Implicit);
84 Dispose(DisposeTypes.Explicit);
85 System.GC.SuppressFinalize(this);
92 /// <since_tizen> 3 </since_tizen>
93 protected virtual void Dispose(DisposeTypes type)
100 if(type == DisposeTypes.Explicit)
103 //Release your own managed resources here.
104 //You should release all of your own disposable objects here.
107 //Release your own unmanaged resources here.
108 //You should not access any managed member here except static instance.
109 //because the execution order of Finalizes is non-deterministic.
111 if (swigCPtr.Handle != global::System.IntPtr.Zero)
116 NDalicPINVOKE.delete_RelayoutContainer(swigCPtr);
118 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
124 /// Adds relayout information to the container if it doesn't already exist.
126 /// <param name="view">The view to relayout.</param>
127 /// <param name="size">The size to relayout.</param>
128 /// <since_tizen> 3 </since_tizen>
129 public virtual void Add(View view, Size2D size)
131 NDalicPINVOKE.RelayoutContainer_Add(swigCPtr, View.getCPtr(view), Size2D.getCPtr(size));
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();