Add ScreenDpi API in Window class
[platform/core/csapi/tizenfx.git] / src / ElmSharp / Interop / Interop.Elementary.Win.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19
20 internal static partial class Interop
21 {
22     internal static partial class Elementary
23     {
24         [DllImport(Libraries.Elementary)]
25         internal static extern IntPtr elm_win_add(IntPtr parent, string name, int type);
26
27         [DllImport(Libraries.Elementary)]
28         internal static extern IntPtr elm_win_util_standard_add(string name, string title);
29
30         [DllImport(Libraries.Elementary)]
31         internal static extern void elm_win_activate(IntPtr obj);
32
33         [DllImport(Libraries.Elementary)]
34         internal static extern void elm_win_title_set(IntPtr obj, string title);
35
36         [DllImport(Libraries.Elementary, EntryPoint = "elm_win_title_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
37         internal static extern IntPtr _elm_win_title_get(IntPtr obj);
38
39         internal static string elm_win_title_get(IntPtr obj)
40         {
41             var text = _elm_win_title_get(obj);
42             return Marshal.PtrToStringAnsi(text);
43         }
44
45         [DllImport(Libraries.Elementary)]
46         internal static extern void elm_win_screen_size_get(IntPtr obj, out int x, out int y, out int w, out int h);
47
48         [DllImport(Libraries.Elementary)]
49         internal static extern void elm_win_resize_object_del(IntPtr obj, IntPtr subobj);
50
51         [DllImport(Libraries.Elementary)]
52         internal static extern void elm_win_resize_object_add(IntPtr obj, IntPtr subobj);
53
54         [DllImport(Libraries.Elementary)]
55         internal static extern void elm_win_autodel_set(IntPtr obj, bool autodel);
56
57         [DllImport(Libraries.Elementary)]
58         internal static extern bool elm_win_autodel_get(IntPtr obj);
59
60         [DllImport(Libraries.Elementary)]
61         internal static extern void elm_win_indicator_opacity_set(IntPtr obj, int opacity);
62
63         [DllImport(Libraries.Elementary)]
64         internal static extern int elm_win_indicator_opacity_get(IntPtr obj);
65
66         [DllImport(Libraries.Elementary)]
67         internal static extern void elm_win_indicator_mode_set(IntPtr obj, int mode);
68
69         [DllImport(Libraries.Elementary)]
70         internal static extern int elm_win_indicator_mode_get(IntPtr obj);
71
72         [DllImport(Libraries.Elementary)]
73         internal static extern void elm_win_conformant_set(IntPtr obj, bool conformant);
74
75         [DllImport(Libraries.Elementary)]
76         internal static extern bool elm_win_fullscreen_get(IntPtr obj);
77
78         [DllImport(Libraries.Elementary)]
79         internal static extern void elm_win_fullscreen_set(IntPtr obj, bool fullscreen);
80
81         [DllImport(Libraries.Elementary)]
82         internal static extern void elm_win_rotation_set(IntPtr obj, int rotation);
83
84         [DllImport(Libraries.Elementary)]
85         internal static extern int elm_win_rotation_get(IntPtr obj);
86
87         [DllImport(Libraries.Elementary)]
88         internal static extern bool elm_win_wm_rotation_supported_get(IntPtr obj);
89
90         [DllImport(Libraries.Elementary, EntryPoint = "elm_win_wm_rotation_available_rotations_set")]
91         internal static extern void _elm_win_wm_rotation_available_rotations_set(IntPtr obj, IntPtr rotations, uint count);
92
93         internal static void elm_win_wm_rotation_available_rotations_set(IntPtr obj, int[] rotations)
94         {
95             IntPtr pRotations = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * rotations.Length);
96             Marshal.Copy(rotations, 0, pRotations, rotations.Length);
97             _elm_win_wm_rotation_available_rotations_set(obj, pRotations, (uint)rotations.Length);
98             Marshal.FreeHGlobal(pRotations);
99         }
100
101         [DllImport(Libraries.Elementary, EntryPoint = "elm_win_wm_rotation_available_rotations_get")]
102         internal static extern bool _elm_win_wm_rotation_available_rotations_get(IntPtr obj, out IntPtr rotations, out int count);
103
104         internal static bool elm_win_wm_rotation_available_rotations_get(IntPtr obj, out int[] rotations)
105         {
106             IntPtr rotationArrPtr;
107             int count;
108             if (_elm_win_wm_rotation_available_rotations_get(obj, out rotationArrPtr, out count))
109             {
110                 rotations = new int[count];
111                 Marshal.Copy(rotationArrPtr, rotations, 0, count);
112                 Libc.Free(rotationArrPtr);
113                 return true;
114             }
115             rotations = null;
116             return false;
117         }
118
119         [DllImport(Libraries.Elementary)]
120         internal static extern void elm_win_screen_dpi_get(IntPtr obj, out int xdpi, out int ydpi);
121     }
122 }