Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Interop / Interop.View.Overlay.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 using ElmSharp;
20
21 internal static partial class Interop
22 {
23     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_set_coordinates")]
24     internal static extern ErrorCode SetCoordinates(this OverlayHandle /* maps_view_object_h */ overlay, CoordinatesHandle /* maps_coordinates_h */ coordinates);
25
26     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_get_coordinates")]
27     internal static extern ErrorCode GetCoordinates(this OverlayHandle /* maps_view_object_h */ overlay, out IntPtr /* maps_coordinates_h */ coordinates);
28
29     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_set_min_zoom_level")]
30     internal static extern ErrorCode SetMinZoomLevel(this OverlayHandle /* maps_view_object_h */ overlay, int zoom);
31
32     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_get_min_zoom_level")]
33     internal static extern ErrorCode GetMinZoomLevel(this OverlayHandle /* maps_view_object_h */ overlay, out int zoom);
34
35     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_set_max_zoom_level")]
36     internal static extern ErrorCode SetMaxZoomLevel(this OverlayHandle /* maps_view_object_h */ overlay, int zoom);
37
38     [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_get_max_zoom_level")]
39     internal static extern ErrorCode GetMaxZoomLevel(this OverlayHandle /* maps_view_object_h */ overlay, out int zoom);
40
41     internal class OverlayHandle : ViewObjectHandle
42     {
43         [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_create_overlay")]
44         internal static extern ErrorCode CreateOverlay(CoordinatesHandle /* maps_coordinates_h */ coordinates, IntPtr viewObject, ViewOverlayType /* maps_view_overlay_type_e */ type, out IntPtr /* maps_view_object_h */ overlay);
45
46         internal int MinZoomLevel
47         {
48             get { return NativeGet<int>(this.GetMinZoomLevel); }
49             set { NativeSet(this.SetMinZoomLevel, value); }
50         }
51
52         internal int MaxZoomLevel
53         {
54             get { return NativeGet<int>(this.GetMaxZoomLevel); }
55             set { NativeSet(this.SetMaxZoomLevel, value); }
56         }
57
58
59         internal CoordinatesHandle Coordinates
60         {
61             get { return NativeGet(this.GetCoordinates, CoordinatesHandle.Create); }
62             set { NativeSet(this.SetCoordinates, value); }
63         }
64
65         internal OverlayHandle(CoordinatesHandle coordinates, EvasObject viewObject, ViewOverlayType type) : base(IntPtr.Zero, true)
66         {
67             var clonedCoordinatesHandle = CoordinatesHandle.CloneFrom(coordinates);
68             CreateOverlay(clonedCoordinatesHandle, viewObject, type, out handle).ThrowIfFailed("Failed to create native overlay handle");
69             clonedCoordinatesHandle.HasOwnership = false;
70         }
71     }
72 }