1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
7 namespace Efl { namespace Ui {
8 /// <summary></summary>
9 /// <param name="str">the formated string to be appended by user.</param>
10 /// <param name="value">The <see cref="Eina.Value"/> passed by <c>obj</c>.</param>
11 /// <returns></returns>
12 public delegate void FormatFuncCb( Eina.Strbuf str, Eina.Value value);
13 public delegate void FormatFuncCbInternal(IntPtr data, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))] Eina.Strbuf str, Eina.ValueNative value);
14 internal class FormatFuncCbWrapper
17 private FormatFuncCbInternal _cb;
18 private IntPtr _cb_data;
19 private EinaFreeCb _cb_free_cb;
21 internal FormatFuncCbWrapper (FormatFuncCbInternal _cb, IntPtr _cb_data, EinaFreeCb _cb_free_cb)
24 this._cb_data = _cb_data;
25 this._cb_free_cb = _cb_free_cb;
28 ~FormatFuncCbWrapper()
30 if (this._cb_free_cb != null)
31 this._cb_free_cb(this._cb_data);
34 internal void ManagedCb( Eina.Strbuf str, Eina.Value value)
36 _cb(_cb_data, str, value);
37 Eina.Error.RaiseIfUnhandledException();
40 internal static void Cb(IntPtr cb_data, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))] Eina.Strbuf str, Eina.ValueNative value)
42 GCHandle handle = GCHandle.FromIntPtr(cb_data);
43 FormatFuncCb cb = (FormatFuncCb)handle.Target;
47 } catch (Exception e) {
48 Eina.Log.Warning($"Callback error: {e.ToString()}");
49 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
54 namespace Efl { namespace Ui {
55 /// <summary>interface class for format_func</summary>
56 [IFormatNativeInherit]
57 public interface IFormat :
58 Efl.Eo.IWrapper, IDisposable
60 /// <summary>Set the format function pointer to format the string.</summary>
61 /// <param name="func">The format function callback</param>
62 /// <returns></returns>
63 void SetFormatCb( Efl.Ui.FormatFuncCb func);
64 /// <summary>Control the format string for a given units label
65 /// 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.
67 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
68 /// <returns>The format string for <c>obj</c>'s units label.</returns>
69 System.String GetFormatString();
70 /// <summary>Control the format string for a given units label
71 /// 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.
73 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
74 /// <param name="units">The format string for <c>obj</c>'s units label.</param>
75 /// <returns></returns>
76 void SetFormatString( System.String units);
77 /// <summary>Set the format function pointer to format the string.</summary>
78 /// <value>The format function callback</value>
79 Efl.Ui.FormatFuncCb FormatCb {
82 /// <summary>Control the format string for a given units label
83 /// 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.
85 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
86 /// <value>The format string for <c>obj</c>'s units label.</value>
87 System.String FormatString {
92 /// <summary>interface class for format_func</summary>
93 sealed public class IFormatConcrete :
98 ///<summary>Pointer to the native class description.</summary>
99 public System.IntPtr NativeClass {
101 if (((object)this).GetType() == typeof (IFormatConcrete))
102 return Efl.Ui.IFormatNativeInherit.GetEflClassStatic();
104 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
107 private System.IntPtr handle;
108 ///<summary>Pointer to the native instance.</summary>
109 public System.IntPtr NativeHandle {
110 get { return handle; }
112 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
113 efl_ui_format_mixin_get();
114 ///<summary>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
115 private IFormatConcrete(System.IntPtr raw)
118 RegisterEventProxies();
120 ///<summary>Destructor.</summary>
125 ///<summary>Releases the underlying native instance.</summary>
126 void Dispose(bool disposing)
128 if (handle != System.IntPtr.Zero) {
129 Efl.Eo.Globals.efl_unref(handle);
130 handle = System.IntPtr.Zero;
133 ///<summary>Releases the underlying native instance.</summary>
134 public void Dispose()
137 GC.SuppressFinalize(this);
139 ///<summary>Verifies if the given object is equal to this one.</summary>
140 public override bool Equals(object obj)
142 var other = obj as Efl.Object;
145 return this.NativeHandle == other.NativeHandle;
147 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
148 public override int GetHashCode()
150 return this.NativeHandle.ToInt32();
152 ///<summary>Turns the native pointer into a string representation.</summary>
153 public override String ToString()
155 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
157 ///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>
158 void RegisterEventProxies()
161 /// <summary>Set the format function pointer to format the string.</summary>
162 /// <param name="func">The format function callback</param>
163 /// <returns></returns>
164 public void SetFormatCb( Efl.Ui.FormatFuncCb func) {
165 GCHandle func_handle = GCHandle.Alloc(func);
166 Efl.Ui.IFormatNativeInherit.efl_ui_format_cb_set_ptr.Value.Delegate(this.NativeHandle,GCHandle.ToIntPtr(func_handle), Efl.Ui.FormatFuncCbWrapper.Cb, Efl.Eo.Globals.free_gchandle);
167 Eina.Error.RaiseIfUnhandledException();
169 /// <summary>Control the format string for a given units label
170 /// 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.
172 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
173 /// <returns>The format string for <c>obj</c>'s units label.</returns>
174 public System.String GetFormatString() {
175 var _ret_var = Efl.Ui.IFormatNativeInherit.efl_ui_format_string_get_ptr.Value.Delegate(this.NativeHandle);
176 Eina.Error.RaiseIfUnhandledException();
179 /// <summary>Control the format string for a given units label
180 /// 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.
182 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
183 /// <param name="units">The format string for <c>obj</c>'s units label.</param>
184 /// <returns></returns>
185 public void SetFormatString( System.String units) {
186 Efl.Ui.IFormatNativeInherit.efl_ui_format_string_set_ptr.Value.Delegate(this.NativeHandle, units);
187 Eina.Error.RaiseIfUnhandledException();
189 /// <summary>Set the format function pointer to format the string.</summary>
190 /// <value>The format function callback</value>
191 public Efl.Ui.FormatFuncCb FormatCb {
192 set { SetFormatCb( value); }
194 /// <summary>Control the format string for a given units label
195 /// 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.
197 /// Note: The default format string is an integer percentage, as in $"%.0f %%".</summary>
198 /// <value>The format string for <c>obj</c>'s units label.</value>
199 public System.String FormatString {
200 get { return GetFormatString(); }
201 set { SetFormatString( value); }
203 private static IntPtr GetEflClassStatic()
205 return Efl.Ui.IFormatConcrete.efl_ui_format_mixin_get();
208 public class IFormatNativeInherit : Efl.Eo.NativeClass{
209 public static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Efl);
210 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
212 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
213 var methods = Efl.Eo.Globals.GetUserMethods(type);
214 if (efl_ui_format_cb_set_static_delegate == null)
215 efl_ui_format_cb_set_static_delegate = new efl_ui_format_cb_set_delegate(format_cb_set);
216 if (methods.FirstOrDefault(m => m.Name == "SetFormatCb") != null)
217 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)});
218 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);
220 if (methods.FirstOrDefault(m => m.Name == "GetFormatString") != null)
221 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)});
222 if (efl_ui_format_string_set_static_delegate == null)
223 efl_ui_format_string_set_static_delegate = new efl_ui_format_string_set_delegate(format_string_set);
224 if (methods.FirstOrDefault(m => m.Name == "SetFormatString") != null)
225 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)});
228 public override IntPtr GetEflClass()
230 return Efl.Ui.IFormatConcrete.efl_ui_format_mixin_get();
232 public static IntPtr GetEflClassStatic()
234 return Efl.Ui.IFormatConcrete.efl_ui_format_mixin_get();
238 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);
241 public delegate void efl_ui_format_cb_set_api_delegate(System.IntPtr obj, IntPtr func_data, Efl.Ui.FormatFuncCbInternal func, EinaFreeCb func_free_cb);
242 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");
243 private static void format_cb_set(System.IntPtr obj, System.IntPtr pd, IntPtr func_data, Efl.Ui.FormatFuncCbInternal func, EinaFreeCb func_free_cb)
245 Eina.Log.Debug("function efl_ui_format_cb_set was called");
246 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
247 if(wrapper != null) {
248 Efl.Ui.FormatFuncCbWrapper func_wrapper = new Efl.Ui.FormatFuncCbWrapper(func, func_data, func_free_cb);
251 ((IFormatConcrete)wrapper).SetFormatCb( func_wrapper.ManagedCb);
252 } catch (Exception e) {
253 Eina.Log.Warning($"Callback error: {e.ToString()}");
254 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
257 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);
260 private static efl_ui_format_cb_set_delegate efl_ui_format_cb_set_static_delegate;
263 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] private delegate System.String efl_ui_format_string_get_delegate(System.IntPtr obj, System.IntPtr pd);
266 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] public delegate System.String efl_ui_format_string_get_api_delegate(System.IntPtr obj);
267 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");
268 private static System.String format_string_get(System.IntPtr obj, System.IntPtr pd)
270 Eina.Log.Debug("function efl_ui_format_string_get was called");
271 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
272 if(wrapper != null) {
273 System.String _ret_var = default(System.String);
275 _ret_var = ((IFormatConcrete)wrapper).GetFormatString();
276 } catch (Exception e) {
277 Eina.Log.Warning($"Callback error: {e.ToString()}");
278 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
282 return efl_ui_format_string_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
285 private static efl_ui_format_string_get_delegate efl_ui_format_string_get_static_delegate;
288 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);
291 public delegate void efl_ui_format_string_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String units);
292 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");
293 private static void format_string_set(System.IntPtr obj, System.IntPtr pd, System.String units)
295 Eina.Log.Debug("function efl_ui_format_string_set was called");
296 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
297 if(wrapper != null) {
300 ((IFormatConcrete)wrapper).SetFormatString( units);
301 } catch (Exception e) {
302 Eina.Log.Warning($"Callback error: {e.ToString()}");
303 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
306 efl_ui_format_string_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), units);
309 private static efl_ui_format_string_set_delegate efl_ui_format_string_set_static_delegate;