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>Class representing an external part in Edje layouts.
13 /// An object of this type is an Efl.Part object, which means its lifecycle is limited to only one function call.
15 /// An external part contains one object, which can be retrieved with <see cref="Efl.IContent.GetContent"/>. Do not delete this object. Just like for other parts Edje is in charge of the visibility, geometry, clip, etc.
17 /// Common usage in pseudo-C would be as follows: Eo *widget = efl_content_get(efl_part(layout, "extpartname")); efl_text_set(widget, "hello");
19 /// Note that as a shortcut the widget's functions can be called directly on this part object. In C++: efl::eo::downcast<efl::Text>(layout.part("title")).text_set("hello"); Or in pseudo-C: efl_text_set(efl_part(layout, "title"), "hello"); Or in pseudo-script: layout["title"].text = "hello";</summary>
20 [Efl.Canvas.LayoutPartExternal.NativeMethods]
21 public class LayoutPartExternal : Efl.Canvas.LayoutPart, Efl.IContent
23 ///<summary>Pointer to the native class description.</summary>
24 public override System.IntPtr NativeClass
28 if (((object)this).GetType() == typeof(LayoutPartExternal))
30 return GetEflClassStatic();
34 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
39 [System.Runtime.InteropServices.DllImport(efl.Libs.Edje)] internal static extern System.IntPtr
40 efl_canvas_layout_part_external_class_get();
41 /// <summary>Initializes a new instance of the <see cref="LayoutPartExternal"/> class.</summary>
42 /// <param name="parent">Parent instance.</param>
43 public LayoutPartExternal(Efl.Object parent= null
44 ) : base(efl_canvas_layout_part_external_class_get(), typeof(LayoutPartExternal), parent)
46 FinishInstantiation();
49 /// <summary>Initializes a new instance of the <see cref="LayoutPartExternal"/> class.
50 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
51 /// <param name="raw">The native pointer to be wrapped.</param>
52 protected LayoutPartExternal(System.IntPtr raw) : base(raw)
56 /// <summary>Initializes a new instance of the <see cref="LayoutPartExternal"/> class.
57 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
58 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
59 /// <param name="managedType">The managed type of the public constructor that originated this call.</param>
60 /// <param name="parent">The Efl.Object parent of this instance.</param>
61 protected LayoutPartExternal(IntPtr baseKlass, System.Type managedType, Efl.Object parent) : base(baseKlass, managedType, parent)
65 /// <summary>Sent after the content is set or unset using the current content object.
66 /// (Since EFL 1.22)</summary>
67 public event EventHandler<Efl.IContentContentChangedEvt_Args> ContentChangedEvt
73 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
75 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
78 Efl.IContentContentChangedEvt_Args args = new Efl.IContentContentChangedEvt_Args();
79 args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.Gfx.IEntityConcrete);
82 value?.Invoke(obj, args);
86 Eina.Log.Error(e.ToString());
87 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
92 string key = "_EFL_CONTENT_EVENT_CONTENT_CHANGED";
93 AddNativeEventHandler(efl.Libs.Edje, key, callerCb, value);
101 string key = "_EFL_CONTENT_EVENT_CONTENT_CHANGED";
102 RemoveNativeEventHandler(efl.Libs.Edje, key, value);
106 ///<summary>Method to raise event ContentChangedEvt.</summary>
107 public void OnContentChangedEvt(Efl.IContentContentChangedEvt_Args e)
109 var key = "_EFL_CONTENT_EVENT_CONTENT_CHANGED";
110 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Edje, key);
111 if (desc == IntPtr.Zero)
113 Eina.Log.Error($"Failed to get native event {key}");
117 IntPtr info = e.arg.NativeHandle;
118 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
120 /// <summary>Sub-object currently set as this object's single content.
121 /// 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).
122 /// (Since EFL 1.22)</summary>
123 /// <returns>The sub-object.</returns>
124 virtual public Efl.Gfx.IEntity GetContent() {
125 var _ret_var = Efl.IContentConcrete.NativeMethods.efl_content_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
126 Eina.Error.RaiseIfUnhandledException();
129 /// <summary>Sub-object currently set as this object's single content.
130 /// 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).
131 /// (Since EFL 1.22)</summary>
132 /// <param name="content">The sub-object.</param>
133 /// <returns><c>true</c> if <c>content</c> was successfully swallowed.</returns>
134 virtual public bool SetContent(Efl.Gfx.IEntity content) {
135 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);
136 Eina.Error.RaiseIfUnhandledException();
139 /// <summary>Remove the sub-object currently set as content of this object and return it. This object becomes empty.
140 /// (Since EFL 1.22)</summary>
141 /// <returns>Unswallowed object</returns>
142 virtual public Efl.Gfx.IEntity UnsetContent() {
143 var _ret_var = Efl.IContentConcrete.NativeMethods.efl_content_unset_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
144 Eina.Error.RaiseIfUnhandledException();
147 /// <summary>Sub-object currently set as this object's single content.
148 /// 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).
149 /// (Since EFL 1.22)</summary>
150 /// <value>The sub-object.</value>
151 public Efl.Gfx.IEntity Content {
152 get { return GetContent(); }
153 set { SetContent(value); }
155 private static IntPtr GetEflClassStatic()
157 return Efl.Canvas.LayoutPartExternal.efl_canvas_layout_part_external_class_get();
159 /// <summary>Wrapper for native methods and virtual method delegates.
160 /// For internal use by generated code only.</summary>
161 public new class NativeMethods : Efl.Canvas.LayoutPart.NativeMethods
163 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Edje);
164 /// <summary>Gets the list of Eo operations to override.</summary>
165 /// <returns>The list of Eo operations to be overload.</returns>
166 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
168 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
169 var methods = Efl.Eo.Globals.GetUserMethods(type);
171 if (efl_content_get_static_delegate == null)
173 efl_content_get_static_delegate = new efl_content_get_delegate(content_get);
176 if (methods.FirstOrDefault(m => m.Name == "GetContent") != null)
178 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) });
181 if (efl_content_set_static_delegate == null)
183 efl_content_set_static_delegate = new efl_content_set_delegate(content_set);
186 if (methods.FirstOrDefault(m => m.Name == "SetContent") != null)
188 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) });
191 if (efl_content_unset_static_delegate == null)
193 efl_content_unset_static_delegate = new efl_content_unset_delegate(content_unset);
196 if (methods.FirstOrDefault(m => m.Name == "UnsetContent") != null)
198 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) });
201 descs.AddRange(base.GetEoOps(type));
204 /// <summary>Returns the Eo class for the native methods of this class.</summary>
205 /// <returns>The native class pointer.</returns>
206 public override IntPtr GetEflClass()
208 return Efl.Canvas.LayoutPartExternal.efl_canvas_layout_part_external_class_get();
211 #pragma warning disable CA1707, CS1591, SA1300, SA1600
213 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
214 private delegate Efl.Gfx.IEntity efl_content_get_delegate(System.IntPtr obj, System.IntPtr pd);
216 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
217 public delegate Efl.Gfx.IEntity efl_content_get_api_delegate(System.IntPtr obj);
219 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");
221 private static Efl.Gfx.IEntity content_get(System.IntPtr obj, System.IntPtr pd)
223 Eina.Log.Debug("function efl_content_get was called");
224 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
227 Efl.Gfx.IEntity _ret_var = default(Efl.Gfx.IEntity);
230 _ret_var = ((LayoutPartExternal)ws.Target).GetContent();
234 Eina.Log.Warning($"Callback error: {e.ToString()}");
235 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
243 return efl_content_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
247 private static efl_content_get_delegate efl_content_get_static_delegate;
249 [return: MarshalAs(UnmanagedType.U1)]
250 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);
252 [return: MarshalAs(UnmanagedType.U1)]
253 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);
255 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");
257 private static bool content_set(System.IntPtr obj, System.IntPtr pd, Efl.Gfx.IEntity content)
259 Eina.Log.Debug("function efl_content_set was called");
260 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
263 bool _ret_var = default(bool);
266 _ret_var = ((LayoutPartExternal)ws.Target).SetContent(content);
270 Eina.Log.Warning($"Callback error: {e.ToString()}");
271 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
279 return efl_content_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), content);
283 private static efl_content_set_delegate efl_content_set_static_delegate;
285 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
286 private delegate Efl.Gfx.IEntity efl_content_unset_delegate(System.IntPtr obj, System.IntPtr pd);
288 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
289 public delegate Efl.Gfx.IEntity efl_content_unset_api_delegate(System.IntPtr obj);
291 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");
293 private static Efl.Gfx.IEntity content_unset(System.IntPtr obj, System.IntPtr pd)
295 Eina.Log.Debug("function efl_content_unset was called");
296 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
299 Efl.Gfx.IEntity _ret_var = default(Efl.Gfx.IEntity);
302 _ret_var = ((LayoutPartExternal)ws.Target).UnsetContent();
306 Eina.Log.Warning($"Callback error: {e.ToString()}");
307 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
315 return efl_content_unset_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
319 private static efl_content_unset_delegate efl_content_unset_static_delegate;
321 #pragma warning restore CA1707, CS1591, SA1300, SA1600