1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
10 /// <summary>Common interface for objects (containers) that can have multiple contents (sub-objects).
11 /// APIs in this interface deal with containers of multiple sub-objects, not with individual parts.
12 /// (Since EFL 1.22)</summary>
13 [Efl.IContainerConcrete.NativeMethods]
14 [Efl.Eo.BindingEntity]
15 public interface IContainer :
16 Efl.Eo.IWrapper, IDisposable
18 /// <summary>Begin iterating over this object's contents.
19 /// (Since EFL 1.22)</summary>
20 /// <returns>Iterator on object's content.</returns>
21 Eina.Iterator<Efl.Gfx.IEntity> ContentIterate();
22 /// <summary>Returns the number of contained sub-objects.
23 /// (Since EFL 1.22)</summary>
24 /// <returns>Number of sub-objects.</returns>
26 /// <summary>Sent after a new sub-object was added.
27 /// (Since EFL 1.22)</summary>
28 event EventHandler<Efl.IContainerContentAddedEvt_Args> ContentAddedEvt;
29 /// <summary>Sent after a sub-object was removed, before unref.
30 /// (Since EFL 1.22)</summary>
31 event EventHandler<Efl.IContainerContentRemovedEvt_Args> ContentRemovedEvt;
33 ///<summary>Event argument wrapper for event <see cref="Efl.IContainer.ContentAddedEvt"/>.</summary>
34 [Efl.Eo.BindingEntity]
35 public class IContainerContentAddedEvt_Args : EventArgs {
36 ///<summary>Actual event payload.</summary>
37 public Efl.Gfx.IEntity arg { get; set; }
39 ///<summary>Event argument wrapper for event <see cref="Efl.IContainer.ContentRemovedEvt"/>.</summary>
40 [Efl.Eo.BindingEntity]
41 public class IContainerContentRemovedEvt_Args : EventArgs {
42 ///<summary>Actual event payload.</summary>
43 public Efl.Gfx.IEntity arg { get; set; }
45 /// <summary>Common interface for objects (containers) that can have multiple contents (sub-objects).
46 /// APIs in this interface deal with containers of multiple sub-objects, not with individual parts.
47 /// (Since EFL 1.22)</summary>
48 sealed public class IContainerConcrete :
53 ///<summary>Pointer to the native class description.</summary>
54 public override System.IntPtr NativeClass
58 if (((object)this).GetType() == typeof(IContainerConcrete))
60 return GetEflClassStatic();
64 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
69 /// <summary>Constructor to be used when objects are expected to be constructed from native code.</summary>
70 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
71 private IContainerConcrete(ConstructingHandle ch) : base(ch)
75 [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr
76 efl_container_interface_get();
77 /// <summary>Initializes a new instance of the <see cref="IContainer"/> class.
78 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
79 /// <param name="wh">The native pointer to be wrapped.</param>
80 private IContainerConcrete(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
84 /// <summary>Sent after a new sub-object was added.
85 /// (Since EFL 1.22)</summary>
86 public event EventHandler<Efl.IContainerContentAddedEvt_Args> ContentAddedEvt
90 lock (eflBindingEventLock)
92 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
94 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
97 Efl.IContainerContentAddedEvt_Args args = new Efl.IContainerContentAddedEvt_Args();
98 args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.Gfx.IEntityConcrete);
101 value?.Invoke(obj, args);
105 Eina.Log.Error(e.ToString());
106 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
111 string key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED";
112 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
118 lock (eflBindingEventLock)
120 string key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED";
121 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
125 ///<summary>Method to raise event ContentAddedEvt.</summary>
126 public void OnContentAddedEvt(Efl.IContainerContentAddedEvt_Args e)
128 var key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED";
129 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
130 if (desc == IntPtr.Zero)
132 Eina.Log.Error($"Failed to get native event {key}");
136 IntPtr info = e.arg.NativeHandle;
137 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
139 /// <summary>Sent after a sub-object was removed, before unref.
140 /// (Since EFL 1.22)</summary>
141 public event EventHandler<Efl.IContainerContentRemovedEvt_Args> ContentRemovedEvt
145 lock (eflBindingEventLock)
147 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
149 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
152 Efl.IContainerContentRemovedEvt_Args args = new Efl.IContainerContentRemovedEvt_Args();
153 args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.Gfx.IEntityConcrete);
156 value?.Invoke(obj, args);
160 Eina.Log.Error(e.ToString());
161 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
166 string key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED";
167 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
173 lock (eflBindingEventLock)
175 string key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED";
176 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
180 ///<summary>Method to raise event ContentRemovedEvt.</summary>
181 public void OnContentRemovedEvt(Efl.IContainerContentRemovedEvt_Args e)
183 var key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED";
184 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
185 if (desc == IntPtr.Zero)
187 Eina.Log.Error($"Failed to get native event {key}");
191 IntPtr info = e.arg.NativeHandle;
192 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
194 /// <summary>Begin iterating over this object's contents.
195 /// (Since EFL 1.22)</summary>
196 /// <returns>Iterator on object's content.</returns>
197 public Eina.Iterator<Efl.Gfx.IEntity> ContentIterate() {
198 var _ret_var = Efl.IContainerConcrete.NativeMethods.efl_content_iterate_ptr.Value.Delegate(this.NativeHandle);
199 Eina.Error.RaiseIfUnhandledException();
200 return new Eina.Iterator<Efl.Gfx.IEntity>(_ret_var, true);
202 /// <summary>Returns the number of contained sub-objects.
203 /// (Since EFL 1.22)</summary>
204 /// <returns>Number of sub-objects.</returns>
205 public int ContentCount() {
206 var _ret_var = Efl.IContainerConcrete.NativeMethods.efl_content_count_ptr.Value.Delegate(this.NativeHandle);
207 Eina.Error.RaiseIfUnhandledException();
210 private static IntPtr GetEflClassStatic()
212 return Efl.IContainerConcrete.efl_container_interface_get();
214 /// <summary>Wrapper for native methods and virtual method delegates.
215 /// For internal use by generated code only.</summary>
216 public new class NativeMethods : Efl.Eo.EoWrapper.NativeMethods
218 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
219 /// <summary>Gets the list of Eo operations to override.</summary>
220 /// <returns>The list of Eo operations to be overload.</returns>
221 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
223 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
224 var methods = Efl.Eo.Globals.GetUserMethods(type);
226 if (efl_content_iterate_static_delegate == null)
228 efl_content_iterate_static_delegate = new efl_content_iterate_delegate(content_iterate);
231 if (methods.FirstOrDefault(m => m.Name == "ContentIterate") != null)
233 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_content_iterate"), func = Marshal.GetFunctionPointerForDelegate(efl_content_iterate_static_delegate) });
236 if (efl_content_count_static_delegate == null)
238 efl_content_count_static_delegate = new efl_content_count_delegate(content_count);
241 if (methods.FirstOrDefault(m => m.Name == "ContentCount") != null)
243 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_content_count"), func = Marshal.GetFunctionPointerForDelegate(efl_content_count_static_delegate) });
248 /// <summary>Returns the Eo class for the native methods of this class.</summary>
249 /// <returns>The native class pointer.</returns>
250 public override IntPtr GetEflClass()
252 return Efl.IContainerConcrete.efl_container_interface_get();
255 #pragma warning disable CA1707, CS1591, SA1300, SA1600
258 private delegate System.IntPtr efl_content_iterate_delegate(System.IntPtr obj, System.IntPtr pd);
261 public delegate System.IntPtr efl_content_iterate_api_delegate(System.IntPtr obj);
263 public static Efl.Eo.FunctionWrapper<efl_content_iterate_api_delegate> efl_content_iterate_ptr = new Efl.Eo.FunctionWrapper<efl_content_iterate_api_delegate>(Module, "efl_content_iterate");
265 private static System.IntPtr content_iterate(System.IntPtr obj, System.IntPtr pd)
267 Eina.Log.Debug("function efl_content_iterate was called");
268 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
271 Eina.Iterator<Efl.Gfx.IEntity> _ret_var = default(Eina.Iterator<Efl.Gfx.IEntity>);
274 _ret_var = ((IContainer)ws.Target).ContentIterate();
278 Eina.Log.Warning($"Callback error: {e.ToString()}");
279 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
282 _ret_var.Own = false; return _ret_var.Handle;
287 return efl_content_iterate_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
291 private static efl_content_iterate_delegate efl_content_iterate_static_delegate;
294 private delegate int efl_content_count_delegate(System.IntPtr obj, System.IntPtr pd);
297 public delegate int efl_content_count_api_delegate(System.IntPtr obj);
299 public static Efl.Eo.FunctionWrapper<efl_content_count_api_delegate> efl_content_count_ptr = new Efl.Eo.FunctionWrapper<efl_content_count_api_delegate>(Module, "efl_content_count");
301 private static int content_count(System.IntPtr obj, System.IntPtr pd)
303 Eina.Log.Debug("function efl_content_count was called");
304 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
307 int _ret_var = default(int);
310 _ret_var = ((IContainer)ws.Target).ContentCount();
314 Eina.Log.Warning($"Callback error: {e.ToString()}");
315 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
323 return efl_content_count_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
327 private static efl_content_count_delegate efl_content_count_static_delegate;
329 #pragma warning restore CA1707, CS1591, SA1300, SA1600