2 #pragma warning disable CS1591
4 using System.Runtime.InteropServices;
5 using System.Collections.Generic;
7 using System.Threading;
8 using System.ComponentModel;
13 /// <summary>Selectable interface for ui objects
14 /// A object implementing this can be selected. When the selected property of this object changes, the selected,changed event is emitted.</summary>
15 /// <remarks>This is a <b>BETA</b> class. It can be modified or removed in the future. Do not use it for product development.</remarks>
16 [Efl.Ui.ISelectableConcrete.NativeMethods]
17 [Efl.Eo.BindingEntity]
18 public interface ISelectable :
19 Efl.Eo.IWrapper, IDisposable
21 /// <summary>The selected state of this object
22 /// A change to this property emits the changed event.</summary>
23 /// <returns>The selected state of this object</returns>
25 /// <summary>The selected state of this object
26 /// A change to this property emits the changed event.</summary>
27 /// <param name="selected">The selected state of this object</param>
28 void SetSelected(bool selected);
29 /// <summary>Called when the selected state has changed</summary>
30 /// <value><see cref="Efl.Ui.ISelectableSelectedChangedEvt_Args"/></value>
31 event EventHandler<Efl.Ui.ISelectableSelectedChangedEvt_Args> SelectedChangedEvt;
32 /// <summary>The selected state of this object
33 /// A change to this property emits the changed event.</summary>
34 /// <value>The selected state of this object</value>
40 /// <summary>Event argument wrapper for event <see cref="Efl.Ui.ISelectable.SelectedChangedEvt"/>.</summary>
41 [Efl.Eo.BindingEntity]
42 public class ISelectableSelectedChangedEvt_Args : EventArgs {
43 /// <summary>Actual event payload.</summary>
44 /// <value>Called when the selected state has changed</value>
45 public bool arg { get; set; }
47 /// <summary>Selectable interface for ui objects
48 /// A object implementing this can be selected. When the selected property of this object changes, the selected,changed event is emitted.</summary>
49 /// <remarks>This is a <b>BETA</b> class. It can be modified or removed in the future. Do not use it for product development.</remarks>
50 sealed public class ISelectableConcrete :
55 /// <summary>Pointer to the native class description.</summary>
56 public override System.IntPtr NativeClass
60 if (((object)this).GetType() == typeof(ISelectableConcrete))
62 return GetEflClassStatic();
66 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
71 /// <summary>Subclasses should override this constructor if they are expected to be instantiated from native code.
72 /// Do not call this constructor directly.</summary>
73 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
74 private ISelectableConcrete(ConstructingHandle ch) : base(ch)
78 [System.Runtime.InteropServices.DllImport(efl.Libs.Elementary)] internal static extern System.IntPtr
79 efl_ui_selectable_interface_get();
80 /// <summary>Initializes a new instance of the <see cref="ISelectable"/> class.
81 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
82 /// <param name="wh">The native pointer to be wrapped.</param>
83 private ISelectableConcrete(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
87 /// <summary>Called when the selected state has changed</summary>
88 /// <value><see cref="Efl.Ui.ISelectableSelectedChangedEvt_Args"/></value>
89 public event EventHandler<Efl.Ui.ISelectableSelectedChangedEvt_Args> SelectedChangedEvt
93 lock (eflBindingEventLock)
95 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
97 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
100 Efl.Ui.ISelectableSelectedChangedEvt_Args args = new Efl.Ui.ISelectableSelectedChangedEvt_Args();
101 args.arg = Marshal.ReadByte(evt.Info) != 0;
104 value?.Invoke(obj, args);
108 Eina.Log.Error(e.ToString());
109 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
114 string key = "_EFL_UI_EVENT_SELECTED_CHANGED";
115 AddNativeEventHandler(efl.Libs.Elementary, key, callerCb, value);
121 lock (eflBindingEventLock)
123 string key = "_EFL_UI_EVENT_SELECTED_CHANGED";
124 RemoveNativeEventHandler(efl.Libs.Elementary, key, value);
128 /// <summary>Method to raise event SelectedChangedEvt.</summary>
129 public void OnSelectedChangedEvt(Efl.Ui.ISelectableSelectedChangedEvt_Args e)
131 var key = "_EFL_UI_EVENT_SELECTED_CHANGED";
132 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Elementary, key);
133 if (desc == IntPtr.Zero)
135 Eina.Log.Error($"Failed to get native event {key}");
139 IntPtr info = Eina.PrimitiveConversion.ManagedToPointerAlloc(e.arg ? (byte) 1 : (byte) 0);
142 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
146 Marshal.FreeHGlobal(info);
149 /// <summary>The selected state of this object
150 /// A change to this property emits the changed event.</summary>
151 /// <returns>The selected state of this object</returns>
152 public bool GetSelected() {
153 var _ret_var = Efl.Ui.ISelectableConcrete.NativeMethods.efl_ui_selectable_selected_get_ptr.Value.Delegate(this.NativeHandle);
154 Eina.Error.RaiseIfUnhandledException();
157 /// <summary>The selected state of this object
158 /// A change to this property emits the changed event.</summary>
159 /// <param name="selected">The selected state of this object</param>
160 public void SetSelected(bool selected) {
161 Efl.Ui.ISelectableConcrete.NativeMethods.efl_ui_selectable_selected_set_ptr.Value.Delegate(this.NativeHandle,selected);
162 Eina.Error.RaiseIfUnhandledException();
164 /// <summary>The selected state of this object
165 /// A change to this property emits the changed event.</summary>
166 /// <value>The selected state of this object</value>
167 public bool Selected {
168 get { return GetSelected(); }
169 set { SetSelected(value); }
171 private static IntPtr GetEflClassStatic()
173 return Efl.Ui.ISelectableConcrete.efl_ui_selectable_interface_get();
175 /// <summary>Wrapper for native methods and virtual method delegates.
176 /// For internal use by generated code only.</summary>
177 public new class NativeMethods : Efl.Eo.EoWrapper.NativeMethods
179 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Elementary);
180 /// <summary>Gets the list of Eo operations to override.</summary>
181 /// <returns>The list of Eo operations to be overload.</returns>
182 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
184 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
185 var methods = Efl.Eo.Globals.GetUserMethods(type);
187 if (efl_ui_selectable_selected_get_static_delegate == null)
189 efl_ui_selectable_selected_get_static_delegate = new efl_ui_selectable_selected_get_delegate(selected_get);
192 if (methods.FirstOrDefault(m => m.Name == "GetSelected") != null)
194 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_selectable_selected_get"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_selectable_selected_get_static_delegate) });
197 if (efl_ui_selectable_selected_set_static_delegate == null)
199 efl_ui_selectable_selected_set_static_delegate = new efl_ui_selectable_selected_set_delegate(selected_set);
202 if (methods.FirstOrDefault(m => m.Name == "SetSelected") != null)
204 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_selectable_selected_set"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_selectable_selected_set_static_delegate) });
209 /// <summary>Returns the Eo class for the native methods of this class.</summary>
210 /// <returns>The native class pointer.</returns>
211 public override IntPtr GetEflClass()
213 return Efl.Ui.ISelectableConcrete.efl_ui_selectable_interface_get();
216 #pragma warning disable CA1707, CS1591, SA1300, SA1600
218 [return: MarshalAs(UnmanagedType.U1)]
219 private delegate bool efl_ui_selectable_selected_get_delegate(System.IntPtr obj, System.IntPtr pd);
221 [return: MarshalAs(UnmanagedType.U1)]
222 public delegate bool efl_ui_selectable_selected_get_api_delegate(System.IntPtr obj);
224 public static Efl.Eo.FunctionWrapper<efl_ui_selectable_selected_get_api_delegate> efl_ui_selectable_selected_get_ptr = new Efl.Eo.FunctionWrapper<efl_ui_selectable_selected_get_api_delegate>(Module, "efl_ui_selectable_selected_get");
226 private static bool selected_get(System.IntPtr obj, System.IntPtr pd)
228 Eina.Log.Debug("function efl_ui_selectable_selected_get was called");
229 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
232 bool _ret_var = default(bool);
235 _ret_var = ((ISelectable)ws.Target).GetSelected();
239 Eina.Log.Warning($"Callback error: {e.ToString()}");
240 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
248 return efl_ui_selectable_selected_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
252 private static efl_ui_selectable_selected_get_delegate efl_ui_selectable_selected_get_static_delegate;
255 private delegate void efl_ui_selectable_selected_set_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.U1)] bool selected);
258 public delegate void efl_ui_selectable_selected_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.U1)] bool selected);
260 public static Efl.Eo.FunctionWrapper<efl_ui_selectable_selected_set_api_delegate> efl_ui_selectable_selected_set_ptr = new Efl.Eo.FunctionWrapper<efl_ui_selectable_selected_set_api_delegate>(Module, "efl_ui_selectable_selected_set");
262 private static void selected_set(System.IntPtr obj, System.IntPtr pd, bool selected)
264 Eina.Log.Debug("function efl_ui_selectable_selected_set was called");
265 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
271 ((ISelectable)ws.Target).SetSelected(selected);
275 Eina.Log.Warning($"Callback error: {e.ToString()}");
276 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
283 efl_ui_selectable_selected_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), selected);
287 private static efl_ui_selectable_selected_set_delegate efl_ui_selectable_selected_set_static_delegate;
289 #pragma warning restore CA1707, CS1591, SA1300, SA1600
298 #pragma warning disable CS1591
299 public static class Efl_UiISelectableConcrete_ExtensionMethods {
300 public static Efl.BindableProperty<bool> Selected<T>(this Efl.Ui.ItemFactory<T> fac, Efl.Csharp.ExtensionTag<Efl.Ui.ISelectable, T>magic = null) where T : Efl.Ui.ISelectable {
301 return new Efl.BindableProperty<bool>("selected", fac);
305 #pragma warning restore CS1591