e64520e37c2fa980564428d6c44bc7593c4e5889
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Alignment.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 using Tizen.NUI.BaseComponents;
18
19 namespace Tizen.NUI
20 {
21
22     internal class Alignment : View
23     {
24         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
25
26         internal Alignment(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Alignment_SWIGUpcast(cPtr), cMemoryOwn)
27         {
28             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
29         }
30
31         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Alignment obj)
32         {
33             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
34         }
35
36         protected override void Dispose(DisposeTypes type)
37         {
38             if (disposed)
39             {
40                 return;
41             }
42
43             if (type == DisposeTypes.Explicit)
44             {
45                 //Called by User
46                 //Release your own managed resources here.
47                 //You should release all of your own disposable objects here.
48
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_Alignment(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
70         public class Padding : global::System.IDisposable
71         {
72             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
73             protected bool swigCMemOwn;
74
75             internal Padding(global::System.IntPtr cPtr, bool cMemoryOwn)
76             {
77                 swigCMemOwn = cMemoryOwn;
78                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
79             }
80
81             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Padding obj)
82             {
83                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
84             }
85
86             //A Flag to check who called Dispose(). (By User or DisposeQueue)
87             private bool isDisposeQueued = false;
88             //A Flat to check if it is already disposed.
89             protected bool disposed = false;
90
91             ~Padding()
92             {
93                 if (!isDisposeQueued)
94                 {
95                     isDisposeQueued = true;
96                     DisposeQueue.Instance.Add(this);
97                 }
98             }
99
100             public void Dispose()
101             {
102                 //Throw excpetion if Dispose() is called in separate thread.
103                 if (!Window.IsInstalled())
104                 {
105                     throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
106                 }
107
108                 if (isDisposeQueued)
109                 {
110                     Dispose(DisposeTypes.Implicit);
111                 }
112                 else
113                 {
114                     Dispose(DisposeTypes.Explicit);
115                     System.GC.SuppressFinalize(this);
116                 }
117             }
118
119             protected virtual void Dispose(DisposeTypes type)
120             {
121                 if (disposed)
122                 {
123                     return;
124                 }
125
126                 if (type == DisposeTypes.Explicit)
127                 {
128                     //Called by User
129                     //Release your own managed resources here.
130                     //You should release all of your own disposable objects here.
131
132                 }
133
134                 //Release your own unmanaged resources here.
135                 //You should not access any managed member here except static instance.
136                 //because the execution order of Finalizes is non-deterministic.
137
138                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
139                 {
140                     if (swigCMemOwn)
141                     {
142                         swigCMemOwn = false;
143                         NDalicPINVOKE.delete_Alignment_Padding(swigCPtr);
144                     }
145                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
146                 }
147
148                 disposed = true;
149             }
150
151             public Padding() : this(NDalicPINVOKE.new_Alignment_Padding__SWIG_0(), true)
152             {
153                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154             }
155
156             public Padding(float l, float r, float t, float b) : this(NDalicPINVOKE.new_Alignment_Padding__SWIG_1(l, r, t, b), true)
157             {
158                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159             }
160
161             public float left
162             {
163                 set
164                 {
165                     NDalicPINVOKE.Alignment_Padding_left_set(swigCPtr, value);
166                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167                 }
168                 get
169                 {
170                     float ret = NDalicPINVOKE.Alignment_Padding_left_get(swigCPtr);
171                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172                     return ret;
173                 }
174             }
175
176             public float right
177             {
178                 set
179                 {
180                     NDalicPINVOKE.Alignment_Padding_right_set(swigCPtr, value);
181                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182                 }
183                 get
184                 {
185                     float ret = NDalicPINVOKE.Alignment_Padding_right_get(swigCPtr);
186                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187                     return ret;
188                 }
189             }
190
191             public float top
192             {
193                 set
194                 {
195                     NDalicPINVOKE.Alignment_Padding_top_set(swigCPtr, value);
196                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197                 }
198                 get
199                 {
200                     float ret = NDalicPINVOKE.Alignment_Padding_top_get(swigCPtr);
201                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202                     return ret;
203                 }
204             }
205
206             public float bottom
207             {
208                 set
209                 {
210                     NDalicPINVOKE.Alignment_Padding_bottom_set(swigCPtr, value);
211                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212                 }
213                 get
214                 {
215                     float ret = NDalicPINVOKE.Alignment_Padding_bottom_get(swigCPtr);
216                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217                     return ret;
218                 }
219             }
220
221         }
222
223         public Alignment(Alignment.Type horizontal, Alignment.Type vertical) : this(NDalicPINVOKE.Alignment_New__SWIG_0((int)horizontal, (int)vertical), true)
224         {
225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226
227         }
228         public Alignment(Alignment.Type horizontal) : this(NDalicPINVOKE.Alignment_New__SWIG_1((int)horizontal), true)
229         {
230             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231
232         }
233         public Alignment() : this(NDalicPINVOKE.Alignment_New__SWIG_2(), true)
234         {
235             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236
237         }
238         public Alignment(Alignment alignment) : this(NDalicPINVOKE.new_Alignment__SWIG_1(Alignment.getCPtr(alignment)), true)
239         {
240             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241         }
242
243         public new static Alignment DownCast(BaseHandle handle)
244         {
245             Alignment ret = new Alignment(NDalicPINVOKE.Alignment_DownCast(BaseHandle.getCPtr(handle)), true);
246             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247             return ret;
248         }
249
250         public void SetAlignmentType(Alignment.Type type)
251         {
252             NDalicPINVOKE.Alignment_SetAlignmentType(swigCPtr, (int)type);
253             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254         }
255
256         public Alignment.Type GetAlignmentType()
257         {
258             Alignment.Type ret = (Alignment.Type)NDalicPINVOKE.Alignment_GetAlignmentType(swigCPtr);
259             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260             return ret;
261         }
262
263         public void SetScaling(Alignment.Scaling scaling)
264         {
265             NDalicPINVOKE.Alignment_SetScaling(swigCPtr, (int)scaling);
266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267         }
268
269         public Alignment.Scaling GetScaling()
270         {
271             Alignment.Scaling ret = (Alignment.Scaling)NDalicPINVOKE.Alignment_GetScaling(swigCPtr);
272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273             return ret;
274         }
275
276         public void SetPadding(Alignment.Padding padding)
277         {
278             NDalicPINVOKE.Alignment_SetPadding(swigCPtr, Alignment.Padding.getCPtr(padding));
279             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280         }
281
282         public Alignment.Padding GetPadding()
283         {
284             Alignment.Padding ret = new Alignment.Padding(NDalicPINVOKE.Alignment_GetPadding(swigCPtr), false);
285             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286             return ret;
287         }
288
289         public Alignment Assign(Alignment alignment)
290         {
291             Alignment ret = new Alignment(NDalicPINVOKE.Alignment_Assign(swigCPtr, Alignment.getCPtr(alignment)), false);
292             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293             return ret;
294         }
295
296         public enum Type
297         {
298             HorizontalLeft = 1,
299             HorizontalCenter = 2,
300             HorizontalRight = 4,
301             VerticalTop = 8,
302             VerticalCenter = 16,
303             VerticalBottom = 32
304         }
305
306         public enum Scaling
307         {
308             ScaleNone,
309             ScaleToFill,
310             ScaleToFitKeepAspect,
311             ScaleToFillKeepAspect,
312             ShrinkToFit,
313             ShrinkToFitKeepAspect
314         }
315
316     }
317
318 }