2 * Copyright(c) 2021 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.
19 using System.Runtime.InteropServices;
23 class ComponentApplication : Application
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27 internal ComponentApplication(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
29 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
32 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ComponentApplication obj)
34 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
37 protected override void Dispose(DisposeTypes type)
44 //Release your own unmanaged resources here.
45 //You should not access any managed member here except static instance.
46 //because the execution order of Finalizes is non-deterministic.
47 if (swigCPtr.Handle != global::System.IntPtr.Zero)
52 Interop.ComponentApplication.DeleteComponentApplication(swigCPtr);
54 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
59 public static ComponentApplication NewComponentApplication(string[] args, string stylesheet)
61 ComponentApplication ret = New(args, stylesheet);
62 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
67 public static ComponentApplication New(string[] args, string stylesheet)
69 int argc = args.Length;
70 string argvStr = string.Join(" ", args);
72 IntPtr widgetIntPtr = Interop.ComponentApplication.New(argc, argvStr, stylesheet);
74 ComponentApplication ret = new ComponentApplication(widgetIntPtr, false);
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 internal ComponentApplication(ComponentApplication componentApplication) : this(Interop.ComponentApplication.NewComponentApplication(ComponentApplication.getCPtr(componentApplication)), true)
83 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86 internal ComponentApplication Assign(ComponentApplication componentApplication)
88 ComponentApplication ret = new ComponentApplication(Interop.ComponentApplication.Assign(swigCPtr, ComponentApplication.getCPtr(componentApplication)), false);
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
94 private delegate IntPtr NUIComponentApplicationCreatenativeEventCallbackDelegate();
96 public delegate IntPtr CreateNativeEventHandler();
97 private CreateNativeEventHandler applicationCreateNativeEventHandler;
98 private NUIComponentApplicationCreatenativeEventCallbackDelegate applicationCreateNativeEventCallbackDelegate;
101 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
102 * provided by the user. Initialized signal is emitted when application is initialised
104 public event CreateNativeEventHandler CreateNative
108 // Restricted to only one listener
109 if (applicationCreateNativeEventHandler == null)
111 applicationCreateNativeEventHandler += value;
113 applicationCreateNativeEventCallbackDelegate = new NUIComponentApplicationCreatenativeEventCallbackDelegate(OnApplicationCreateNative);
114 Connect(applicationCreateNativeEventCallbackDelegate);
120 if (applicationCreateNativeEventHandler != null)
122 Disconnect(applicationCreateNativeEventCallbackDelegate);
125 applicationCreateNativeEventHandler -= value;
130 public void Connect(System.Delegate func)
132 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
134 Interop.ComponentApplication.CreateNativeSignalConnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
135 if (NDalicPINVOKE.SWIGPendingException.Pending)
137 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 public void Disconnect(System.Delegate func)
144 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
146 Interop.ComponentApplication.CreateNativeSignalDisconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
147 if (NDalicPINVOKE.SWIGPendingException.Pending)
149 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154 internal ApplicationSignal CreateNativeSignal()
156 ApplicationSignal ret = new ApplicationSignal(Interop.ComponentApplication.CreateNativeSignal(swigCPtr), false);
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161 // Callback for Application InitSignal
162 private IntPtr OnApplicationCreateNative()
164 return applicationCreateNativeEventHandler?.Invoke() ?? IntPtr.Zero;