1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
12 /// <summary>Represents a SWALLOW part of an Edje object.
13 /// Its lifetime is limited to one function call only, unless an extra reference is explicitely held.</summary>
14 [Efl.Canvas.LayoutPartSwallow.NativeMethods]
15 public class LayoutPartSwallow : Efl.Canvas.LayoutPart, Efl.Eo.IWrapper,Efl.IContent
17 ///<summary>Pointer to the native class description.</summary>
18 public override System.IntPtr NativeClass
22 if (((object)this).GetType() == typeof(LayoutPartSwallow))
24 return GetEflClassStatic();
28 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
33 [System.Runtime.InteropServices.DllImport(efl.Libs.Edje)] internal static extern System.IntPtr
34 efl_canvas_layout_part_swallow_class_get();
35 /// <summary>Initializes a new instance of the <see cref="LayoutPartSwallow"/> class.</summary>
36 /// <param name="parent">Parent instance.</param>
37 public LayoutPartSwallow(Efl.Object parent= null
38 ) : base(efl_canvas_layout_part_swallow_class_get(), typeof(LayoutPartSwallow), parent)
40 FinishInstantiation();
43 /// <summary>Initializes a new instance of the <see cref="LayoutPartSwallow"/> class.
44 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
45 /// <param name="raw">The native pointer to be wrapped.</param>
46 protected LayoutPartSwallow(System.IntPtr raw) : base(raw)
50 /// <summary>Initializes a new instance of the <see cref="LayoutPartSwallow"/> class.
51 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
52 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
53 /// <param name="managedType">The managed type of the public constructor that originated this call.</param>
54 /// <param name="parent">The Efl.Object parent of this instance.</param>
55 protected LayoutPartSwallow(IntPtr baseKlass, System.Type managedType, Efl.Object parent) : base(baseKlass, managedType, parent)
59 /// <summary>Verifies if the given object is equal to this one.</summary>
60 /// <param name="instance">The object to compare to.</param>
61 /// <returns>True if both objects point to the same native object.</returns>
62 public override bool Equals(object instance)
64 var other = instance as Efl.Object;
69 return this.NativeHandle == other.NativeHandle;
72 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
73 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
74 public override int GetHashCode()
76 return this.NativeHandle.ToInt32();
79 /// <summary>Turns the native pointer into a string representation.</summary>
80 /// <returns>A string with the type and the native pointer for this object.</returns>
81 public override String ToString()
83 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
86 /// <summary>Sent after the content is set or unset using the current content object.
87 /// (Since EFL 1.22)</summary>
88 public event EventHandler<Efl.IContentContentChangedEvt_Args> ContentChangedEvt
94 var wRef = new WeakReference(this);
95 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
97 var obj = wRef.Target as Efl.Eo.IWrapper;
100 Efl.IContentContentChangedEvt_Args args = new Efl.IContentContentChangedEvt_Args();
101 args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.Gfx.IEntityConcrete);
104 value?.Invoke(obj, args);
108 Eina.Log.Error(e.ToString());
109 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
114 string key = "_EFL_CONTENT_EVENT_CONTENT_CHANGED";
115 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
123 string key = "_EFL_CONTENT_EVENT_CONTENT_CHANGED";
124 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
128 ///<summary>Method to raise event ContentChangedEvt.</summary>
129 public void OnContentChangedEvt(Efl.IContentContentChangedEvt_Args e)
131 var key = "_EFL_CONTENT_EVENT_CONTENT_CHANGED";
132 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
133 if (desc == IntPtr.Zero)
135 Eina.Log.Error($"Failed to get native event {key}");
139 IntPtr info = e.arg.NativeHandle;
140 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
142 /// <summary>Sub-object currently set as this object's single content.
143 /// If it is set multiple times, previous sub-objects are removed first. Therefore, if an invalid <c>content</c> is set the object will become empty (it will have no sub-object).
144 /// (Since EFL 1.22)</summary>
145 /// <returns>The sub-object.</returns>
146 virtual public Efl.Gfx.IEntity GetContent() {
147 var _ret_var = Efl.IContentConcrete.NativeMethods.efl_content_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
148 Eina.Error.RaiseIfUnhandledException();
151 /// <summary>Sub-object currently set as this object's single content.
152 /// If it is set multiple times, previous sub-objects are removed first. Therefore, if an invalid <c>content</c> is set the object will become empty (it will have no sub-object).
153 /// (Since EFL 1.22)</summary>
154 /// <param name="content">The sub-object.</param>
155 /// <returns><c>true</c> if <c>content</c> was successfully swallowed.</returns>
156 virtual public bool SetContent(Efl.Gfx.IEntity content) {
157 var _ret_var = Efl.IContentConcrete.NativeMethods.efl_content_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle),content);
158 Eina.Error.RaiseIfUnhandledException();
161 /// <summary>Remove the sub-object currently set as content of this object and return it. This object becomes empty.
162 /// (Since EFL 1.22)</summary>
163 /// <returns>Unswallowed object</returns>
164 virtual public Efl.Gfx.IEntity UnsetContent() {
165 var _ret_var = Efl.IContentConcrete.NativeMethods.efl_content_unset_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
166 Eina.Error.RaiseIfUnhandledException();
169 /// <summary>Sub-object currently set as this object's single content.
170 /// If it is set multiple times, previous sub-objects are removed first. Therefore, if an invalid <c>content</c> is set the object will become empty (it will have no sub-object).
171 /// (Since EFL 1.22)</summary>
172 /// <value>The sub-object.</value>
173 public Efl.Gfx.IEntity Content {
174 get { return GetContent(); }
175 set { SetContent(value); }
177 private static IntPtr GetEflClassStatic()
179 return Efl.Canvas.LayoutPartSwallow.efl_canvas_layout_part_swallow_class_get();
181 /// <summary>Wrapper for native methods and virtual method delegates.
182 /// For internal use by generated code only.</summary>
183 public new class NativeMethods : Efl.Canvas.LayoutPart.NativeMethods
185 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Edje);
186 /// <summary>Gets the list of Eo operations to override.</summary>
187 /// <returns>The list of Eo operations to be overload.</returns>
188 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
190 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
191 var methods = Efl.Eo.Globals.GetUserMethods(type);
193 if (efl_content_get_static_delegate == null)
195 efl_content_get_static_delegate = new efl_content_get_delegate(content_get);
198 if (methods.FirstOrDefault(m => m.Name == "GetContent") != null)
200 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_content_get"), func = Marshal.GetFunctionPointerForDelegate(efl_content_get_static_delegate) });
203 if (efl_content_set_static_delegate == null)
205 efl_content_set_static_delegate = new efl_content_set_delegate(content_set);
208 if (methods.FirstOrDefault(m => m.Name == "SetContent") != null)
210 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_content_set"), func = Marshal.GetFunctionPointerForDelegate(efl_content_set_static_delegate) });
213 if (efl_content_unset_static_delegate == null)
215 efl_content_unset_static_delegate = new efl_content_unset_delegate(content_unset);
218 if (methods.FirstOrDefault(m => m.Name == "UnsetContent") != null)
220 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_content_unset"), func = Marshal.GetFunctionPointerForDelegate(efl_content_unset_static_delegate) });
223 descs.AddRange(base.GetEoOps(type));
226 /// <summary>Returns the Eo class for the native methods of this class.</summary>
227 /// <returns>The native class pointer.</returns>
228 public override IntPtr GetEflClass()
230 return Efl.Canvas.LayoutPartSwallow.efl_canvas_layout_part_swallow_class_get();
233 #pragma warning disable CA1707, SA1300, SA1600
235 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
236 private delegate Efl.Gfx.IEntity efl_content_get_delegate(System.IntPtr obj, System.IntPtr pd);
238 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
239 public delegate Efl.Gfx.IEntity efl_content_get_api_delegate(System.IntPtr obj);
241 public static Efl.Eo.FunctionWrapper<efl_content_get_api_delegate> efl_content_get_ptr = new Efl.Eo.FunctionWrapper<efl_content_get_api_delegate>(Module, "efl_content_get");
243 private static Efl.Gfx.IEntity content_get(System.IntPtr obj, System.IntPtr pd)
245 Eina.Log.Debug("function efl_content_get was called");
246 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
249 Efl.Gfx.IEntity _ret_var = default(Efl.Gfx.IEntity);
252 _ret_var = ((LayoutPartSwallow)wrapper).GetContent();
256 Eina.Log.Warning($"Callback error: {e.ToString()}");
257 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
265 return efl_content_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
269 private static efl_content_get_delegate efl_content_get_static_delegate;
271 [return: MarshalAs(UnmanagedType.U1)]
272 private delegate bool efl_content_set_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.Gfx.IEntity content);
274 [return: MarshalAs(UnmanagedType.U1)]
275 public delegate bool efl_content_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.Gfx.IEntity content);
277 public static Efl.Eo.FunctionWrapper<efl_content_set_api_delegate> efl_content_set_ptr = new Efl.Eo.FunctionWrapper<efl_content_set_api_delegate>(Module, "efl_content_set");
279 private static bool content_set(System.IntPtr obj, System.IntPtr pd, Efl.Gfx.IEntity content)
281 Eina.Log.Debug("function efl_content_set was called");
282 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
285 bool _ret_var = default(bool);
288 _ret_var = ((LayoutPartSwallow)wrapper).SetContent(content);
292 Eina.Log.Warning($"Callback error: {e.ToString()}");
293 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
301 return efl_content_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), content);
305 private static efl_content_set_delegate efl_content_set_static_delegate;
307 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
308 private delegate Efl.Gfx.IEntity efl_content_unset_delegate(System.IntPtr obj, System.IntPtr pd);
310 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
311 public delegate Efl.Gfx.IEntity efl_content_unset_api_delegate(System.IntPtr obj);
313 public static Efl.Eo.FunctionWrapper<efl_content_unset_api_delegate> efl_content_unset_ptr = new Efl.Eo.FunctionWrapper<efl_content_unset_api_delegate>(Module, "efl_content_unset");
315 private static Efl.Gfx.IEntity content_unset(System.IntPtr obj, System.IntPtr pd)
317 Eina.Log.Debug("function efl_content_unset was called");
318 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
321 Efl.Gfx.IEntity _ret_var = default(Efl.Gfx.IEntity);
324 _ret_var = ((LayoutPartSwallow)wrapper).UnsetContent();
328 Eina.Log.Warning($"Callback error: {e.ToString()}");
329 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
337 return efl_content_unset_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
341 private static efl_content_unset_delegate efl_content_unset_static_delegate;
343 #pragma warning restore CA1707, SA1300, SA1600