2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
23 /// Enumeration for the ContextPopup direction types.
25 /// <since_tizen> preview </since_tizen>
26 [Obsolete("This has been deprecated in API12")]
27 public enum ContextPopupDirection
30 /// The ContextPopup appears below the clicked area.
34 /// The ContextPopup appears to the right of the clicked area.
38 /// The ContextPopup appears to the left of the clicked area.
42 /// The ContextPopup appears above the clicked area.
46 /// The ContextPopup does not determine it's direction yet.
52 /// It inherits <see cref="Layout"/>.
53 /// The ContextPopup is a widget that when shown, pops up a list of items.
55 /// <since_tizen> preview </since_tizen>
56 [Obsolete("This has been deprecated in API12")]
57 public class ContextPopup : Layout
59 HashSet<ContextPopupItem> _children = new HashSet<ContextPopupItem>();
60 SmartEvent _dismissed;
61 Interop.Evas.SmartCallback _onSelected;
64 /// Creates and initializes a new instance of the ContextPopup class.
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)
72 _dismissed = new SmartEvent(this, this.RealHandle, "dismissed");
73 _dismissed.On += (sender, e) =>
75 Dismissed?.Invoke(this, EventArgs.Empty);
77 _onSelected = (data, obj, info) =>
79 ContextPopupItem item = ItemObject.GetItemById((int)data) as ContextPopupItem;
85 /// Dismissed is raised when the ContextPopup item is dismissed.
88 /// Outside of ContextPopup is clicked or it's parent area is changed or the language is changed, and then ContextPopup is dismissed.
90 /// <since_tizen> preview </since_tizen>
91 [Obsolete("This has been deprecated in API12")]
92 public event EventHandler Dismissed;
95 /// Gets the current direction of a ContextPopup.
98 /// Once the ContextPopup shows up, the direction would be determined.
100 /// <since_tizen> preview </since_tizen>
101 [Obsolete("This has been deprecated in API12")]
102 public ContextPopupDirection Direction
106 return (ContextPopupDirection)Interop.Elementary.elm_ctxpopup_direction_get(RealHandle);
111 /// Gets or sets the value of the current ContextPopup object's orientation.
112 /// True for horizontal mode, False for vertical mode (or errors).
114 /// <since_tizen> preview </since_tizen>
115 [Obsolete("This has been deprecated in API12")]
116 public bool IsHorizontal
120 return Interop.Elementary.elm_ctxpopup_horizontal_get(RealHandle);
124 Interop.Elementary.elm_ctxpopup_horizontal_set(RealHandle, value);
129 /// Gets or sets whether the ContextPopup hides automatically
130 /// or not when the parent of the ContextPopup is resized.
133 /// Default value of AutoHide is False.
135 /// <since_tizen> preview </since_tizen>
136 [Obsolete("This has been deprecated in API12")]
141 return !Interop.Elementary.elm_ctxpopup_auto_hide_disabled_get(RealHandle);
145 Interop.Elementary.elm_ctxpopup_auto_hide_disabled_set(RealHandle, !value);
150 /// Clears all the items in a given ContextPopup object.
152 /// <since_tizen> preview </since_tizen>
153 [Obsolete("This has been deprecated in API12")]
156 Interop.Elementary.elm_ctxpopup_clear(Handle);
160 /// Sets the direction priority of a ContextPopup.
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)
170 Interop.Elementary.elm_ctxpopup_direction_priority_set(RealHandle, (int)first, (int)second, (int)third, (int)fourth);
174 /// Gets the direction priority of a ContextPopup.
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)
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;
193 /// Adds a new item to a ContextPopup object with the label.
195 /// <param name="label">Label of the new item.</param>
197 /// A ContextPopupItem added, or null on errors.
199 /// <since_tizen> preview </since_tizen>
200 [Obsolete("This has been deprecated in API12")]
201 public ContextPopupItem Append(string label)
203 return Append(label, null);
207 /// Adds a new item to a ContextPopup object with the label and icon.
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)
216 ContextPopupItem item = new ContextPopupItem(label, icon, this);
217 item.Handle = Interop.Elementary.elm_ctxpopup_item_append(RealHandle, label, icon, _onSelected, (IntPtr)item.Id);
223 /// Dismisses a ContextPopup object. The ContextPopup will be hidden and the "clicked" signal will be emitted.
225 /// <since_tizen> preview </since_tizen>
226 [Obsolete("This has been deprecated in API12")]
227 public void Dismiss()
229 Interop.Elementary.elm_ctxpopup_dismiss(RealHandle);
233 /// Gets the possibility that the direction would be available.
235 /// <param name="direction">A direction that the user wants to check.</param>
237 /// Get false if you cannot put it in the direction. Get true if it's possible.
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)
244 Console.WriteLine("ContextPopup.IsAvailableDirection is obsolete as of API6 and is no longer supported.");
249 /// Gets the Alpha of a default Color class.
251 /// <since_tizen> preview </since_tizen>
252 [Obsolete("This has been deprecated in API12")]
253 public override int Opacity
257 return Color.Default.A;
262 Console.WriteLine("ContextPopup instance doesn't support to set Opacity.");
267 /// Creates a widget handle.
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)
275 return Interop.Elementary.elm_ctxpopup_add(parent.Handle);
278 void AddInternal(ContextPopupItem item)
281 item.Deleted += Item_Deleted;
284 void Item_Deleted(object sender, EventArgs e)
286 _children.Remove((ContextPopupItem)sender);