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 override System.IntPtr NativeClass
132 if (((object)this).GetType() == typeof(IFormatConcrete))
134 return GetEflClassStatic();
138 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
143 [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr
144 efl_ui_format_mixin_get();
145 /// <summary>Initializes a new instance of the <see cref="IFormat"/> class.
146 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
147 private IFormatConcrete(System.IntPtr raw) : base(raw)
151 /// <summary>Set the format function pointer to format the string.</summary>
152 /// <param name="func">The format function callback</param>
153 public void SetFormatCb(Efl.Ui.FormatFuncCb func) {
154 GCHandle func_handle = GCHandle.Alloc(func);
155 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);
156 Eina.Error.RaiseIfUnhandledException();
158 /// <summary>Control the format string for a given units label
159 /// 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.
161 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
162 /// <returns>The format string for <c>obj</c>'s units label.</returns>
163 public System.String GetFormatString() {
164 var _ret_var = Efl.Ui.IFormatConcrete.NativeMethods.efl_ui_format_string_get_ptr.Value.Delegate(this.NativeHandle);
165 Eina.Error.RaiseIfUnhandledException();
168 /// <summary>Control the format string for a given units label
169 /// 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.
171 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
172 /// <param name="units">The format string for <c>obj</c>'s units label.</param>
173 public void SetFormatString(System.String units) {
174 Efl.Ui.IFormatConcrete.NativeMethods.efl_ui_format_string_set_ptr.Value.Delegate(this.NativeHandle,units);
175 Eina.Error.RaiseIfUnhandledException();
177 /// <summary>Set the format function pointer to format the string.</summary>
178 /// <value>The format function callback</value>
179 public Efl.Ui.FormatFuncCb FormatCb {
180 set { SetFormatCb(value); }
182 /// <summary>Control the format string for a given units label
183 /// 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.
185 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
186 /// <value>The format string for <c>obj</c>'s units label.</value>
187 public System.String FormatString {
188 get { return GetFormatString(); }
189 set { SetFormatString(value); }
191 private static IntPtr GetEflClassStatic()
193 return Efl.Ui.IFormatConcrete.efl_ui_format_mixin_get();
195 /// <summary>Wrapper for native methods and virtual method delegates.
196 /// For internal use by generated code only.</summary>
197 public class NativeMethods : Efl.Eo.NativeClass
199 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
200 /// <summary>Gets the list of Eo operations to override.</summary>
201 /// <returns>The list of Eo operations to be overload.</returns>
202 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
204 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
205 var methods = Efl.Eo.Globals.GetUserMethods(type);
207 if (efl_ui_format_cb_set_static_delegate == null)
209 efl_ui_format_cb_set_static_delegate = new efl_ui_format_cb_set_delegate(format_cb_set);
212 if (methods.FirstOrDefault(m => m.Name == "SetFormatCb") != null)
214 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) });
217 if (efl_ui_format_string_get_static_delegate == null)
219 efl_ui_format_string_get_static_delegate = new efl_ui_format_string_get_delegate(format_string_get);
222 if (methods.FirstOrDefault(m => m.Name == "GetFormatString") != null)
224 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) });
227 if (efl_ui_format_string_set_static_delegate == null)
229 efl_ui_format_string_set_static_delegate = new efl_ui_format_string_set_delegate(format_string_set);
232 if (methods.FirstOrDefault(m => m.Name == "SetFormatString") != null)
234 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) });
239 /// <summary>Returns the Eo class for the native methods of this class.</summary>
240 /// <returns>The native class pointer.</returns>
241 public override IntPtr GetEflClass()
243 return Efl.Ui.IFormatConcrete.efl_ui_format_mixin_get();
246 #pragma warning disable CA1707, CS1591, SA1300, SA1600
249 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);
252 public delegate void efl_ui_format_cb_set_api_delegate(System.IntPtr obj, IntPtr func_data, Efl.Ui.FormatFuncCbInternal func, EinaFreeCb func_free_cb);
254 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");
256 private static void format_cb_set(System.IntPtr obj, System.IntPtr pd, IntPtr func_data, Efl.Ui.FormatFuncCbInternal func, EinaFreeCb func_free_cb)
258 Eina.Log.Debug("function efl_ui_format_cb_set was called");
259 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
262 Efl.Ui.FormatFuncCbWrapper func_wrapper = new Efl.Ui.FormatFuncCbWrapper(func, func_data, func_free_cb);
266 ((IFormat)ws.Target).SetFormatCb(func_wrapper.ManagedCb);
270 Eina.Log.Warning($"Callback error: {e.ToString()}");
271 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
278 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);
282 private static efl_ui_format_cb_set_delegate efl_ui_format_cb_set_static_delegate;
284 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]
285 private delegate System.String efl_ui_format_string_get_delegate(System.IntPtr obj, System.IntPtr pd);
287 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]
288 public delegate System.String efl_ui_format_string_get_api_delegate(System.IntPtr obj);
290 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");
292 private static System.String format_string_get(System.IntPtr obj, System.IntPtr pd)
294 Eina.Log.Debug("function efl_ui_format_string_get was called");
295 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
298 System.String _ret_var = default(System.String);
301 _ret_var = ((IFormat)ws.Target).GetFormatString();
305 Eina.Log.Warning($"Callback error: {e.ToString()}");
306 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
314 return efl_ui_format_string_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
318 private static efl_ui_format_string_get_delegate efl_ui_format_string_get_static_delegate;
321 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);
324 public delegate void efl_ui_format_string_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String units);
326 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");
328 private static void format_string_set(System.IntPtr obj, System.IntPtr pd, System.String units)
330 Eina.Log.Debug("function efl_ui_format_string_set was called");
331 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
337 ((IFormat)ws.Target).SetFormatString(units);
341 Eina.Log.Warning($"Callback error: {e.ToString()}");
342 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
349 efl_ui_format_string_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), units);
353 private static efl_ui_format_string_set_delegate efl_ui_format_string_set_static_delegate;
355 #pragma warning restore CA1707, CS1591, SA1300, SA1600