118318c1d3719b8c8def052cb3d511108913c395
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Popup.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 popup orientation types.
24     /// </summary>
25     /// <since_tizen> preview </since_tizen>
26     [Obsolete("This has been deprecated in API12")]
27     public enum PopupOrientation
28     {
29         /// <summary>
30         /// Appears in the top of parent, by default.
31         /// </summary>
32         Top,
33         /// <summary>
34         /// Appears in the center of parent.
35         /// </summary>
36         Center,
37         /// <summary>
38         /// Appears in the bottom of parent.
39         /// </summary>
40         Bottom,
41         /// <summary>
42         /// Appears in the left of parent.
43         /// </summary>
44         Left,
45         /// <summary>
46         /// Appears in the right of parent.
47         /// </summary>
48         Right,
49         /// <summary>
50         /// Appears in the top left of parent.
51         /// </summary>
52         TopLeft,
53         /// <summary>
54         /// Appears in the top right of parent.
55         /// </summary>
56         TopRight,
57         /// <summary>
58         /// Appears in the bottom left of parent.
59         /// </summary>
60         BottomLeft,
61         /// <summary>
62         /// Appears in the bottom right of parent.
63         /// </summary>
64         BottomRight
65     }
66
67     /// <summary>
68     /// The Popup is a widget that is an enhancement of notify.
69     /// In addition to content area, there are two optional sections, namely title area and action area.
70     /// </summary>
71     /// <since_tizen> preview </since_tizen>
72     [Obsolete("This has been deprecated in API12")]
73     public class Popup : Layout
74     {
75         HashSet<PopupItem> _children = new HashSet<PopupItem>();
76         SmartEvent _dismissed;
77         SmartEvent _blockClicked;
78         SmartEvent _timeout;
79         SmartEvent _showFinished;
80
81         /// <summary>
82         /// Creates and initializes a new instance of the Popup class.
83         /// </summary>
84         /// <param name="parent">The EvasObject to which the new popup will be attached as a child.</param>
85         /// <since_tizen> preview </since_tizen>
86         [Obsolete("This has been deprecated in API12")]
87         public Popup(EvasObject parent) : base(parent)
88         {
89             _dismissed = new SmartEvent(this, "dismissed");
90             _dismissed.On += (sender, e) =>
91             {
92                 Dismissed?.Invoke(this, EventArgs.Empty);
93             };
94
95             _blockClicked = new SmartEvent(this, "block,clicked");
96             _blockClicked.On += (sender, e) =>
97             {
98                 OutsideClicked?.Invoke(this, EventArgs.Empty);
99             };
100
101             _timeout = new SmartEvent(this, "timeout");
102             _timeout.On += (sender, e) =>
103             {
104                 TimedOut?.Invoke(this, EventArgs.Empty);
105             };
106
107             _showFinished = new SmartEvent(this, "show,finished");
108             _showFinished.On += (sender, e) =>
109             {
110                 ShowAnimationFinished?.Invoke(this, EventArgs.Empty);
111             };
112         }
113
114         /// <summary>
115         /// Dismissed will be triggered when the popup has been dismissed.
116         /// </summary>
117         /// <since_tizen> preview </since_tizen>
118         [Obsolete("This has been deprecated in API12")]
119         public event EventHandler Dismissed;
120
121         /// <summary>
122         /// OutsideClicked will be triggered when users taps on the outside of Popup.
123         /// </summary>
124         /// <since_tizen> preview </since_tizen>
125         [Obsolete("This has been deprecated in API12")]
126         public event EventHandler OutsideClicked;
127
128         /// <summary>
129         /// OutsideClicked will be triggered when the popup is closed as a result of timeout.
130         /// </summary>
131         /// <since_tizen> preview </since_tizen>
132         [Obsolete("This has been deprecated in API12")]
133         public event EventHandler TimedOut;
134
135         /// <summary>
136         /// OutsideClicked will be triggered when the popup transition has finished in showing.
137         /// </summary>
138         /// <since_tizen> preview </since_tizen>
139         [Obsolete("This has been deprecated in API12")]
140         public event EventHandler ShowAnimationFinished;
141
142         /// <summary>
143         /// Sets or gets the position in which the popup will appear in its parent.
144         /// </summary>
145         /// <since_tizen> preview </since_tizen>
146         [Obsolete("This has been deprecated in API12")]
147         public PopupOrientation Orientation
148         {
149             get
150             {
151                 return (PopupOrientation)Interop.Elementary.elm_popup_orient_get(Handle);
152             }
153             set
154             {
155                 Interop.Elementary.elm_popup_orient_set(Handle, (int)value);
156             }
157         }
158
159         /// <summary>
160         /// Sets or gets the wrapping type of content text packed in the content area of Popup widget.
161         /// </summary>
162         /// <remarks>
163         /// Popup need to wrap the content text, so not allowing WrapType.None.
164         /// </remarks>
165         /// <since_tizen> preview </since_tizen>
166         [Obsolete("This has been deprecated in API12")]
167         public WrapType ContentTextWrapType
168         {
169             get
170             {
171                 return (WrapType)Interop.Elementary.elm_popup_content_text_wrap_type_get(Handle);
172             }
173             set
174             {
175                 Interop.Elementary.elm_popup_content_text_wrap_type_set(Handle, (int)value);
176             }
177         }
178
179         /// <summary>
180         /// Sets or gets the timeout value set to the popup (in seconds).
181         /// </summary>
182         /// <remarks>
183         /// Since calling Show() on a popup restarts the timer controlling when it is hidden,
184         /// setting this before the popup is shown, will in effect mean starting the timer when the popup is shown.
185         /// TimedOut is called afterwards, which can be handled, if needed.
186         /// <![CDATA[Set a value <= 0.0 to disable a running timer. If the value is > 0.0 and the popup is previously visible,]]>
187         /// the timer will be started with this value, canceling any running timer.
188         /// </remarks>
189         /// <since_tizen> preview </since_tizen>
190         [Obsolete("This has been deprecated in API12")]
191         public double Timeout
192         {
193             get
194             {
195                 return Interop.Elementary.elm_popup_timeout_get(Handle);
196             }
197             set
198             {
199                 Interop.Elementary.elm_popup_timeout_set(Handle, value);
200             }
201         }
202
203         /// <summary>
204         /// Sets or gets whether events should be passed to the event blocked area by a click outside.
205         /// </summary>
206         /// <remarks>
207         /// The visible region of the popup is surrounded by a translucent region called the Blocked event area.
208         /// </remarks>
209         /// <since_tizen> preview </since_tizen>
210         [Obsolete("This has been deprecated in API12")]
211         public bool AllowEvents
212         {
213             get
214             {
215                 return Interop.Elementary.elm_popup_allow_events_get(Handle);
216             }
217             set
218             {
219                 Interop.Elementary.elm_popup_allow_events_set(Handle, value);
220             }
221         }
222
223         /// <summary>
224         /// Sets or gets the AlignmentX in which the popup will appear in its parent.
225         /// </summary>
226         /// <since_tizen> preview </since_tizen>
227         [Obsolete("This has been deprecated in API12")]
228         public override double AlignmentX
229         {
230             get
231             {
232                 return Interop.Elementary.GetPopupAlignX(Handle);
233             }
234             set
235             {
236                 Interop.Elementary.SetPopupAlignX(Handle, value);
237             }
238         }
239
240         /// <summary>
241         /// Sets or gets the AlignmentY in which the popup will appear in its parent.
242         /// </summary>
243         /// <since_tizen> preview </since_tizen>
244         [Obsolete("This has been deprecated in API12")]
245         public override double AlignmentY
246         {
247             get
248             {
249                 return Interop.Elementary.GetPopupAlignY(Handle);
250             }
251             set
252             {
253                 Interop.Elementary.SetPopupAlignY(Handle, value);
254             }
255         }
256
257         /// <summary>
258         /// Gets the opacity value of the popup.
259         /// </summary>
260         /// <since_tizen> preview </since_tizen>
261         [Obsolete("This has been deprecated in API12")]
262         public override int Opacity
263         {
264             get
265             {
266                 return Color.Default.A;
267             }
268
269             set
270             {
271                 Console.WriteLine("Popup instance doesn't support to set Opacity.");
272             }
273         }
274
275         /// <summary>
276         /// Adds the label to a Popup widget.
277         /// </summary>
278         /// <param name="label"></param>
279         /// <returns>The new PopupItem which contains a label.</returns>
280         /// <since_tizen> preview </since_tizen>
281         [Obsolete("This has been deprecated in API12")]
282         public PopupItem Append(string label)
283         {
284             return Append(label, null);
285         }
286
287         /// <summary>
288         /// Adds the Label and icon to a Popup widget.
289         /// </summary>
290         /// <param name="label">The Label, which will be added into a new PopupItem.</param>
291         /// <param name="icon">The icon, which will be added into a new PopupItem. </param>
292         /// <returns>The new PopupItem, which contains the label and icon.</returns>
293         /// <since_tizen> preview </since_tizen>
294         [Obsolete("This has been deprecated in API12")]
295         public PopupItem Append(string label, EvasObject icon)
296         {
297             PopupItem item = new PopupItem(label, icon, this);
298             item.Handle = Interop.Elementary.elm_popup_item_append(Handle, label, icon, null, (IntPtr)item.Id);
299             AddInternal(item);
300             return item;
301         }
302
303         /// <summary>
304         /// Uses this function to dismiss the popup in hide effect.
305         /// When the Popup is dismissed, the "dismissed" signal will be emitted.
306         /// </summary>
307         /// <since_tizen> preview </since_tizen>
308         [Obsolete("This has been deprecated in API12")]
309         public void Dismiss()
310         {
311             Interop.Elementary.elm_popup_dismiss(Handle);
312         }
313
314         /// <summary>
315         /// Creates a widget handle.
316         /// </summary>
317         /// <param name="parent">Parent EvasObject.</param>
318         /// <returns>Handle IntPtr.</returns>
319         /// <since_tizen> preview </since_tizen>
320         [Obsolete("This has been deprecated in API12")]
321         protected override IntPtr CreateHandle(EvasObject parent)
322         {
323             return Interop.Elementary.elm_popup_add(parent.Handle);
324         }
325         void AddInternal(PopupItem item)
326         {
327             _children.Add(item);
328             item.Deleted += Item_Deleted;
329         }
330         void Item_Deleted(object sender, EventArgs e)
331         {
332             _children.Remove((PopupItem)sender);
333         }
334     }
335 }