/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; namespace ElmSharp { /// /// Enumeration for the popup orientation types. /// /// preview [Obsolete("This has been deprecated in API12")] public enum PopupOrientation { /// /// Appears in the top of parent, by default. /// Top, /// /// Appears in the center of parent. /// Center, /// /// Appears in the bottom of parent. /// Bottom, /// /// Appears in the left of parent. /// Left, /// /// Appears in the right of parent. /// Right, /// /// Appears in the top left of parent. /// TopLeft, /// /// Appears in the top right of parent. /// TopRight, /// /// Appears in the bottom left of parent. /// BottomLeft, /// /// Appears in the bottom right of parent. /// BottomRight } /// /// The Popup is a widget that is an enhancement of notify. /// In addition to content area, there are two optional sections, namely title area and action area. /// /// preview [Obsolete("This has been deprecated in API12")] public class Popup : Layout { HashSet _children = new HashSet(); SmartEvent _dismissed; SmartEvent _blockClicked; SmartEvent _timeout; SmartEvent _showFinished; /// /// Creates and initializes a new instance of the Popup class. /// /// The EvasObject to which the new popup will be attached as a child. /// preview [Obsolete("This has been deprecated in API12")] public Popup(EvasObject parent) : base(parent) { _dismissed = new SmartEvent(this, "dismissed"); _dismissed.On += (sender, e) => { Dismissed?.Invoke(this, EventArgs.Empty); }; _blockClicked = new SmartEvent(this, "block,clicked"); _blockClicked.On += (sender, e) => { OutsideClicked?.Invoke(this, EventArgs.Empty); }; _timeout = new SmartEvent(this, "timeout"); _timeout.On += (sender, e) => { TimedOut?.Invoke(this, EventArgs.Empty); }; _showFinished = new SmartEvent(this, "show,finished"); _showFinished.On += (sender, e) => { ShowAnimationFinished?.Invoke(this, EventArgs.Empty); }; } /// /// Dismissed will be triggered when the popup has been dismissed. /// /// preview [Obsolete("This has been deprecated in API12")] public event EventHandler Dismissed; /// /// OutsideClicked will be triggered when users taps on the outside of Popup. /// /// preview [Obsolete("This has been deprecated in API12")] public event EventHandler OutsideClicked; /// /// OutsideClicked will be triggered when the popup is closed as a result of timeout. /// /// preview [Obsolete("This has been deprecated in API12")] public event EventHandler TimedOut; /// /// OutsideClicked will be triggered when the popup transition has finished in showing. /// /// preview [Obsolete("This has been deprecated in API12")] public event EventHandler ShowAnimationFinished; /// /// Sets or gets the position in which the popup will appear in its parent. /// /// preview [Obsolete("This has been deprecated in API12")] public PopupOrientation Orientation { get { return (PopupOrientation)Interop.Elementary.elm_popup_orient_get(Handle); } set { Interop.Elementary.elm_popup_orient_set(Handle, (int)value); } } /// /// Sets or gets the wrapping type of content text packed in the content area of Popup widget. /// /// /// Popup need to wrap the content text, so not allowing WrapType.None. /// /// preview [Obsolete("This has been deprecated in API12")] public WrapType ContentTextWrapType { get { return (WrapType)Interop.Elementary.elm_popup_content_text_wrap_type_get(Handle); } set { Interop.Elementary.elm_popup_content_text_wrap_type_set(Handle, (int)value); } } /// /// Sets or gets the timeout value set to the popup (in seconds). /// /// /// Since calling Show() on a popup restarts the timer controlling when it is hidden, /// setting this before the popup is shown, will in effect mean starting the timer when the popup is shown. /// TimedOut is called afterwards, which can be handled, if needed. /// 0.0 and the popup is previously visible,]]> /// the timer will be started with this value, canceling any running timer. /// /// preview [Obsolete("This has been deprecated in API12")] public double Timeout { get { return Interop.Elementary.elm_popup_timeout_get(Handle); } set { Interop.Elementary.elm_popup_timeout_set(Handle, value); } } /// /// Sets or gets whether events should be passed to the event blocked area by a click outside. /// /// /// The visible region of the popup is surrounded by a translucent region called the Blocked event area. /// /// preview [Obsolete("This has been deprecated in API12")] public bool AllowEvents { get { return Interop.Elementary.elm_popup_allow_events_get(Handle); } set { Interop.Elementary.elm_popup_allow_events_set(Handle, value); } } /// /// Sets or gets the AlignmentX in which the popup will appear in its parent. /// /// preview [Obsolete("This has been deprecated in API12")] public override double AlignmentX { get { return Interop.Elementary.GetPopupAlignX(Handle); } set { Interop.Elementary.SetPopupAlignX(Handle, value); } } /// /// Sets or gets the AlignmentY in which the popup will appear in its parent. /// /// preview [Obsolete("This has been deprecated in API12")] public override double AlignmentY { get { return Interop.Elementary.GetPopupAlignY(Handle); } set { Interop.Elementary.SetPopupAlignY(Handle, value); } } /// /// Gets the opacity value of the popup. /// /// preview [Obsolete("This has been deprecated in API12")] public override int Opacity { get { return Color.Default.A; } set { Console.WriteLine("Popup instance doesn't support to set Opacity."); } } /// /// Adds the label to a Popup widget. /// /// /// The new PopupItem which contains a label. /// preview [Obsolete("This has been deprecated in API12")] public PopupItem Append(string label) { return Append(label, null); } /// /// Adds the Label and icon to a Popup widget. /// /// The Label, which will be added into a new PopupItem. /// The icon, which will be added into a new PopupItem. /// The new PopupItem, which contains the label and icon. /// preview [Obsolete("This has been deprecated in API12")] public PopupItem Append(string label, EvasObject icon) { PopupItem item = new PopupItem(label, icon, this); item.Handle = Interop.Elementary.elm_popup_item_append(Handle, label, icon, null, (IntPtr)item.Id); AddInternal(item); return item; } /// /// Uses this function to dismiss the popup in hide effect. /// When the Popup is dismissed, the "dismissed" signal will be emitted. /// /// preview [Obsolete("This has been deprecated in API12")] public void Dismiss() { Interop.Elementary.elm_popup_dismiss(Handle); } /// /// Creates a widget handle. /// /// Parent EvasObject. /// Handle IntPtr. /// preview [Obsolete("This has been deprecated in API12")] protected override IntPtr CreateHandle(EvasObject parent) { return Interop.Elementary.elm_popup_add(parent.Handle); } void AddInternal(PopupItem item) { _children.Add(item); item.Deleted += Item_Deleted; } void Item_Deleted(object sender, EventArgs e) { _children.Remove((PopupItem)sender); } } }