1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
12 /// <param name="str">the formated string to be appended by user.</param>
13 /// <param name="value">The <see cref="Eina.Value"/> passed by <c>obj</c>.</param>
14 public delegate void FormatFuncCb(Eina.Strbuf str, Eina.Value value);
15 public delegate void FormatFuncCbInternal(IntPtr data, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))] Eina.Strbuf str, Eina.ValueNative value);
16 internal class FormatFuncCbWrapper : IDisposable
19 private FormatFuncCbInternal _cb;
20 private IntPtr _cb_data;
21 private EinaFreeCb _cb_free_cb;
23 internal FormatFuncCbWrapper (FormatFuncCbInternal _cb, IntPtr _cb_data, EinaFreeCb _cb_free_cb)
26 this._cb_data = _cb_data;
27 this._cb_free_cb = _cb_free_cb;
30 ~FormatFuncCbWrapper()
35 protected virtual void Dispose(bool disposing)
37 if (this._cb_free_cb != null)
41 this._cb_free_cb(this._cb_data);
45 Efl.Eo.Globals.ThreadSafeFreeCbExec(this._cb_free_cb, this._cb_data);
47 this._cb_free_cb = null;
48 this._cb_data = IntPtr.Zero;
56 GC.SuppressFinalize(this);
59 internal void ManagedCb(Eina.Strbuf str,Eina.Value value)
61 _cb(_cb_data, str, value);
62 Eina.Error.RaiseIfUnhandledException();
65 internal static void Cb(IntPtr cb_data, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))] Eina.Strbuf str, Eina.ValueNative value)
67 GCHandle handle = GCHandle.FromIntPtr(cb_data);
68 FormatFuncCb cb = (FormatFuncCb)handle.Target;
72 } catch (Exception e) {
73 Eina.Log.Warning($"Callback error: {e.ToString()}");
74 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
86 /// <summary>interface class for format_func</summary>
87 [Efl.Ui.IFormatConcrete.NativeMethods]
88 public interface IFormat :
89 Efl.Eo.IWrapper, IDisposable
91 /// <summary>Set the format function pointer to format the string.</summary>
92 /// <param name="func">The format function callback</param>
93 void SetFormatCb(Efl.Ui.FormatFuncCb func);
94 /// <summary>Control the format string for a given units label
95 /// If <c>NULL</c> is passed to <c>format</c>, it will hide <c>obj</c>'s units area completely. If not, it'll set the <b>format string</b> for the units label text. The units label is provided as a floating point value, so the units text can display at most one floating point value. Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
97 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
98 /// <returns>The format string for <c>obj</c>'s units label.</returns>
99 System.String GetFormatString();
100 /// <summary>Control the format string for a given units label
101 /// If <c>NULL</c> is passed to <c>format</c>, it will hide <c>obj</c>'s units area completely. If not, it'll set the <b>format string</b> for the units label text. The units label is provided as a floating point value, so the units text can display at most one floating point value. Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
103 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
104 /// <param name="units">The format string for <c>obj</c>'s units label.</param>
105 void SetFormatString(System.String units);
106 /// <summary>Set the format function pointer to format the string.</summary>
107 /// <value>The format function callback</value>
108 Efl.Ui.FormatFuncCb FormatCb {
111 /// <summary>Control the format string for a given units label
112 /// If <c>NULL</c> is passed to <c>format</c>, it will hide <c>obj</c>'s units area completely. If not, it'll set the <b>format string</b> for the units label text. The units label is provided as a floating point value, so the units text can display at most one floating point value. Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
114 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
115 /// <value>The format string for <c>obj</c>'s units label.</value>
116 System.String FormatString {
121 /// <summary>interface class for format_func</summary>
122 sealed public class IFormatConcrete :
127 ///<summary>Pointer to the native class description.</summary>
128 public System.IntPtr NativeClass
132 if (((object)this).GetType() == typeof(IFormatConcrete))
134 return GetEflClassStatic();
138 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
143 private System.IntPtr handle;
144 ///<summary>Pointer to the native instance.</summary>
145 public System.IntPtr NativeHandle
147 get { return handle; }
150 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
151 efl_ui_format_mixin_get();
152 /// <summary>Initializes a new instance of the <see cref="IFormat"/> class.
153 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
154 private IFormatConcrete(System.IntPtr raw)
158 ///<summary>Destructor.</summary>
164 ///<summary>Releases the underlying native instance.</summary>
165 private void Dispose(bool disposing)
167 if (handle != System.IntPtr.Zero)
170 handle = IntPtr.Zero;
172 IntPtr gcHandlePtr = IntPtr.Zero;
175 Efl.Eo.Globals.efl_mono_native_dispose(h, gcHandlePtr);
179 Monitor.Enter(Efl.All.InitLock);
180 if (Efl.All.MainLoopInitialized)
182 Efl.Eo.Globals.efl_mono_thread_safe_native_dispose(h, gcHandlePtr);
185 Monitor.Exit(Efl.All.InitLock);
191 ///<summary>Releases the underlying native instance.</summary>
192 public void Dispose()
195 GC.SuppressFinalize(this);
198 /// <summary>Verifies if the given object is equal to this one.</summary>
199 /// <param name="instance">The object to compare to.</param>
200 /// <returns>True if both objects point to the same native object.</returns>
201 public override bool Equals(object instance)
203 var other = instance as Efl.Object;
208 return this.NativeHandle == other.NativeHandle;
211 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
212 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
213 public override int GetHashCode()
215 return this.NativeHandle.ToInt32();
218 /// <summary>Turns the native pointer into a string representation.</summary>
219 /// <returns>A string with the type and the native pointer for this object.</returns>
220 public override String ToString()
222 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
225 /// <summary>Set the format function pointer to format the string.</summary>
226 /// <param name="func">The format function callback</param>
227 public void SetFormatCb(Efl.Ui.FormatFuncCb func) {
228 GCHandle func_handle = GCHandle.Alloc(func);
229 Efl.Ui.IFormatConcrete.NativeMethods.efl_ui_format_cb_set_ptr.Value.Delegate(this.NativeHandle,GCHandle.ToIntPtr(func_handle), Efl.Ui.FormatFuncCbWrapper.Cb, Efl.Eo.Globals.free_gchandle);
230 Eina.Error.RaiseIfUnhandledException();
232 /// <summary>Control the format string for a given units label
233 /// If <c>NULL</c> is passed to <c>format</c>, it will hide <c>obj</c>'s units area completely. If not, it'll set the <b>format string</b> for the units label text. The units label is provided as a floating point value, so the units text can display at most one floating point value. Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
235 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
236 /// <returns>The format string for <c>obj</c>'s units label.</returns>
237 public System.String GetFormatString() {
238 var _ret_var = Efl.Ui.IFormatConcrete.NativeMethods.efl_ui_format_string_get_ptr.Value.Delegate(this.NativeHandle);
239 Eina.Error.RaiseIfUnhandledException();
242 /// <summary>Control the format string for a given units label
243 /// If <c>NULL</c> is passed to <c>format</c>, it will hide <c>obj</c>'s units area completely. If not, it'll set the <b>format string</b> for the units label text. The units label is provided as a floating point value, so the units text can display at most one floating point value. Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
245 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
246 /// <param name="units">The format string for <c>obj</c>'s units label.</param>
247 public void SetFormatString(System.String units) {
248 Efl.Ui.IFormatConcrete.NativeMethods.efl_ui_format_string_set_ptr.Value.Delegate(this.NativeHandle,units);
249 Eina.Error.RaiseIfUnhandledException();
251 /// <summary>Set the format function pointer to format the string.</summary>
252 /// <value>The format function callback</value>
253 public Efl.Ui.FormatFuncCb FormatCb {
254 set { SetFormatCb(value); }
256 /// <summary>Control the format string for a given units label
257 /// If <c>NULL</c> is passed to <c>format</c>, it will hide <c>obj</c>'s units area completely. If not, it'll set the <b>format string</b> for the units label text. The units label is provided as a floating point value, so the units text can display at most one floating point value. Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
259 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
260 /// <value>The format string for <c>obj</c>'s units label.</value>
261 public System.String FormatString {
262 get { return GetFormatString(); }
263 set { SetFormatString(value); }
265 private static IntPtr GetEflClassStatic()
267 return Efl.Ui.IFormatConcrete.efl_ui_format_mixin_get();
269 /// <summary>Wrapper for native methods and virtual method delegates.
270 /// For internal use by generated code only.</summary>
271 public class NativeMethods : Efl.Eo.NativeClass
273 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
274 /// <summary>Gets the list of Eo operations to override.</summary>
275 /// <returns>The list of Eo operations to be overload.</returns>
276 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
278 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
279 var methods = Efl.Eo.Globals.GetUserMethods(type);
281 if (efl_ui_format_cb_set_static_delegate == null)
283 efl_ui_format_cb_set_static_delegate = new efl_ui_format_cb_set_delegate(format_cb_set);
286 if (methods.FirstOrDefault(m => m.Name == "SetFormatCb") != null)
288 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_format_cb_set"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_format_cb_set_static_delegate) });
291 if (efl_ui_format_string_get_static_delegate == null)
293 efl_ui_format_string_get_static_delegate = new efl_ui_format_string_get_delegate(format_string_get);
296 if (methods.FirstOrDefault(m => m.Name == "GetFormatString") != null)
298 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_format_string_get"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_format_string_get_static_delegate) });
301 if (efl_ui_format_string_set_static_delegate == null)
303 efl_ui_format_string_set_static_delegate = new efl_ui_format_string_set_delegate(format_string_set);
306 if (methods.FirstOrDefault(m => m.Name == "SetFormatString") != null)
308 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_format_string_set"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_format_string_set_static_delegate) });
313 /// <summary>Returns the Eo class for the native methods of this class.</summary>
314 /// <returns>The native class pointer.</returns>
315 public override IntPtr GetEflClass()
317 return Efl.Ui.IFormatConcrete.efl_ui_format_mixin_get();
320 #pragma warning disable CA1707, SA1300, SA1600
323 private delegate void efl_ui_format_cb_set_delegate(System.IntPtr obj, System.IntPtr pd, IntPtr func_data, Efl.Ui.FormatFuncCbInternal func, EinaFreeCb func_free_cb);
326 public delegate void efl_ui_format_cb_set_api_delegate(System.IntPtr obj, IntPtr func_data, Efl.Ui.FormatFuncCbInternal func, EinaFreeCb func_free_cb);
328 public static Efl.Eo.FunctionWrapper<efl_ui_format_cb_set_api_delegate> efl_ui_format_cb_set_ptr = new Efl.Eo.FunctionWrapper<efl_ui_format_cb_set_api_delegate>(Module, "efl_ui_format_cb_set");
330 private static void format_cb_set(System.IntPtr obj, System.IntPtr pd, IntPtr func_data, Efl.Ui.FormatFuncCbInternal func, EinaFreeCb func_free_cb)
332 Eina.Log.Debug("function efl_ui_format_cb_set was called");
333 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
336 Efl.Ui.FormatFuncCbWrapper func_wrapper = new Efl.Ui.FormatFuncCbWrapper(func, func_data, func_free_cb);
340 ((IFormatConcrete)wrapper).SetFormatCb(func_wrapper.ManagedCb);
344 Eina.Log.Warning($"Callback error: {e.ToString()}");
345 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
352 efl_ui_format_cb_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), func_data, func, func_free_cb);
356 private static efl_ui_format_cb_set_delegate efl_ui_format_cb_set_static_delegate;
358 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]
359 private delegate System.String efl_ui_format_string_get_delegate(System.IntPtr obj, System.IntPtr pd);
361 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]
362 public delegate System.String efl_ui_format_string_get_api_delegate(System.IntPtr obj);
364 public static Efl.Eo.FunctionWrapper<efl_ui_format_string_get_api_delegate> efl_ui_format_string_get_ptr = new Efl.Eo.FunctionWrapper<efl_ui_format_string_get_api_delegate>(Module, "efl_ui_format_string_get");
366 private static System.String format_string_get(System.IntPtr obj, System.IntPtr pd)
368 Eina.Log.Debug("function efl_ui_format_string_get was called");
369 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
372 System.String _ret_var = default(System.String);
375 _ret_var = ((IFormatConcrete)wrapper).GetFormatString();
379 Eina.Log.Warning($"Callback error: {e.ToString()}");
380 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
388 return efl_ui_format_string_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
392 private static efl_ui_format_string_get_delegate efl_ui_format_string_get_static_delegate;
395 private delegate void efl_ui_format_string_set_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String units);
398 public delegate void efl_ui_format_string_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String units);
400 public static Efl.Eo.FunctionWrapper<efl_ui_format_string_set_api_delegate> efl_ui_format_string_set_ptr = new Efl.Eo.FunctionWrapper<efl_ui_format_string_set_api_delegate>(Module, "efl_ui_format_string_set");
402 private static void format_string_set(System.IntPtr obj, System.IntPtr pd, System.String units)
404 Eina.Log.Debug("function efl_ui_format_string_set was called");
405 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
411 ((IFormatConcrete)wrapper).SetFormatString(units);
415 Eina.Log.Warning($"Callback error: {e.ToString()}");
416 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
423 efl_ui_format_string_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), units);
427 private static efl_ui_format_string_set_delegate efl_ui_format_string_set_static_delegate;
429 #pragma warning restore CA1707, SA1300, SA1600