[Tizen] Fix build warnings
[platform/core/csapi/nui.git] / Tizen.NUI / src / internal / Builder.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 namespace Tizen.NUI
18 {
19
20     using System;
21     using System.Runtime.InteropServices;
22     using Tizen.NUI.BaseComponents;
23
24
25     internal class Builder : BaseHandle
26     {
27         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28
29         internal Builder(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Builder_SWIGUpcast(cPtr), cMemoryOwn)
30         {
31             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
32         }
33
34         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Builder obj)
35         {
36             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
37         }
38
39         protected override void Dispose(DisposeTypes type)
40         {
41             if (disposed)
42             {
43                 return;
44             }
45
46             if (type == DisposeTypes.Explicit)
47             {
48                 //Called by User
49                 //Release your own managed resources here.
50                 //You should release all of your own disposable objects here.
51
52             }
53
54             //Release your own unmanaged resources here.
55             //You should not access any managed member here except static instance.
56             //because the execution order of Finalizes is non-deterministic.
57
58
59             if (swigCPtr.Handle != global::System.IntPtr.Zero)
60             {
61                 if (swigCMemOwn)
62                 {
63                     swigCMemOwn = false;
64                     NDalicPINVOKE.delete_Builder(swigCPtr);
65                 }
66                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
67             }
68
69             base.Dispose(type);
70         }
71
72
73
74         public class QuitEventArgs : EventArgs
75         {
76         }
77
78         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79         private delegate void QuitEventCallbackDelegate();
80         private DaliEventHandler<object, QuitEventArgs> _builderQuitEventHandler;
81         private QuitEventCallbackDelegate _builderQuitEventCallbackDelegate;
82
83         public event DaliEventHandler<object, QuitEventArgs> Quit
84         {
85             add
86             {
87                 lock (this)
88                 {
89                     // Restricted to only one listener
90                     if (_builderQuitEventHandler == null)
91                     {
92                         _builderQuitEventHandler += value;
93
94                         _builderQuitEventCallbackDelegate = new QuitEventCallbackDelegate(OnQuit);
95                         this.QuitSignal().Connect(_builderQuitEventCallbackDelegate);
96                     }
97                 }
98             }
99
100             remove
101             {
102                 lock (this)
103                 {
104                     if (_builderQuitEventHandler != null)
105                     {
106                         this.QuitSignal().Disconnect(_builderQuitEventCallbackDelegate);
107                     }
108
109                     _builderQuitEventHandler -= value;
110                 }
111             }
112         }
113
114         // Callback for Builder QuitSignal
115         private void OnQuit()
116         {
117             QuitEventArgs e = new QuitEventArgs();
118
119             if (_builderQuitEventHandler != null)
120             {
121                 //here we send all data to user event handlers
122                 _builderQuitEventHandler(this, e);
123             }
124         }
125
126         ///
127         public void LoadFromFile(string fileName)
128         {
129             try
130             {
131                 string json = System.IO.File.ReadAllText(fileName);
132                 if (json.Length > 0)
133                 {
134                     LoadFromString(json);
135                 }
136                 else
137                 {
138                     throw new global::System.InvalidOperationException("Failed to load file " + fileName);
139
140                 }
141             }
142             catch (System.Exception e)
143             {
144                 NUILog.Error(e.Message);
145                 throw new global::System.InvalidOperationException("Failed to parse " + fileName);
146             }
147         }
148
149
150
151         public Builder() : this(NDalicPINVOKE.Builder_New(), true)
152         {
153             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154
155         }
156         public void LoadFromString(string data, Builder.UIFormat format)
157         {
158             NDalicPINVOKE.Builder_LoadFromString__SWIG_0(swigCPtr, data, (int)format);
159             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160         }
161
162         public void LoadFromString(string data)
163         {
164             NDalicPINVOKE.Builder_LoadFromString__SWIG_1(swigCPtr, data);
165             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166         }
167
168         public void AddConstants(PropertyMap map)
169         {
170             NDalicPINVOKE.Builder_AddConstants(swigCPtr, PropertyMap.getCPtr(map));
171             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172         }
173
174         public void AddConstant(string key, PropertyValue value)
175         {
176             NDalicPINVOKE.Builder_AddConstant(swigCPtr, key, PropertyValue.getCPtr(value));
177             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178         }
179
180         public PropertyMap GetConstants()
181         {
182             PropertyMap ret = new PropertyMap(NDalicPINVOKE.Builder_GetConstants(swigCPtr), false);
183             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184             return ret;
185         }
186
187         public PropertyValue GetConstant(string key)
188         {
189             PropertyValue ret = new PropertyValue(NDalicPINVOKE.Builder_GetConstant(swigCPtr, key), false);
190             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191             return ret;
192         }
193
194         public Animation CreateAnimation(string animationName)
195         {
196             Animation ret = new Animation(NDalicPINVOKE.Builder_CreateAnimation__SWIG_0(swigCPtr, animationName), true);
197             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198             return ret;
199         }
200
201         public Animation CreateAnimation(string animationName, PropertyMap map)
202         {
203             Animation ret = new Animation(NDalicPINVOKE.Builder_CreateAnimation__SWIG_1(swigCPtr, animationName, PropertyMap.getCPtr(map)), true);
204             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205             return ret;
206         }
207
208         public Animation CreateAnimation(string animationName, View sourceActor)
209         {
210             Animation ret = new Animation(NDalicPINVOKE.Builder_CreateAnimation__SWIG_2(swigCPtr, animationName, View.getCPtr(sourceActor)), true);
211             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212             return ret;
213         }
214
215         public Animation CreateAnimation(string animationName, PropertyMap map, View sourceActor)
216         {
217             Animation ret = new Animation(NDalicPINVOKE.Builder_CreateAnimation__SWIG_3(swigCPtr, animationName, PropertyMap.getCPtr(map), View.getCPtr(sourceActor)), true);
218             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219             return ret;
220         }
221
222         public View Create(string templateName)
223         {
224             View ret = new View(NDalicPINVOKE.Builder_Create__SWIG_0(swigCPtr, templateName), true);
225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226             return ret;
227         }
228
229         public BaseHandle Create(string templateName, PropertyMap map)
230         {
231             BaseHandle ret = new BaseHandle(NDalicPINVOKE.Builder_Create__SWIG_1(swigCPtr, templateName, PropertyMap.getCPtr(map)), true);
232             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233             return ret;
234         }
235
236         public BaseHandle CreateFromJson(string json)
237         {
238             BaseHandle ret = new BaseHandle(NDalicPINVOKE.Builder_CreateFromJson(swigCPtr, json), true);
239             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240             return ret;
241         }
242
243         public bool ApplyStyle(string styleName, Animatable handle)
244         {
245             bool ret = NDalicPINVOKE.Builder_ApplyStyle(swigCPtr, styleName, Animatable.getCPtr(handle));
246             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247             return ret;
248         }
249
250         public bool ApplyFromJson(Animatable handle, string json)
251         {
252             bool ret = NDalicPINVOKE.Builder_ApplyFromJson(swigCPtr, Animatable.getCPtr(handle), json);
253             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254             return ret;
255         }
256
257         public void AddViews(View toActor)
258         {
259             NDalicPINVOKE.Builder_AddActors__SWIG_0(swigCPtr, View.getCPtr(toActor));
260             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261         }
262
263         public void AddViews(string sectionName, View toActor)
264         {
265             NDalicPINVOKE.Builder_AddActors__SWIG_1(swigCPtr, sectionName, View.getCPtr(toActor));
266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267         }
268
269         public void CreateRenderTask(string name)
270         {
271             NDalicPINVOKE.Builder_CreateRenderTask(swigCPtr, name);
272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273         }
274
275         internal FrameBufferImage GetFrameBufferImage(string name)
276         {
277             FrameBufferImage ret = new FrameBufferImage(NDalicPINVOKE.Builder_GetFrameBufferImage(swigCPtr, name), true);
278             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279             return ret;
280         }
281
282         public Path GetPath(string name)
283         {
284             Path ret = new Path(NDalicPINVOKE.Builder_GetPath(swigCPtr, name), true);
285             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286             return ret;
287         }
288
289         internal PathConstrainer GetPathConstrainer(string pathConstrainerName)
290         {
291             PathConstrainer ret = new PathConstrainer(NDalicPINVOKE.Builder_GetPathConstrainer(swigCPtr, pathConstrainerName), true);
292             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293             return ret;
294         }
295
296         internal LinearConstrainer GetLinearConstrainer(string linearConstrainerName)
297         {
298             LinearConstrainer ret = new LinearConstrainer(NDalicPINVOKE.Builder_GetLinearConstrainer(swigCPtr, linearConstrainerName), true);
299             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300             return ret;
301         }
302
303         internal VoidSignal QuitSignal()
304         {
305             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Builder_QuitSignal(swigCPtr), false);
306             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307             return ret;
308         }
309
310         public enum UIFormat
311         {
312             JSON
313         }
314
315     }
316
317 }