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 /// The FlipSelector is a widget to show a set of text items, one at a time, with the same sheet switching style as the clock widget when one changes the current displaying sheet.
25 /// <since_tizen> preview </since_tizen>
26 public class FlipSelector : Layout
29 SmartEvent _overflowed;
30 SmartEvent _underflowed;
33 /// Creates and initializes a new instance of the FlipSelector.
35 /// <param name="parent">Parent EvasObject.</param>
36 /// <since_tizen> preview </since_tizen>
37 public FlipSelector(EvasObject parent) : base(parent)
39 _selected = new SmartEvent(this, Handle, "selected");
40 _overflowed = new SmartEvent(this, Handle, "overflowed");
41 _underflowed = new SmartEvent(this, Handle, "underflowed");
43 _selected.On += SelectedChanged;
44 _overflowed.On += OverflowedChanged;
45 _underflowed.On += UnderflowedChanged;
49 /// Selected will be triggered when selected.
51 /// <since_tizen> preview </since_tizen>
52 public event EventHandler Selected;
54 /// Overflowed will be triggered when overflowed.
56 /// <since_tizen> preview </since_tizen>
57 public event EventHandler Overflowed;
59 /// Underflowed will be triggered when underflowed.
61 /// <since_tizen> preview </since_tizen>
62 public event EventHandler Underflowed;
65 /// Sets or gets the interval on time updates for a user mouse button to hold on the flip selector widget.
67 /// <since_tizen> preview </since_tizen>
68 public double Interval
72 return Interop.Elementary.elm_flipselector_first_interval_get(Handle);
76 Interop.Elementary.elm_flipselector_first_interval_set(Handle, value);
82 /// Gets the currently selected item in the flip selector widget.
84 /// <since_tizen> preview </since_tizen>
85 public FlipSelectorItem SelectedItem
89 IntPtr handle = Interop.Elementary.elm_flipselector_selected_item_get(Handle);
90 return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
95 /// Gets the first item in the given flip selector widget's list of items.
97 /// <since_tizen> preview </since_tizen>
98 public FlipSelectorItem FirstItem
102 IntPtr handle = Interop.Elementary.elm_flipselector_first_item_get(Handle);
103 return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
108 /// Gets the last item in the given flip selector widget's list of items.
110 /// <since_tizen> preview </since_tizen>
111 public FlipSelectorItem LastItem
115 IntPtr handle = Interop.Elementary.elm_flipselector_last_item_get(Handle);
116 return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
121 /// Appends the (text) item to the flip selector widget.
123 /// <param name="text">text value</param>
125 /// A handle to the item added, or null on errors.
128 /// The widget's list of labels to show will be appended with the given value. If the user wishes so, a callback function pointer can be passed, which will get called when the same item is selected.
130 /// <since_tizen> preview </since_tizen>
131 public FlipSelectorItem Append(string text)
133 FlipSelectorItem item = new FlipSelectorItem(text, this);
134 item.Handle = Interop.Elementary.elm_flipselector_item_append(Handle, text, null, (IntPtr)item.Id);
139 /// Prepends the (text) item to a flip selector widget.
141 /// <param name="text">Prepend text</param>
142 /// <returns>A handle to the item added, or null on errors.</returns>
144 /// The widget's list of labels to show will be prepended with the given value. If the user wishes so, a callback function pointer can be passed, which will get called when the same item is selected.
146 /// <since_tizen> preview </since_tizen>
147 public FlipSelectorItem Prepend(string text)
149 FlipSelectorItem item = new FlipSelectorItem(text, this);
150 item.Handle = Interop.Elementary.elm_flipselector_item_prepend(Handle, text, null, (IntPtr)item.Id);
155 /// To remove the given item.
157 /// <param name="item">FlipSelector's item.</param>
158 /// <since_tizen> preview </since_tizen>
159 public void Remove(FlipSelectorItem item)
166 /// Programmatically select the next item of the flip selector widget.
169 /// The selection will be animated. Also, if it reaches the beginning of its list of member items, it will continue with the last one backwards.
171 /// <since_tizen> preview </since_tizen>
174 Interop.Elementary.elm_flipselector_flip_next(Handle);
178 /// Programmatically select the previous item of the flip selector widget.
180 /// <since_tizen> preview </since_tizen>
183 Interop.Elementary.elm_flipselector_flip_prev(Handle);
187 /// Creates a widget handle.
189 /// <param name="parent">Parent EvasObject.</param>
190 /// <returns>Handle IntPtr.</returns>
191 /// <since_tizen> preview </since_tizen>
192 protected override IntPtr CreateHandle(EvasObject parent)
194 return Interop.Elementary.elm_flipselector_add(parent.Handle);
197 void SelectedChanged(object sender, EventArgs e)
199 SelectedItem?.SendSelected();
200 Selected?.Invoke(this, EventArgs.Empty);
203 void OverflowedChanged(object sender, EventArgs e)
205 Overflowed?.Invoke(this, e);
208 void UnderflowedChanged(object sender, EventArgs e)
210 Underflowed?.Invoke(this, e);