[ACR-564] deprecate unused API
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / ContextPopup.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.Collections.Generic;
19
20 namespace ElmSharp
21 {
22     /// <summary>
23     /// Enumeration for the ContextPopup direction types.
24     /// </summary>
25     /// <since_tizen> preview </since_tizen>
26     [Obsolete("This has been deprecated in API12")]
27     public enum ContextPopupDirection
28     {
29         /// <summary>
30         /// The ContextPopup appears below the clicked area.
31         /// /// </summary>
32         Down,
33         /// <summary>
34         /// The ContextPopup appears to the right of the clicked area.
35         /// </summary>
36         Right,
37         /// <summary>
38         /// The ContextPopup appears to the left of the clicked area.
39         /// </summary>
40         Left,
41         /// <summary>
42         /// The ContextPopup appears above the clicked area.
43         /// </summary>
44         Up,
45         /// <summary>
46         /// The ContextPopup does not determine it's direction yet.
47         /// </summary>
48         Unknown
49     }
50
51     /// <summary>
52     /// It inherits <see cref="Layout"/>.
53     /// The ContextPopup is a widget that when shown, pops up a list of items.
54     /// </summary>
55     /// <since_tizen> preview </since_tizen>
56     [Obsolete("This has been deprecated in API12")]
57     public class ContextPopup : Layout
58     {
59         HashSet<ContextPopupItem> _children = new HashSet<ContextPopupItem>();
60         SmartEvent _dismissed;
61         Interop.Evas.SmartCallback _onSelected;
62
63         /// <summary>
64         /// Creates and initializes a new instance of the ContextPopup class.
65         /// </summary>
66         /// <param name="parent">The parent is a given container, which will be attached by ContextPopup
67         /// as a child. It's <see cref="EvasObject"/> type.</param>
68         /// <since_tizen> preview </since_tizen>
69         [Obsolete("This has been deprecated in API12")]
70         public ContextPopup(EvasObject parent) : base(parent)
71         {
72             _dismissed = new SmartEvent(this, this.RealHandle, "dismissed");
73             _dismissed.On += (sender, e) =>
74             {
75                 Dismissed?.Invoke(this, EventArgs.Empty);
76             };
77             _onSelected = (data, obj, info) =>
78             {
79                 ContextPopupItem item = ItemObject.GetItemById((int)data) as ContextPopupItem;
80                 item?.SendSelected();
81             };
82         }
83
84         /// <summary>
85         /// Dismissed is raised when the ContextPopup item is dismissed.
86         /// </summary>
87         /// <remarks>
88         /// Outside of ContextPopup is clicked or it's parent area is changed or the language is changed, and then ContextPopup is dismissed.
89         /// </remarks>
90         /// <since_tizen> preview </since_tizen>
91         [Obsolete("This has been deprecated in API12")]
92         public event EventHandler Dismissed;
93
94         /// <summary>
95         /// Gets the current direction of a ContextPopup.
96         /// </summary>
97         /// <remarks>
98         /// Once the ContextPopup shows up, the direction would be determined.
99         /// </remarks>
100         /// <since_tizen> preview </since_tizen>
101         [Obsolete("This has been deprecated in API12")]
102         public ContextPopupDirection Direction
103         {
104             get
105             {
106                 return (ContextPopupDirection)Interop.Elementary.elm_ctxpopup_direction_get(RealHandle);
107             }
108         }
109
110         /// <summary>
111         /// Gets or sets the value of the current ContextPopup object's orientation.
112         /// True for horizontal mode, False for vertical mode (or errors).
113         /// </summary>
114         /// <since_tizen> preview </since_tizen>
115         [Obsolete("This has been deprecated in API12")]
116         public bool IsHorizontal
117         {
118             get
119             {
120                 return Interop.Elementary.elm_ctxpopup_horizontal_get(RealHandle);
121             }
122             set
123             {
124                 Interop.Elementary.elm_ctxpopup_horizontal_set(RealHandle, value);
125             }
126         }
127
128         /// <summary>
129         /// Gets or sets whether the ContextPopup hides automatically
130         /// or not when the parent of the ContextPopup is resized.
131         /// </summary>
132         /// <remarks>
133         /// Default value of AutoHide is False.
134         /// </remarks>
135         /// <since_tizen> preview </since_tizen>
136         [Obsolete("This has been deprecated in API12")]
137         public bool AutoHide
138         {
139             get
140             {
141                 return !Interop.Elementary.elm_ctxpopup_auto_hide_disabled_get(RealHandle);
142             }
143             set
144             {
145                 Interop.Elementary.elm_ctxpopup_auto_hide_disabled_set(RealHandle, !value);
146             }
147         }
148
149         /// <summary>
150         /// Clears all the items in a given ContextPopup object.
151         /// </summary>
152         /// <since_tizen> preview </since_tizen>
153         [Obsolete("This has been deprecated in API12")]
154         public void Clear()
155         {
156             Interop.Elementary.elm_ctxpopup_clear(Handle);
157         }
158
159         /// <summary>
160         /// Sets the direction priority of a ContextPopup.
161         /// </summary>
162         /// <param name="first">1st priority of the direction.</param>
163         /// <param name="second">2nd priority of the direction.</param>
164         /// <param name="third">3th priority of the direction.</param>
165         /// <param name="fourth">4th priority of the direction.</param>
166         /// <since_tizen> preview </since_tizen>
167         [Obsolete("This has been deprecated in API12")]
168         public void SetDirectionPriorty(ContextPopupDirection first, ContextPopupDirection second, ContextPopupDirection third, ContextPopupDirection fourth)
169         {
170             Interop.Elementary.elm_ctxpopup_direction_priority_set(RealHandle, (int)first, (int)second, (int)third, (int)fourth);
171         }
172
173         /// <summary>
174         /// Gets the direction priority of a ContextPopup.
175         /// </summary>
176         /// <param name="first">1st priority of the direction to be returned.</param>
177         /// <param name="second">2nd priority of the direction to be returned.</param>
178         /// <param name="third">2nd priority of the direction to be returned.</param>
179         /// <param name="fourth">4th priority of the direction to be returned.</param>
180         /// <since_tizen> preview </since_tizen>
181         [Obsolete("This has been deprecated in API12")]
182         public void GetDirectionPriority(out ContextPopupDirection first, out ContextPopupDirection second, out ContextPopupDirection third, out ContextPopupDirection fourth)
183         {
184             int firstOut, secondOut, thirdOut, fourthOut;
185             Interop.Elementary.elm_ctxpopup_direction_priority_get(Handle, out firstOut, out secondOut, out thirdOut, out fourthOut);
186             first = (ContextPopupDirection)firstOut;
187             second = (ContextPopupDirection)secondOut;
188             third = (ContextPopupDirection)thirdOut;
189             fourth = (ContextPopupDirection)fourthOut;
190         }
191
192         /// <summary>
193         /// Adds a new item to a ContextPopup object with the label.
194         /// </summary>
195         /// <param name="label">Label of the new item.</param>
196         /// <returns>
197         /// A ContextPopupItem added, or null on errors.
198         /// </returns>
199         /// <since_tizen> preview </since_tizen>
200         [Obsolete("This has been deprecated in API12")]
201         public ContextPopupItem Append(string label)
202         {
203             return Append(label, null);
204         }
205
206         /// <summary>
207         /// Adds a new item to a ContextPopup object with the label and icon.
208         /// </summary>
209         /// <param name="label">Label of the new item.</param>
210         /// <param name="icon">Icon to be set on the new item.</param>
211         /// <returns>A ContextPopupItem added, or null on errors.</returns>
212         /// <since_tizen> preview </since_tizen>
213         [Obsolete("This has been deprecated in API12")]
214         public ContextPopupItem Append(string label, EvasObject icon)
215         {
216             ContextPopupItem item = new ContextPopupItem(label, icon, this);
217             item.Handle = Interop.Elementary.elm_ctxpopup_item_append(RealHandle, label, icon, _onSelected, (IntPtr)item.Id);
218             AddInternal(item);
219             return item;
220         }
221
222         /// <summary>
223         /// Dismisses a ContextPopup object. The ContextPopup will be hidden and the "clicked" signal will be emitted.
224         /// </summary>
225         /// <since_tizen> preview </since_tizen>
226         [Obsolete("This has been deprecated in API12")]
227         public void Dismiss()
228         {
229             Interop.Elementary.elm_ctxpopup_dismiss(RealHandle);
230         }
231
232         /// <summary>
233         /// Gets the possibility that the direction would be available.
234         /// </summary>
235         /// <param name="direction">A direction that the user wants to check.</param>
236         /// <returns>
237         /// Get false if you cannot put it in the direction. Get true if it's possible.
238         /// </returns>
239         /// <since_tizen> preview </since_tizen>
240         [Obsolete("This has been deprecated in API12")]
241         /// [Obsolete("IsAvailableDirection is obsolete as of API6 and is no longer supported.")]
242         public bool IsAvailableDirection(ContextPopupDirection direction)
243         {
244             Console.WriteLine("ContextPopup.IsAvailableDirection is obsolete as of API6 and is no longer supported.");
245             return false;
246         }
247
248         /// <summary>
249         /// Gets the Alpha of a default Color class.
250         /// </summary>
251         /// <since_tizen> preview </since_tizen>
252         [Obsolete("This has been deprecated in API12")]
253         public override int Opacity
254         {
255             get
256             {
257                 return Color.Default.A;
258             }
259
260             set
261             {
262                 Console.WriteLine("ContextPopup instance doesn't support to set Opacity.");
263             }
264         }
265
266         /// <summary>
267         /// Creates a widget handle.
268         /// </summary>
269         /// <param name="parent">Parent EvasObject.</param>
270         /// <returns>Handle IntPtr.</returns>
271         /// <since_tizen> preview </since_tizen>
272         [Obsolete("This has been deprecated in API12")]
273         protected override IntPtr CreateHandle(EvasObject parent)
274         {
275             return Interop.Elementary.elm_ctxpopup_add(parent.Handle);
276         }
277
278         void AddInternal(ContextPopupItem item)
279         {
280             _children.Add(item);
281             item.Deleted += Item_Deleted;
282         }
283
284         void Item_Deleted(object sender, EventArgs e)
285         {
286             _children.Remove((ContextPopupItem)sender);
287         }
288     }
289 }