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 ToolbarSelectionMode
30 public enum ToolbarShrinkMode
39 public class ToolbarItemEventArgs : EventArgs {
40 public ToolbarItem Item { get; private set; }
42 internal static ToolbarItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
44 ToolbarItem item = ItemObject.GetItemByHandle(info) as ToolbarItem;
45 return new ToolbarItemEventArgs() { Item = item };
49 public class Toolbar : Widget
51 SmartEvent<ToolbarItemEventArgs> _clicked;
52 SmartEvent<ToolbarItemEventArgs> _selected;
53 SmartEvent<ToolbarItemEventArgs> _longpressed;
54 public Toolbar(EvasObject parent) : base(parent)
56 _selected = new SmartEvent<ToolbarItemEventArgs>(this, this.RealHandle, "selected", ToolbarItemEventArgs.CreateFromSmartEvent);
57 _selected.On += (s, e) =>
61 Selected?.Invoke(this, e);
62 e.Item.SendSelected();
65 _longpressed = new SmartEvent<ToolbarItemEventArgs>(this, this.RealHandle, "longpressed", ToolbarItemEventArgs.CreateFromSmartEvent);
66 _longpressed.On += (s, e) =>
68 e.Item?.SendLongPressed();
70 _clicked = new SmartEvent<ToolbarItemEventArgs>(this, this.RealHandle, "clicked", ToolbarItemEventArgs.CreateFromSmartEvent);
71 _clicked.On += (s, e) =>
73 e.Item?.SendClicked();
77 public event EventHandler<ToolbarItemEventArgs> Selected;
79 public bool Homogeneous
83 return Interop.Elementary.elm_toolbar_homogeneous_get(RealHandle);
87 Interop.Elementary.elm_toolbar_homogeneous_set(RealHandle, value);
91 public ToolbarSelectionMode SelectionMode
95 return (ToolbarSelectionMode)Interop.Elementary.elm_toolbar_select_mode_get(RealHandle);
99 Interop.Elementary.elm_toolbar_select_mode_set(RealHandle, (int)value);
103 public ToolbarShrinkMode ShrinkMode
107 return (ToolbarShrinkMode)Interop.Elementary.elm_toolbar_shrink_mode_get(RealHandle);
111 Interop.Elementary.elm_toolbar_shrink_mode_set(RealHandle, (int)value);
115 public double ItemAlignment
119 return Interop.Elementary.elm_toolbar_align_get(RealHandle);
123 Interop.Elementary.elm_toolbar_align_set(RealHandle, value);
127 public bool TransverseExpansion
131 return Interop.Elementary.elm_toolbar_transverse_expanded_get(RealHandle);
135 Interop.Elementary.elm_toolbar_transverse_expanded_set(RealHandle, value);
139 public ToolbarItem Append(string label)
141 return Append(label, null);
143 public ToolbarItem Append(string label, string icon)
145 ToolbarItem item = new ToolbarItem(label, icon);
146 item.Handle = Interop.Elementary.elm_toolbar_item_append(RealHandle, icon, label, null, (IntPtr)item.Id);
150 public ToolbarItem Prepend(string label)
152 return Prepend(label, null);
155 public ToolbarItem Prepend(string label, string icon)
157 ToolbarItem item = new ToolbarItem(label, icon);
158 item.Handle = Interop.Elementary.elm_toolbar_item_prepend(RealHandle, icon, label, null, (IntPtr)item.Id);
162 public ToolbarItem InsertBefore(ToolbarItem before, string label)
164 return InsertBefore(before, label);
167 public ToolbarItem InsertBefore(ToolbarItem before, string label, string icon)
169 ToolbarItem item = new ToolbarItem(label, icon);
170 item.Handle = Interop.Elementary.elm_toolbar_item_insert_before(RealHandle, before, icon, label, null, (IntPtr)item.Id);
174 public ToolbarItem SelectedItem
178 IntPtr handle = Interop.Elementary.elm_toolbar_selected_item_get(RealHandle);
179 return ItemObject.GetItemByHandle(handle) as ToolbarItem;
183 protected override IntPtr CreateHandle(EvasObject parent)
185 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
186 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
188 RealHandle = Interop.Elementary.elm_toolbar_add(handle);
189 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);