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 public interface IContainer :
15 Efl.Eo.IWrapper, IDisposable
17 /// <summary>Begin iterating over this object's contents.
18 /// (Since EFL 1.22)</summary>
19 /// <returns>Iterator on object's content.</returns>
20 Eina.Iterator<Efl.Gfx.IEntity> ContentIterate();
21 /// <summary>Returns the number of contained sub-objects.
22 /// (Since EFL 1.22)</summary>
23 /// <returns>Number of sub-objects.</returns>
25 /// <summary>Sent after a new sub-object was added.
26 /// (Since EFL 1.22)</summary>
27 event EventHandler<Efl.IContainerContentAddedEvt_Args> ContentAddedEvt;
28 /// <summary>Sent after a sub-object was removed, before unref.
29 /// (Since EFL 1.22)</summary>
30 event EventHandler<Efl.IContainerContentRemovedEvt_Args> ContentRemovedEvt;
32 ///<summary>Event argument wrapper for event <see cref="Efl.IContainer.ContentAddedEvt"/>.</summary>
33 public class IContainerContentAddedEvt_Args : EventArgs {
34 ///<summary>Actual event payload.</summary>
35 public Efl.Gfx.IEntity arg { get; set; }
37 ///<summary>Event argument wrapper for event <see cref="Efl.IContainer.ContentRemovedEvt"/>.</summary>
38 public class IContainerContentRemovedEvt_Args : EventArgs {
39 ///<summary>Actual event payload.</summary>
40 public Efl.Gfx.IEntity arg { get; set; }
42 /// <summary>Common interface for objects (containers) that can have multiple contents (sub-objects).
43 /// APIs in this interface deal with containers of multiple sub-objects, not with individual parts.
44 /// (Since EFL 1.22)</summary>
45 sealed public class IContainerConcrete :
50 ///<summary>Pointer to the native class description.</summary>
51 public override System.IntPtr NativeClass
55 if (((object)this).GetType() == typeof(IContainerConcrete))
57 return GetEflClassStatic();
61 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
66 [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr
67 efl_container_interface_get();
68 /// <summary>Initializes a new instance of the <see cref="IContainer"/> class.
69 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
70 private IContainerConcrete(System.IntPtr raw) : base(raw)
74 /// <summary>Sent after a new sub-object was added.
75 /// (Since EFL 1.22)</summary>
76 public event EventHandler<Efl.IContainerContentAddedEvt_Args> ContentAddedEvt
82 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
84 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
87 Efl.IContainerContentAddedEvt_Args args = new Efl.IContainerContentAddedEvt_Args();
88 args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.Gfx.IEntityConcrete);
91 value?.Invoke(obj, args);
95 Eina.Log.Error(e.ToString());
96 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
101 string key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED";
102 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
110 string key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED";
111 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
115 ///<summary>Method to raise event ContentAddedEvt.</summary>
116 public void OnContentAddedEvt(Efl.IContainerContentAddedEvt_Args e)
118 var key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED";
119 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
120 if (desc == IntPtr.Zero)
122 Eina.Log.Error($"Failed to get native event {key}");
126 IntPtr info = e.arg.NativeHandle;
127 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
129 /// <summary>Sent after a sub-object was removed, before unref.
130 /// (Since EFL 1.22)</summary>
131 public event EventHandler<Efl.IContainerContentRemovedEvt_Args> ContentRemovedEvt
137 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
139 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
142 Efl.IContainerContentRemovedEvt_Args args = new Efl.IContainerContentRemovedEvt_Args();
143 args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.Gfx.IEntityConcrete);
146 value?.Invoke(obj, args);
150 Eina.Log.Error(e.ToString());
151 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
156 string key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED";
157 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
165 string key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED";
166 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
170 ///<summary>Method to raise event ContentRemovedEvt.</summary>
171 public void OnContentRemovedEvt(Efl.IContainerContentRemovedEvt_Args e)
173 var key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED";
174 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
175 if (desc == IntPtr.Zero)
177 Eina.Log.Error($"Failed to get native event {key}");
181 IntPtr info = e.arg.NativeHandle;
182 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
184 /// <summary>Begin iterating over this object's contents.
185 /// (Since EFL 1.22)</summary>
186 /// <returns>Iterator on object's content.</returns>
187 public Eina.Iterator<Efl.Gfx.IEntity> ContentIterate() {
188 var _ret_var = Efl.IContainerConcrete.NativeMethods.efl_content_iterate_ptr.Value.Delegate(this.NativeHandle);
189 Eina.Error.RaiseIfUnhandledException();
190 return new Eina.Iterator<Efl.Gfx.IEntity>(_ret_var, true, false);
192 /// <summary>Returns the number of contained sub-objects.
193 /// (Since EFL 1.22)</summary>
194 /// <returns>Number of sub-objects.</returns>
195 public int ContentCount() {
196 var _ret_var = Efl.IContainerConcrete.NativeMethods.efl_content_count_ptr.Value.Delegate(this.NativeHandle);
197 Eina.Error.RaiseIfUnhandledException();
200 private static IntPtr GetEflClassStatic()
202 return Efl.IContainerConcrete.efl_container_interface_get();
204 /// <summary>Wrapper for native methods and virtual method delegates.
205 /// For internal use by generated code only.</summary>
206 public class NativeMethods : Efl.Eo.NativeClass
208 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
209 /// <summary>Gets the list of Eo operations to override.</summary>
210 /// <returns>The list of Eo operations to be overload.</returns>
211 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
213 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
214 var methods = Efl.Eo.Globals.GetUserMethods(type);
216 if (efl_content_iterate_static_delegate == null)
218 efl_content_iterate_static_delegate = new efl_content_iterate_delegate(content_iterate);
221 if (methods.FirstOrDefault(m => m.Name == "ContentIterate") != null)
223 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) });
226 if (efl_content_count_static_delegate == null)
228 efl_content_count_static_delegate = new efl_content_count_delegate(content_count);
231 if (methods.FirstOrDefault(m => m.Name == "ContentCount") != null)
233 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) });
238 /// <summary>Returns the Eo class for the native methods of this class.</summary>
239 /// <returns>The native class pointer.</returns>
240 public override IntPtr GetEflClass()
242 return Efl.IContainerConcrete.efl_container_interface_get();
245 #pragma warning disable CA1707, CS1591, SA1300, SA1600
248 private delegate System.IntPtr efl_content_iterate_delegate(System.IntPtr obj, System.IntPtr pd);
251 public delegate System.IntPtr efl_content_iterate_api_delegate(System.IntPtr obj);
253 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");
255 private static System.IntPtr content_iterate(System.IntPtr obj, System.IntPtr pd)
257 Eina.Log.Debug("function efl_content_iterate was called");
258 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
261 Eina.Iterator<Efl.Gfx.IEntity> _ret_var = default(Eina.Iterator<Efl.Gfx.IEntity>);
264 _ret_var = ((IContainer)ws.Target).ContentIterate();
268 Eina.Log.Warning($"Callback error: {e.ToString()}");
269 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
272 _ret_var.Own = false; return _ret_var.Handle;
277 return efl_content_iterate_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
281 private static efl_content_iterate_delegate efl_content_iterate_static_delegate;
284 private delegate int efl_content_count_delegate(System.IntPtr obj, System.IntPtr pd);
287 public delegate int efl_content_count_api_delegate(System.IntPtr obj);
289 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");
291 private static int content_count(System.IntPtr obj, System.IntPtr pd)
293 Eina.Log.Debug("function efl_content_count was called");
294 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
297 int _ret_var = default(int);
300 _ret_var = ((IContainer)ws.Target).ContentCount();
304 Eina.Log.Warning($"Callback error: {e.ToString()}");
305 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
313 return efl_content_count_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
317 private static efl_content_count_delegate efl_content_count_static_delegate;
319 #pragma warning restore CA1707, CS1591, SA1300, SA1600