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;
22 public enum PopupOrientation
35 public class Popup : Layout
37 HashSet<PopupItem> _children = new HashSet<PopupItem>();
38 SmartEvent _dismissed;
39 SmartEvent _blockClicked;
41 SmartEvent _showFinished;
43 public Popup(EvasObject parent) : base(parent)
45 _dismissed = new SmartEvent(this, "dismissed");
46 _dismissed.On += (sender, e) =>
48 Dismissed?.Invoke(this, EventArgs.Empty);
51 _blockClicked = new SmartEvent(this, "block,clicked");
52 _blockClicked.On += (sender, e) =>
54 OutsideClicked?.Invoke(this, EventArgs.Empty);
57 _timeout = new SmartEvent(this, "timeout");
58 _timeout.On += (sender, e) =>
60 TimedOut?.Invoke(this, EventArgs.Empty);
63 _showFinished = new SmartEvent(this, "show,finished");
64 _showFinished.On += (sender, e) =>
66 ShowAnimationFinished?.Invoke(this, EventArgs.Empty);
70 public event EventHandler Dismissed;
72 public event EventHandler OutsideClicked;
74 public event EventHandler TimedOut;
76 public event EventHandler ShowAnimationFinished;
78 public PopupOrientation Orientation
82 return (PopupOrientation)Interop.Elementary.elm_popup_orient_get(Handle);
86 Interop.Elementary.elm_popup_orient_set(Handle, (int)value);
90 public WrapType ContentTextWrapType
94 return (WrapType)Interop.Elementary.elm_popup_content_text_wrap_type_get(Handle);
98 Interop.Elementary.elm_popup_content_text_wrap_type_set(Handle, (int)value);
102 public double Timeout
106 return Interop.Elementary.elm_popup_timeout_get(Handle);
110 Interop.Elementary.elm_popup_timeout_set(Handle, value);
114 public bool AllowEvents
118 return Interop.Elementary.elm_popup_allow_events_get(Handle);
122 Interop.Elementary.elm_popup_allow_events_set(Handle, value);
126 public override double AlignmentX
130 return Interop.Elementary.GetPopupAlignX(Handle);
134 Interop.Elementary.SetPopupAlignX(Handle, value);
138 public override double AlignmentY
142 return Interop.Elementary.GetPopupAlignY(Handle);
146 Interop.Elementary.SetPopupAlignY(Handle, value);
150 public override int Opacity
154 return Color.Default.A;
159 Console.WriteLine("Popup instance doesn't support to set Opacity.");
163 public PopupItem Append(string label)
165 return Append(label, null);
168 public PopupItem Append(string label, EvasObject icon)
170 PopupItem item = new PopupItem(label, icon);
171 item.Handle = Interop.Elementary.elm_popup_item_append(Handle, label, icon, null, (IntPtr)item.Id);
176 public void Dismiss()
178 Interop.Elementary.elm_popup_dismiss(Handle);
181 protected override IntPtr CreateHandle(EvasObject parent)
183 return Interop.Elementary.elm_popup_add(parent.Handle);
186 void AddInternal(PopupItem item)
189 item.Deleted += Item_Deleted;
192 void Item_Deleted(object sender, EventArgs e)
194 _children.Remove((PopupItem)sender);