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 /// A flip selector 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 public class FlipSelector : Layout
28 SmartEvent _overflowed;
29 SmartEvent _underflowed;
32 /// Creates and initializes a new instance of the FlipSelector.
34 /// <param name="parent">Parent EvasObject </param>
35 public FlipSelector(EvasObject parent) : base(parent)
37 _selected = new SmartEvent(this, Handle, "selected");
38 _overflowed = new SmartEvent(this, Handle, "overflowed");
39 _underflowed = new SmartEvent(this, Handle, "underflowed");
41 _selected.On += SelectedChanged;
42 _overflowed.On += OverflowedChanged;
43 _underflowed.On += UnderflowedChanged;
47 /// Selected will be triggered when be Selected
49 public event EventHandler Selected;
51 /// Overflowed will be triggered when Overflowed
53 public event EventHandler Overflowed;
55 /// Underflowed will be triggered when be Underflowed
57 public event EventHandler Underflowed;
60 /// Sets or gets the interval on time updates for an user mouse button hold on a flip selector widget.
62 public double Interval
66 return Interop.Elementary.elm_flipselector_first_interval_get(Handle);
70 Interop.Elementary.elm_flipselector_first_interval_set(Handle, value);
76 /// Gets the currently selected item in a flip selector widget.
78 public FlipSelectorItem SelectedItem
82 IntPtr handle = Interop.Elementary.elm_flipselector_selected_item_get(Handle);
83 return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
88 /// Gets the first item in the given flip selector widget's list of items.
90 public FlipSelectorItem FirstItem
94 IntPtr handle = Interop.Elementary.elm_flipselector_first_item_get(Handle);
95 return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
100 /// Gets the last item in the given flip selector widget's list of items.
102 public FlipSelectorItem LastItem
106 IntPtr handle = Interop.Elementary.elm_flipselector_last_item_get(Handle);
107 return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
112 /// Appends a (text) item to a flip selector widget.
114 /// <param name="text">text value</param>
116 /// A handle to the item added or NULL, on errors
119 /// 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 this same item is selected.
121 public FlipSelectorItem Append(string text)
123 FlipSelectorItem item = new FlipSelectorItem(text);
124 item.Handle = Interop.Elementary.elm_flipselector_item_append(Handle, text, null, (IntPtr)item.Id);
129 /// Prepend a (text) item to a flip selector widget.
131 /// <param name="text">Prepend text</param>
132 /// <returns>A handle to the item added or NULL, on errors</returns>
134 /// 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 this same item is selected.
136 public FlipSelectorItem Prepend(string text)
138 FlipSelectorItem item = new FlipSelectorItem(text);
139 item.Handle = Interop.Elementary.elm_flipselector_item_prepend(Handle, text, null, (IntPtr)item.Id);
144 /// To remove the given item.
146 /// <param name="item">FlipSelector's item</param>
147 public void Remove(FlipSelectorItem item)
149 if (item as FlipSelectorItem != null)
154 /// Programmatically select the next item of a flip selector widget.
157 /// 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.
161 Interop.Elementary.elm_flipselector_flip_next(Handle);
165 /// Programmatically select the previous item of a flip selector widget.
169 Interop.Elementary.elm_flipselector_flip_prev(Handle);
173 /// Creates a widget handle.
175 /// <param name="parent">Parent EvasObject</param>
176 /// <returns>Handle IntPtr</returns>
177 protected override IntPtr CreateHandle(EvasObject parent)
179 return Interop.Elementary.elm_flipselector_add(parent.Handle);
182 void SelectedChanged(object sender, EventArgs e)
184 SelectedItem?.SendSelected();
185 Selected?.Invoke(this, EventArgs.Empty);
188 void OverflowedChanged(object sender, EventArgs e)
190 Overflowed?.Invoke(this, e);
193 void UnderflowedChanged(object sender, EventArgs e)
195 Underflowed?.Invoke(this, e);