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.
21 public class Button : Layout
23 private SmartEvent _clicked;
24 private SmartEvent _repeated;
25 private SmartEvent _pressed;
26 private SmartEvent _released;
28 public Button(EvasObject parent) : base(parent)
30 _clicked = new SmartEvent(this, this.RealHandle, "clicked");
31 _repeated = new SmartEvent(this, this.RealHandle, "repeated");
32 _pressed = new SmartEvent(this, this.RealHandle, "pressed");
33 _released = new SmartEvent(this, this.RealHandle, "unpressed");
35 _clicked.On += (sender, e) =>
37 Clicked?.Invoke(this, EventArgs.Empty);
40 _repeated.On += (sender, e) =>
42 Repeated?.Invoke(this, EventArgs.Empty);
45 _pressed.On += (sender, e) =>
47 Pressed?.Invoke(this, EventArgs.Empty);
50 _released.On += (sender, e) =>
52 Released?.Invoke(this, EventArgs.Empty);
56 public event EventHandler Clicked;
58 public event EventHandler Repeated;
60 public event EventHandler Pressed;
62 public event EventHandler Released;
64 public bool AutoRepeat
68 return !Interop.Elementary.elm_button_autorepeat_get(RealHandle);
72 Interop.Elementary.elm_button_autorepeat_set(RealHandle, value);
76 public double AutoRepeatInitialTime
80 return Interop.Elementary.elm_button_autorepeat_initial_timeout_get(RealHandle);
84 Interop.Elementary.elm_button_autorepeat_initial_timeout_set(RealHandle, value);
88 public double AutoRepeatGapTimeout
92 return Interop.Elementary.elm_button_autorepeat_gap_timeout_get(RealHandle);
96 Interop.Elementary.elm_button_autorepeat_gap_timeout_set(RealHandle, value);
100 [Obsolete("DeleteColorClass is obsolete, please use EdjeObject.DeleteColorClass(string)")]
101 public void DeleteColorClass(string part)
103 Interop.Elementary.edje_object_color_class_del(Handle, part);
106 public override Color BackgroundColor
112 EdjeObject.DeleteColorClass("button/bg");
113 EdjeObject.DeleteColorClass("button/bg_pressed");
117 SetPartColor("bg", value);
118 SetPartColor("bg_pressed", value);
120 _backgroundColor = value;
124 protected override IntPtr CreateHandle(EvasObject parent)
126 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
127 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
129 RealHandle = Interop.Elementary.elm_button_add(handle);
130 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);