[NUI] Add NUI-Layout (#293)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Layouting / LayoutMeasureSpec.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.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20
21 namespace Tizen.NUI
22 {
23
24     /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public class LayoutMeasureSpec : global::System.IDisposable
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
30         [EditorBrowsable(EditorBrowsableState.Never)]
31         protected bool swigCMemOwn;
32
33         internal LayoutMeasureSpec(global::System.IntPtr cPtr, bool cMemoryOwn)
34         {
35             swigCMemOwn = cMemoryOwn;
36             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
37         }
38
39         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutMeasureSpec obj)
40         {
41             return (obj.Equals(null)) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42         }
43
44         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
45         [EditorBrowsable(EditorBrowsableState.Never)]
46         ~LayoutMeasureSpec()
47         {
48             Dispose();
49         }
50
51         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
52         [EditorBrowsable(EditorBrowsableState.Never)]
53         public virtual void Dispose()
54         {
55             lock (this)
56             {
57                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
58                 {
59                     if (swigCMemOwn)
60                     {
61                         swigCMemOwn = false;
62                         LayoutPINVOKE.delete_MeasureSpec(swigCPtr);
63                     }
64                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
65                 }
66             }
67         }
68
69         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
70         [EditorBrowsable(EditorBrowsableState.Never)]
71         public LayoutMeasureSpec(LayoutLength measureSpec, LayoutMeasureSpec.ModeType mode) : this(LayoutPINVOKE.new_MeasureSpec__SWIG_0(LayoutLength.getCPtr(measureSpec), (int)mode), true)
72         {
73             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74         }
75
76         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
77         [EditorBrowsable(EditorBrowsableState.Never)]
78         public LayoutMeasureSpec(int measureSpec) : this(LayoutPINVOKE.new_MeasureSpec__SWIG_1(measureSpec), true)
79         {
80             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81         }
82
83         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
84         [EditorBrowsable(EditorBrowsableState.Never)]
85         public static bool operator ==(LayoutMeasureSpec r1, LayoutMeasureSpec r2)
86         {
87             return r1.EqualTo(r2);
88         }
89
90         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
91         [EditorBrowsable(EditorBrowsableState.Never)]
92         public static bool operator !=(LayoutMeasureSpec r1, LayoutMeasureSpec r2)
93         {
94             return !r1.EqualTo(r2);
95         }
96
97         private bool EqualTo(LayoutMeasureSpec value)
98         {
99             bool ret = LayoutPINVOKE.MeasureSpec_EqualTo(swigCPtr, LayoutMeasureSpec.getCPtr(value));
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101             return ret;
102         }
103
104         private bool NotEqualTo(LayoutMeasureSpec value)
105         {
106             bool ret = LayoutPINVOKE.MeasureSpec_NotEqualTo(swigCPtr, LayoutMeasureSpec.getCPtr(value));
107             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108             return ret;
109         }
110
111         private LayoutMeasureSpec.ModeType GetMode()
112         {
113             LayoutMeasureSpec.ModeType ret = (LayoutMeasureSpec.ModeType)LayoutPINVOKE.MeasureSpec_GetMode(swigCPtr);
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115             return ret;
116         }
117
118         private int GetSize()
119         {
120             int ret = LayoutPINVOKE.MeasureSpec_GetSize(swigCPtr);
121             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122             return ret;
123         }
124
125         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         public static LayoutMeasureSpec Adjust(LayoutMeasureSpec measureSpec, int delta)
128         {
129             LayoutMeasureSpec ret = new LayoutMeasureSpec(LayoutPINVOKE.MeasureSpec_Adjust(LayoutMeasureSpec.getCPtr(measureSpec), delta), true);
130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131             return ret;
132         }
133
134         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
135         [EditorBrowsable(EditorBrowsableState.Never)]
136         public int Size
137         {
138             set
139             {
140                 LayoutPINVOKE.MeasureSpec_mSize_set(swigCPtr, value);
141                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142             }
143             get
144             {
145                 int ret = LayoutPINVOKE.MeasureSpec_mSize_get(swigCPtr);
146                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147                 return ret;
148             }
149         }
150
151         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
152         [EditorBrowsable(EditorBrowsableState.Never)]
153         public LayoutMeasureSpec.ModeType Mode
154         {
155             set
156             {
157                 LayoutPINVOKE.MeasureSpec_mMode_set(swigCPtr, (int)value);
158                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159             }
160             get
161             {
162                 LayoutMeasureSpec.ModeType ret = (LayoutMeasureSpec.ModeType)LayoutPINVOKE.MeasureSpec_mMode_get(swigCPtr);
163                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164                 return ret;
165             }
166         }
167
168         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
169         [EditorBrowsable(EditorBrowsableState.Never)]
170         public enum ModeType
171         {
172             UNSPECIFIED, ///< This is used by a parent to determine the desired dimension of a child layout.
173             EXACTLY,     /** This is used by a parent to impose an exact size on the child. The child must use
174                              this size, and guarantee that all of its descendants will fit within this size. */
175             AT_MOST      /** This is used by the parent to impose a maximum size on the child. The child must guarantee
176                           * that it and all of it's descendants will fit within this size. */
177         }
178     }
179 }