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.
22 /// The check is a widget allows for toggling a value between true and false.
24 public class Check : Layout
26 private SmartEvent _changed;
27 private bool _currentState;
30 /// Creates and initializes a new instance of the Check class.
32 /// <param name="parent">
33 /// The EvasObject to which the new Check will be attached as a child.
35 public Check(EvasObject parent) : base(parent)
37 _changed = new SmartEvent(this, this.RealHandle, "changed");
38 _changed.On += (sender, e) =>
40 StateChanged?.Invoke(this, new CheckStateChangedEventArgs(_currentState, IsChecked));
45 /// StateChanged will be triggered when the IsChecked in the Check is changed.
47 public event EventHandler<CheckStateChangedEventArgs> StateChanged;
50 /// Sets or gets whether the given Check is checked or not.
53 /// When object is checked, the value will set to true, Conversely will set to false.
59 _currentState = Interop.Elementary.elm_check_state_get(RealHandle);
64 Interop.Elementary.elm_check_state_set(RealHandle, value);
69 /// Creates a widget handle.
71 /// <param name="parent">Parent EvasObject</param>
72 /// <returns>Handle IntPtr</returns>
73 protected override IntPtr CreateHandle(EvasObject parent)
75 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
76 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
78 RealHandle = Interop.Elementary.elm_check_add(handle);
79 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);