1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
10 /// <summary>Efl screen interface
11 /// (Since EFL 1.22)</summary>
12 [Efl.IScreenConcrete.NativeMethods]
13 public interface IScreen :
14 Efl.Eo.IWrapper, IDisposable
16 /// <summary>Get screen size (in pixels) for the screen.
17 /// Note that on some display systems this information is not available and a value of 0x0 will be returned.
18 /// (Since EFL 1.22)</summary>
19 /// <returns>The screen size in pixels.</returns>
20 Eina.Size2D GetScreenSizeInPixels();
21 /// <summary>Get screen scaling factor.
22 /// This is the factor by which window contents will be scaled on the screen.
24 /// Note that on some display systems this information is not available and a value of 1.0 will be returned.
25 /// (Since EFL 1.22)</summary>
26 /// <returns>The screen scaling factor.</returns>
27 float GetScreenScaleFactor();
28 /// <summary>Get the rotation of the screen.
29 /// Most engines only return multiples of 90.
30 /// (Since EFL 1.22)</summary>
31 /// <returns>Screen rotation in degrees.</returns>
32 int GetScreenRotation();
33 /// <summary>Get the pixel density in DPI (Dots Per Inch) for the screen that a window is on.
34 /// (Since EFL 1.22)</summary>
35 /// <param name="xdpi">Horizontal DPI.</param>
36 /// <param name="ydpi">Vertical DPI.</param>
37 void GetScreenDpi(out int xdpi, out int ydpi);
38 /// <summary>Get screen size (in pixels) for the screen.
39 /// Note that on some display systems this information is not available and a value of 0x0 will be returned.
40 /// (Since EFL 1.22)</summary>
41 /// <value>The screen size in pixels.</value>
42 Eina.Size2D ScreenSizeInPixels {
45 /// <summary>Get screen scaling factor.
46 /// This is the factor by which window contents will be scaled on the screen.
48 /// Note that on some display systems this information is not available and a value of 1.0 will be returned.
49 /// (Since EFL 1.22)</summary>
50 /// <value>The screen scaling factor.</value>
51 float ScreenScaleFactor {
54 /// <summary>Get the rotation of the screen.
55 /// Most engines only return multiples of 90.
56 /// (Since EFL 1.22)</summary>
57 /// <value>Screen rotation in degrees.</value>
62 /// <summary>Efl screen interface
63 /// (Since EFL 1.22)</summary>
64 sealed public class IScreenConcrete :
69 ///<summary>Pointer to the native class description.</summary>
70 public System.IntPtr NativeClass
74 if (((object)this).GetType() == typeof(IScreenConcrete))
76 return GetEflClassStatic();
80 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
85 private System.IntPtr handle;
86 ///<summary>Pointer to the native instance.</summary>
87 public System.IntPtr NativeHandle
89 get { return handle; }
92 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
93 efl_screen_interface_get();
94 /// <summary>Initializes a new instance of the <see cref="IScreen"/> class.
95 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
96 private IScreenConcrete(System.IntPtr raw)
100 ///<summary>Destructor.</summary>
106 ///<summary>Releases the underlying native instance.</summary>
107 private void Dispose(bool disposing)
109 if (handle != System.IntPtr.Zero)
112 handle = IntPtr.Zero;
114 IntPtr gcHandlePtr = IntPtr.Zero;
117 Efl.Eo.Globals.efl_mono_native_dispose(h, gcHandlePtr);
121 Monitor.Enter(Efl.All.InitLock);
122 if (Efl.All.MainLoopInitialized)
124 Efl.Eo.Globals.efl_mono_thread_safe_native_dispose(h, gcHandlePtr);
127 Monitor.Exit(Efl.All.InitLock);
133 ///<summary>Releases the underlying native instance.</summary>
134 public void Dispose()
137 GC.SuppressFinalize(this);
140 /// <summary>Verifies if the given object is equal to this one.</summary>
141 /// <param name="instance">The object to compare to.</param>
142 /// <returns>True if both objects point to the same native object.</returns>
143 public override bool Equals(object instance)
145 var other = instance as Efl.Object;
150 return this.NativeHandle == other.NativeHandle;
153 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
154 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
155 public override int GetHashCode()
157 return this.NativeHandle.ToInt32();
160 /// <summary>Turns the native pointer into a string representation.</summary>
161 /// <returns>A string with the type and the native pointer for this object.</returns>
162 public override String ToString()
164 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
167 /// <summary>Get screen size (in pixels) for the screen.
168 /// Note that on some display systems this information is not available and a value of 0x0 will be returned.
169 /// (Since EFL 1.22)</summary>
170 /// <returns>The screen size in pixels.</returns>
171 public Eina.Size2D GetScreenSizeInPixels() {
172 var _ret_var = Efl.IScreenConcrete.NativeMethods.efl_screen_size_in_pixels_get_ptr.Value.Delegate(this.NativeHandle);
173 Eina.Error.RaiseIfUnhandledException();
176 /// <summary>Get screen scaling factor.
177 /// This is the factor by which window contents will be scaled on the screen.
179 /// Note that on some display systems this information is not available and a value of 1.0 will be returned.
180 /// (Since EFL 1.22)</summary>
181 /// <returns>The screen scaling factor.</returns>
182 public float GetScreenScaleFactor() {
183 var _ret_var = Efl.IScreenConcrete.NativeMethods.efl_screen_scale_factor_get_ptr.Value.Delegate(this.NativeHandle);
184 Eina.Error.RaiseIfUnhandledException();
187 /// <summary>Get the rotation of the screen.
188 /// Most engines only return multiples of 90.
189 /// (Since EFL 1.22)</summary>
190 /// <returns>Screen rotation in degrees.</returns>
191 public int GetScreenRotation() {
192 var _ret_var = Efl.IScreenConcrete.NativeMethods.efl_screen_rotation_get_ptr.Value.Delegate(this.NativeHandle);
193 Eina.Error.RaiseIfUnhandledException();
196 /// <summary>Get the pixel density in DPI (Dots Per Inch) for the screen that a window is on.
197 /// (Since EFL 1.22)</summary>
198 /// <param name="xdpi">Horizontal DPI.</param>
199 /// <param name="ydpi">Vertical DPI.</param>
200 public void GetScreenDpi(out int xdpi, out int ydpi) {
201 Efl.IScreenConcrete.NativeMethods.efl_screen_dpi_get_ptr.Value.Delegate(this.NativeHandle,out xdpi, out ydpi);
202 Eina.Error.RaiseIfUnhandledException();
204 /// <summary>Get screen size (in pixels) for the screen.
205 /// Note that on some display systems this information is not available and a value of 0x0 will be returned.
206 /// (Since EFL 1.22)</summary>
207 /// <value>The screen size in pixels.</value>
208 public Eina.Size2D ScreenSizeInPixels {
209 get { return GetScreenSizeInPixels(); }
211 /// <summary>Get screen scaling factor.
212 /// This is the factor by which window contents will be scaled on the screen.
214 /// Note that on some display systems this information is not available and a value of 1.0 will be returned.
215 /// (Since EFL 1.22)</summary>
216 /// <value>The screen scaling factor.</value>
217 public float ScreenScaleFactor {
218 get { return GetScreenScaleFactor(); }
220 /// <summary>Get the rotation of the screen.
221 /// Most engines only return multiples of 90.
222 /// (Since EFL 1.22)</summary>
223 /// <value>Screen rotation in degrees.</value>
224 public int ScreenRotation {
225 get { return GetScreenRotation(); }
227 private static IntPtr GetEflClassStatic()
229 return Efl.IScreenConcrete.efl_screen_interface_get();
231 /// <summary>Wrapper for native methods and virtual method delegates.
232 /// For internal use by generated code only.</summary>
233 public class NativeMethods : Efl.Eo.NativeClass
235 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
236 /// <summary>Gets the list of Eo operations to override.</summary>
237 /// <returns>The list of Eo operations to be overload.</returns>
238 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
240 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
241 var methods = Efl.Eo.Globals.GetUserMethods(type);
243 if (efl_screen_size_in_pixels_get_static_delegate == null)
245 efl_screen_size_in_pixels_get_static_delegate = new efl_screen_size_in_pixels_get_delegate(screen_size_in_pixels_get);
248 if (methods.FirstOrDefault(m => m.Name == "GetScreenSizeInPixels") != null)
250 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_screen_size_in_pixels_get"), func = Marshal.GetFunctionPointerForDelegate(efl_screen_size_in_pixels_get_static_delegate) });
253 if (efl_screen_scale_factor_get_static_delegate == null)
255 efl_screen_scale_factor_get_static_delegate = new efl_screen_scale_factor_get_delegate(screen_scale_factor_get);
258 if (methods.FirstOrDefault(m => m.Name == "GetScreenScaleFactor") != null)
260 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_screen_scale_factor_get"), func = Marshal.GetFunctionPointerForDelegate(efl_screen_scale_factor_get_static_delegate) });
263 if (efl_screen_rotation_get_static_delegate == null)
265 efl_screen_rotation_get_static_delegate = new efl_screen_rotation_get_delegate(screen_rotation_get);
268 if (methods.FirstOrDefault(m => m.Name == "GetScreenRotation") != null)
270 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_screen_rotation_get"), func = Marshal.GetFunctionPointerForDelegate(efl_screen_rotation_get_static_delegate) });
273 if (efl_screen_dpi_get_static_delegate == null)
275 efl_screen_dpi_get_static_delegate = new efl_screen_dpi_get_delegate(screen_dpi_get);
278 if (methods.FirstOrDefault(m => m.Name == "GetScreenDpi") != null)
280 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_screen_dpi_get"), func = Marshal.GetFunctionPointerForDelegate(efl_screen_dpi_get_static_delegate) });
285 /// <summary>Returns the Eo class for the native methods of this class.</summary>
286 /// <returns>The native class pointer.</returns>
287 public override IntPtr GetEflClass()
289 return Efl.IScreenConcrete.efl_screen_interface_get();
292 #pragma warning disable CA1707, SA1300, SA1600
295 private delegate Eina.Size2D.NativeStruct efl_screen_size_in_pixels_get_delegate(System.IntPtr obj, System.IntPtr pd);
298 public delegate Eina.Size2D.NativeStruct efl_screen_size_in_pixels_get_api_delegate(System.IntPtr obj);
300 public static Efl.Eo.FunctionWrapper<efl_screen_size_in_pixels_get_api_delegate> efl_screen_size_in_pixels_get_ptr = new Efl.Eo.FunctionWrapper<efl_screen_size_in_pixels_get_api_delegate>(Module, "efl_screen_size_in_pixels_get");
302 private static Eina.Size2D.NativeStruct screen_size_in_pixels_get(System.IntPtr obj, System.IntPtr pd)
304 Eina.Log.Debug("function efl_screen_size_in_pixels_get was called");
305 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
308 Eina.Size2D _ret_var = default(Eina.Size2D);
311 _ret_var = ((IScreen)wrapper).GetScreenSizeInPixels();
315 Eina.Log.Warning($"Callback error: {e.ToString()}");
316 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
324 return efl_screen_size_in_pixels_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
328 private static efl_screen_size_in_pixels_get_delegate efl_screen_size_in_pixels_get_static_delegate;
331 private delegate float efl_screen_scale_factor_get_delegate(System.IntPtr obj, System.IntPtr pd);
334 public delegate float efl_screen_scale_factor_get_api_delegate(System.IntPtr obj);
336 public static Efl.Eo.FunctionWrapper<efl_screen_scale_factor_get_api_delegate> efl_screen_scale_factor_get_ptr = new Efl.Eo.FunctionWrapper<efl_screen_scale_factor_get_api_delegate>(Module, "efl_screen_scale_factor_get");
338 private static float screen_scale_factor_get(System.IntPtr obj, System.IntPtr pd)
340 Eina.Log.Debug("function efl_screen_scale_factor_get was called");
341 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
344 float _ret_var = default(float);
347 _ret_var = ((IScreen)wrapper).GetScreenScaleFactor();
351 Eina.Log.Warning($"Callback error: {e.ToString()}");
352 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
360 return efl_screen_scale_factor_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
364 private static efl_screen_scale_factor_get_delegate efl_screen_scale_factor_get_static_delegate;
367 private delegate int efl_screen_rotation_get_delegate(System.IntPtr obj, System.IntPtr pd);
370 public delegate int efl_screen_rotation_get_api_delegate(System.IntPtr obj);
372 public static Efl.Eo.FunctionWrapper<efl_screen_rotation_get_api_delegate> efl_screen_rotation_get_ptr = new Efl.Eo.FunctionWrapper<efl_screen_rotation_get_api_delegate>(Module, "efl_screen_rotation_get");
374 private static int screen_rotation_get(System.IntPtr obj, System.IntPtr pd)
376 Eina.Log.Debug("function efl_screen_rotation_get was called");
377 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
380 int _ret_var = default(int);
383 _ret_var = ((IScreen)wrapper).GetScreenRotation();
387 Eina.Log.Warning($"Callback error: {e.ToString()}");
388 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
396 return efl_screen_rotation_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
400 private static efl_screen_rotation_get_delegate efl_screen_rotation_get_static_delegate;
403 private delegate void efl_screen_dpi_get_delegate(System.IntPtr obj, System.IntPtr pd, out int xdpi, out int ydpi);
406 public delegate void efl_screen_dpi_get_api_delegate(System.IntPtr obj, out int xdpi, out int ydpi);
408 public static Efl.Eo.FunctionWrapper<efl_screen_dpi_get_api_delegate> efl_screen_dpi_get_ptr = new Efl.Eo.FunctionWrapper<efl_screen_dpi_get_api_delegate>(Module, "efl_screen_dpi_get");
410 private static void screen_dpi_get(System.IntPtr obj, System.IntPtr pd, out int xdpi, out int ydpi)
412 Eina.Log.Debug("function efl_screen_dpi_get was called");
413 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
416 xdpi = default(int); ydpi = default(int);
419 ((IScreen)wrapper).GetScreenDpi(out xdpi, out ydpi);
423 Eina.Log.Warning($"Callback error: {e.ToString()}");
424 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
431 efl_screen_dpi_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), out xdpi, out ydpi);
435 private static efl_screen_dpi_get_delegate efl_screen_dpi_get_static_delegate;
437 #pragma warning restore CA1707, SA1300, SA1600