[Maps] Add doxygen for map view classes
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / 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 EvasObject = ElmSharp.EvasObject;
19
20 namespace Tizen.Maps
21 {
22     /// <summary>
23     /// Overlay map object
24     /// </summary>
25     public class Overlay : MapObject
26     {
27         private EvasObject _containedObject;
28
29         /// <summary>
30         /// Creates normal overlay map object
31         /// </summary>
32         /// <param name="coordinates"></param>
33         /// <param name="objectToContain"></param>
34         public Overlay(Geocoordinates coordinates, EvasObject objectToContain) : this(coordinates, objectToContain, Interop.ViewOverlayType.Normal)
35         {
36         }
37
38         internal Overlay(Interop.ViewObjectHandle nativeHandle) : base(nativeHandle)
39         {
40         }
41
42         internal Overlay(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type) : base(CreateNativeHandle(coordinates, objectToContain, type))
43         {
44             var err = Interop.ErrorCode.InvalidParameter;
45             if (coordinates == null || objectToContain == null)
46             {
47                 err.ThrowIfFailed("given coordinates or parent evas object is null");
48             }
49
50             _containedObject = objectToContain;
51         }
52
53         /// <summary>
54         /// Geographical coordinates for overlay
55         /// </summary>
56         public Geocoordinates Coordinates
57         {
58             get
59             {
60                 IntPtr nativeHandle;
61                 Interop.ViewObject.OverlayGetCoordinates(handle, out nativeHandle);
62                 return new Geocoordinates(nativeHandle);
63             }
64             set
65             {
66                 // Overlay takes ownership of the native handle.
67                 IntPtr nativeHandle;
68                 var err = Interop.Coordinates.Clone(value.handle, out nativeHandle);
69                 err.WarnIfFailed("Failed to clone native handle for coordinates");
70
71                 Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(nativeHandle);
72                 err = Interop.ViewObject.OverlaySetCoordinates(handle, clonedHandle);
73                 if (err.WarnIfFailed("Failed to set coordinates to overlay"))
74                 {
75                     clonedHandle.ReleaseOwnership();
76                 }
77             }
78         }
79
80         /// <summary>
81         /// Minimum zoom level for overlay
82         /// </summary>
83         public int MinimumZoomLevel
84         {
85             get
86             {
87                 int value;
88                 Interop.ViewObject.OverlayGetMinZoomLevel(handle, out value);
89                 return value;
90             }
91             set
92             {
93                 Interop.ViewObject.OverlaySetMinZoomLevel(handle, value);
94             }
95         }
96
97         /// <summary>
98         /// Maximum zoom lever for overlay
99         /// </summary>
100         public int MaximumZoomLevel
101         {
102             get
103             {
104                 int value;
105                 Interop.ViewObject.OverlayGetMaxZoomLevel(handle, out value);
106                 return value;
107             }
108             set
109             {
110                 Interop.ViewObject.OverlaySetMaxZoomLevel(handle, value);
111             }
112         }
113
114         private static Interop.ViewObjectHandle CreateNativeHandle(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type)
115         {
116             if (coordinates == null || objectToContain == null) return new Interop.ViewObjectHandle(IntPtr.Zero);
117
118             IntPtr nativeHandle;
119             var err = Interop.Coordinates.Clone(coordinates.handle, out nativeHandle);
120             err.ThrowIfFailed("Failed to clone native handle for coordinates");
121
122             Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(nativeHandle);
123             err = Interop.ViewObject.CreateOverlay(clonedHandle, objectToContain, type, out nativeHandle);
124             err.ThrowIfFailed("Failed to create native handle for Overlay");
125
126             clonedHandle.ReleaseOwnership();
127             return new Interop.ViewObjectHandle(nativeHandle);
128         }
129     }
130
131     /// <summary>
132     /// Bubble overlay map object
133     /// </summary>
134     public class BubbleOverlay : Overlay
135     {
136         public BubbleOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Bubble)
137         {
138         }
139     }
140
141     /// <summary>
142     /// Box Overlay map object
143     /// </summary>
144     public class BoxOverlay : Overlay
145     {
146         /// <summary>
147         /// Creates Box overlay
148         /// </summary>
149         public BoxOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Box)
150         {
151         }
152     }
153 }