[ACR-564] deprecate unused API
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Naviframe.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     /// The NaviframeEventArgs is an event arguments class for naviframe.
24     /// Inherits EventArgs.
25     /// </summary>
26     /// <since_tizen> preview </since_tizen>
27     [Obsolete("This has been deprecated in API12")]
28     public class NaviframeEventArgs : EventArgs
29     {
30         /// <summary>
31         /// Sets or gets the content object. The name of the content part is "elm.swallow.content".
32         /// </summary>
33         /// <since_tizen> preview </since_tizen>
34         [Obsolete("This has been deprecated in API12")]
35         public EvasObject Content { get; set; }
36     }
37     /// <summary>
38     /// The Naviframe is a widget to stand for the navigation frame. It's a views manager for applications.
39     /// Inherits Widget.
40     /// </summary>
41     /// <since_tizen> preview </since_tizen>
42     [Obsolete("This has been deprecated in API12")]
43     public class Naviframe : Widget
44     {
45         SmartEvent _transitionFinished;
46         readonly List<NaviItem> _itemStack = new List<NaviItem>();
47
48         /// <summary>
49         /// Creates and initializes a new instance of the Naviframe class.
50         /// </summary>
51         /// <param name="parent">The parent is a given container which will be attached by Naviframe as a child. It's <see cref="EvasObject"/> type.</param>
52         /// <since_tizen> preview </since_tizen>
53         [Obsolete("This has been deprecated in API12")]
54         public Naviframe(EvasObject parent) : base(parent)
55         {
56             _transitionFinished = new SmartEvent(this, this.RealHandle, "transition,finished");
57             _transitionFinished.On += (s, e) => AnimationFinished?.Invoke(this, EventArgs.Empty);
58         }
59
60         /// <summary>
61         /// Popped will be triggered when the NaviItem is removed.
62         /// </summary>
63         /// <remarks>
64         /// It is always called when the NaviItem is removed.
65         /// (even if removed by NaviItem.Delete())
66         /// This event will be invoked in progress of the Pop/Delete operation.
67         /// After calling the Popped event, the Pop/Delete method will be returned.
68         /// </remarks>
69         /// <since_tizen> preview </since_tizen>
70         [Obsolete("This has been deprecated in API12")]
71         public event EventHandler<NaviframeEventArgs> Popped;
72
73         /// <summary>
74         /// AnimationFinished will be triggered when the animation is finished.
75         /// </summary>
76         /// <since_tizen> preview </since_tizen>
77         [Obsolete("This has been deprecated in API12")]
78         public event EventHandler AnimationFinished;
79
80         /// <summary>
81         /// Gets the list of the navi item.
82         /// </summary>
83         /// <since_tizen> preview </since_tizen>
84         [Obsolete("This has been deprecated in API12")]
85         public IReadOnlyList<NaviItem> NavigationStack
86         {
87             get { return _itemStack; }
88         }
89
90         /// <summary>
91         /// Sets or gets the preserve content objects when items are popped.
92         /// </summary>
93         /// <since_tizen> preview </since_tizen>
94         [Obsolete("This has been deprecated in API12")]
95         public bool PreserveContentOnPop
96         {
97             get
98             {
99                 return Interop.Elementary.elm_naviframe_content_preserve_on_pop_get(RealHandle);
100             }
101             set
102             {
103                 Interop.Elementary.elm_naviframe_content_preserve_on_pop_set(RealHandle, value);
104             }
105         }
106
107         /// <summary>
108         /// Sets or gets whether the default back button is enabled.
109         /// </summary>
110         /// <since_tizen> preview </since_tizen>
111         [Obsolete("This has been deprecated in API12")]
112         public bool DefaultBackButtonEnabled
113         {
114             get
115             {
116                 return Interop.Elementary.elm_naviframe_prev_btn_auto_pushed_get(RealHandle);
117             }
118             set
119             {
120                 Interop.Elementary.elm_naviframe_prev_btn_auto_pushed_set(RealHandle, value);
121             }
122         }
123
124         /// <summary>
125         /// Pushes a new item to the top of the naviframe stack and shows it.
126         /// The title and style are null.
127         /// </summary>
128         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
129         /// <returns>The created item, or null upon failure.</returns>
130         /// <since_tizen> preview </since_tizen>
131         [Obsolete("This has been deprecated in API12")]
132         public NaviItem Push(EvasObject content)
133         {
134             return Push(content, null);
135         }
136
137         /// <summary>
138         /// Pushes a new item to the top of the naviframe stack and shows it.
139         /// The style is null.
140         /// </summary>
141         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
142         /// <param name="title">The current item title. Null would be default.</param>
143         /// <returns></returns>
144         /// <since_tizen> preview </since_tizen>
145         [Obsolete("This has been deprecated in API12")]
146         public NaviItem Push(EvasObject content, string title)
147         {
148             return Push(content, title, null);
149         }
150
151         /// <summary>
152         /// Pushes a new item to the top of the naviframe stack and shows it.
153         /// </summary>
154         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
155         /// <param name="title">The current item title. Null would be default.</param>
156         /// <param name="style">The current item style name. Null would be default.</param>
157         /// <returns>The created item, or null upon failure.</returns>
158         /// <since_tizen> preview </since_tizen>
159         [Obsolete("This has been deprecated in API12")]
160         public NaviItem Push(EvasObject content, string title, string style)
161         {
162             IntPtr item = Interop.Elementary.elm_naviframe_item_push(RealHandle, title, IntPtr.Zero, IntPtr.Zero, content.Handle, style);
163             NaviItem naviItem = NaviItem.FromNativeHandle(item, content, this);
164             _itemStack.Add(naviItem);
165             naviItem.Popped += ItemPoppedHandler;
166             return naviItem;
167         }
168
169         /// <summary>
170         /// Inserts a new item into the naviframe before the item.
171         /// The title is "" and the style is null.
172         /// </summary>
173         /// <param name="before">The item for which a new item is inserted before.</param>
174         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
175         /// <returns>The created item, or null upon failure.</returns>
176         /// <since_tizen> preview </since_tizen>
177         [Obsolete("This has been deprecated in API12")]
178         public NaviItem InsertBefore(NaviItem before, EvasObject content)
179         {
180             return InsertBefore(before, content, "");
181         }
182
183         /// <summary>
184         /// Inserts a new item into the naviframe before the item.
185         /// The style is null.
186         /// </summary>
187         /// <param name="before">The item for which a new item is inserted before.</param>
188         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
189         /// <param name="title">The current item title. Null would be default.</param>
190         /// <returns>The created item, or null upon failure.</returns>
191         /// <since_tizen> preview </since_tizen>
192         [Obsolete("This has been deprecated in API12")]
193         public NaviItem InsertBefore(NaviItem before, EvasObject content, string title)
194         {
195             return InsertBefore(before, content, title, null);
196         }
197
198         /// <summary>
199         /// Inserts a new item into the naviframe before the item.
200         /// </summary>
201         /// <param name="before">The item for which a new item is inserted before.</param>
202         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
203         /// <param name="title">The current item title. Null would be default.</param>
204         /// <param name="style">The current item style name. Null would be default.</param>
205         /// <returns>The created item, or null upon failure.</returns>
206         /// <since_tizen> preview </since_tizen>
207         [Obsolete("This has been deprecated in API12")]
208         public NaviItem InsertBefore(NaviItem before, EvasObject content, string title, string style)
209         {
210             IntPtr item = Interop.Elementary.elm_naviframe_item_insert_before(RealHandle, before, title, IntPtr.Zero, IntPtr.Zero, content, null);
211             NaviItem naviItem = NaviItem.FromNativeHandle(item, content, this);
212             int idx = _itemStack.IndexOf(before);
213             _itemStack.Insert(idx, naviItem);
214             naviItem.Popped += ItemPoppedHandler;
215             return naviItem;
216         }
217
218         /// <summary>
219         /// Inserts a new item into the naviframe after the item.
220         /// The title is "" and the style is null.
221         /// </summary>
222         /// <param name="after">The item for which a new item is inserted after.</param>
223         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
224         /// <returns>The created item, or null upon failure.</returns>
225         /// <since_tizen> preview </since_tizen>
226         [Obsolete("This has been deprecated in API12")]
227         public NaviItem InsertAfter(NaviItem after, EvasObject content)
228         {
229             return InsertAfter(after, content, "");
230         }
231
232         /// <summary>
233         /// Inserts a new item into the naviframe after the item.
234         /// The style is null.
235         /// </summary>
236         /// <param name="after">The item which a new item is inserted after.</param>
237         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
238         /// <param name="title">The current item title. Null would be default.</param>
239         /// <returns>The created item, or null upon failure.</returns>
240         /// <since_tizen> preview </since_tizen>
241         [Obsolete("This has been deprecated in API12")]
242         public NaviItem InsertAfter(NaviItem after, EvasObject content, string title)
243         {
244             return InsertAfter(after, content, title, null);
245         }
246
247         /// <summary>
248         /// Inserts a new item into the naviframe after the item.
249         /// </summary>
250         /// <param name="after">The item for which a new item is inserted after.</param>
251         /// <param name="content">The main content object. The name of the content part is "elm.swallow.content".</param>
252         /// <param name="title">The current item title. Null would be default.</param>
253         /// <param name="style">The current item style name. Null would be default.</param>
254         /// <returns>The created item, or null upon failure.</returns>
255         /// <since_tizen> preview </since_tizen>
256         [Obsolete("This has been deprecated in API12")]
257         public NaviItem InsertAfter(NaviItem after, EvasObject content, string title, string style)
258         {
259             IntPtr item = Interop.Elementary.elm_naviframe_item_insert_after(RealHandle, after, title, IntPtr.Zero, IntPtr.Zero, content, null);
260             NaviItem naviItem = NaviItem.FromNativeHandle(item, content, this);
261             int idx = _itemStack.IndexOf(after);
262             _itemStack.Insert(idx + 1, naviItem);
263             naviItem.Popped += ItemPoppedHandler;
264             return naviItem;
265         }
266
267         /// <summary>
268         /// Pops an item that is on top of the stack.
269         /// </summary>
270         /// <since_tizen> preview </since_tizen>
271         [Obsolete("This has been deprecated in API12")]
272         public void Pop()
273         {
274             Interop.Elementary.elm_naviframe_item_pop(RealHandle);
275         }
276
277         /// <summary>
278         /// Creates a widget handle.
279         /// </summary>
280         /// <param name="parent">Parent EvasObject.</param>
281         /// <returns>Handle IntPtr.</returns>
282         /// <since_tizen> preview </since_tizen>
283         [Obsolete("This has been deprecated in API12")]
284         protected override IntPtr CreateHandle(EvasObject parent)
285         {
286             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
287             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
288
289             RealHandle = Interop.Elementary.elm_naviframe_add(handle);
290             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
291
292             return handle;
293         }
294
295         void ItemPoppedHandler(object sender, EventArgs e)
296         {
297             NaviItem item = sender as NaviItem;
298             if (item == null)
299                 return;
300             _itemStack.Remove(item);
301             Popped?.Invoke(this, new NaviframeEventArgs { Content = item.Content });
302         }
303     }
304 }