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