3d41c11156eb2062fbe076d541ba7a82342e41da
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / efl / efl_ui_property_bind.eo.cs
1 #pragma warning disable CS1591
2 using System;
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Threading;
7 using System.ComponentModel;
8 namespace Efl {
9
10 namespace Ui {
11
12 /// <summary>Efl UI Property_Bind interface. view object can have <see cref="Efl.IModel"/> to manage the data, the interface can help loading and tracking child data from the model property. see <see cref="Efl.IModel"/> see <see cref="Efl.Ui.IFactory"/></summary>
13 [Efl.Ui.IPropertyBindConcrete.NativeMethods]
14 [Efl.Eo.BindingEntity]
15 public interface IPropertyBind : 
16     Efl.Eo.IWrapper, IDisposable
17 {
18     /// <summary>bind property data with the given key string. when the data is ready or changed, bind the data to the key action and process promised work.</summary>
19 /// <param name="key">key string for bind model property data</param>
20 /// <param name="property">Model property name</param>
21 /// <returns>0 when it succeed, an error code otherwise.</returns>
22 Eina.Error PropertyBind(System.String key, System.String property);
23         /// <summary>Event dispatched when a property on the object has changed due to an user interaction on the object that a model could be interested in.</summary>
24     event EventHandler<Efl.Ui.IPropertyBindPropertiesChangedEvt_Args> PropertiesChangedEvt;
25     /// <summary>Event dispatched when a property on the object is bound to a model. This is useful to not overgenerate event.</summary>
26     event EventHandler<Efl.Ui.IPropertyBindPropertyBoundEvt_Args> PropertyBoundEvt;
27 }
28 ///<summary>Event argument wrapper for event <see cref="Efl.Ui.IPropertyBind.PropertiesChangedEvt"/>.</summary>
29 [Efl.Eo.BindingEntity]
30 public class IPropertyBindPropertiesChangedEvt_Args : EventArgs {
31     ///<summary>Actual event payload.</summary>
32     public Efl.Ui.PropertyEvent arg { get; set; }
33 }
34 ///<summary>Event argument wrapper for event <see cref="Efl.Ui.IPropertyBind.PropertyBoundEvt"/>.</summary>
35 [Efl.Eo.BindingEntity]
36 public class IPropertyBindPropertyBoundEvt_Args : EventArgs {
37     ///<summary>Actual event payload.</summary>
38     public System.String arg { get; set; }
39 }
40 /// <summary>Efl UI Property_Bind interface. view object can have <see cref="Efl.IModel"/> to manage the data, the interface can help loading and tracking child data from the model property. see <see cref="Efl.IModel"/> see <see cref="Efl.Ui.IFactory"/></summary>
41 sealed public class IPropertyBindConcrete :
42     Efl.Eo.EoWrapper
43     , IPropertyBind
44     
45 {
46     ///<summary>Pointer to the native class description.</summary>
47     public override System.IntPtr NativeClass
48     {
49         get
50         {
51             if (((object)this).GetType() == typeof(IPropertyBindConcrete))
52             {
53                 return GetEflClassStatic();
54             }
55             else
56             {
57                 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
58             }
59         }
60     }
61
62     /// <summary>Constructor to be used when objects are expected to be constructed from native code.</summary>
63     /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
64     private IPropertyBindConcrete(ConstructingHandle ch) : base(ch)
65     {
66     }
67
68     [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr
69         efl_ui_property_bind_interface_get();
70     /// <summary>Initializes a new instance of the <see cref="IPropertyBind"/> class.
71     /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
72     /// <param name="wh">The native pointer to be wrapped.</param>
73     private IPropertyBindConcrete(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
74     {
75     }
76
77     /// <summary>Event dispatched when a property on the object has changed due to an user interaction on the object that a model could be interested in.</summary>
78     public event EventHandler<Efl.Ui.IPropertyBindPropertiesChangedEvt_Args> PropertiesChangedEvt
79     {
80         add
81         {
82             lock (eflBindingEventLock)
83             {
84                 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
85                 {
86                     var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
87                     if (obj != null)
88                     {
89                         Efl.Ui.IPropertyBindPropertiesChangedEvt_Args args = new Efl.Ui.IPropertyBindPropertiesChangedEvt_Args();
90                         args.arg =  evt.Info;
91                         try
92                         {
93                             value?.Invoke(obj, args);
94                         }
95                         catch (Exception e)
96                         {
97                             Eina.Log.Error(e.ToString());
98                             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
99                         }
100                     }
101                 };
102
103                 string key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTIES_CHANGED";
104                 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
105             }
106         }
107
108         remove
109         {
110             lock (eflBindingEventLock)
111             {
112                 string key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTIES_CHANGED";
113                 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
114             }
115         }
116     }
117     ///<summary>Method to raise event PropertiesChangedEvt.</summary>
118     public void OnPropertiesChangedEvt(Efl.Ui.IPropertyBindPropertiesChangedEvt_Args e)
119     {
120         var key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTIES_CHANGED";
121         IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
122         if (desc == IntPtr.Zero)
123         {
124             Eina.Log.Error($"Failed to get native event {key}");
125             return;
126         }
127
128         IntPtr info = Marshal.AllocHGlobal(Marshal.SizeOf(e.arg));
129         try
130         {
131             Marshal.StructureToPtr(e.arg, info, false);
132             Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
133         }
134         finally
135         {
136             Marshal.FreeHGlobal(info);
137         }
138     }
139     /// <summary>Event dispatched when a property on the object is bound to a model. This is useful to not overgenerate event.</summary>
140     public event EventHandler<Efl.Ui.IPropertyBindPropertyBoundEvt_Args> PropertyBoundEvt
141     {
142         add
143         {
144             lock (eflBindingEventLock)
145             {
146                 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
147                 {
148                     var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
149                     if (obj != null)
150                     {
151                         Efl.Ui.IPropertyBindPropertyBoundEvt_Args args = new Efl.Ui.IPropertyBindPropertyBoundEvt_Args();
152                         args.arg = Eina.StringConversion.NativeUtf8ToManagedString(evt.Info);
153                         try
154                         {
155                             value?.Invoke(obj, args);
156                         }
157                         catch (Exception e)
158                         {
159                             Eina.Log.Error(e.ToString());
160                             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
161                         }
162                     }
163                 };
164
165                 string key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTY_BOUND";
166                 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
167             }
168         }
169
170         remove
171         {
172             lock (eflBindingEventLock)
173             {
174                 string key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTY_BOUND";
175                 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
176             }
177         }
178     }
179     ///<summary>Method to raise event PropertyBoundEvt.</summary>
180     public void OnPropertyBoundEvt(Efl.Ui.IPropertyBindPropertyBoundEvt_Args e)
181     {
182         var key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTY_BOUND";
183         IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
184         if (desc == IntPtr.Zero)
185         {
186             Eina.Log.Error($"Failed to get native event {key}");
187             return;
188         }
189
190         IntPtr info = Eina.StringConversion.ManagedStringToNativeUtf8Alloc(e.arg);
191         try
192         {
193             Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
194         }
195         finally
196         {
197             Eina.MemoryNative.Free(info);
198         }
199     }
200     /// <summary>bind property data with the given key string. when the data is ready or changed, bind the data to the key action and process promised work.</summary>
201     /// <param name="key">key string for bind model property data</param>
202     /// <param name="property">Model property name</param>
203     /// <returns>0 when it succeed, an error code otherwise.</returns>
204     public Eina.Error PropertyBind(System.String key, System.String property) {
205                                                          var _ret_var = Efl.Ui.IPropertyBindConcrete.NativeMethods.efl_ui_property_bind_ptr.Value.Delegate(this.NativeHandle,key, property);
206         Eina.Error.RaiseIfUnhandledException();
207                                         return _ret_var;
208  }
209     private static IntPtr GetEflClassStatic()
210     {
211         return Efl.Ui.IPropertyBindConcrete.efl_ui_property_bind_interface_get();
212     }
213     /// <summary>Wrapper for native methods and virtual method delegates.
214     /// For internal use by generated code only.</summary>
215     public new class NativeMethods : Efl.Eo.EoWrapper.NativeMethods
216     {
217         private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule(    efl.Libs.Efl);
218         /// <summary>Gets the list of Eo operations to override.</summary>
219         /// <returns>The list of Eo operations to be overload.</returns>
220         public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
221         {
222             var descs = new System.Collections.Generic.List<Efl_Op_Description>();
223             var methods = Efl.Eo.Globals.GetUserMethods(type);
224
225             if (efl_ui_property_bind_static_delegate == null)
226             {
227                 efl_ui_property_bind_static_delegate = new efl_ui_property_bind_delegate(property_bind);
228             }
229
230             if (methods.FirstOrDefault(m => m.Name == "PropertyBind") != null)
231             {
232                 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_property_bind"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_property_bind_static_delegate) });
233             }
234
235             return descs;
236         }
237         /// <summary>Returns the Eo class for the native methods of this class.</summary>
238         /// <returns>The native class pointer.</returns>
239         public override IntPtr GetEflClass()
240         {
241             return Efl.Ui.IPropertyBindConcrete.efl_ui_property_bind_interface_get();
242         }
243
244         #pragma warning disable CA1707, CS1591, SA1300, SA1600
245
246         
247         private delegate Eina.Error efl_ui_property_bind_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String key, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String property);
248
249         
250         public delegate Eina.Error efl_ui_property_bind_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String key, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String property);
251
252         public static Efl.Eo.FunctionWrapper<efl_ui_property_bind_api_delegate> efl_ui_property_bind_ptr = new Efl.Eo.FunctionWrapper<efl_ui_property_bind_api_delegate>(Module, "efl_ui_property_bind");
253
254         private static Eina.Error property_bind(System.IntPtr obj, System.IntPtr pd, System.String key, System.String property)
255         {
256             Eina.Log.Debug("function efl_ui_property_bind was called");
257             var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
258             if (ws != null)
259             {
260                                                             Eina.Error _ret_var = default(Eina.Error);
261                 try
262                 {
263                     _ret_var = ((IPropertyBind)ws.Target).PropertyBind(key, property);
264                 }
265                 catch (Exception e)
266                 {
267                     Eina.Log.Warning($"Callback error: {e.ToString()}");
268                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
269                 }
270
271                                         return _ret_var;
272
273             }
274             else
275             {
276                 return efl_ui_property_bind_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), key, property);
277             }
278         }
279
280         private static efl_ui_property_bind_delegate efl_ui_property_bind_static_delegate;
281
282         #pragma warning restore CA1707, CS1591, SA1300, SA1600
283
284 }
285 }
286 }
287
288 }
289
290 namespace Efl {
291
292 namespace Ui {
293
294 /// <summary>EFL Ui property event data structure triggered when an object property change due to the interaction on the object.</summary>
295 [StructLayout(LayoutKind.Sequential)]
296 [Efl.Eo.BindingEntity]
297 public struct PropertyEvent
298 {
299     /// <summary>List of changed properties</summary>
300     public Eina.Array<Eina.Stringshare> Changed_properties;
301     ///<summary>Constructor for PropertyEvent.</summary>
302     public PropertyEvent(
303         Eina.Array<Eina.Stringshare> Changed_properties = default(Eina.Array<Eina.Stringshare>)    )
304     {
305         this.Changed_properties = Changed_properties;
306     }
307
308     ///<summary>Implicit conversion to the managed representation from a native pointer.</summary>
309     ///<param name="ptr">Native pointer to be converted.</param>
310     public static implicit operator PropertyEvent(IntPtr ptr)
311     {
312         var tmp = (PropertyEvent.NativeStruct)Marshal.PtrToStructure(ptr, typeof(PropertyEvent.NativeStruct));
313         return tmp;
314     }
315
316     #pragma warning disable CS1591
317
318     ///<summary>Internal wrapper for struct PropertyEvent.</summary>
319     [StructLayout(LayoutKind.Sequential)]
320     public struct NativeStruct
321     {
322         
323         public System.IntPtr Changed_properties;
324         ///<summary>Implicit conversion to the internal/marshalling representation.</summary>
325         public static implicit operator PropertyEvent.NativeStruct(PropertyEvent _external_struct)
326         {
327             var _internal_struct = new PropertyEvent.NativeStruct();
328             _internal_struct.Changed_properties = _external_struct.Changed_properties.Handle;
329             return _internal_struct;
330         }
331
332         ///<summary>Implicit conversion to the managed representation.</summary>
333         public static implicit operator PropertyEvent(PropertyEvent.NativeStruct _internal_struct)
334         {
335             var _external_struct = new PropertyEvent();
336             _external_struct.Changed_properties = new Eina.Array<Eina.Stringshare>(_internal_struct.Changed_properties, false, false);
337             return _external_struct;
338         }
339
340     }
341
342     #pragma warning restore CS1591
343
344 }
345
346 }
347
348 }
349