9178713a8dd24b9c0fa65d5a516964d2e7b9c72b
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / efl_content.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.ComponentModel;
7 namespace Efl { 
8 /// <summary>Common interface for objects that have a (single) content.
9 /// This is used for the default content part of widgets, as well as for individual parts through <see cref="Efl.Part"/>.</summary>
10 [ContentNativeInherit]
11 public interface Content : 
12    Efl.Eo.IWrapper, IDisposable
13 {
14    /// <summary>Swallowed sub-object contained in this object.</summary>
15 /// <returns>The object to swallow.</returns>
16 Efl.Gfx.Entity GetContent();
17    /// <summary>Swallowed sub-object contained in this object.</summary>
18 /// <param name="content">The object to swallow.</param>
19 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
20 bool SetContent( Efl.Gfx.Entity content);
21    /// <summary>Unswallow the object in the current container and return it.</summary>
22 /// <returns>Unswallowed object</returns>
23 Efl.Gfx.Entity UnsetContent();
24             /// <summary>Sent after the content is set or unset using the current content object.</summary>
25    event EventHandler<Efl.ContentContentChangedEvt_Args> ContentChangedEvt;
26    /// <summary>Swallowed sub-object contained in this object.</summary>
27 /// <value>The object to swallow.</value>
28    Efl.Gfx.Entity Content {
29       get ;
30       set ;
31    }
32 }
33 ///<summary>Event argument wrapper for event <see cref="Efl.Content.ContentChangedEvt"/>.</summary>
34 public class ContentContentChangedEvt_Args : EventArgs {
35    ///<summary>Actual event payload.</summary>
36    public Efl.Gfx.Entity arg { get; set; }
37 }
38 /// <summary>Common interface for objects that have a (single) content.
39 /// This is used for the default content part of widgets, as well as for individual parts through <see cref="Efl.Part"/>.</summary>
40 sealed public class ContentConcrete : 
41
42 Content
43    
44 {
45    ///<summary>Pointer to the native class description.</summary>
46    public System.IntPtr NativeClass {
47       get {
48          if (((object)this).GetType() == typeof (ContentConcrete))
49             return Efl.ContentNativeInherit.GetEflClassStatic();
50          else
51             return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
52       }
53    }
54    private EventHandlerList eventHandlers = new EventHandlerList();
55    private  System.IntPtr handle;
56    ///<summary>Pointer to the native instance.</summary>
57    public System.IntPtr NativeHandle {
58       get { return handle; }
59    }
60    [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
61       efl_content_interface_get();
62    ///<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>
63    public ContentConcrete(System.IntPtr raw)
64    {
65       handle = raw;
66       register_event_proxies();
67    }
68    ///<summary>Destructor.</summary>
69    ~ContentConcrete()
70    {
71       Dispose(false);
72    }
73    ///<summary>Releases the underlying native instance.</summary>
74    void Dispose(bool disposing)
75    {
76       if (handle != System.IntPtr.Zero) {
77          Efl.Eo.Globals.efl_unref(handle);
78          handle = System.IntPtr.Zero;
79       }
80    }
81    ///<summary>Releases the underlying native instance.</summary>
82    public void Dispose()
83    {
84       Dispose(true);
85       GC.SuppressFinalize(this);
86    }
87    ///<summary>Casts obj into an instance of this type.</summary>
88    public static ContentConcrete static_cast(Efl.Object obj)
89    {
90       if (obj == null)
91          throw new System.ArgumentNullException("obj");
92       return new ContentConcrete(obj.NativeHandle);
93    }
94    ///<summary>Verifies if the given object is equal to this one.</summary>
95    public override bool Equals(object obj)
96    {
97       var other = obj as Efl.Object;
98       if (other == null)
99          return false;
100       return this.NativeHandle == other.NativeHandle;
101    }
102    ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
103    public override int GetHashCode()
104    {
105       return this.NativeHandle.ToInt32();
106    }
107    ///<summary>Turns the native pointer into a string representation.</summary>
108    public override String ToString()
109    {
110       return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
111    }
112    private readonly object eventLock = new object();
113    private Dictionary<string, int> event_cb_count = new Dictionary<string, int>();
114    private bool add_cpp_event_handler(string lib, string key, Efl.EventCb evt_delegate) {
115       int event_count = 0;
116       if (!event_cb_count.TryGetValue(key, out event_count))
117          event_cb_count[key] = event_count;
118       if (event_count == 0) {
119          IntPtr desc = Efl.EventDescription.GetNative(lib, key);
120          if (desc == IntPtr.Zero) {
121             Eina.Log.Error($"Failed to get native event {key}");
122             return false;
123          }
124           bool result = Efl.Eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);
125          if (!result) {
126             Eina.Log.Error($"Failed to add event proxy for event {key}");
127             return false;
128          }
129          Eina.Error.RaiseIfUnhandledException();
130       } 
131       event_cb_count[key]++;
132       return true;
133    }
134    private bool remove_cpp_event_handler(string key, Efl.EventCb evt_delegate) {
135       int event_count = 0;
136       if (!event_cb_count.TryGetValue(key, out event_count))
137          event_cb_count[key] = event_count;
138       if (event_count == 1) {
139          IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
140          if (desc == IntPtr.Zero) {
141             Eina.Log.Error($"Failed to get native event {key}");
142             return false;
143          }
144          bool result = Efl.Eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);
145          if (!result) {
146             Eina.Log.Error($"Failed to remove event proxy for event {key}");
147             return false;
148          }
149          Eina.Error.RaiseIfUnhandledException();
150       } else if (event_count == 0) {
151          Eina.Log.Error($"Trying to remove proxy for event {key} when there is nothing registered.");
152          return false;
153       } 
154       event_cb_count[key]--;
155       return true;
156    }
157 private static object ContentChangedEvtKey = new object();
158    /// <summary>Sent after the content is set or unset using the current content object.</summary>
159    public event EventHandler<Efl.ContentContentChangedEvt_Args> ContentChangedEvt
160    {
161       add {
162          lock (eventLock) {
163             string key = "_EFL_CONTENT_EVENT_CONTENT_CHANGED";
164             if (add_cpp_event_handler(efl.Libs.Efl, key, this.evt_ContentChangedEvt_delegate)) {
165                eventHandlers.AddHandler(ContentChangedEvtKey , value);
166             } else
167                Eina.Log.Error($"Error adding proxy for event {key}");
168          }
169       }
170       remove {
171          lock (eventLock) {
172             string key = "_EFL_CONTENT_EVENT_CONTENT_CHANGED";
173             if (remove_cpp_event_handler(key, this.evt_ContentChangedEvt_delegate)) { 
174                eventHandlers.RemoveHandler(ContentChangedEvtKey , value);
175             } else
176                Eina.Log.Error($"Error removing proxy for event {key}");
177          }
178       }
179    }
180    ///<summary>Method to raise event ContentChangedEvt.</summary>
181    public void On_ContentChangedEvt(Efl.ContentContentChangedEvt_Args e)
182    {
183       EventHandler<Efl.ContentContentChangedEvt_Args> evt;
184       lock (eventLock) {
185       evt = (EventHandler<Efl.ContentContentChangedEvt_Args>)eventHandlers[ContentChangedEvtKey];
186       }
187       evt?.Invoke(this, e);
188    }
189    Efl.EventCb evt_ContentChangedEvt_delegate;
190    private void on_ContentChangedEvt_NativeCallback(System.IntPtr data, ref Efl.Event_StructInternal evt)
191    {
192       Efl.ContentContentChangedEvt_Args args = new Efl.ContentContentChangedEvt_Args();
193       args.arg = new Efl.Gfx.EntityConcrete(evt.Info);
194       try {
195          On_ContentChangedEvt(args);
196       } catch (Exception e) {
197          Eina.Log.Error(e.ToString());
198          Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
199       }
200    }
201
202     void register_event_proxies()
203    {
204       evt_ContentChangedEvt_delegate = new Efl.EventCb(on_ContentChangedEvt_NativeCallback);
205    }
206    /// <summary>Swallowed sub-object contained in this object.</summary>
207    /// <returns>The object to swallow.</returns>
208    public Efl.Gfx.Entity GetContent() {
209        var _ret_var = Efl.ContentNativeInherit.efl_content_get_ptr.Value.Delegate(this.NativeHandle);
210       Eina.Error.RaiseIfUnhandledException();
211       return _ret_var;
212  }
213    /// <summary>Swallowed sub-object contained in this object.</summary>
214    /// <param name="content">The object to swallow.</param>
215    /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
216    public bool SetContent( Efl.Gfx.Entity content) {
217                          var _ret_var = Efl.ContentNativeInherit.efl_content_set_ptr.Value.Delegate(this.NativeHandle, content);
218       Eina.Error.RaiseIfUnhandledException();
219                   return _ret_var;
220  }
221    /// <summary>Unswallow the object in the current container and return it.</summary>
222    /// <returns>Unswallowed object</returns>
223    public Efl.Gfx.Entity UnsetContent() {
224        var _ret_var = Efl.ContentNativeInherit.efl_content_unset_ptr.Value.Delegate(this.NativeHandle);
225       Eina.Error.RaiseIfUnhandledException();
226       return _ret_var;
227  }
228    /// <summary>Swallowed sub-object contained in this object.</summary>
229 /// <value>The object to swallow.</value>
230    public Efl.Gfx.Entity Content {
231       get { return GetContent(); }
232       set { SetContent( value); }
233    }
234 }
235 public class ContentNativeInherit  : Efl.Eo.NativeClass{
236    public  static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Efl);
237    public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
238    {
239       var descs = new System.Collections.Generic.List<Efl_Op_Description>();
240       if (efl_content_get_static_delegate == null)
241       efl_content_get_static_delegate = new efl_content_get_delegate(content_get);
242       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)});
243       if (efl_content_set_static_delegate == null)
244       efl_content_set_static_delegate = new efl_content_set_delegate(content_set);
245       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)});
246       if (efl_content_unset_static_delegate == null)
247       efl_content_unset_static_delegate = new efl_content_unset_delegate(content_unset);
248       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)});
249       return descs;
250    }
251    public override IntPtr GetEflClass()
252    {
253       return Efl.ContentConcrete.efl_content_interface_get();
254    }
255    public static  IntPtr GetEflClassStatic()
256    {
257       return Efl.ContentConcrete.efl_content_interface_get();
258    }
259
260
261    [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.Gfx.EntityConcrete, Efl.Eo.NonOwnTag>))] private delegate Efl.Gfx.Entity efl_content_get_delegate(System.IntPtr obj, System.IntPtr pd);
262
263
264    [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.Gfx.EntityConcrete, Efl.Eo.NonOwnTag>))] public delegate Efl.Gfx.Entity efl_content_get_api_delegate(System.IntPtr obj);
265     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");
266     private static Efl.Gfx.Entity content_get(System.IntPtr obj, System.IntPtr pd)
267    {
268       Eina.Log.Debug("function efl_content_get was called");
269       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
270       if(wrapper != null) {
271                   Efl.Gfx.Entity _ret_var = default(Efl.Gfx.Entity);
272          try {
273             _ret_var = ((Content)wrapper).GetContent();
274          } catch (Exception e) {
275             Eina.Log.Warning($"Callback error: {e.ToString()}");
276             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
277          }
278       return _ret_var;
279       } else {
280          return efl_content_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
281       }
282    }
283    private static efl_content_get_delegate efl_content_get_static_delegate;
284
285
286     [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_content_set_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.Gfx.EntityConcrete, Efl.Eo.NonOwnTag>))]  Efl.Gfx.Entity content);
287
288
289     [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_content_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.Gfx.EntityConcrete, Efl.Eo.NonOwnTag>))]  Efl.Gfx.Entity content);
290     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");
291     private static bool content_set(System.IntPtr obj, System.IntPtr pd,  Efl.Gfx.Entity content)
292    {
293       Eina.Log.Debug("function efl_content_set was called");
294       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
295       if(wrapper != null) {
296                                     bool _ret_var = default(bool);
297          try {
298             _ret_var = ((Content)wrapper).SetContent( content);
299          } catch (Exception e) {
300             Eina.Log.Warning($"Callback error: {e.ToString()}");
301             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
302          }
303                   return _ret_var;
304       } else {
305          return efl_content_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  content);
306       }
307    }
308    private static efl_content_set_delegate efl_content_set_static_delegate;
309
310
311    [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.Gfx.EntityConcrete, Efl.Eo.NonOwnTag>))] private delegate Efl.Gfx.Entity efl_content_unset_delegate(System.IntPtr obj, System.IntPtr pd);
312
313
314    [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.Gfx.EntityConcrete, Efl.Eo.NonOwnTag>))] public delegate Efl.Gfx.Entity efl_content_unset_api_delegate(System.IntPtr obj);
315     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");
316     private static Efl.Gfx.Entity content_unset(System.IntPtr obj, System.IntPtr pd)
317    {
318       Eina.Log.Debug("function efl_content_unset was called");
319       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
320       if(wrapper != null) {
321                   Efl.Gfx.Entity _ret_var = default(Efl.Gfx.Entity);
322          try {
323             _ret_var = ((Content)wrapper).UnsetContent();
324          } catch (Exception e) {
325             Eina.Log.Warning($"Callback error: {e.ToString()}");
326             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
327          }
328       return _ret_var;
329       } else {
330          return efl_content_unset_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
331       }
332    }
333    private static efl_content_unset_delegate efl_content_unset_static_delegate;
334 }
335